diff options
author | Frankie <frankie.diamond@gmail.com> | 2017-01-05 05:05:29 +0800 |
---|---|---|
committer | Frankie <frankie.diamond@gmail.com> | 2017-01-05 05:05:29 +0800 |
commit | 354fa763d4962deeeb4584c5d5bd5f6d007e211a (patch) | |
tree | 0b3996c83748803caa47268d90cd1c7fdaf462d6 /app/scripts/metamask-controller.js | |
parent | e6da8e2762cd54975c334314357f1cd27cc980c8 (diff) | |
parent | c22da8450cf5014fb2bf3c96e0df88c70aa39465 (diff) | |
download | tangerine-wallet-browser-354fa763d4962deeeb4584c5d5bd5f6d007e211a.tar tangerine-wallet-browser-354fa763d4962deeeb4584c5d5bd5f6d007e211a.tar.gz tangerine-wallet-browser-354fa763d4962deeeb4584c5d5bd5f6d007e211a.tar.bz2 tangerine-wallet-browser-354fa763d4962deeeb4584c5d5bd5f6d007e211a.tar.lz tangerine-wallet-browser-354fa763d4962deeeb4584c5d5bd5f6d007e211a.tar.xz tangerine-wallet-browser-354fa763d4962deeeb4584c5d5bd5f6d007e211a.tar.zst tangerine-wallet-browser-354fa763d4962deeeb4584c5d5bd5f6d007e211a.zip |
Merge branch 'dev' into fixtTxManager
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r-- | app/scripts/metamask-controller.js | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 32e9faab2..4caad46e1 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -60,19 +60,24 @@ module.exports = class MetamaskController { this.idStoreMigrator = new IdStoreMigrator({ configManager: this.configManager, }) + + this.ethStore.on('update', this.sendUpdate.bind(this)) } getState () { - return extend( - this.state, - this.ethStore.getState(), - this.configManager.getConfig(), - this.keyringController.getState(), - this.txManager.getState(), - this.noticeController.getState(), { - lostAccounts: this.configManager.getLostAccounts(), - } - ) + return this.keyringController.getState() + .then((keyringControllerState) => { + return extend( + this.state, + this.ethStore.getState(), + this.configManager.getConfig(), + this.txManager.getState(), + keyringControllerState, + this.noticeController.getState(), { + lostAccounts: this.configManager.getLostAccounts(), + } + ) + }) } getApi () { @@ -81,7 +86,7 @@ module.exports = class MetamaskController { const noticeController = this.noticeController return { - getState: (cb) => { cb(null, this.getState()) }, + getState: nodeify(this.getState.bind(this)), setRpcTarget: this.setRpcTarget.bind(this), setProviderType: this.setProviderType.bind(this), useEtherscanProvider: this.useEtherscanProvider.bind(this), @@ -101,7 +106,7 @@ module.exports = class MetamaskController { setLocked: nodeify(keyringController.setLocked).bind(keyringController), submitPassword: (password, cb) => { this.migrateOldVaultIfAny(password) - .then(keyringController.submitPassword.bind(keyringController)) + .then(keyringController.submitPassword.bind(keyringController, password)) .then((newState) => { cb(null, newState) }) .catch((reason) => { cb(reason) }) }, @@ -158,8 +163,12 @@ module.exports = class MetamaskController { } sendUpdate () { - this.listeners.forEach((remote) => { - remote.sendUpdate(this.getState()) + this.getState() + .then((state) => { + + this.listeners.forEach((remote) => { + remote.sendUpdate(state) + }) }) } @@ -479,7 +488,7 @@ module.exports = class MetamaskController { return this.idStoreMigrator.migratedVaultForPassword(password) .then(this.restoreOldVaultAccounts.bind(this)) .then(this.restoreOldLostAccounts.bind(this)) - .then(keyringController.persistAllKeyrings.bind(keyringController)) + .then(keyringController.persistAllKeyrings.bind(keyringController, password)) .then(() => password) } |