Cleanup keypair add functionality (#217)
* Cleanup keypair add functionality * Expose addPair
This commit is contained in:
+2
-2
@@ -20,7 +20,7 @@
|
||||
"test": "jest --coverage"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/dev": "^0.20.19",
|
||||
"@polkadot/ts": "^0.1.27"
|
||||
"@polkadot/dev": "^0.20.21",
|
||||
"@polkadot/ts": "^0.1.30"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,13 @@ export default class Keyring implements KeyringInstance {
|
||||
this._pairs = new Pairs();
|
||||
}
|
||||
|
||||
addPair (pair: KeyringPair): KeyringPair {
|
||||
return this._pairs.add(pair);
|
||||
}
|
||||
|
||||
addFromAddress (address: string | Uint8Array, meta?: KeyringPair$Meta, defaultEncoded?: Uint8Array): KeyringPair {
|
||||
// @ts-ignore no secretKey - cannot unlock
|
||||
return this._pairs.add(createPair({ publicKey: addressDecode(address) }, meta, defaultEncoded));
|
||||
return this.addPair(createPair({ publicKey: addressDecode(address) }, meta, defaultEncoded));
|
||||
}
|
||||
|
||||
addFromJson ({ address, encoded, meta }: KeyringPair$Json): KeyringPair {
|
||||
@@ -28,7 +32,7 @@ export default class Keyring implements KeyringInstance {
|
||||
}
|
||||
|
||||
addFromSeed (seed: Uint8Array, meta?: KeyringPair$Meta): KeyringPair {
|
||||
return this._pairs.add(createPair(naclKeypairFromSeed(seed), meta));
|
||||
return this.addPair(createPair(naclKeypairFromSeed(seed), meta));
|
||||
}
|
||||
|
||||
getPair (address: string | Uint8Array): KeyringPair {
|
||||
|
||||
Vendored
+1
@@ -39,6 +39,7 @@ export interface KeyringPairs {
|
||||
}
|
||||
|
||||
export interface KeyringInstance {
|
||||
addPair (pair: KeyringPair): KeyringPair,
|
||||
addFromAddress (address: string | Uint8Array, meta?: KeyringPair$Meta): KeyringPair,
|
||||
addFromSeed (seed: Uint8Array, meta?: KeyringPair$Meta): KeyringPair,
|
||||
addFromJson (pair: KeyringPair$Json): KeyringPair,
|
||||
|
||||
Reference in New Issue
Block a user