aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-11-21 06:15:21 +0800
committerDan Finlay <dan@danfinlay.com>2017-11-21 06:15:21 +0800
commitd19aa016aad6a655188f5622150ca44553856305 (patch)
tree3c2abc38d301bd1a6466c261ee425d6c1a81333a
parent884f2035648a8ab7ddbde9f911ed608670912752 (diff)
parent597af980dd68c0252625e7cc5b6a6a223406fbc2 (diff)
downloadtangerine-wallet-browser-d19aa016aad6a655188f5622150ca44553856305.tar
tangerine-wallet-browser-d19aa016aad6a655188f5622150ca44553856305.tar.gz
tangerine-wallet-browser-d19aa016aad6a655188f5622150ca44553856305.tar.bz2
tangerine-wallet-browser-d19aa016aad6a655188f5622150ca44553856305.tar.lz
tangerine-wallet-browser-d19aa016aad6a655188f5622150ca44553856305.tar.xz
tangerine-wallet-browser-d19aa016aad6a655188f5622150ca44553856305.tar.zst
tangerine-wallet-browser-d19aa016aad6a655188f5622150ca44553856305.zip
Merge branch 'i2577-SeedPhraseBug' into i2577-SeedPhraseBug-Test
-rw-r--r--app/scripts/metamask-controller.js32
-rw-r--r--ui/app/first-time/init-menu.js7
2 files changed, 34 insertions, 5 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 968589f6e..a4c77e468 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -31,6 +31,7 @@ const ConfigManager = require('./lib/config-manager')
const nodeify = require('./lib/nodeify')
const accountImporter = require('./account-import-strategies')
const getBuyEthUrl = require('./lib/buy-eth-url')
+const Mutex = require('await-semaphore').Mutex
const version = require('../manifest.json').version
module.exports = class MetamaskController extends EventEmitter {
@@ -38,6 +39,7 @@ module.exports = class MetamaskController extends EventEmitter {
constructor (opts) {
super()
+
this.sendUpdate = debounce(this.privateSendUpdate.bind(this), 200)
this.opts = opts
@@ -49,6 +51,9 @@ module.exports = class MetamaskController extends EventEmitter {
// observable state store
this.store = new ObservableStore(initState)
+ // lock to ensure only one vault created at once
+ this.createVaultMutex = new Mutex()
+
// network store
this.networkController = new NetworkController(initState.NetworkController)
@@ -467,15 +472,34 @@ module.exports = class MetamaskController extends EventEmitter {
// Vault Management
//
- async createNewVaultAndKeychain (password, cb) {
- const vault = await this.keyringController.createNewVaultAndKeychain(password)
- this.selectFirstIdentity(vault)
+ async createNewVaultAndKeychain (password) {
+ const release = await this.createVaultMutex.acquire()
+ let vault
+
+ try {
+ const accounts = await this.keyringController.getAccounts()
+
+ if (accounts.length > 0) {
+ vault = await this.keyringController.fullUpdate()
+
+ } else {
+ let vault = await this.keyringController.createNewVaultAndKeychain(password)
+ this.selectFirstIdentity(vault)
+ }
+ release()
+ } catch (err) {
+ release()
+ throw err
+ }
+
return vault
}
- async createNewVaultAndRestore (password, seed, cb) {
+ async createNewVaultAndRestore (password, seed) {
+ const release = await this.createVaultMutex.acquire()
const vault = await this.keyringController.createNewVaultAndRestore(password, seed)
this.selectFirstIdentity(vault)
+ release()
return vault
}
diff --git a/ui/app/first-time/init-menu.js b/ui/app/first-time/init-menu.js
index cc7c51bd3..b4587f1ee 100644
--- a/ui/app/first-time/init-menu.js
+++ b/ui/app/first-time/init-menu.js
@@ -8,6 +8,8 @@ const actions = require('../actions')
const Tooltip = require('../components/tooltip')
const getCaretCoordinates = require('textarea-caret')
+let isSubmitting = false
+
module.exports = connect(mapStateToProps)(InitializeMenuScreen)
inherits(InitializeMenuScreen, Component)
@@ -164,7 +166,10 @@ InitializeMenuScreen.prototype.createNewVaultAndKeychain = function () {
return
}
- this.props.dispatch(actions.createNewVaultAndKeychain(password))
+ if (!isSubmitting) {
+ isSubmitting = true
+ this.props.dispatch(actions.createNewVaultAndKeychain(password))
+ }
}
InitializeMenuScreen.prototype.inputChanged = function (event) {