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

prevent add duplicates when address is not new

This commit is contained in:
Jenny Pollack 2019-03-28 19:18:53 -07:00
parent 649a1d483a
commit 356ef794f2
2 changed files with 3 additions and 2 deletions

View File

@ -96,9 +96,10 @@ function mapDispatchToProps (dispatch) {
return dispatch(updateTransaction(editingTx)) return dispatch(updateTransaction(editingTx))
}, },
addToAddressBookIfNew: (newAddress, toAccounts, nickname = '') => { addToAddressBookIfNew: (newAddress, toAccounts, nickname = '') => {
const hexPrefixedAddress = ethUtil.addHexPrefix(newAddress) const hexPrefixedAddress = ethUtil.addHexPrefix(newAddress)
if (addressIsNew(toAccounts)) { if (addressIsNew(toAccounts, hexPrefixedAddress)) {
// TODO: nickname, i.e. addToAddressBook(recipient, nickname) // TODO: nickname, i.e. addToAddressBook(recipient, nickname)
dispatch(addToAddressBook(hexPrefixedAddress, nickname)) dispatch(addToAddressBook(hexPrefixedAddress, nickname))
} }

View File

@ -74,7 +74,7 @@ function constructUpdatedTx ({
} }
function addressIsNew (toAccounts, newAddress) { function addressIsNew (toAccounts, newAddress) {
return !toAccounts.find(({ address }) => newAddress === address) return !toAccounts.find(({ address }) => (newAddress === address || newAddress.toLowerCase() === address))
} }
module.exports = { module.exports = {