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
+17 -10
View File
@@ -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();