From ea56426b2355c1076c18256fb0b4e74f47ff4b39 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 21 Nov 2016 20:08:36 -0800 Subject: [PATCH 1/5] Use callback in placeSeedWord method. When displaying seed words, we were not using a callback, which had some race condition potential. This is simply a little cleaner and more correct. Fixes #842 --- app/scripts/keyring-controller.js | 7 ++++++- ui/app/actions.js | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js index cf761c88c..49a41df66 100644 --- a/app/scripts/keyring-controller.js +++ b/app/scripts/keyring-controller.js @@ -173,10 +173,15 @@ module.exports = class KeyringController extends EventEmitter { }) } - placeSeedWords () { + placeSeedWords (cb) { const firstKeyring = this.keyrings[0] const seedWords = firstKeyring.serialize().mnemonic this.configManager.setSeedWords(seedWords) + + if (cb && typeof cb === 'function') { + cb() + this.emit('update') + } } submitPassword (password, cb) { diff --git a/ui/app/actions.js b/ui/app/actions.js index e69b743e9..4a5507d33 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -221,9 +221,11 @@ function requestRevealSeed (password) { return (dispatch) => { dispatch(actions.showLoadingIndication()) background.submitPassword(password, (err) => { - dispatch(actions.hideLoadingIndication()) if (err) return dispatch(actions.displayWarning(err.message)) - background.placeSeedWords() + background.placeSeedWords((err) => { + if (err) return dispatch(actions.displayWarning(err.message)) + dispatch(actions.hideLoadingIndication()) + }) }) } } From a67b4d7131b05256dbef69fc34cbae3944c1e43e Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 22 Nov 2016 12:54:27 -0800 Subject: [PATCH 2/5] Fix etherscan link generation test --- test/unit/account-link-test.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/unit/account-link-test.js b/test/unit/account-link-test.js index 39889b6be..4ea12e002 100644 --- a/test/unit/account-link-test.js +++ b/test/unit/account-link-test.js @@ -3,9 +3,15 @@ var linkGen = require('../../ui/lib/account-link') describe('account-link', function() { - it('adds testnet prefix to morden test network', function() { + it('adds morden prefix to morden test network', function() { var result = linkGen('account', '2') - assert.notEqual(result.indexOf('testnet'), -1, 'testnet injected') + assert.notEqual(result.indexOf('morden'), -1, 'testnet included') + assert.notEqual(result.indexOf('account'), -1, 'account included') + }) + + it('adds testnet prefix to ropsten test network', function() { + var result = linkGen('account', '3') + assert.notEqual(result.indexOf('testnet'), -1, 'testnet included') assert.notEqual(result.indexOf('account'), -1, 'account included') }) From 606c0b761827df86ded4763a67f38a98738014e8 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 22 Nov 2016 12:57:15 -0800 Subject: [PATCH 3/5] Remove callback type check --- app/scripts/keyring-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js index 51369eac8..224d6ba7a 100644 --- a/app/scripts/keyring-controller.js +++ b/app/scripts/keyring-controller.js @@ -178,7 +178,7 @@ module.exports = class KeyringController extends EventEmitter { const seedWords = firstKeyring.serialize().mnemonic this.configManager.setSeedWords(seedWords) - if (cb && typeof cb === 'function') { + if (cb) { cb() this.emit('update') } From 869d7313192df9ffa0941c3dc808dc73b812e656 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 22 Nov 2016 13:00:13 -0800 Subject: [PATCH 4/5] Restore ropsten link support --- ui/lib/account-link.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/lib/account-link.js b/ui/lib/account-link.js index a29ba5e69..ff52d9c54 100644 --- a/ui/lib/account-link.js +++ b/ui/lib/account-link.js @@ -1,4 +1,4 @@ -module.exports = function (address, network) { +module.exports = function(address, network) { const net = parseInt(network) let link @@ -7,10 +7,10 @@ module.exports = function (address, network) { link = `http://etherscan.io/address/${address}` break case 2: // morden test net - link = `http://testnet.etherscan.io/address/${address}` + link = `http://morden.etherscan.io/address/${address}` break case 3: // ropsten test net - link = '' + link = `http://testnet.etherscan.io/address/${address}` break default: link = '' From c4056a861a4a383b3bea18225e71435bdf75f6d0 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 22 Nov 2016 13:13:10 -0800 Subject: [PATCH 5/5] Move state update outside of conditional callback block --- app/scripts/keyring-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js index 224d6ba7a..cb92af388 100644 --- a/app/scripts/keyring-controller.js +++ b/app/scripts/keyring-controller.js @@ -180,8 +180,8 @@ module.exports = class KeyringController extends EventEmitter { if (cb) { cb() - this.emit('update') } + this.emit('update') } submitPassword (password, cb) {