diff options
metamask - move selectedAccount set/get to preferencesController
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r-- | app/scripts/metamask-controller.js | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index c0673dda4..2f9e37cee 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -42,8 +42,8 @@ module.exports = class MetamaskController extends EventEmitter { this.configManager.updateConversionRate() // preferences controller - this.prefencesController = new PreferencesController({ - initState: initState.PrefencesController, + this.preferencesController = new PreferencesController({ + initState: initState.PreferencesController, }) // rpc provider @@ -71,7 +71,7 @@ module.exports = class MetamaskController extends EventEmitter { txList: this.configManager.getTxList(), txHistoryLimit: 40, setTxList: this.configManager.setTxList.bind(this.configManager), - getSelectedAccount: this.keyringController.getSelectedAccount.bind(this.keyringController), + getSelectedAccount: this.preferencesController.getSelectedAccount.bind(this.preferencesController), getGasMultiplier: this.configManager.getGasMultiplier.bind(this.configManager), getNetwork: this.getStateNetwork.bind(this), signTransaction: this.keyringController.signTransaction.bind(this.keyringController), @@ -107,8 +107,8 @@ module.exports = class MetamaskController extends EventEmitter { this.keyringController.store.subscribe((state) => { this.store.updateState({ KeyringController: state }) }) - this.prefencesController.store.subscribe((state) => { - this.store.updateState({ PrefencesController: state }) + this.preferencesController.store.subscribe((state) => { + this.store.updateState({ PreferencesController: state }) }) } @@ -125,7 +125,7 @@ module.exports = class MetamaskController extends EventEmitter { rpcUrl: this.configManager.getCurrentRpcAddress(), // account mgmt getAccounts: (cb) => { - let selectedAccount = this.keyringController.getSelectedAccount() + let selectedAccount = this.preferencesController.getSelectedAccount() let result = selectedAccount ? [selectedAccount] : [] cb(null, result) }, @@ -191,6 +191,7 @@ module.exports = class MetamaskController extends EventEmitter { getApi () { const keyringController = this.keyringController + const preferencesController = this.preferencesController const txManager = this.txManager const noticeController = this.noticeController @@ -221,12 +222,14 @@ module.exports = class MetamaskController extends EventEmitter { // vault management submitPassword: this.submitPassword.bind(this), + // PreferencesController + setSelectedAccount: nodeify(preferencesController.setSelectedAccount).bind(preferencesController), + // KeyringController setLocked: nodeify(keyringController.setLocked).bind(keyringController), createNewVaultAndKeychain: nodeify(keyringController.createNewVaultAndKeychain).bind(keyringController), createNewVaultAndRestore: nodeify(keyringController.createNewVaultAndRestore).bind(keyringController), addNewKeyring: nodeify(keyringController.addNewKeyring).bind(keyringController), - setSelectedAccount: nodeify(keyringController.setSelectedAccount).bind(keyringController), saveAccountLabel: nodeify(keyringController.saveAccountLabel).bind(keyringController), exportAccount: nodeify(keyringController.exportAccount).bind(keyringController), @@ -339,7 +342,7 @@ module.exports = class MetamaskController extends EventEmitter { // ensuring they are only ever available in the background process. clearSeedWordCache (cb) { this.configManager.setSeedWords(null) - cb(null, this.keyringController.getSelectedAccount()) + cb(null, this.preferencesController.getSelectedAccount()) } importAccountWithStrategy (strategy, args, cb) { @@ -348,7 +351,7 @@ module.exports = class MetamaskController extends EventEmitter { return this.keyringController.addNewKeyring('Simple Key Pair', [ privateKey ]) }) .then(keyring => keyring.getAccounts()) - .then((accounts) => this.keyringController.setSelectedAccount(accounts[0])) + .then((accounts) => this.preferencesController.setSelectedAccount(accounts[0])) .then(() => { cb(null, this.keyringController.fullUpdate()) }) .catch((reason) => { cb(reason) }) } |