Merge pull request #5112 from MetaMask/hardware-wallet-fixes

Hardware wallet fixes
This commit is contained in:
Bruno Barbieri 2018-08-21 10:48:40 -04:00 committed by GitHub
commit 282820c93a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -668,7 +668,9 @@ module.exports = class MetamaskController extends EventEmitter {
this.preferencesController.setAddresses(newAccounts) this.preferencesController.setAddresses(newAccounts)
newAccounts.forEach(address => { newAccounts.forEach(address => {
if (!oldAccounts.includes(address)) { if (!oldAccounts.includes(address)) {
this.preferencesController.setAccountLabel(address, `${deviceName.toUpperCase()} ${parseInt(index, 10) + 1}`) // Set the account label to Trezor 1 / Ledger 1, etc
this.preferencesController.setAccountLabel(address, `${deviceName[0].toUpperCase()}${deviceName.slice(1)} ${parseInt(index, 10) + 1}`)
// Select the account
this.preferencesController.setSelectedAddress(address) this.preferencesController.setSelectedAddress(address)
} }
}) })
@ -800,7 +802,8 @@ module.exports = class MetamaskController extends EventEmitter {
// Remove account from the preferences controller // Remove account from the preferences controller
this.preferencesController.removeAddress(address) this.preferencesController.removeAddress(address)
// Remove account from the account tracker controller // Remove account from the account tracker controller
this.accountTracker.removeAccount(address) this.accountTracker.removeAccount([address])
// Remove account from the keyring // Remove account from the keyring
await this.keyringController.removeAccount(address) await this.keyringController.removeAccount(address)
return address return address

View File

@ -573,7 +573,7 @@ describe('MetaMaskController', function () {
assert(metamaskController.preferencesController.removeAddress.calledWith(addressToRemove)) assert(metamaskController.preferencesController.removeAddress.calledWith(addressToRemove))
}) })
it('should call accountTracker.removeAccount', async function () { it('should call accountTracker.removeAccount', async function () {
assert(metamaskController.accountTracker.removeAccount.calledWith(addressToRemove)) assert(metamaskController.accountTracker.removeAccount.calledWith([addressToRemove]))
}) })
it('should call keyringController.removeAccount', async function () { it('should call keyringController.removeAccount', async function () {
assert(metamaskController.keyringController.removeAccount.calledWith(addressToRemove)) assert(metamaskController.keyringController.removeAccount.calledWith(addressToRemove))