|
|
@ -436,28 +436,24 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
* @returns {Object} vault |
|
|
|
* @returns {Object} vault |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
async createNewVaultAndKeychain (password) { |
|
|
|
async createNewVaultAndKeychain (password) { |
|
|
|
const release = await this.createVaultMutex.acquire() |
|
|
|
const releaseLock = await this.createVaultMutex.acquire() |
|
|
|
let vault |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
let vault |
|
|
|
const accounts = await this.keyringController.getAccounts() |
|
|
|
const accounts = await this.keyringController.getAccounts() |
|
|
|
|
|
|
|
|
|
|
|
if (accounts.length > 0) { |
|
|
|
if (accounts.length > 0) { |
|
|
|
vault = await this.keyringController.fullUpdate() |
|
|
|
vault = await this.keyringController.fullUpdate() |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
vault = await this.keyringController.createNewVaultAndKeychain(password) |
|
|
|
vault = await this.keyringController.createNewVaultAndKeychain(password) |
|
|
|
const accounts = await this.keyringController.getAccounts() |
|
|
|
const accounts = await this.keyringController.getAccounts() |
|
|
|
this.preferencesController.setAddresses(accounts) |
|
|
|
this.preferencesController.setAddresses(accounts) |
|
|
|
this.selectFirstIdentity() |
|
|
|
this.selectFirstIdentity() |
|
|
|
} |
|
|
|
} |
|
|
|
release() |
|
|
|
releaseLock() |
|
|
|
|
|
|
|
return vault |
|
|
|
} catch (err) { |
|
|
|
} catch (err) { |
|
|
|
release() |
|
|
|
releaseLock() |
|
|
|
throw err |
|
|
|
throw err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return vault |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -466,7 +462,7 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
* @param {} seed |
|
|
|
* @param {} seed |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
async createNewVaultAndRestore (password, seed) { |
|
|
|
async createNewVaultAndRestore (password, seed) { |
|
|
|
const release = await this.createVaultMutex.acquire() |
|
|
|
const releaseLock = await this.createVaultMutex.acquire() |
|
|
|
try { |
|
|
|
try { |
|
|
|
// clear known identities
|
|
|
|
// clear known identities
|
|
|
|
this.preferencesController.setAddresses([]) |
|
|
|
this.preferencesController.setAddresses([]) |
|
|
@ -476,10 +472,10 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
const accounts = await this.keyringController.getAccounts() |
|
|
|
const accounts = await this.keyringController.getAccounts() |
|
|
|
this.preferencesController.setAddresses(accounts) |
|
|
|
this.preferencesController.setAddresses(accounts) |
|
|
|
this.selectFirstIdentity() |
|
|
|
this.selectFirstIdentity() |
|
|
|
release() |
|
|
|
releaseLock() |
|
|
|
return vault |
|
|
|
return vault |
|
|
|
} catch (err) { |
|
|
|
} catch (err) { |
|
|
|
release() |
|
|
|
releaseLock() |
|
|
|
throw err |
|
|
|
throw err |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|