Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/v0.2.12 #2276

Merged
merged 6 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.11",
"version": "0.2.12",
"private": true,
"dependencies": {
"@apollo/client": "^3.7.10",
Expand Down
1 change: 1 addition & 0 deletions src/components/Proposals/ProposalSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export function AzoriusProposalSummary({ proposal }: { proposal: AzoriusProposal
}, [
address,
baseContracts,
votesToken?.decimals,
governanceContracts.ozLinearVotingContractAddress,
proposal.proposalId,
]);
Expand Down
1 change: 1 addition & 0 deletions src/hooks/utils/cache/cacheDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface MasterCacheKey extends CacheKey {
cacheName: CacheKeys.MASTER_COPY;
chainId: number;
proxyAddress: Address;
moduleProxyFactoryAddress: Address;
}

export interface ProposalCacheKey extends CacheKey {
Expand Down
23 changes: 19 additions & 4 deletions src/hooks/utils/useMasterCopy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ModuleProxyFactory } from '@fractal-framework/fractal-contracts';
import { Contract } from 'ethers';
import { useCallback } from 'react';
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';
Expand All @@ -10,7 +10,10 @@ import { getValue, setValue } from './cache/useLocalStorage';

export function useMasterCopy() {
const { baseContracts } = useFractal();
const { chain } = useNetworkConfig();
const {
chain,
contracts: { zodiacModuleProxyFactoryOld },
} = useNetworkConfig();

const isOzLinearVoting = useCallback(
(masterCopyAddress: Address) =>
Expand Down Expand Up @@ -54,18 +57,20 @@ export function useMasterCopy() {
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 => {
// @dev to prevent redundant queries, cache the master copy address as AddressZero if no proxies were created
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,
Expand All @@ -78,6 +83,7 @@ export function useMasterCopy() {
{
cacheName: CacheKeys.MASTER_COPY,
chainId: chain.id,
moduleProxyFactoryAddress: getAddress(contract.address),
proxyAddress,
},
masterCopyAddress,
Expand All @@ -91,12 +97,20 @@ export function useMasterCopy() {
const getZodiacModuleProxyMasterCopyData = useCallback(
async function (proxyAddress: Address) {
let masterCopyAddress: Address = zeroAddress;
let error;
let error: string | null = null;
if (baseContracts) {
const contract = getEventRPC<ModuleProxyFactory>(
baseContracts?.zodiacModuleProxyFactoryContract,
);
[masterCopyAddress, error] = await getMasterCopyAddress(contract, proxyAddress);
// @dev checks Zodiac's ModuleProxyFactory Contract if the first one fails.
if (error) {
const moduleProxyFactoryOld = contract.attach(zodiacModuleProxyFactoryOld);
[masterCopyAddress, error] = await getMasterCopyAddress(
moduleProxyFactoryOld,
proxyAddress,
);
}
if (error) {
console.error(error);
}
Expand All @@ -122,6 +136,7 @@ export function useMasterCopy() {
isOzLinearVoting,
isOzLinearVotingERC721,
baseContracts,
zodiacModuleProxyFactoryOld,
],
);

Expand Down
3 changes: 2 additions & 1 deletion src/providers/NetworkConfig/networks/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export const baseConfig: NetworkConfig = {
version: SAFE_VERSION,
network: base.id.toString(),
})?.networkAddresses[base.id.toString()]!,
zodiacModuleProxyFactory: ModuleProxyFactory.address,
zodiacModuleProxyFactory: '0x000000000000aDdB49795b0f9bA5BC298cDda236',
zodiacModuleProxyFactoryOld: ModuleProxyFactory.address,
linearVotingMasterCopy: LinearERC20Voting.address,
multisend: getMultiSendCallOnlyDeployment({
version: SAFE_VERSION,
Expand Down
3 changes: 2 additions & 1 deletion src/providers/NetworkConfig/networks/baseSepolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export const baseSepoliaConfig: NetworkConfig = {
version: SAFE_VERSION,
network: baseSepolia.id.toString(),
})?.networkAddresses[baseSepolia.id.toString()]!,
zodiacModuleProxyFactory: ModuleProxyFactory.address,
zodiacModuleProxyFactory: '0x000000000000aDdB49795b0f9bA5BC298cDda236',
zodiacModuleProxyFactoryOld: ModuleProxyFactory.address,
linearVotingMasterCopy: LinearERC20Voting.address,
multisend: getMultiSendCallOnlyDeployment({
version: SAFE_VERSION,
Expand Down
3 changes: 2 additions & 1 deletion src/providers/NetworkConfig/networks/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export const mainnetConfig: NetworkConfig = {
version: SAFE_VERSION,
network: mainnet.id.toString(),
})?.networkAddresses[mainnet.id.toString()]!,
zodiacModuleProxyFactory: ModuleProxyFactory.address,
zodiacModuleProxyFactory: '0x000000000000aDdB49795b0f9bA5BC298cDda236',
zodiacModuleProxyFactoryOld: ModuleProxyFactory.address,
linearVotingMasterCopy: LinearERC20Voting.address,
multisend: getMultiSendCallOnlyDeployment({
version: SAFE_VERSION,
Expand Down
3 changes: 2 additions & 1 deletion src/providers/NetworkConfig/networks/optimism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export const optimismConfig: NetworkConfig = {
version: SAFE_VERSION,
network: optimism.id.toString(),
})?.networkAddresses[optimism.id.toString()]!,
zodiacModuleProxyFactory: ModuleProxyFactory.address,
zodiacModuleProxyFactory: '0x000000000000aDdB49795b0f9bA5BC298cDda236',
zodiacModuleProxyFactoryOld: ModuleProxyFactory.address,
linearVotingMasterCopy: LinearERC20Voting.address,
multisend: getMultiSendCallOnlyDeployment({
version: SAFE_VERSION,
Expand Down
3 changes: 2 additions & 1 deletion src/providers/NetworkConfig/networks/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export const polygonConfig: NetworkConfig = {
version: SAFE_VERSION,
network: polygon.id.toString(),
})?.networkAddresses[polygon.id.toString()]!,
zodiacModuleProxyFactory: ModuleProxyFactory.address,
zodiacModuleProxyFactory: '0x000000000000aDdB49795b0f9bA5BC298cDda236',
zodiacModuleProxyFactoryOld: ModuleProxyFactory.address,
linearVotingMasterCopy: LinearERC20Voting.address,
multisend: getMultiSendCallOnlyDeployment({
version: SAFE_VERSION,
Expand Down
3 changes: 2 additions & 1 deletion src/providers/NetworkConfig/networks/sepolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export const sepoliaConfig: NetworkConfig = {
version: SAFE_VERSION,
network: sepolia.id.toString(),
})?.networkAddresses[sepolia.id.toString()]!,
zodiacModuleProxyFactory: ModuleProxyFactory.address,
zodiacModuleProxyFactory: '0x000000000000aDdB49795b0f9bA5BC298cDda236',
zodiacModuleProxyFactoryOld: ModuleProxyFactory.address,
linearVotingMasterCopy: LinearERC20Voting.address,
multisend: getMultiSendCallOnlyDeployment({
version: SAFE_VERSION,
Expand Down
1 change: 1 addition & 0 deletions src/types/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type NetworkConfig = {
safeFactory: string;
fallbackHandler: string;
zodiacModuleProxyFactory: string;
zodiacModuleProxyFactoryOld: string;
linearVotingMasterCopy: string;
multisend: string;
fractalAzoriusMasterCopy: string;
Expand Down