From e9468790b56b5ef3e106cc4072db09e94dd91b8e Mon Sep 17 00:00:00 2001 From: Fernando Date: Tue, 22 Sep 2020 16:06:06 -0300 Subject: [PATCH] (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 Co-authored-by: Mati Dastugue --- .../SendModal/screens/AddressBookInput/index.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx index f766ea53..db9b9c90 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx @@ -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, }) }