diff --git a/packages/ui-identicon/package.json b/packages/ui-identicon/package.json index 4b574d1b..7534cc2e 100644 --- a/packages/ui-identicon/package.json +++ b/packages/ui-identicon/package.json @@ -10,9 +10,9 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.1.5", - "@polkadot/keyring": "^0.33.11", + "@polkadot/keyring": "^0.33.12", "@polkadot/ui-settings": "^0.22.11", - "@polkadot/util-crypto": "^0.33.11", + "@polkadot/util-crypto": "^0.33.12", "@types/color": "^3.0.0", "@types/react-copy-to-clipboard": "^4.2.6", "color": "^3.0.0", diff --git a/packages/ui-keyring/package.json b/packages/ui-keyring/package.json index 233a6081..1a8f71df 100644 --- a/packages/ui-keyring/package.json +++ b/packages/ui-keyring/package.json @@ -11,8 +11,8 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.1.5", - "@polkadot/keyring": "^0.33.11", - "@polkadot/types": "^0.33.7", + "@polkadot/keyring": "^0.33.12", + "@polkadot/types": "^0.33.8", "store": "^2.0.12" } } diff --git a/packages/ui-keyring/src/index.ts b/packages/ui-keyring/src/index.ts index 6d92f6cb..8ec65fb0 100644 --- a/packages/ui-keyring/src/index.ts +++ b/packages/ui-keyring/src/index.ts @@ -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 { diff --git a/packages/ui-keyring/src/options/index.ts b/packages/ui-keyring/src/options/index.ts index 3aa91cc0..7dc4487b 100644 --- a/packages/ui-keyring/src/options/index.ts +++ b/packages/ui-keyring/src/options/index.ts @@ -35,17 +35,13 @@ class KeyringOption implements KeyringOptionInstance { this.addAccounts(keyring, options); this.addAddresses(keyring, options); - options.address = ([] as KeyringSectionOptions).concat( - options.address.length ? [ this.createOptionHeader('Addresses') ] : [], - options.address, - options.recent.length ? [ this.createOptionHeader('Recent') ] : [], - options.recent + options.address = this.linkItems( + { header: 'Addresses', options: options.address }, + { header: 'Recent', options: options.recent } ); - options.account = ([] as KeyringSectionOptions).concat( - options.account.length ? [ this.createOptionHeader('Accounts') ] : [], - options.account, - options.testing.length ? [ this.createOptionHeader('Development') ] : [], - options.testing + options.account = this.linkItems( + { header: 'Accounts', options: options.account }, + { header: 'Development', options: options.testing } ); options.all = ([] as KeyringSectionOptions).concat( @@ -59,6 +55,17 @@ class KeyringOption implements KeyringOptionInstance { hasCalledInitOptions = true; } + private linkItems (...items: Array<{ header: string, options: KeyringSectionOptions }>) { + return items.reduce((result, { header, options }) => { + return result.concat( + options.length + ? [this.createOptionHeader(header)] + : [], + options + ); + }, [] as KeyringSectionOptions); + } + private addAccounts (keyring: KeyringStruct, options: KeyringOptions): void { const available = keyring.accounts.subject.getValue(); diff --git a/yarn.lock b/yarn.lock index b24c2a67..60355a90 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1430,14 +1430,14 @@ typedoc-plugin-no-inherit "^1.0.2" typescript "^3.2.1" -"@polkadot/keyring@^0.33.11": - version "0.33.11" - resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.33.11.tgz#79c6174e9b27147ff69a2375f39a2462b2d581c7" - integrity sha512-AP98VfGbcdXo9Bp650klh0l734kcmrYM1kzDs+mpGmpwMQtjRrEuitWwAvb84Sl6Snq6qMOadLXVAxU8PtOtgA== +"@polkadot/keyring@^0.33.12": + version "0.33.12" + resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.33.12.tgz#7e5d8e5ad996981790b76c4741b89eea4ce8988d" + integrity sha512-qClQCGtP6zMZzi6WZbToyyaifbpX3D25UAgEl4wyGn+G1NM8anRVRcjtRFOBRSE+WFZU6SPyMtmyMWI+roQ42A== dependencies: "@babel/runtime" "^7.1.5" - "@polkadot/util" "^0.33.11" - "@polkadot/util-crypto" "^0.33.11" + "@polkadot/util" "^0.33.12" + "@polkadot/util-crypto" "^0.33.12" "@types/bs58" "^3.0.30" bs58 "^4.0.1" @@ -1446,22 +1446,22 @@ resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.41.tgz#647b44b038f94a7acf76633b25cb72df897872fc" integrity sha512-/vYpjqKU+QKHNAlFdLgFZAAr54wxQMgIuszZ5BxaayUoq7ukDlvCPhUGQ3fNoyBSEaL7uTCZ/5SVRc363IehoA== -"@polkadot/types@^0.33.7": - version "0.33.7" - resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.33.7.tgz#60363d6272ee5d37eac10998b6930c06fc40d7e8" - integrity sha512-kkzIMIk+Ai6Elg/mYA5bDn75X68p2yns+dfA8uouuR20MysbxhCNtLkC/dTW0wHiRaNsCjDN+knbWiliLBygEg== +"@polkadot/types@^0.33.8": + version "0.33.8" + resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.33.8.tgz#289e235612152b1f416f7ac0bb893dddfb2236c1" + integrity sha512-za2hDhLtdtWndNgoMLXlNg1Y4xVu+Fl9ruFzbmm9PLkSg8fR6uZpqSHm5PCDJvbJJG+13PhLGse0Bd5OcvGUww== dependencies: "@babel/runtime" "^7.1.5" - "@polkadot/keyring" "^0.33.11" - "@polkadot/util" "^0.33.11" + "@polkadot/keyring" "^0.33.12" + "@polkadot/util" "^0.33.12" -"@polkadot/util-crypto@^0.33.11": - version "0.33.11" - resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.33.11.tgz#25b30e69a4da1f6a42d3680536130ca4f9480db6" - integrity sha512-jL1TzlqHGKRu9SN80e0K/0H1ZZ6fRTv96s2f6s27GrGt6+tcPEVcmaQK5vjEDMw2pT9+b5TPwcx2gLwh56GLVg== +"@polkadot/util-crypto@^0.33.12": + version "0.33.12" + resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.33.12.tgz#1f5ab4f6cda328ca4460be3c6d083671e815ff1e" + integrity sha512-iIY4qminRjWOrYhbl9DuJ6CjQC0sivrkGI1yV5wVxSVPwC9GHYL/3MKmw4FX7vhtaLlrcs0hTz/g/MOt66fX/Q== dependencies: "@babel/runtime" "^7.1.5" - "@polkadot/util" "^0.33.11" + "@polkadot/util" "^0.33.12" "@types/bip39" "^2.4.1" bip39 "^2.5.0" blakejs "^1.1.0" @@ -1469,10 +1469,10 @@ tweetnacl "^1.0.0" xxhashjs "^0.2.2" -"@polkadot/util@^0.33.11": - version "0.33.11" - resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.33.11.tgz#3e2433e556ee14c685ebc5920c229cb76e0b985b" - integrity sha512-Tn+WYU+RxOaJhrUsPjBOk77MDKb6bsqVkcs5ysSc1HUDIRqZwGABnX1rhP2/DipS91hj8DQ2HZE18S7mCBv1bQ== +"@polkadot/util@^0.33.12": + version "0.33.12" + resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.33.12.tgz#489fbe478887ec1bba0b7873b3cff39bf17899fb" + integrity sha512-8qAjFGR9IjS8CBEqvJyPUEFasJVCF/bB/vqZFKG/LPi3oL1y4kTIWnwp1GhLhXCVIjfoZOxaW5wpnRajbeHINQ== dependencies: "@babel/runtime" "^7.1.5" "@types/bn.js" "^4.11.3"