mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
Stop tracking old account balances after restore vault
Per @kgserrano note
This commit is contained in:
parent
cafabf914f
commit
7032edf32b
@ -459,17 +459,30 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||
//
|
||||
|
||||
async createNewVaultAndKeychain (password, cb) {
|
||||
this.forgetOldAccounts()
|
||||
const vault = await this.keyringController.createNewVaultAndKeychain(password)
|
||||
this.selectFirstIdentity(vault)
|
||||
return vault
|
||||
}
|
||||
|
||||
async createNewVaultAndRestore (password, seed, cb) {
|
||||
this.forgetOldAccounts()
|
||||
const vault = await this.keyringController.createNewVaultAndRestore(password, seed)
|
||||
this.selectFirstIdentity(vault)
|
||||
return vault
|
||||
}
|
||||
|
||||
forgetOldAccounts () {
|
||||
const { accountTracker } = this
|
||||
let oldAccounts = []
|
||||
try {
|
||||
oldAccounts = Object.keys(accountTracker.store.getState().accounts)
|
||||
} catch (e) {
|
||||
log.warn('Could not load old accounts to forget', e)
|
||||
}
|
||||
oldAccounts.forEach(addr => accountTracker.removeAccount(addr))
|
||||
}
|
||||
|
||||
selectFirstIdentity (vault) {
|
||||
const { identities } = vault
|
||||
const address = Object.keys(identities)[0]
|
||||
|
Loading…
Reference in New Issue
Block a user