From 2222fb94239f03f373bfa78bb95846e8c8778feb Mon Sep 17 00:00:00 2001 From: fernandomg Date: Tue, 22 Sep 2020 12:59:40 -0300 Subject: [PATCH 1/4] fix address being used as name --- .../screens/AddressBookInput/index.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 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 f766ea53de..b1ca8cff5d 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx @@ -108,10 +108,20 @@ const AddressBookInput = ({ }) setADBKList(filteredADBK) if (!addressErrorMessage) { - setSelectedEntry({ - name: normalizedAddress, - address: resolvedAddress, - }) + // if address is valid, and is in the address book, then we use the stored values + if (filteredADBK.length === 1) { + const addressBookContact = filteredADBK[0] + setSelectedEntry({ + name: addressBookContact.name ?? '', + address: addressBookContact.address ?? resolvedAddress, + }) + } else { + // if address is valid, but does not exist in the address book, we just set the address + setSelectedEntry({ + name: '', + address: resolvedAddress, + }) + } } } setIsValidForm(addressErrorMessage === undefined) From e229d0e20dd4639788c11878943699bbd5d5a110 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Date: Tue, 22 Sep 2020 19:19:28 +0200 Subject: [PATCH 2/4] Restore ENS name when sending transaction --- .../screens/AddressBookInput/index.tsx | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 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 b1ca8cff5d..b89e156a57 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx @@ -108,20 +108,20 @@ const AddressBookInput = ({ }) 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] - setSelectedEntry({ - name: addressBookContact.name ?? '', - address: addressBookContact.address ?? resolvedAddress, - }) - } else { - // if address is valid, but does not exist in the address book, we just set the address - setSelectedEntry({ - name: '', - address: resolvedAddress, - }) + addressName = addressBookContact.name ?? '' } + + setSelectedEntry({ + name: addressName, + address: resolvedAddress, + }) } } setIsValidForm(addressErrorMessage === undefined) From 3bc4300ccbaa9accd7c0598696d8ef0d958a1c9f Mon Sep 17 00:00:00 2001 From: fernandomg Date: Tue, 22 Sep 2020 14:48:21 -0300 Subject: [PATCH 3/4] use `addressName` as default value if it happens that the name in the addressBook is not defined --- .../Balances/SendModal/screens/AddressBookInput/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b89e156a57..ff95269db4 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx @@ -115,7 +115,7 @@ const AddressBookInput = ({ // 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 = addressBookContact.name ?? addressName } setSelectedEntry({ From 70da69bfc395bda3daf97003464083df05a482ab Mon Sep 17 00:00:00 2001 From: fernandomg Date: Tue, 22 Sep 2020 14:49:21 -0300 Subject: [PATCH 4/4] use resolvedAddress to filter by address in the address book --- .../Balances/SendModal/screens/AddressBookInput/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ff95269db4..db9b9c90d2 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx +++ b/src/routes/safe/components/Balances/SendModal/screens/AddressBookInput/index.tsx @@ -103,7 +103,7 @@ const AddressBookInput = ({ const { address, name } = adbkEntry return ( name.toLowerCase().includes(normalizedAddress.toLowerCase()) || - address.toLowerCase().includes(normalizedAddress.toLowerCase()) + address.toLowerCase().includes(resolvedAddress.toLowerCase()) ) }) setADBKList(filteredADBK)