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

Fix account nicknaming bug

When nicknaming, we weren't normalizing the input, and so we were retrieving with differently formatted addresses than we were persisting.
This commit is contained in:
Dan Finlay 2016-11-03 11:59:20 -07:00
parent 9ca3c57339
commit bd2a429a85
3 changed files with 19 additions and 3 deletions

View File

@ -250,7 +250,7 @@ module.exports = class KeyringController extends EventEmitter {
address,
name,
}
this.saveAccountLabel(address, name)
return this.saveAccountLabel(address, name)
}
saveAccountLabel (account, label, cb) {
@ -259,6 +259,8 @@ module.exports = class KeyringController extends EventEmitter {
configManager.setNicknameForWallet(address, label)
if (cb) {
cb(null, label)
} else {
return label
}
}
@ -270,6 +272,7 @@ module.exports = class KeyringController extends EventEmitter {
data: k.serialize(),
}
})
return this.encryptor.encryptWithKey(this.key, serialized)
.then((encryptedString) => {
this.configManager.setVault(encryptedString)

View File

@ -269,13 +269,15 @@ ConfigManager.prototype.getWalletNicknames = function () {
}
ConfigManager.prototype.nicknameForWallet = function (account) {
const address = ethUtil.addHexPrefix(account.toLowerCase())
const nicknames = this.getWalletNicknames()
return nicknames[account]
return nicknames[address]
}
ConfigManager.prototype.setNicknameForWallet = function (account, nickname) {
const address = ethUtil.addHexPrefix(account.toLowerCase())
const nicknames = this.getWalletNicknames()
nicknames[account] = nickname
nicknames[address] = nickname
var data = this.getData()
data.walletNicknames = nicknames
this.setData(data)

View File

@ -105,6 +105,17 @@ describe('KeyringController', function() {
})
})
describe('#saveAccountLabel', function() {
it ('sets the nickname', function() {
const account = addresses[0]
var nick = 'Test nickname'
const label = keyringController.saveAccountLabel(account, nick)
assert.equal(label, nick)
const persisted = keyringController.configManager.nicknameForWallet(account)
assert.equal(persisted, nick)
})
})
})