-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #431 from docknetwork/trust-registry-change-partic…
…ipants `TrustRegistry` change participants + remove outdated code
- Loading branch information
Showing
10 changed files
with
530 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,24 @@ | ||
import { getHexIdentifier, isHexWithGivenByteSize } from '../../codec'; | ||
|
||
import DockDidOrDidMethodKey from './dock-did-or-did-method-key'; | ||
import DockDid from './dock-did'; | ||
import DidMethodKey from './did-method-key'; // eslint-disable-line | ||
|
||
import { DockDIDQualifier, DockDIDByteSize } from '../constants'; | ||
import DidMethodKey from "./did-method-key"; // eslint-disable-line | ||
|
||
/** | ||
* Takes a DID string, gets the hexadecimal value of that and returns either the `DockDid` or `DidMethodKey` object. | ||
* @param {{ specVersion: number }} api | ||
* @deprecated Use `DockDidOrDidMethodKey.from`/`DockDid.from`/`DidMethodKey.from` instead. | ||
* @todo remove `api` parameter | ||
* | ||
* @param {*} api - unused | ||
* @param {string|DockDid|DidMethodKey|object} did - The DID can be passed as fully qualified DID like `did:dock:<SS58 string>` or | ||
* `did:key:<BS58 public key>` or a 32 byte hex string | ||
* @return {string|DockDid|DidMethodKey} Returns a `string` or `DockDid` or `DidMethodKey` object. | ||
*/ | ||
export function typedHexDID(api, did) { | ||
if (api.specVersion < 50) { | ||
return getHexIdentifier(did, DockDIDQualifier, DockDIDByteSize); | ||
} else { | ||
return DockDidOrDidMethodKey.from(did); | ||
} | ||
export function typedHexDID(_api, did) { | ||
return DockDidOrDidMethodKey.from(did); | ||
} | ||
|
||
/** | ||
* Create and return a fully qualified Dock DID, i.e. "did:dock:<SS58 string>" | ||
* | ||
* @returns {string} - The DID | ||
*/ | ||
export const createNewDockDID = () => DockDid.random().toQualifiedEncodedString(); | ||
|
||
/** | ||
* Temporary solution for the DID's backward compatibility. | ||
* | ||
* -------------------------------------------------------- | ||
*/ | ||
// eslint-disable-next-line no-extend-native | ||
Object.defineProperty(String.prototype, 'asDid', { | ||
get() { | ||
if (this.isDid) { | ||
return String(this); | ||
} else { | ||
throw new Error('Not a `Did`'); | ||
} | ||
}, | ||
}); | ||
// eslint-disable-next-line no-extend-native | ||
Object.defineProperty(String.prototype, 'isDid', { | ||
get() { | ||
return isHexWithGivenByteSize(String(this), DockDIDByteSize); | ||
}, | ||
}); | ||
// eslint-disable-next-line no-extend-native | ||
Object.defineProperty(String.prototype, 'toQualifiedEncodedString', { | ||
value: function toQualifiedEncodedString() { | ||
return new DockDid(this.asDid).toQualifiedEncodedString(); | ||
}, | ||
}); | ||
|
||
/** | ||
* -------------------------------------------------------- | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.