From 4b60f19ed41753cbbaec9f2bbbedcc8042ac6c48 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Mon, 19 Aug 2024 16:24:50 -0400 Subject: [PATCH 1/2] Comment out reading from and writing to cache --- src/hooks/utils/useMasterCopy.ts | 89 ++++++++++++++++---------------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/src/hooks/utils/useMasterCopy.ts b/src/hooks/utils/useMasterCopy.ts index 5030e867b..eb05f759c 100644 --- a/src/hooks/utils/useMasterCopy.ts +++ b/src/hooks/utils/useMasterCopy.ts @@ -1,17 +1,18 @@ import { ModuleProxyFactory } from '@fractal-framework/fractal-contracts'; import { Contract } from 'ethers'; import { useCallback } from 'react'; -import { Address, getAddress, zeroAddress } from 'viem'; +import { Address, zeroAddress } from 'viem'; +// import { Address, getAddress, zeroAddress } from 'viem'; import { getEventRPC } from '../../helpers'; import { useFractal } from '../../providers/App/AppProvider'; import { useNetworkConfig } from '../../providers/NetworkConfig/NetworkConfigProvider'; -import { CacheExpiry, CacheKeys } from './cache/cacheDefaults'; -import { getValue, setValue } from './cache/useLocalStorage'; +// import { CacheExpiry, CacheKeys } from './cache/cacheDefaults'; +// import { getValue, setValue } from './cache/useLocalStorage'; export function useMasterCopy() { const { baseContracts } = useFractal(); const { - chain, + // chain, contracts: { zodiacModuleProxyFactoryOld }, } = useNetworkConfig(); @@ -52,47 +53,47 @@ export function useMasterCopy() { [baseContracts], ); - const getMasterCopyAddress = useCallback( - async function (contract: Contract, proxyAddress: Address): Promise<[Address, string | null]> { - const cachedValue = getValue({ - cacheName: CacheKeys.MASTER_COPY, - chainId: chain.id, - moduleProxyFactoryAddress: getAddress(contract.address), - proxyAddress, - }); - if (cachedValue) return [cachedValue, null] as const; + const getMasterCopyAddress = useCallback(async function ( + contract: Contract, + proxyAddress: Address, + ): Promise<[Address, string | null]> { + // const cachedValue = getValue({ + // cacheName: CacheKeys.MASTER_COPY, + // chainId: chain.id, + // moduleProxyFactoryAddress: getAddress(contract.address), + // proxyAddress, + // }); + // if (cachedValue) return [cachedValue, null] as const; - const filter = contract.filters.ModuleProxyCreation(proxyAddress, null); - return contract.queryFilter(filter).then(proxiesCreated => { - if (proxiesCreated.length === 0) { - // @dev to prevent redundant queries, cache the master copy address as AddressZero if no proxies were created - setValue( - { - cacheName: CacheKeys.MASTER_COPY, - chainId: chain.id, - moduleProxyFactoryAddress: getAddress(contract.address), - proxyAddress, - }, - zeroAddress, - CacheExpiry.ONE_WEEK, - ); - return [zeroAddress, 'No proxies created'] as const; - } - const masterCopyAddress = proxiesCreated[0].args!.masterCopy; - setValue( - { - cacheName: CacheKeys.MASTER_COPY, - chainId: chain.id, - moduleProxyFactoryAddress: getAddress(contract.address), - proxyAddress, - }, - masterCopyAddress, - ); - return [masterCopyAddress, null] as const; - }); - }, - [chain.id], - ); + const filter = contract.filters.ModuleProxyCreation(proxyAddress, null); + return contract.queryFilter(filter).then(proxiesCreated => { + if (proxiesCreated.length === 0) { + // @dev to prevent redundant queries, cache the master copy address as AddressZero if no proxies were created + // setValue( + // { + // cacheName: CacheKeys.MASTER_COPY, + // chainId: chain.id, + // moduleProxyFactoryAddress: getAddress(contract.address), + // proxyAddress, + // }, + // zeroAddress, + // CacheExpiry.ONE_WEEK, + // ); + return [zeroAddress, 'No proxies created'] as const; + } + const masterCopyAddress = proxiesCreated[0].args!.masterCopy; + // setValue( + // { + // cacheName: CacheKeys.MASTER_COPY, + // chainId: chain.id, + // moduleProxyFactoryAddress: getAddress(contract.address), + // proxyAddress, + // }, + // masterCopyAddress, + // ); + return [masterCopyAddress, null] as const; + }); + }, []); const getZodiacModuleProxyMasterCopyData = useCallback( async function (proxyAddress: Address) { From 2e301ab4a273a2373ff1915782899308b2dd1f8d Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Mon, 19 Aug 2024 16:29:49 -0400 Subject: [PATCH 2/2] Bump version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 52858e2fb..50cd748ff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "decent-interface", - "version": "0.2.12", + "version": "0.2.13", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "decent-interface", - "version": "0.2.12", + "version": "0.2.13", "hasInstallScript": true, "dependencies": { "@apollo/client": "^3.7.10", diff --git a/package.json b/package.json index c86c501f2..e3ad230e4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "decent-interface", - "version": "0.2.12", + "version": "0.2.13", "private": true, "dependencies": { "@apollo/client": "^3.7.10",