(Fix) Recipient address used as name as well (#1387)

* fix address being used as name

* Restore ENS name when sending transaction

* use `addressName` as default value if it happens that the name in the addressBook is not defined

* use resolvedAddress to filter by address in the address book

Co-authored-by: Daniel Sanchez <daniel.sanchez@gnosis.pm>
Co-authored-by: Mati Dastugue <matias.dastugue@altoros.com>
This commit is contained in:
Fernando 2020-09-22 16:06:06 -03:00 committed by GitHub
parent eebe972bac
commit e9468790b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -103,13 +103,23 @@ const AddressBookInput = ({
const { address, name } = adbkEntry
return (
name.toLowerCase().includes(normalizedAddress.toLowerCase()) ||
address.toLowerCase().includes(normalizedAddress.toLowerCase())
address.toLowerCase().includes(resolvedAddress.toLowerCase())
)
})
setADBKList(filteredADBK)
if (!addressErrorMessage) {
// base case if isENSDomain we set the domain as the name
// if address does not exist in address book we use blank name
let addressName = isENSDomain ? normalizedAddress : ''
// if address is valid, and is in the address book, then we use the stored values
if (filteredADBK.length === 1) {
const addressBookContact = filteredADBK[0]
addressName = addressBookContact.name ?? addressName
}
setSelectedEntry({
name: normalizedAddress,
name: addressName,
address: resolvedAddress,
})
}