From 1047c4bd358a3618ecfa6c777fbff5695e8e6a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Paczy=C5=84ski?= Date: Tue, 24 Oct 2023 09:58:21 +0200 Subject: [PATCH] Prevent caching addresses without ens or uns data --- src/shared/utils/names.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/shared/utils/names.ts b/src/shared/utils/names.ts index f23b12f92..ec21305d3 100644 --- a/src/shared/utils/names.ts +++ b/src/shared/utils/names.ts @@ -29,13 +29,13 @@ const getCachedNames = () => { const addCachedName = ({ name, avatar, address, type }: NameWithProvider) => { const cachedNames = getCachedNames() const normalizedAddress = normalizeAddress(address) - const newCachedData = name ? { [type]: { name, avatar } } : {} + const newData = name ? { [type]: { name, avatar } } : {} const newCache = JSON.stringify({ ...cachedNames, [normalizedAddress]: { ...(cachedNames[normalizedAddress] ?? {}), - ...newCachedData, + ...newData, lastUpdate: Date.now(), }, }) @@ -45,10 +45,7 @@ const addCachedName = ({ name, avatar, address, type }: NameWithProvider) => { const resolveENSPromise = (address: string) => resolveAddressToENS(address).then((data): WalletData | null => { - if (!data) { - addCachedName({ type: "ens", address }) - return null - } + if (!data) return null addCachedName({ type: "ens", address, ...data }) return data