KeyringStore interface (#127)

This commit is contained in:
Jaco Greeff
2019-05-18 18:03:09 +02:00
committed by GitHub
parent 7101c29ffb
commit f1104b423c
6 changed files with 57 additions and 16 deletions
@@ -0,0 +1,29 @@
// Copyright 2017-2019 @polkadot/ui-keyring authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { KeyringStore } from '../types';
import store from 'store';
export default class Store implements KeyringStore {
all (cb: (key: string, value: any) => void): void {
store.each((value: any, key: string) =>
cb(key, value)
);
}
get (key: string, cb: (value: any) => void): void {
cb(store.get(key));
}
remove (key: string, cb?: () => void): void {
store.remove(key);
cb && cb();
}
set (key: string, value: any, cb?: () => void): void {
store.set(key, value);
cb && cb();
}
}