Merge pull request #6372 from MetaMask/addAddressIfNew

prevent add duplicates when address is not new
feature/default_network_editable
kumavis 6 years ago committed by GitHub
commit 133ed80aee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      ui/app/components/app/send/send-footer/send-footer.container.js
  2. 4
      ui/app/components/app/send/send-footer/send-footer.utils.js

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

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

Loading…
Cancel
Save