aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/metamask-controller.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-01-31 05:01:07 +0800
committerkumavis <aaron@kumavis.me>2017-01-31 05:01:07 +0800
commit4dafb09db20a8c7050a431e70eb773e2ac62d6c8 (patch)
tree0a9019e8f54078f88a9b0cab6464ef869f465aba /app/scripts/metamask-controller.js
parent0a1918f71a0a5768d7501e3ee799a3ed2e6d9f49 (diff)
downloadtangerine-wallet-browser-4dafb09db20a8c7050a431e70eb773e2ac62d6c8.tar
tangerine-wallet-browser-4dafb09db20a8c7050a431e70eb773e2ac62d6c8.tar.gz
tangerine-wallet-browser-4dafb09db20a8c7050a431e70eb773e2ac62d6c8.tar.bz2
tangerine-wallet-browser-4dafb09db20a8c7050a431e70eb773e2ac62d6c8.tar.lz
tangerine-wallet-browser-4dafb09db20a8c7050a431e70eb773e2ac62d6c8.tar.xz
tangerine-wallet-browser-4dafb09db20a8c7050a431e70eb773e2ac62d6c8.tar.zst
tangerine-wallet-browser-4dafb09db20a8c7050a431e70eb773e2ac62d6c8.zip
metamask - move selectedAccount set/get to preferencesController
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r--app/scripts/metamask-controller.js21
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) })
}