From 265ec8d2610fddca1ca3bdeb833f2d405f40690f Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Wed, 1 May 2024 15:41:36 -0400 Subject: [PATCH 1/4] Delete unused interface --- src/types/daoProposal.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/types/daoProposal.ts b/src/types/daoProposal.ts index cc6bf6712b..20960affbe 100644 --- a/src/types/daoProposal.ts +++ b/src/types/daoProposal.ts @@ -33,10 +33,6 @@ export interface AzoriusProposal extends GovernanceActivity { startBlock: bigint; } -export interface AzoriusERC721Proposal extends AzoriusProposal { - votes: ERC721ProposalVote[]; -} - export interface MultisigProposal extends GovernanceActivity { confirmations: SafeMultisigConfirmationResponse[]; signersThreshold?: number; From 8be90a9b40094f1c878b7c1d96552a92d8125bd9 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Wed, 1 May 2024 15:55:03 -0400 Subject: [PATCH 2/4] Remove "supportsENS" function, just let wagmi handle that --- src/helpers/crypto.ts | 5 ----- src/hooks/utils/useAddress.ts | 6 ------ 2 files changed, 11 deletions(-) diff --git a/src/helpers/crypto.ts b/src/helpers/crypto.ts index 117be476b0..a23184ef30 100644 --- a/src/helpers/crypto.ts +++ b/src/helpers/crypto.ts @@ -1,7 +1,6 @@ import { TypedDataSigner } from '@ethersproject/abstract-signer'; import { Contract, utils, Signer } from 'ethers'; import { zeroAddress } from 'viem'; -import { sepolia, mainnet } from 'wagmi/chains'; import { ContractConnection } from '../types'; import { MetaTransaction, SafePostTransaction, SafeTransaction } from '../types/transaction'; @@ -189,7 +188,3 @@ export const encodeMultiSend = (txs: MetaTransaction[]): string => { export function getEventRPC(connection: ContractConnection): T { return connection.asProvider; } - -export function supportsENS(chainId: number): boolean { - return chainId === sepolia.id || chainId == mainnet.id || chainId == sepolia.id; -} diff --git a/src/hooks/utils/useAddress.ts b/src/hooks/utils/useAddress.ts index a6fcbdb2b8..279933b322 100644 --- a/src/hooks/utils/useAddress.ts +++ b/src/hooks/utils/useAddress.ts @@ -1,6 +1,5 @@ import { useEffect, useState } from 'react'; import { getAddress, isAddress } from 'viem'; -import { supportsENS } from '../../helpers'; import { useEthersProvider } from '../../providers/Ethers/hooks/useEthersProvider'; import { useNetworkConfig } from '../../providers/NetworkConfig/NetworkConfigProvider'; import { couldBeENS } from '../../utils/url'; @@ -42,11 +41,6 @@ const useAddress = (addressInput: string | undefined) => { return; } - // only continue with ENS checks if the chain actually supports ENS - if (!supportsENS(chain.id)) { - return; - } - // if it can't be an ENS address, validation is false if (!couldBeENS(addressInput)) { setAddress(addressInput); From e300a1f89ab1a387f4ce44c70926ebd5df49700b Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Wed, 1 May 2024 15:56:23 -0400 Subject: [PATCH 3/4] Remove AUDIT_WARNING_SHOWN cache key, not being used anywhere --- src/hooks/utils/cache/cacheDefaults.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hooks/utils/cache/cacheDefaults.ts b/src/hooks/utils/cache/cacheDefaults.ts index 29c61ccd63..97868df41b 100644 --- a/src/hooks/utils/cache/cacheDefaults.ts +++ b/src/hooks/utils/cache/cacheDefaults.ts @@ -24,7 +24,6 @@ export enum CacheExpiry { */ export enum CacheKeys { FAVORITES = 'favorites', - AUDIT_WARNING_SHOWN = 'audit_warning_shown', ENS_RESOLVE_PREFIX = 'ens_resolve_', // name.eth -> 0x0 caching DECODED_TRANSACTION_PREFIX = 'decode_trans_', MULTISIG_METADATA_PREFIX = 'm_m_', @@ -42,7 +41,6 @@ interface IndexedObject { */ export const CACHE_DEFAULTS: IndexedObject = { [CacheKeys.FAVORITES.toString()]: Array(), - [CacheKeys.AUDIT_WARNING_SHOWN.toString()]: true, }; /** From 46b0c42e432e476fb020ba495f0d209e41fe168a Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Wed, 1 May 2024 15:57:30 -0400 Subject: [PATCH 4/4] Don't cache things when doing ENS name network lookups, let wagmi/viem handle caching --- src/hooks/utils/cache/cacheDefaults.ts | 1 - src/hooks/utils/useAddress.ts | 32 ++------------------------ 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/src/hooks/utils/cache/cacheDefaults.ts b/src/hooks/utils/cache/cacheDefaults.ts index 97868df41b..686ba77f63 100644 --- a/src/hooks/utils/cache/cacheDefaults.ts +++ b/src/hooks/utils/cache/cacheDefaults.ts @@ -24,7 +24,6 @@ export enum CacheExpiry { */ export enum CacheKeys { FAVORITES = 'favorites', - ENS_RESOLVE_PREFIX = 'ens_resolve_', // name.eth -> 0x0 caching DECODED_TRANSACTION_PREFIX = 'decode_trans_', MULTISIG_METADATA_PREFIX = 'm_m_', MASTER_COPY_PREFIX = 'master_copy_of_', diff --git a/src/hooks/utils/useAddress.ts b/src/hooks/utils/useAddress.ts index 279933b322..9b49510ab5 100644 --- a/src/hooks/utils/useAddress.ts +++ b/src/hooks/utils/useAddress.ts @@ -1,10 +1,7 @@ import { useEffect, useState } from 'react'; import { getAddress, isAddress } from 'viem'; import { useEthersProvider } from '../../providers/Ethers/hooks/useEthersProvider'; -import { useNetworkConfig } from '../../providers/NetworkConfig/NetworkConfigProvider'; import { couldBeENS } from '../../utils/url'; -import { CacheKeys, CacheExpiry } from './cache/cacheDefaults'; -import { useLocalStorage } from './cache/useLocalStorage'; const useAddress = (addressInput: string | undefined) => { const provider = useEthersProvider(); @@ -12,8 +9,6 @@ const useAddress = (addressInput: string | undefined) => { const [address, setAddress] = useState(); const [isValidAddress, setIsValidAddress] = useState(); const [isAddressLoading, setIsAddressLoading] = useState(false); - const { setValue, getValue } = useLocalStorage(); - const { chain } = useNetworkConfig(); useEffect(() => { setIsAddressLoading(true); @@ -49,21 +44,6 @@ const useAddress = (addressInput: string | undefined) => { return; } - // check our cache for a potential resolved address (name.eth -> 0x0) - const cachedResolvedAddress = getValue(addressInput); - if (cachedResolvedAddress) { - setAddress(cachedResolvedAddress); - setIsValidAddress(true); - setIsAddressLoading(false); - return; - } else if (cachedResolvedAddress === undefined) { - // a previous lookup did not resolve - setAddress(addressInput); - setIsValidAddress(false); - setIsAddressLoading(false); - return; - } - if (!provider) { setAddress(addressInput); setIsValidAddress(undefined); @@ -73,19 +53,11 @@ const useAddress = (addressInput: string | undefined) => { provider .resolveName(addressInput) - .then((resolvedAddress: any) => { + .then(resolvedAddress => { if (!resolvedAddress) { - // cache an unresolved address as 'undefined' for 20 minutes - setValue(CacheKeys.ENS_RESOLVE_PREFIX + addressInput, undefined, 20); setAddress(addressInput); setIsValidAddress(false); } else { - // cache a resolved address for a week - setValue( - CacheKeys.ENS_RESOLVE_PREFIX + addressInput, - resolvedAddress, - CacheExpiry.ONE_WEEK, - ); setAddress(resolvedAddress); setIsValidAddress(true); } @@ -97,7 +69,7 @@ const useAddress = (addressInput: string | undefined) => { .finally(() => { setIsAddressLoading(false); }); - }, [provider, addressInput, getValue, setValue, chain]); + }, [addressInput, provider]); return { address, isValidAddress, isAddressLoading }; };