Skip to content

Commit

Permalink
Merge pull request #1625 from decentdao/remove-old-stuff
Browse files Browse the repository at this point in the history
Remove old stuff
  • Loading branch information
adamgall authored May 5, 2024
2 parents b1d9cf6 + 0e1ac74 commit 30de55b
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 49 deletions.
5 changes: 0 additions & 5 deletions src/helpers/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
Hex,
isHex,
} from 'viem';
import { sepolia, mainnet } from 'wagmi/chains';
import { ContractConnection } from '../types';
import { MetaTransaction, SafePostTransaction, SafeTransaction } from '../types/transaction';

Expand Down Expand Up @@ -205,7 +204,3 @@ export const encodeMultiSend = (txs: MetaTransaction[]): string => {
export function getEventRPC<T>(connection: ContractConnection<T>): T {
return connection.asProvider;
}

export function supportsENS(chainId: number): boolean {
return chainId === sepolia.id || chainId == mainnet.id || chainId == sepolia.id;
}
3 changes: 0 additions & 3 deletions src/hooks/utils/cache/cacheDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +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_',
MASTER_COPY_PREFIX = 'master_copy_of_',
Expand All @@ -42,7 +40,6 @@ interface IndexedObject {
*/
export const CACHE_DEFAULTS: IndexedObject = {
[CacheKeys.FAVORITES.toString()]: Array<string>(),
[CacheKeys.AUDIT_WARNING_SHOWN.toString()]: true,
};

/**
Expand Down
40 changes: 3 additions & 37 deletions src/hooks/utils/useAddress.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import { useEffect, useState } from 'react';
import { Address, 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';
import { CacheKeys, CacheExpiry } from './cache/cacheDefaults';
import { useLocalStorage } from './cache/useLocalStorage';

const useAddress = (addressInput: string | undefined) => {
const provider = useEthersProvider();

const [address, setAddress] = useState<Address>();
const [isValidAddress, setIsValidAddress] = useState<boolean>();
const [isAddressLoading, setIsAddressLoading] = useState<boolean>(false);
const { setValue, getValue } = useLocalStorage();
const { chain } = useNetworkConfig();

useEffect(() => {
setIsAddressLoading(true);
Expand Down Expand Up @@ -42,11 +36,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(getAddress(addressInput));
Expand All @@ -55,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(getAddress(addressInput));
setIsValidAddress(false);
setIsAddressLoading(false);
return;
}

if (!provider) {
setAddress(getAddress(addressInput));
setIsValidAddress(undefined);
Expand All @@ -79,20 +53,12 @@ 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(getAddress(addressInput));
setIsValidAddress(false);
} else {
// cache a resolved address for a week
setValue(
CacheKeys.ENS_RESOLVE_PREFIX + addressInput,
resolvedAddress,
CacheExpiry.ONE_WEEK,
);
setAddress(resolvedAddress);
setAddress(getAddress(resolvedAddress));
setIsValidAddress(true);
}
})
Expand All @@ -103,7 +69,7 @@ const useAddress = (addressInput: string | undefined) => {
.finally(() => {
setIsAddressLoading(false);
});
}, [provider, addressInput, getValue, setValue, chain]);
}, [addressInput, provider]);

return { address, isValidAddress, isAddressLoading };
};
Expand Down
4 changes: 0 additions & 4 deletions src/types/daoProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ export interface AzoriusProposal extends GovernanceActivity {
startBlock: bigint;
}

export interface AzoriusERC721Proposal extends AzoriusProposal {
votes: ERC721ProposalVote[];
}

export interface MultisigProposal extends GovernanceActivity {
confirmations: SafeMultisigConfirmationResponse[];
signersThreshold?: number;
Expand Down

0 comments on commit 30de55b

Please sign in to comment.