Adapt interfaces for latest @polkadot/keyring (#146)

* Adapt interfaces for latest @polkadot/keyring

* Re-write yarn.lock

* Bump latest api
This commit is contained in:
Jaco Greeff
2019-06-13 16:16:53 +02:00
committed by GitHub
parent 77f3ad1b55
commit b26a0ef083
8 changed files with 109 additions and 131 deletions
+7 -12
View File
@@ -58,11 +58,11 @@ export default class Base {
return this._genesisHash;
}
decodeAddress (key: string | Uint8Array, ignoreChecksum?: boolean): Uint8Array {
decodeAddress = (key: string | Uint8Array, ignoreChecksum?: boolean): Uint8Array => {
return this.keyring.decodeAddress(key, ignoreChecksum);
}
encodeAddress (key: string | Uint8Array): string {
encodeAddress = (key: string | Uint8Array): string => {
return this.keyring.encodeAddress(key);
}
@@ -72,7 +72,7 @@ export default class Base {
getPairs (): Array<KeyringPair> {
return this.keyring.getPairs().filter((pair: KeyringPair) =>
env.isDevelopment() || pair.getMeta().isTesting !== true
env.isDevelopment() || pair.meta.isTesting !== true
);
}
@@ -116,19 +116,14 @@ export default class Base {
protected addAccountPairs (): void {
this.keyring
.getPairs()
.forEach((pair: KeyringPair) => {
const address = pair.address();
this.accounts.add(this._store, address, {
address,
meta: pair.getMeta()
});
.forEach(({ address, meta }: KeyringPair) => {
this.accounts.add(this._store, address, { address, meta });
});
}
protected addTimestamp (pair: KeyringPair): void {
if (!pair.getMeta().whenCreated) {
pair.setMeta({ whenCreated: Date.now() });
if (!pair.meta.whenCreated) {
pair.setMeta({ whenCreated: Date.now() });
}
}
}