|
|
@ -39,9 +39,6 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
constructor (opts) { |
|
|
|
constructor (opts) { |
|
|
|
super() |
|
|
|
super() |
|
|
|
|
|
|
|
|
|
|
|
this.createVaultRequestStart = [] |
|
|
|
|
|
|
|
this.createVaultRequestEnd = [] |
|
|
|
|
|
|
|
this.createVaultMutex = new Mutex() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.sendUpdate = debounce(this.privateSendUpdate.bind(this), 200) |
|
|
|
this.sendUpdate = debounce(this.privateSendUpdate.bind(this), 200) |
|
|
|
|
|
|
|
|
|
|
@ -54,6 +51,9 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
// observable state store
|
|
|
|
// observable state store
|
|
|
|
this.store = new ObservableStore(initState) |
|
|
|
this.store = new ObservableStore(initState) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// lock to ensure only one vault created at once
|
|
|
|
|
|
|
|
this.createVaultMutex = new Mutex() |
|
|
|
|
|
|
|
|
|
|
|
// network store
|
|
|
|
// network store
|
|
|
|
this.networkController = new NetworkController(initState.NetworkController) |
|
|
|
this.networkController = new NetworkController(initState.NetworkController) |
|
|
|
|
|
|
|
|
|
|
@ -474,36 +474,25 @@ module.exports = class MetamaskController extends EventEmitter { |
|
|
|
|
|
|
|
|
|
|
|
async createNewVaultAndKeychain (password) { |
|
|
|
async createNewVaultAndKeychain (password) { |
|
|
|
const release = await this.createVaultMutex.acquire() |
|
|
|
const release = await this.createVaultMutex.acquire() |
|
|
|
this.createVaultRequestStart.push(performance.now()) |
|
|
|
let vault |
|
|
|
this.createVaultRequestEnd.push(0); |
|
|
|
|
|
|
|
const idx = this.createVaultRequestStart.length - 1; |
|
|
|
try { |
|
|
|
if(idx === 1) { |
|
|
|
const accounts = await this.keyringController.getAccounts() |
|
|
|
await this.sleep(8000) |
|
|
|
|
|
|
|
} |
|
|
|
if (accounts.length > 0) { |
|
|
|
const vault = await this.keyringController.createNewVaultAndKeychain(password) |
|
|
|
vault = await this.keyringController.fullUpdate() |
|
|
|
if(idx === 0) { |
|
|
|
|
|
|
|
//await this.sleep(3000)
|
|
|
|
} else { |
|
|
|
} |
|
|
|
let vault = await this.keyringController.createNewVaultAndKeychain(password) |
|
|
|
console.log({ |
|
|
|
|
|
|
|
"idx": idx, |
|
|
|
|
|
|
|
"when": "before", |
|
|
|
|
|
|
|
"obj": vault |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
this.selectFirstIdentity(vault) |
|
|
|
this.selectFirstIdentity(vault) |
|
|
|
console.log({ |
|
|
|
} |
|
|
|
"idx": idx, |
|
|
|
|
|
|
|
"when": "after", |
|
|
|
|
|
|
|
"obj": vault |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
this.createVaultRequestEnd[idx] = performance.now() |
|
|
|
|
|
|
|
console.log(this.createVaultRequestStart) |
|
|
|
|
|
|
|
console.log(this.createVaultRequestEnd) |
|
|
|
|
|
|
|
release() |
|
|
|
release() |
|
|
|
return vault |
|
|
|
} catch (err) { |
|
|
|
|
|
|
|
release() |
|
|
|
|
|
|
|
throw err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sleep(ms) { |
|
|
|
return vault |
|
|
|
return new Promise(resolve => setTimeout(resolve, ms)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async createNewVaultAndRestore (password, seed) { |
|
|
|
async createNewVaultAndRestore (password, seed) { |
|
|
|