Cleanup keypair add functionality (#217)

* Cleanup keypair add functionality

* Expose addPair
This commit is contained in:
Jaco Greeff
2018-09-20 16:57:39 +02:00
committed by GitHub
parent 2edb1e7cfb
commit 9765b2c05d
4 changed files with 1425 additions and 108 deletions
+2 -2
View File
@@ -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"
}
}
+6 -2
View File
@@ -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 {
+1
View File
@@ -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,
+1416 -104
View File
File diff suppressed because it is too large Load Diff