aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/keyring-controller.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-01-29 05:12:12 +0800
committerkumavis <aaron@kumavis.me>2017-01-29 05:12:12 +0800
commite9cdbf4f89085cc6c31991416eaac7ca91f9c1d4 (patch)
tree170305624e085f7774c35c537627ca708b258d40 /app/scripts/keyring-controller.js
parent1fd17467442fb60f308b116fea53f87a4cc16dca (diff)
downloadtangerine-wallet-browser-e9cdbf4f89085cc6c31991416eaac7ca91f9c1d4.tar
tangerine-wallet-browser-e9cdbf4f89085cc6c31991416eaac7ca91f9c1d4.tar.gz
tangerine-wallet-browser-e9cdbf4f89085cc6c31991416eaac7ca91f9c1d4.tar.bz2
tangerine-wallet-browser-e9cdbf4f89085cc6c31991416eaac7ca91f9c1d4.tar.lz
tangerine-wallet-browser-e9cdbf4f89085cc6c31991416eaac7ca91f9c1d4.tar.xz
tangerine-wallet-browser-e9cdbf4f89085cc6c31991416eaac7ca91f9c1d4.tar.zst
tangerine-wallet-browser-e9cdbf4f89085cc6c31991416eaac7ca91f9c1d4.zip
keyring - add and initialize obs-store
Diffstat (limited to 'app/scripts/keyring-controller.js')
-rw-r--r--app/scripts/keyring-controller.js38
1 files changed, 33 insertions, 5 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index e1e1342aa..460c71e27 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -1,12 +1,14 @@
const ethUtil = require('ethereumjs-util')
+const BN = ethUtil.BN
const bip39 = require('bip39')
const EventEmitter = require('events').EventEmitter
+const ObservableStore = require('obs-store')
const filter = require('promise-filter')
const encryptor = require('browser-passworder')
-
+const createId = require('./lib/random-id')
const normalize = require('./lib/sig-util').normalize
const messageManager = require('./lib/message-manager')
-const BN = ethUtil.BN
+function noop () {}
// Keyrings:
const SimpleKeyring = require('./keyrings/simple')
@@ -16,9 +18,8 @@ const keyringTypes = [
HdKeyring,
]
-const createId = require('./lib/random-id')
-module.exports = class KeyringController extends EventEmitter {
+class KeyringController extends EventEmitter {
// PUBLIC METHODS
//
@@ -29,6 +30,8 @@ module.exports = class KeyringController extends EventEmitter {
constructor (opts) {
super()
+ const initState = opts.initState || {}
+ this.store = new ObservableStore(initState)
this.configManager = opts.configManager
this.ethStore = opts.ethStore
this.encryptor = encryptor
@@ -643,5 +646,30 @@ module.exports = class KeyringController extends EventEmitter {
}
+//
+// Static Class Methods
+//
+
+KeyringController.selectFromState = (state) => {
+ const config = state.config
+ return {
+ vault: state.vault,
+ selectedAccount: config.selectedAccount,
+ walletNicknames: state.walletNicknames,
+ }
+}
+
+KeyringController.flattenToOldState = (state) => {
+ const data = {
+ vault: state.vault,
+ walletNicknames: state.walletNicknames,
+ config: {
+ selectedAccount: state.selectedAccount,
+ },
+ }
+ return data
+}
+
+
+module.exports = KeyringController
-function noop () {}