From 2dd7bd6bd0d026da339c1e55d52270674be13f3d Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 25 Apr 2016 12:20:33 -0700 Subject: Make account detail view the primary view - When unlocking, the first account is now selected by default and displayed as the main view. - There is now a "CHANGE ACCT" button on the detail view to show the accounts list. - Clicking an account from the accounts list now navigates to the detail view and selects that account. - Config/Info screen "back" buttons now fire a new action, `GO_HOME`, which is configured to navigate to the accountDetail view, putting that logic in one place. - When locking and unlocking again, the first account is always displayed, eventually we should persist the selection. --- app/scripts/lib/idStore.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'app/scripts/lib/idStore.js') diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index 7763d33d8..525fdae30 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -72,7 +72,8 @@ IdentityStore.prototype.setStore = function(store){ IdentityStore.prototype.clearSeedWordCache = function(cb) { configManager.setShowSeedWords(false) - cb() + var accounts = this._loadIdentities() + cb(null, accounts) } IdentityStore.prototype.getState = function(){ @@ -119,8 +120,8 @@ IdentityStore.prototype.submitPassword = function(password, cb){ this._tryPassword(password, (err) => { if (err) return cb(err) // load identities before returning... - this._loadIdentities() - cb() + var accounts = this._loadIdentities() + cb(null, accounts) }) } @@ -212,6 +213,7 @@ IdentityStore.prototype._loadIdentities = function(){ if (!this._isUnlocked()) throw new Error('not unlocked') var addresses = this._getAddresses() + var accountArray = [] addresses.forEach((address, i) => { // // add to ethStore this._ethStore.addAccount(address) @@ -223,8 +225,10 @@ IdentityStore.prototype._loadIdentities = function(){ mayBeFauceting: this._mayBeFauceting(i), } this._currentState.identities[address] = identity + accountArray.push(identity) }) this._didUpdate() + return accountArray } // mayBeFauceting -- cgit v1.2.3 From 1025eb3b4f90c2b909fe9d238cebba878c8ce2db Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 25 Apr 2016 14:14:34 -0700 Subject: Persist selected account When selecting an account, we now persist the selection to the `configManager`, so the selection can be restored when re-unlocking Metamask. Also found the bug where `rawtestrpc` was still being used as a default, and fixed it! --- app/scripts/lib/idStore.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'app/scripts/lib/idStore.js') diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index 525fdae30..92d0f9668 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -9,7 +9,7 @@ const extend = require('xtend') const createId = require('web3-provider-engine/util/random-id') const autoFaucet = require('./auto-faucet') const configManager = require('./config-manager-singleton') -const DEFAULT_RPC = 'https://rawtestrpc.metamask.io/' +const DEFAULT_RPC = 'https://testrpc.metamask.io/' module.exports = IdentityStore @@ -72,8 +72,7 @@ IdentityStore.prototype.setStore = function(store){ IdentityStore.prototype.clearSeedWordCache = function(cb) { configManager.setShowSeedWords(false) - var accounts = this._loadIdentities() - cb(null, accounts) + cb(null, configManager.getSelectedAccount()) } IdentityStore.prototype.getState = function(){ @@ -85,6 +84,7 @@ IdentityStore.prototype.getState = function(){ seedWords: seedWords, unconfTxs: configManager.unconfirmedTxs(), transactions: configManager.getTxList(), + selectedAddress: configManager.getSelectedAccount(), })) } @@ -97,7 +97,7 @@ IdentityStore.prototype.getSeedIfUnlocked = function() { } IdentityStore.prototype.getSelectedAddress = function(){ - return this._currentState.selectedAddress + return configManager.getSelectedAccount() } IdentityStore.prototype.setSelectedAddress = function(address){ @@ -106,7 +106,7 @@ IdentityStore.prototype.setSelectedAddress = function(address){ address = addresses[0] } - this._currentState.selectedAddress = address + configManager.setSelectedAccount(address) this._didUpdate() } @@ -120,8 +120,8 @@ IdentityStore.prototype.submitPassword = function(password, cb){ this._tryPassword(password, (err) => { if (err) return cb(err) // load identities before returning... - var accounts = this._loadIdentities() - cb(null, accounts) + this._loadIdentities() + cb(null, configManager.getSelectedAccount()) }) } @@ -213,7 +213,6 @@ IdentityStore.prototype._loadIdentities = function(){ if (!this._isUnlocked()) throw new Error('not unlocked') var addresses = this._getAddresses() - var accountArray = [] addresses.forEach((address, i) => { // // add to ethStore this._ethStore.addAccount(address) @@ -225,10 +224,8 @@ IdentityStore.prototype._loadIdentities = function(){ mayBeFauceting: this._mayBeFauceting(i), } this._currentState.identities[address] = identity - accountArray.push(identity) }) this._didUpdate() - return accountArray } // mayBeFauceting -- cgit v1.2.3