Skip to content

Commit

Permalink
Merge pull request #2280 from decentdao/hotfix/v0.2.13
Browse files Browse the repository at this point in the history
Hotfix/v0.2.13
  • Loading branch information
adamgall authored Aug 19, 2024
2 parents 60e01d9 + 2e301ab commit b84b0e9
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 47 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "decent-interface",
"version": "0.2.12",
"version": "0.2.13",
"private": true,
"dependencies": {
"@apollo/client": "^3.7.10",
Expand Down
89 changes: 45 additions & 44 deletions src/hooks/utils/useMasterCopy.ts
Original file line number Diff line number Diff line change
@@ -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();

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b84b0e9

Please sign in to comment.