Bump deps, small cleanups (#15)

This commit is contained in:
Jaco Greeff
2018-12-10 07:53:58 +01:00
committed by GitHub
parent 48400b6d80
commit 4a89bc4204
5 changed files with 53 additions and 44 deletions
+11 -9
View File
@@ -112,6 +112,15 @@ class Keyring extends Base implements KeyringStruct {
.map((address) => this.getAddress(address));
}
private rewriteKey (json: KeyringJson, key: string, hexAddr: string, creator: (addr: string) => string) {
if (hexAddr.substr(0, 2) === '0x') {
return;
}
store.remove(key);
store.set(creator(hexAddr), json);
}
private loadAccount (json: KeyringJson, key: string) {
if (!json.meta.isTesting && (json as KeyringPair$Json).encoded) {
const pair = this.keyring.addFromJson(json as KeyringPair$Json);
@@ -121,10 +130,7 @@ class Keyring extends Base implements KeyringStruct {
const [, hexAddr] = key.split(':');
if (hexAddr.substr(0, 2) !== '0x') {
store.remove(key);
store.set(accountKey(hexAddr), json);
}
this.rewriteKey(json, key, hexAddr, accountKey);
}
private loadAddress (json: KeyringJson, key: string) {
@@ -136,11 +142,7 @@ class Keyring extends Base implements KeyringStruct {
const [, hexAddr] = key.split(':');
this.addresses.add(address, json);
if (hexAddr.substr(0, 2) !== '0x') {
store.remove(key);
store.set(addressKey(hexAddr), json);
}
this.rewriteKey(json, key, hexAddr, addressKey);
}
loadAll (): void {