Skip to content

Commit

Permalink
Merge pull request #4523 from MetaMask/i4462-FixResetBug
Browse files Browse the repository at this point in the history
Fix bug where reset account would not work.
  • Loading branch information
danfinlay authored Jun 7, 2018
2 parents 9882837 + c53c5d5 commit c0d2dab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions app/scripts/controllers/network/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
5 changes: 1 addition & 4 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,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
}
Expand Down

0 comments on commit c0d2dab

Please sign in to comment.