1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fix bug where reset account would not work.

Fixes #4462

Ensures that resetAccount() can work on non-stock providers.

I'm unclear how this was ever working, this code hasn't moved in months,
but users report it recently breaking. Maybe we only recently pushed it
to prod.
This commit is contained in:
Dan Finlay 2018-06-06 16:46:39 -07:00
parent aea9491f6a
commit c53c5d5c9e
3 changed files with 12 additions and 6 deletions

View File

@ -2,6 +2,8 @@
## Current Master
- Fix bug where account reset did not work with custom RPC providers.
## 4.7.4 Tue Jun 05 2018
- Add diagnostic reporting for users with multiple HD keyrings

View File

@ -89,14 +89,21 @@ module.exports = class NetworkController extends EventEmitter {
type: 'rpc',
rpcTarget,
}
this.providerStore.updateState(providerConfig)
this._switchNetwork(providerConfig)
this.providerConfig = providerConfig
}
async setProviderType (type) {
assert.notEqual(type, 'rpc', `NetworkController - cannot call "setProviderType" with type 'rpc'. use "setRpcTarget"`)
assert(INFURA_PROVIDER_TYPES.includes(type) || type === LOCALHOST, `NetworkController - Unknown rpc type "${type}"`)
const providerConfig = { type }
this.providerConfig = providerConfig
}
resetConnection () {
this.providerConfig = this.getProviderConfig()
}
set providerConfig (providerConfig) {
this.providerStore.updateState(providerConfig)
this._switchNetwork(providerConfig)
}

View File

@ -628,10 +628,7 @@ module.exports = class MetamaskController extends EventEmitter {
async resetAccount () {
const selectedAddress = this.preferencesController.getSelectedAddress()
this.txController.wipeTransactions(selectedAddress)
const networkController = this.networkController
const oldType = networkController.getProviderConfig().type
await networkController.setProviderType(oldType, true)
this.networkController.resetConnection()
return selectedAddress
}