mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Merge pull request #6372 from MetaMask/addAddressIfNew
prevent add duplicates when address is not new
This commit is contained in:
commit
133ed80aee
@ -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…
Reference in New Issue
Block a user