aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-01-31 07:08:31 +0800
committerkumavis <aaron@kumavis.me>2017-01-31 07:08:31 +0800
commitf9b31fe2c3a43339a4519761e4c8b2f3813e85e0 (patch)
tree123f368b533b374a89cb5e5da593d3babb5002e2 /app
parentb1de2cdefa2341eeab8d0269a1b14b349fdd5d16 (diff)
downloadtangerine-wallet-browser-f9b31fe2c3a43339a4519761e4c8b2f3813e85e0.tar
tangerine-wallet-browser-f9b31fe2c3a43339a4519761e4c8b2f3813e85e0.tar.gz
tangerine-wallet-browser-f9b31fe2c3a43339a4519761e4c8b2f3813e85e0.tar.bz2
tangerine-wallet-browser-f9b31fe2c3a43339a4519761e4c8b2f3813e85e0.tar.lz
tangerine-wallet-browser-f9b31fe2c3a43339a4519761e4c8b2f3813e85e0.tar.xz
tangerine-wallet-browser-f9b31fe2c3a43339a4519761e4c8b2f3813e85e0.tar.zst
tangerine-wallet-browser-f9b31fe2c3a43339a4519761e4c8b2f3813e85e0.zip
rename selectedAccount to selectedAddress
Diffstat (limited to 'app')
-rw-r--r--app/scripts/keyring-controller.js4
-rw-r--r--app/scripts/lib/controllers/preferences.js7
-rw-r--r--app/scripts/metamask-controller.js10
-rw-r--r--app/scripts/migrations/006.js2
4 files changed, 13 insertions, 10 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index 3e329cb3f..f7a4e4010 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -150,7 +150,7 @@ class KeyringController extends EventEmitter {
const firstAccount = accounts[0]
if (!firstAccount) throw new Error('KeyringController - First Account not found.')
const hexAccount = normalizeAddress(firstAccount)
- this.setSelectedAccount(hexAccount)
+ this.emit('newAccount', hexAccount)
return this.setupAccounts(accounts)
})
.then(this.persistAllKeyrings.bind(this, password))
@@ -391,7 +391,6 @@ class KeyringController extends EventEmitter {
const firstAccount = accounts[0]
if (!firstAccount) throw new Error('KeyringController - No account found on keychain.')
const hexAccount = normalizeAddress(firstAccount)
- this.setSelectedAccount(hexAccount)
this.emit('newAccount', hexAccount)
return this.setupAccounts(accounts)
})
@@ -638,7 +637,6 @@ class KeyringController extends EventEmitter {
this.keyrings = []
this.identities = {}
- this.setSelectedAccount()
}
}
diff --git a/app/scripts/lib/controllers/preferences.js b/app/scripts/lib/controllers/preferences.js
index e338f5b5e..dc9464c4e 100644
--- a/app/scripts/lib/controllers/preferences.js
+++ b/app/scripts/lib/controllers/preferences.js
@@ -13,8 +13,11 @@ class PreferencesController {
//
setSelectedAddress(_address) {
- const address = normalizeAddress(_address)
- this.store.updateState({ selectedAddress: address })
+ return new Promise((resolve, reject) => {
+ const address = normalizeAddress(_address)
+ this.store.updateState({ selectedAddress: address })
+ resolve()
+ })
}
getSelectedAddress(_address) {
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 64deae426..e081188ce 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -62,8 +62,9 @@ module.exports = class MetamaskController extends EventEmitter {
configManager: this.configManager,
getNetwork: this.getStateNetwork.bind(this),
})
- this.keyringController.on('newAccount', (account) => {
- autoFaucet(account)
+ this.keyringController.on('newAccount', (address) => {
+ this.preferencesController.setSelectedAddress(address)
+ autoFaucet(address)
})
// tx mgmt
@@ -176,6 +177,7 @@ module.exports = class MetamaskController extends EventEmitter {
this.configManager.getConfig(),
this.txManager.getState(),
keyringControllerState,
+ this.preferencesController.store.getState(),
this.noticeController.getState(),
{
shapeShiftTxList: this.configManager.getShapeShiftTxList(),
@@ -223,7 +225,7 @@ module.exports = class MetamaskController extends EventEmitter {
submitPassword: this.submitPassword.bind(this),
// PreferencesController
- setSelectedAccount: nodeify(preferencesController.setSelectedAccount).bind(preferencesController),
+ setSelectedAddress: nodeify(preferencesController.setSelectedAddress).bind(preferencesController),
// KeyringController
setLocked: nodeify(keyringController.setLocked).bind(keyringController),
@@ -351,7 +353,7 @@ module.exports = class MetamaskController extends EventEmitter {
return this.keyringController.addNewKeyring('Simple Key Pair', [ privateKey ])
})
.then(keyring => keyring.getAccounts())
- .then((accounts) => this.preferencesController.setSelectedAccount(accounts[0]))
+ .then((accounts) => this.preferencesController.setSelectedAddress(accounts[0]))
.then(() => { cb(null, this.keyringController.fullUpdate()) })
.catch((reason) => { cb(reason) })
}
diff --git a/app/scripts/migrations/006.js b/app/scripts/migrations/006.js
index b2fcbae15..677e89bf7 100644
--- a/app/scripts/migrations/006.js
+++ b/app/scripts/migrations/006.js
@@ -30,7 +30,7 @@ function migrateState (state) {
// add new state
const newState = extend(state, {
PreferencesController: {
- selectedAccount: config.selectedAccount,
+ selectedAddress: config.selectedAccount,
},
})