mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-05-30 23:21:04 +00:00
Bump deps, small cleanups (#15)
This commit is contained in:
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user