From 7e05b91e8917a4af3540ccbceac3b10217eae4af Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sat, 4 May 2024 16:22:09 -0400 Subject: [PATCH 01/19] DRY chain references in network configs --- src/providers/NetworkConfig/networks/base.ts | 20 ++++++++++--------- .../NetworkConfig/networks/baseSepolia.ts | 20 ++++++++++--------- .../NetworkConfig/networks/mainnet.ts | 20 ++++++++++--------- .../NetworkConfig/networks/optimism.ts | 20 ++++++++++--------- .../NetworkConfig/networks/polygon.ts | 20 ++++++++++--------- .../NetworkConfig/networks/sepolia.ts | 20 ++++++++++--------- 6 files changed, 66 insertions(+), 54 deletions(-) diff --git a/src/providers/NetworkConfig/networks/base.ts b/src/providers/NetworkConfig/networks/base.ts index f90ecba350..b78027f212 100644 --- a/src/providers/NetworkConfig/networks/base.ts +++ b/src/providers/NetworkConfig/networks/base.ts @@ -25,9 +25,11 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; +const chain = base; + export const baseConfig: NetworkConfig = { order: 10, - chain: base, + chain, rpcEndpoint: `https://base-mainnet.g.alchemy.com/v2/${import.meta.env.VITE_APP_ALCHEMY_BASE_API_KEY}`, safeBaseURL: 'https://safe-transaction-base.safe.global', etherscanBaseURL: 'https://basescan.org/', @@ -53,20 +55,20 @@ export const baseConfig: NetworkConfig = { multisigFreezeGuardMasterCopy: MultisigFreezeGuard.address, fallbackHandler: getCompatibilityFallbackHandlerDeployment({ version: SAFE_VERSION, - network: base.id.toString(), - })?.networkAddresses[base.id.toString()]!, - safe: getSafeL2SingletonDeployment({ version: SAFE_VERSION, network: base.id.toString() }) - ?.networkAddresses[base.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, + safe: getSafeL2SingletonDeployment({ version: SAFE_VERSION, network: chain.id.toString() }) + ?.networkAddresses[chain.id.toString()]!, safeFactory: getProxyFactoryDeployment({ version: SAFE_VERSION, - network: base.id.toString(), - })?.networkAddresses[base.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, zodiacModuleProxyFactory: ModuleProxyFactory.address, linearVotingMasterCopy: LinearERC20Voting.address, multisend: getMultiSendCallOnlyDeployment({ version: SAFE_VERSION, - network: base.id.toString(), - })?.networkAddresses[base.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, votesERC20WrapperMasterCopy: VotesERC20Wrapper.address, keyValuePairs: KeyValuePairs.address, }, diff --git a/src/providers/NetworkConfig/networks/baseSepolia.ts b/src/providers/NetworkConfig/networks/baseSepolia.ts index 10ffc53e39..edcb30f63e 100644 --- a/src/providers/NetworkConfig/networks/baseSepolia.ts +++ b/src/providers/NetworkConfig/networks/baseSepolia.ts @@ -25,9 +25,11 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; +const chain = baseSepolia; + export const baseSepoliaConfig: NetworkConfig = { order: 40, - chain: baseSepolia, + chain, rpcEndpoint: `https://base-sepolia.g.alchemy.com/v2/${import.meta.env.VITE_APP_ALCHEMY_BASE_SEPOLIA_API_KEY}`, safeBaseURL: 'https://safe-transaction-base-sepolia.safe.global', etherscanBaseURL: 'https://sepolia.basescan.org/', @@ -53,22 +55,22 @@ export const baseSepoliaConfig: NetworkConfig = { multisigFreezeGuardMasterCopy: MultisigFreezeGuard.address, fallbackHandler: getCompatibilityFallbackHandlerDeployment({ version: SAFE_VERSION, - network: baseSepolia.id.toString(), - })?.networkAddresses[baseSepolia.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, safe: getSafeL2SingletonDeployment({ version: SAFE_VERSION, - network: baseSepolia.id.toString(), - })?.networkAddresses[baseSepolia.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, safeFactory: getProxyFactoryDeployment({ version: SAFE_VERSION, - network: baseSepolia.id.toString(), - })?.networkAddresses[baseSepolia.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, zodiacModuleProxyFactory: ModuleProxyFactory.address, linearVotingMasterCopy: LinearERC20Voting.address, multisend: getMultiSendCallOnlyDeployment({ version: SAFE_VERSION, - network: baseSepolia.id.toString(), - })?.networkAddresses[baseSepolia.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, votesERC20WrapperMasterCopy: VotesERC20Wrapper.address, keyValuePairs: KeyValuePairs.address, }, diff --git a/src/providers/NetworkConfig/networks/mainnet.ts b/src/providers/NetworkConfig/networks/mainnet.ts index 76b2301703..e70c0a961a 100644 --- a/src/providers/NetworkConfig/networks/mainnet.ts +++ b/src/providers/NetworkConfig/networks/mainnet.ts @@ -25,9 +25,11 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; +const chain = mainnet; + export const mainnetConfig: NetworkConfig = { order: 0, - chain: mainnet, + chain, rpcEndpoint: `https://eth-mainnet.g.alchemy.com/v2/${import.meta.env.VITE_APP_ALCHEMY_MAINNET_API_KEY}`, safeBaseURL: 'https://safe-transaction-mainnet.safe.global', etherscanBaseURL: 'https://etherscan.io', @@ -53,20 +55,20 @@ export const mainnetConfig: NetworkConfig = { multisigFreezeGuardMasterCopy: MultisigFreezeGuard.address, fallbackHandler: getCompatibilityFallbackHandlerDeployment({ version: SAFE_VERSION, - network: mainnet.id.toString(), - })?.networkAddresses[mainnet.id.toString()]!, - safe: getSafeL2SingletonDeployment({ version: SAFE_VERSION, network: mainnet.id.toString() }) - ?.networkAddresses[mainnet.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, + safe: getSafeL2SingletonDeployment({ version: SAFE_VERSION, network: chain.id.toString() }) + ?.networkAddresses[chain.id.toString()]!, safeFactory: getProxyFactoryDeployment({ version: SAFE_VERSION, - network: mainnet.id.toString(), - })?.networkAddresses[mainnet.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, zodiacModuleProxyFactory: ModuleProxyFactory.address, linearVotingMasterCopy: LinearERC20Voting.address, multisend: getMultiSendCallOnlyDeployment({ version: SAFE_VERSION, - network: mainnet.id.toString(), - })?.networkAddresses[mainnet.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, votesERC20WrapperMasterCopy: VotesERC20Wrapper.address, keyValuePairs: KeyValuePairs.address, }, diff --git a/src/providers/NetworkConfig/networks/optimism.ts b/src/providers/NetworkConfig/networks/optimism.ts index f3da6f13c1..c29715510a 100644 --- a/src/providers/NetworkConfig/networks/optimism.ts +++ b/src/providers/NetworkConfig/networks/optimism.ts @@ -25,9 +25,11 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; +const chain = optimism; + export const optimismConfig: NetworkConfig = { order: 15, - chain: optimism, + chain, rpcEndpoint: `https://opt-mainnet.g.alchemy.com/v2/${import.meta.env.VITE_APP_ALCHEMY_OPTIMISM_API_KEY}`, safeBaseURL: 'https://safe-transaction-optimism.safe.global', etherscanBaseURL: 'https://optimistic.etherscan.io/', @@ -53,20 +55,20 @@ export const optimismConfig: NetworkConfig = { multisigFreezeGuardMasterCopy: MultisigFreezeGuard.address, fallbackHandler: getCompatibilityFallbackHandlerDeployment({ version: SAFE_VERSION, - network: optimism.id.toString(), - })?.networkAddresses[optimism.id.toString()]!, - safe: getSafeL2SingletonDeployment({ version: SAFE_VERSION, network: optimism.id.toString() }) - ?.networkAddresses[optimism.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, + safe: getSafeL2SingletonDeployment({ version: SAFE_VERSION, network: chain.id.toString() }) + ?.networkAddresses[chain.id.toString()]!, safeFactory: getProxyFactoryDeployment({ version: SAFE_VERSION, - network: optimism.id.toString(), - })?.networkAddresses[optimism.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, zodiacModuleProxyFactory: ModuleProxyFactory.address, linearVotingMasterCopy: LinearERC20Voting.address, multisend: getMultiSendCallOnlyDeployment({ version: SAFE_VERSION, - network: optimism.id.toString(), - })?.networkAddresses[optimism.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, votesERC20WrapperMasterCopy: VotesERC20Wrapper.address, keyValuePairs: KeyValuePairs.address, }, diff --git a/src/providers/NetworkConfig/networks/polygon.ts b/src/providers/NetworkConfig/networks/polygon.ts index 4f6507c315..0d27d80bcf 100644 --- a/src/providers/NetworkConfig/networks/polygon.ts +++ b/src/providers/NetworkConfig/networks/polygon.ts @@ -25,9 +25,11 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; +const chain = polygon; + export const polygonConfig: NetworkConfig = { order: 20, - chain: polygon, + chain, rpcEndpoint: `https://polygon-mainnet.g.alchemy.com/v2/${import.meta.env.VITE_APP_ALCHEMY_POLYGON_API_KEY}`, safeBaseURL: 'https://safe-transaction-polygon.safe.global', etherscanBaseURL: 'https://polygonscan.com', @@ -53,20 +55,20 @@ export const polygonConfig: NetworkConfig = { multisigFreezeGuardMasterCopy: MultisigFreezeGuard.address, fallbackHandler: getCompatibilityFallbackHandlerDeployment({ version: SAFE_VERSION, - network: polygon.id.toString(), - })?.networkAddresses[polygon.id.toString()]!, - safe: getSafeL2SingletonDeployment({ version: SAFE_VERSION, network: polygon.id.toString() }) - ?.networkAddresses[polygon.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, + safe: getSafeL2SingletonDeployment({ version: SAFE_VERSION, network: chain.id.toString() }) + ?.networkAddresses[chain.id.toString()]!, safeFactory: getProxyFactoryDeployment({ version: SAFE_VERSION, - network: polygon.id.toString(), - })?.networkAddresses[polygon.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, zodiacModuleProxyFactory: ModuleProxyFactory.address, linearVotingMasterCopy: LinearERC20Voting.address, multisend: getMultiSendCallOnlyDeployment({ version: SAFE_VERSION, - network: polygon.id.toString(), - })?.networkAddresses[polygon.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, votesERC20WrapperMasterCopy: VotesERC20Wrapper.address, keyValuePairs: KeyValuePairs.address, }, diff --git a/src/providers/NetworkConfig/networks/sepolia.ts b/src/providers/NetworkConfig/networks/sepolia.ts index 62443ab27d..b0571c4f22 100644 --- a/src/providers/NetworkConfig/networks/sepolia.ts +++ b/src/providers/NetworkConfig/networks/sepolia.ts @@ -25,9 +25,11 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; +const chain = sepolia; + export const sepoliaConfig: NetworkConfig = { order: 30, - chain: sepolia, + chain, rpcEndpoint: `https://eth-sepolia.g.alchemy.com/v2/${import.meta.env.VITE_APP_ALCHEMY_SEPOLIA_API_KEY}`, safeBaseURL: 'https://safe-transaction-sepolia.safe.global', etherscanBaseURL: 'https://sepolia.etherscan.io', @@ -53,20 +55,20 @@ export const sepoliaConfig: NetworkConfig = { multisigFreezeGuardMasterCopy: MultisigFreezeGuard.address, fallbackHandler: getCompatibilityFallbackHandlerDeployment({ version: SAFE_VERSION, - network: sepolia.id.toString(), - })?.networkAddresses[sepolia.id.toString()]!, - safe: getSafeL2SingletonDeployment({ version: SAFE_VERSION, network: sepolia.id.toString() }) - ?.networkAddresses[sepolia.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, + safe: getSafeL2SingletonDeployment({ version: SAFE_VERSION, network: chain.id.toString() }) + ?.networkAddresses[chain.id.toString()]!, safeFactory: getProxyFactoryDeployment({ version: SAFE_VERSION, - network: sepolia.id.toString(), - })?.networkAddresses[sepolia.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, zodiacModuleProxyFactory: ModuleProxyFactory.address, linearVotingMasterCopy: LinearERC20Voting.address, multisend: getMultiSendCallOnlyDeployment({ version: SAFE_VERSION, - network: sepolia.id.toString(), - })?.networkAddresses[sepolia.id.toString()]!, + network: chain.id.toString(), + })?.networkAddresses[chain.id.toString()]!, votesERC20WrapperMasterCopy: VotesERC20Wrapper.address, keyValuePairs: KeyValuePairs.address, }, From dc4c650e6c6468e08c82c2d26ddcc28973da4028 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sat, 4 May 2024 16:39:30 -0400 Subject: [PATCH 02/19] Change type of VotesERC20Wrapper to Address, use the address from new deployments artifact --- src/providers/NetworkConfig/networks/base.ts | 6 ++++-- src/providers/NetworkConfig/networks/baseSepolia.ts | 6 ++++-- src/providers/NetworkConfig/networks/mainnet.ts | 6 ++++-- src/providers/NetworkConfig/networks/optimism.ts | 6 ++++-- src/providers/NetworkConfig/networks/polygon.ts | 6 ++++-- src/providers/NetworkConfig/networks/sepolia.ts | 6 ++++-- src/types/network.ts | 4 ++-- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/providers/NetworkConfig/networks/base.ts b/src/providers/NetworkConfig/networks/base.ts index b78027f212..162c294cf2 100644 --- a/src/providers/NetworkConfig/networks/base.ts +++ b/src/providers/NetworkConfig/networks/base.ts @@ -1,3 +1,5 @@ +import Deployments from '@fractal-framework/fractal-contracts-new/deployments'; + import Azorius from '@fractal-framework/fractal-contracts/deployments/base/Azorius.json'; import AzoriusFreezeGuard from '@fractal-framework/fractal-contracts/deployments/base/AzoriusFreezeGuard.json'; import ERC20Claim from '@fractal-framework/fractal-contracts/deployments/base/ERC20Claim.json'; @@ -12,7 +14,6 @@ import ModuleProxyFactory from '@fractal-framework/fractal-contracts/deployments import MultisigFreezeGuard from '@fractal-framework/fractal-contracts/deployments/base/MultisigFreezeGuard.json'; import MultisigFreezeVoting from '@fractal-framework/fractal-contracts/deployments/base/MultisigFreezeVoting.json'; import VotesERC20 from '@fractal-framework/fractal-contracts/deployments/base/VotesERC20.json'; -import VotesERC20Wrapper from '@fractal-framework/fractal-contracts/deployments/base/VotesERC20Wrapper.json'; import { getProxyFactoryDeployment, getMultiSendCallOnlyDeployment, @@ -26,6 +27,7 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; const chain = base; +const contracts = Deployments[chain.id][0].contracts; export const baseConfig: NetworkConfig = { order: 10, @@ -69,7 +71,7 @@ export const baseConfig: NetworkConfig = { version: SAFE_VERSION, network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, - votesERC20WrapperMasterCopy: VotesERC20Wrapper.address, + votesERC20WrapperMasterCopy: contracts.VotesERC20Wrapper.address, keyValuePairs: KeyValuePairs.address, }, staking: {}, diff --git a/src/providers/NetworkConfig/networks/baseSepolia.ts b/src/providers/NetworkConfig/networks/baseSepolia.ts index edcb30f63e..4ee9bc0e1e 100644 --- a/src/providers/NetworkConfig/networks/baseSepolia.ts +++ b/src/providers/NetworkConfig/networks/baseSepolia.ts @@ -1,3 +1,5 @@ +import Deployments from '@fractal-framework/fractal-contracts-new/deployments'; + import Azorius from '@fractal-framework/fractal-contracts/deployments/baseSepolia/Azorius.json'; import AzoriusFreezeGuard from '@fractal-framework/fractal-contracts/deployments/baseSepolia/AzoriusFreezeGuard.json'; import ERC20Claim from '@fractal-framework/fractal-contracts/deployments/baseSepolia/ERC20Claim.json'; @@ -12,7 +14,6 @@ import ModuleProxyFactory from '@fractal-framework/fractal-contracts/deployments import MultisigFreezeGuard from '@fractal-framework/fractal-contracts/deployments/baseSepolia/MultisigFreezeGuard.json'; import MultisigFreezeVoting from '@fractal-framework/fractal-contracts/deployments/baseSepolia/MultisigFreezeVoting.json'; import VotesERC20 from '@fractal-framework/fractal-contracts/deployments/baseSepolia/VotesERC20.json'; -import VotesERC20Wrapper from '@fractal-framework/fractal-contracts/deployments/baseSepolia/VotesERC20Wrapper.json'; import { getProxyFactoryDeployment, getMultiSendCallOnlyDeployment, @@ -26,6 +27,7 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; const chain = baseSepolia; +const contracts = Deployments[chain.id][0].contracts; export const baseSepoliaConfig: NetworkConfig = { order: 40, @@ -71,7 +73,7 @@ export const baseSepoliaConfig: NetworkConfig = { version: SAFE_VERSION, network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, - votesERC20WrapperMasterCopy: VotesERC20Wrapper.address, + votesERC20WrapperMasterCopy: contracts.VotesERC20Wrapper.address, keyValuePairs: KeyValuePairs.address, }, staking: {}, diff --git a/src/providers/NetworkConfig/networks/mainnet.ts b/src/providers/NetworkConfig/networks/mainnet.ts index e70c0a961a..48bc1a1650 100644 --- a/src/providers/NetworkConfig/networks/mainnet.ts +++ b/src/providers/NetworkConfig/networks/mainnet.ts @@ -1,3 +1,5 @@ +import Deployments from '@fractal-framework/fractal-contracts-new/deployments'; + import Azorius from '@fractal-framework/fractal-contracts/deployments/mainnet/Azorius.json'; import AzoriusFreezeGuard from '@fractal-framework/fractal-contracts/deployments/mainnet/AzoriusFreezeGuard.json'; import ERC20Claim from '@fractal-framework/fractal-contracts/deployments/mainnet/ERC20Claim.json'; @@ -12,7 +14,6 @@ import ModuleProxyFactory from '@fractal-framework/fractal-contracts/deployments import MultisigFreezeGuard from '@fractal-framework/fractal-contracts/deployments/mainnet/MultisigFreezeGuard.json'; import MultisigFreezeVoting from '@fractal-framework/fractal-contracts/deployments/mainnet/MultisigFreezeVoting.json'; import VotesERC20 from '@fractal-framework/fractal-contracts/deployments/mainnet/VotesERC20.json'; -import VotesERC20Wrapper from '@fractal-framework/fractal-contracts/deployments/mainnet/VotesERC20Wrapper.json'; import { getProxyFactoryDeployment, getMultiSendCallOnlyDeployment, @@ -26,6 +27,7 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; const chain = mainnet; +const contracts = Deployments[chain.id][0].contracts; export const mainnetConfig: NetworkConfig = { order: 0, @@ -69,7 +71,7 @@ export const mainnetConfig: NetworkConfig = { version: SAFE_VERSION, network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, - votesERC20WrapperMasterCopy: VotesERC20Wrapper.address, + votesERC20WrapperMasterCopy: contracts.VotesERC20Wrapper.address, keyValuePairs: KeyValuePairs.address, }, staking: { diff --git a/src/providers/NetworkConfig/networks/optimism.ts b/src/providers/NetworkConfig/networks/optimism.ts index c29715510a..6e245e98d3 100644 --- a/src/providers/NetworkConfig/networks/optimism.ts +++ b/src/providers/NetworkConfig/networks/optimism.ts @@ -1,3 +1,5 @@ +import Deployments from '@fractal-framework/fractal-contracts-new/deployments'; + import Azorius from '@fractal-framework/fractal-contracts/deployments/optimism/Azorius.json'; import AzoriusFreezeGuard from '@fractal-framework/fractal-contracts/deployments/optimism/AzoriusFreezeGuard.json'; import ERC20Claim from '@fractal-framework/fractal-contracts/deployments/optimism/ERC20Claim.json'; @@ -12,7 +14,6 @@ import ModuleProxyFactory from '@fractal-framework/fractal-contracts/deployments import MultisigFreezeGuard from '@fractal-framework/fractal-contracts/deployments/optimism/MultisigFreezeGuard.json'; import MultisigFreezeVoting from '@fractal-framework/fractal-contracts/deployments/optimism/MultisigFreezeVoting.json'; import VotesERC20 from '@fractal-framework/fractal-contracts/deployments/optimism/VotesERC20.json'; -import VotesERC20Wrapper from '@fractal-framework/fractal-contracts/deployments/optimism/VotesERC20Wrapper.json'; import { getProxyFactoryDeployment, getMultiSendCallOnlyDeployment, @@ -26,6 +27,7 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; const chain = optimism; +const contracts = Deployments[chain.id][0].contracts; export const optimismConfig: NetworkConfig = { order: 15, @@ -69,7 +71,7 @@ export const optimismConfig: NetworkConfig = { version: SAFE_VERSION, network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, - votesERC20WrapperMasterCopy: VotesERC20Wrapper.address, + votesERC20WrapperMasterCopy: contracts.VotesERC20Wrapper.address, keyValuePairs: KeyValuePairs.address, }, staking: {}, diff --git a/src/providers/NetworkConfig/networks/polygon.ts b/src/providers/NetworkConfig/networks/polygon.ts index 0d27d80bcf..7954428208 100644 --- a/src/providers/NetworkConfig/networks/polygon.ts +++ b/src/providers/NetworkConfig/networks/polygon.ts @@ -1,3 +1,5 @@ +import Deployments from '@fractal-framework/fractal-contracts-new/deployments'; + import Azorius from '@fractal-framework/fractal-contracts/deployments/polygon/Azorius.json'; import AzoriusFreezeGuard from '@fractal-framework/fractal-contracts/deployments/polygon/AzoriusFreezeGuard.json'; import ERC20Claim from '@fractal-framework/fractal-contracts/deployments/polygon/ERC20Claim.json'; @@ -12,7 +14,6 @@ import ModuleProxyFactory from '@fractal-framework/fractal-contracts/deployments import MultisigFreezeGuard from '@fractal-framework/fractal-contracts/deployments/polygon/MultisigFreezeGuard.json'; import MultisigFreezeVoting from '@fractal-framework/fractal-contracts/deployments/polygon/MultisigFreezeVoting.json'; import VotesERC20 from '@fractal-framework/fractal-contracts/deployments/polygon/VotesERC20.json'; -import VotesERC20Wrapper from '@fractal-framework/fractal-contracts/deployments/polygon/VotesERC20Wrapper.json'; import { getProxyFactoryDeployment, getMultiSendCallOnlyDeployment, @@ -26,6 +27,7 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; const chain = polygon; +const contracts = Deployments[chain.id][0].contracts; export const polygonConfig: NetworkConfig = { order: 20, @@ -69,7 +71,7 @@ export const polygonConfig: NetworkConfig = { version: SAFE_VERSION, network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, - votesERC20WrapperMasterCopy: VotesERC20Wrapper.address, + votesERC20WrapperMasterCopy: contracts.VotesERC20Wrapper.address, keyValuePairs: KeyValuePairs.address, }, staking: {}, diff --git a/src/providers/NetworkConfig/networks/sepolia.ts b/src/providers/NetworkConfig/networks/sepolia.ts index b0571c4f22..7ca38ec0fd 100644 --- a/src/providers/NetworkConfig/networks/sepolia.ts +++ b/src/providers/NetworkConfig/networks/sepolia.ts @@ -1,3 +1,5 @@ +import Deployments from '@fractal-framework/fractal-contracts-new/deployments'; + import Azorius from '@fractal-framework/fractal-contracts/deployments/sepolia/Azorius.json'; import AzoriusFreezeGuard from '@fractal-framework/fractal-contracts/deployments/sepolia/AzoriusFreezeGuard.json'; import ERC20Claim from '@fractal-framework/fractal-contracts/deployments/sepolia/ERC20Claim.json'; @@ -12,7 +14,6 @@ import ModuleProxyFactory from '@fractal-framework/fractal-contracts/deployments import MultisigFreezeGuard from '@fractal-framework/fractal-contracts/deployments/sepolia/MultisigFreezeGuard.json'; import MultisigFreezeVoting from '@fractal-framework/fractal-contracts/deployments/sepolia/MultisigFreezeVoting.json'; import VotesERC20 from '@fractal-framework/fractal-contracts/deployments/sepolia/VotesERC20.json'; -import VotesERC20Wrapper from '@fractal-framework/fractal-contracts/deployments/sepolia/VotesERC20Wrapper.json'; import { getMultiSendCallOnlyDeployment, getProxyFactoryDeployment, @@ -26,6 +27,7 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; const chain = sepolia; +const contracts = Deployments[chain.id][0].contracts; export const sepoliaConfig: NetworkConfig = { order: 30, @@ -69,7 +71,7 @@ export const sepoliaConfig: NetworkConfig = { version: SAFE_VERSION, network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, - votesERC20WrapperMasterCopy: VotesERC20Wrapper.address, + votesERC20WrapperMasterCopy: contracts.VotesERC20Wrapper.address, keyValuePairs: KeyValuePairs.address, }, staking: {}, diff --git a/src/types/network.ts b/src/types/network.ts index 2ad64d6a68..1fad136fff 100644 --- a/src/types/network.ts +++ b/src/types/network.ts @@ -1,5 +1,5 @@ import { ethers } from 'ethers'; -import { Chain } from 'viem'; +import { Address, Chain } from 'viem'; import { GovernanceType } from './fractal'; export type Providers = @@ -39,7 +39,7 @@ export type NetworkConfig = { multisigFreezeVotingMasterCopy: string; erc20FreezeVotingMasterCopy: string; erc721FreezeVotingMasterCopy: string; - votesERC20WrapperMasterCopy: string; + votesERC20WrapperMasterCopy: Address; keyValuePairs: string; }; staking: { From 5ea9fc15b1c22e3fea131b0a4bfb9a91f72979d0 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sat, 4 May 2024 16:42:27 -0400 Subject: [PATCH 03/19] Install new version of contracts repo alongside existing version --- package-lock.json | 7 +++++++ package.json | 1 + 2 files changed, 8 insertions(+) diff --git a/package-lock.json b/package-lock.json index 1227202c32..7f5000d0b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "@fontsource/ibm-plex-mono": "^4.5.12", "@fontsource/ibm-plex-sans": "^4.5.13", "@fractal-framework/fractal-contracts": "^0.7.0", + "@fractal-framework/fractal-contracts-new": "npm:@fractal-framework/fractal-contracts@^1.1.0", "@graphprotocol/client-apollo": "^1.0.16", "@lido-sdk/contracts": "^3.0.2", "@netlify/blobs": "^6.5.0", @@ -4925,6 +4926,12 @@ "solidity-docgen": "^0.6.0-beta.35" } }, + "node_modules/@fractal-framework/fractal-contracts-new": { + "name": "@fractal-framework/fractal-contracts", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@fractal-framework/fractal-contracts/-/fractal-contracts-1.1.0.tgz", + "integrity": "sha512-0VRR/g0lb1hFA73CgzFevGhGiL88IN+vd2N2vruOUzifOsytCw3sy4pZyLL2Vgc3/14qBLSH9Vf0VIbdh1tLLQ==" + }, "node_modules/@fractal-framework/fractal-contracts/node_modules/@noble/hashes": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.2.0.tgz", diff --git a/package.json b/package.json index 9175d797b3..193da1bd2a 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@fontsource/ibm-plex-mono": "^4.5.12", "@fontsource/ibm-plex-sans": "^4.5.13", "@fractal-framework/fractal-contracts": "^0.7.0", + "@fractal-framework/fractal-contracts-new": "npm:@fractal-framework/fractal-contracts@^1.1.0", "@graphprotocol/client-apollo": "^1.0.16", "@lido-sdk/contracts": "^3.0.2", "@netlify/blobs": "^6.5.0", From 6b6f46d8cdf645f9b8c4fda7dc9457ba39137d9e Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sat, 4 May 2024 22:20:49 -0400 Subject: [PATCH 04/19] Add "as const" to GnosisSafeL2 abi, and therefore fix some types --- src/assets/abi/GnosisSafeL2.ts | 6 ++++-- src/models/helpers/safeData.ts | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/assets/abi/GnosisSafeL2.ts b/src/assets/abi/GnosisSafeL2.ts index 95b0bf23e0..fa2eb254ae 100644 --- a/src/assets/abi/GnosisSafeL2.ts +++ b/src/assets/abi/GnosisSafeL2.ts @@ -1,4 +1,4 @@ -export default [ +const GnosisSafeL2Abi = [ { anonymous: false, inputs: [ @@ -1135,4 +1135,6 @@ export default [ stateMutability: 'payable', type: 'receive', }, -]; +] as const; + +export default GnosisSafeL2Abi; diff --git a/src/models/helpers/safeData.ts b/src/models/helpers/safeData.ts index a601e90cf3..c7942b91af 100644 --- a/src/models/helpers/safeData.ts +++ b/src/models/helpers/safeData.ts @@ -32,13 +32,13 @@ export const safeData = async ( const createSafeCalldata = encodeFunctionData({ functionName: 'setup', args: [ - signers, - 1, // Threshold + signers.map(signer => getAddress(signer)), + 1n, // Threshold zeroAddress, zeroHash, - fallbackHandler, + getAddress(fallbackHandler), zeroAddress, - 0, + 0n, zeroAddress, ], abi: GnosisSafeL2ABI, From 7315571231b27b160e054036e304d65bba7cdbe6 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sat, 4 May 2024 22:36:52 -0400 Subject: [PATCH 05/19] Add an ABI for VotesERC20 --- src/assets/abi/VotesERC20.ts | 757 +++++++++++++++++++++++++++++++++++ 1 file changed, 757 insertions(+) create mode 100644 src/assets/abi/VotesERC20.ts diff --git a/src/assets/abi/VotesERC20.ts b/src/assets/abi/VotesERC20.ts new file mode 100644 index 0000000000..c841daedf3 --- /dev/null +++ b/src/assets/abi/VotesERC20.ts @@ -0,0 +1,757 @@ +const VotesERC20 = [ + { + inputs: [], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'Approval', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'delegator', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'fromDelegate', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'toDelegate', + type: 'address', + }, + ], + name: 'DelegateChanged', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'delegate', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'previousBalance', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'newBalance', + type: 'uint256', + }, + ], + name: 'DelegateVotesChanged', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint8', + name: 'version', + type: 'uint8', + }, + ], + name: 'Initialized', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'previousOwner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnershipTransferred', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'id', + type: 'uint256', + }, + ], + name: 'Snapshot', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'Transfer', + type: 'event', + }, + { + inputs: [], + name: 'DOMAIN_SEPARATOR', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + ], + name: 'allowance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'approve', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + ], + name: 'balanceOf', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'uint256', + name: 'snapshotId', + type: 'uint256', + }, + ], + name: 'balanceOfAt', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'captureSnapShot', + outputs: [ + { + internalType: 'uint256', + name: 'snapId', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'uint32', + name: 'pos', + type: 'uint32', + }, + ], + name: 'checkpoints', + outputs: [ + { + components: [ + { + internalType: 'uint32', + name: 'fromBlock', + type: 'uint32', + }, + { + internalType: 'uint224', + name: 'votes', + type: 'uint224', + }, + ], + internalType: 'struct ERC20VotesUpgradeable.Checkpoint', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'decimals', + outputs: [ + { + internalType: 'uint8', + name: '', + type: 'uint8', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'subtractedValue', + type: 'uint256', + }, + ], + name: 'decreaseAllowance', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'delegatee', + type: 'address', + }, + ], + name: 'delegate', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'delegatee', + type: 'address', + }, + { + internalType: 'uint256', + name: 'nonce', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'expiry', + type: 'uint256', + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + }, + ], + name: 'delegateBySig', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + ], + name: 'delegates', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'blockNumber', + type: 'uint256', + }, + ], + name: 'getPastTotalSupply', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'uint256', + name: 'blockNumber', + type: 'uint256', + }, + ], + name: 'getPastVotes', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + ], + name: 'getVotes', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'addedValue', + type: 'uint256', + }, + ], + name: 'increaseAllowance', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'name', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + ], + name: 'nonces', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + ], + name: 'numCheckpoints', + outputs: [ + { + internalType: 'uint32', + name: '', + type: 'uint32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'owner', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + }, + ], + name: 'permit', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'renounceOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'initializeParams', + type: 'bytes', + }, + ], + name: 'setUp', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes4', + name: 'interfaceId', + type: 'bytes4', + }, + ], + name: 'supportsInterface', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'symbol', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalSupply', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'snapshotId', + type: 'uint256', + }, + ], + name: 'totalSupplyAt', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'transfer', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'from', + type: 'address', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'transferFrom', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'transferOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; + +export default VotesERC20; From d942e119820f22031645ca900763582e3f87d01d Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sat, 4 May 2024 22:37:28 -0400 Subject: [PATCH 06/19] Create a second useTransaction hook for these viem-style contract calls --- src/hooks/utils/useTransaction.ts | 76 ++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/src/hooks/utils/useTransaction.ts b/src/hooks/utils/useTransaction.ts index 1e0cb1c4ed..db41b3da0d 100644 --- a/src/hooks/utils/useTransaction.ts +++ b/src/hooks/utils/useTransaction.ts @@ -2,6 +2,8 @@ import { ContractReceipt, ethers } from 'ethers'; import React, { useCallback, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { toast } from 'react-toastify'; +import { Hash, TransactionReceipt } from 'viem'; +import { usePublicClient } from 'wagmi'; import { logError } from '../../helpers/errorLogging'; interface ProviderRpcError extends Error { @@ -10,6 +12,16 @@ interface ProviderRpcError extends Error { data?: any; } +interface ContractCallParamsViem { + contractFn: () => Promise; + pendingMessage: string; + failedMessage: string; + successMessage: string; + failedCallback?: () => void; + successCallback?: (txReceipt: TransactionReceipt) => void; + completedCallback?: () => void; +} + interface ContractCallParams { contractFn: () => Promise; pendingMessage: string; @@ -23,6 +35,8 @@ interface ContractCallParams { const useTransaction = () => { const [pending, setPending] = useState(false); const { t } = useTranslation(['transaction', 'common']); + const publicClient = usePublicClient(); + const contractCall = useCallback( (params: ContractCallParams) => { let toastId: React.ReactText; @@ -36,7 +50,7 @@ const useTransaction = () => { setPending(true); params .contractFn() - .then((txResponse: ethers.ContractTransaction) => { + .then(txResponse => { return Promise.all([txResponse.wait(), toastId]); }) .then(([txReceipt, toastID]) => { @@ -76,7 +90,65 @@ const useTransaction = () => { [t], ); - return [contractCall, pending] as const; + const contractCallViem = useCallback( + (params: ContractCallParamsViem) => { + if (!publicClient) return; + + let toastId: React.ReactText; + toastId = toast(params.pendingMessage, { + autoClose: false, + closeOnClick: false, + draggable: false, + closeButton: false, + progress: 1, + }); + setPending(true); + params + .contractFn() + .then(txReceipt => { + return Promise.all([ + publicClient.waitForTransactionReceipt({ hash: txReceipt }), + toastId, + ]); + }) + .then(([txReceipt, toastID]) => { + toast.dismiss(toastID); + if (txReceipt.status === 'reverted') { + toast.error(params.failedMessage); + if (params.failedCallback) params.failedCallback(); + } else if (txReceipt.status === 'success') { + toast(params.successMessage); + if (params.successCallback) params.successCallback(txReceipt); + } else { + toast.error(t('errorTransactionUnknown')); + if (params.failedCallback) params.failedCallback(); + } + if (params.completedCallback) params.completedCallback(); + + // Give the block event emitter a couple seconds to play the latest + // block on the app state, before informing app that the transaction + // is completed. + setTimeout(() => { + setPending(false); + }, 2000); + }) + .catch((error: ProviderRpcError) => { + logError(error); + toast.dismiss(toastId); + setPending(false); + + if (error.code === 4001) { + toast.error(t('errorUserDeniedTransaction')); + return; + } + + toast.error(t('errorGeneral', { ns: 'common' })); + }); + }, + [t, publicClient], + ); + + return [contractCall, pending, contractCallViem] as const; }; export { useTransaction }; From c4518f4bebcec671dcb9399f44f25da325c23487 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sat, 4 May 2024 22:39:16 -0400 Subject: [PATCH 07/19] Add type to declaration, not "as type" when instantiating --- src/hooks/DAO/useBuildDAOTx.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/DAO/useBuildDAOTx.ts b/src/hooks/DAO/useBuildDAOTx.ts index 24af6c17c4..eac2c6f127 100644 --- a/src/hooks/DAO/useBuildDAOTx.ts +++ b/src/hooks/DAO/useBuildDAOTx.ts @@ -34,7 +34,7 @@ const useBuildDAOTx = () => { parentAddress?: string, parentTokenAddress?: string, ) => { - let azoriusContracts; + let azoriusContracts: AzoriusContracts | undefined; if (!user.address || !signerOrProvider || !baseContracts) { return; @@ -88,7 +88,7 @@ const useBuildDAOTx = () => { votesTokenMasterCopyContract: votesTokenMasterCopyContract.asSigner, claimingMasterCopyContract: claimingMasterCopyContract.asSigner, votesERC20WrapperMasterCopyContract: votesERC20WrapperMasterCopyContract.asSigner, - } as AzoriusContracts; + }; } const buildrerBaseContracts = { From 78379cb6ce58ef8fde2a7c4abe40589ecbcc2a0e Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sat, 4 May 2024 22:41:46 -0400 Subject: [PATCH 08/19] Don't need walletClient, only reading --- src/components/ui/modals/WrapToken.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/ui/modals/WrapToken.tsx b/src/components/ui/modals/WrapToken.tsx index 9abdf840ad..289b14062e 100644 --- a/src/components/ui/modals/WrapToken.tsx +++ b/src/components/ui/modals/WrapToken.tsx @@ -4,7 +4,7 @@ import { Formik, FormikProps } from 'formik'; import { useCallback, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { erc20Abi, getContract } from 'viem'; -import { useAccount, usePublicClient, useWalletClient } from 'wagmi'; +import { useAccount, usePublicClient } from 'wagmi'; import * as Yup from 'yup'; import { logError } from '../../../helpers/errorLogging'; import { useERC20LinearToken } from '../../../hooks/DAO/loaders/governance/useERC20LinearToken'; @@ -22,7 +22,6 @@ export function WrapToken({ close }: { close: () => void }) { const { governance, governanceContracts } = useFractal(); const azoriusGovernance = governance as AzoriusGovernance; const signer = useEthersSigner(); - const { data: walletClient } = useWalletClient(); const publicClient = usePublicClient(); const { address: account } = useAccount(); const [userBalance, setUserBalance] = useState({ @@ -59,7 +58,7 @@ export function WrapToken({ close }: { close: () => void }) { const baseTokenContract = getContract({ address: azoriusGovernance.votesToken.underlyingTokenData.address, abi: erc20Abi, - client: { wallet: walletClient, public: publicClient }, + client: publicClient, }); try { const [balance, decimals] = await Promise.all([ @@ -79,7 +78,7 @@ export function WrapToken({ close }: { close: () => void }) { logError(e); return; } - }, [account, azoriusGovernance.votesToken, publicClient, walletClient]); + }, [account, azoriusGovernance.votesToken, publicClient]); useEffect(() => { getUserUnderlyingTokenBalance(); From df5fff97020422fc1fa5e32ecacc398d09924922 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sat, 4 May 2024 22:59:33 -0400 Subject: [PATCH 09/19] I think the "wrong" type was being used on this address, but it was fine because they both have the same function that was being used from this contract instance --- src/components/ui/modals/DelegateModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ui/modals/DelegateModal.tsx b/src/components/ui/modals/DelegateModal.tsx index bcf804805e..1dd792877d 100644 --- a/src/components/ui/modals/DelegateModal.tsx +++ b/src/components/ui/modals/DelegateModal.tsx @@ -44,7 +44,7 @@ export function DelegateModal({ close }: { close: Function }) { validAddress = getAddress(await signer.resolveName(values.address)); } const votingTokenContract = - baseContracts.votesERC20WrapperMasterCopyContract.asSigner.attach(votesTokenContractAddress); + baseContracts.votesTokenMasterCopyContract.asSigner.attach(votesTokenContractAddress); delegateVote({ delegatee: validAddress, votingTokenContract, From ce177621e576dc2d9df12214ea286489c7e4f7e5 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sun, 5 May 2024 09:15:18 -0400 Subject: [PATCH 10/19] Add an ABI for VotesERC20Wrapper --- src/assets/abi/VotesERC20Wrapper.ts | 818 ++++++++++++++++++++++++++++ 1 file changed, 818 insertions(+) create mode 100644 src/assets/abi/VotesERC20Wrapper.ts diff --git a/src/assets/abi/VotesERC20Wrapper.ts b/src/assets/abi/VotesERC20Wrapper.ts new file mode 100644 index 0000000000..99b9c97b91 --- /dev/null +++ b/src/assets/abi/VotesERC20Wrapper.ts @@ -0,0 +1,818 @@ +const VotesERC20Wrapper = [ + { + inputs: [], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'Approval', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'delegator', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'fromDelegate', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'toDelegate', + type: 'address', + }, + ], + name: 'DelegateChanged', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'delegate', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'previousBalance', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'newBalance', + type: 'uint256', + }, + ], + name: 'DelegateVotesChanged', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint8', + name: 'version', + type: 'uint8', + }, + ], + name: 'Initialized', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'previousOwner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnershipTransferred', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'id', + type: 'uint256', + }, + ], + name: 'Snapshot', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'Transfer', + type: 'event', + }, + { + inputs: [], + name: 'DOMAIN_SEPARATOR', + outputs: [ + { + internalType: 'bytes32', + name: '', + type: 'bytes32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + ], + name: 'allowance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'approve', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + ], + name: 'balanceOf', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'uint256', + name: 'snapshotId', + type: 'uint256', + }, + ], + name: 'balanceOfAt', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'captureSnapShot', + outputs: [ + { + internalType: 'uint256', + name: 'snapId', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'uint32', + name: 'pos', + type: 'uint32', + }, + ], + name: 'checkpoints', + outputs: [ + { + components: [ + { + internalType: 'uint32', + name: 'fromBlock', + type: 'uint32', + }, + { + internalType: 'uint224', + name: 'votes', + type: 'uint224', + }, + ], + internalType: 'struct ERC20VotesUpgradeable.Checkpoint', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'decimals', + outputs: [ + { + internalType: 'uint8', + name: '', + type: 'uint8', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'subtractedValue', + type: 'uint256', + }, + ], + name: 'decreaseAllowance', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'delegatee', + type: 'address', + }, + ], + name: 'delegate', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'delegatee', + type: 'address', + }, + { + internalType: 'uint256', + name: 'nonce', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'expiry', + type: 'uint256', + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + }, + ], + name: 'delegateBySig', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + ], + name: 'delegates', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'depositFor', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'blockNumber', + type: 'uint256', + }, + ], + name: 'getPastTotalSupply', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'uint256', + name: 'blockNumber', + type: 'uint256', + }, + ], + name: 'getPastVotes', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + ], + name: 'getVotes', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'addedValue', + type: 'uint256', + }, + ], + name: 'increaseAllowance', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'name', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + ], + name: 'nonces', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + ], + name: 'numCheckpoints', + outputs: [ + { + internalType: 'uint32', + name: '', + type: 'uint32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'owner', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'deadline', + type: 'uint256', + }, + { + internalType: 'uint8', + name: 'v', + type: 'uint8', + }, + { + internalType: 'bytes32', + name: 'r', + type: 'bytes32', + }, + { + internalType: 'bytes32', + name: 's', + type: 'bytes32', + }, + ], + name: 'permit', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'renounceOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'initializeParams', + type: 'bytes', + }, + ], + name: 'setUp', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes4', + name: 'interfaceId', + type: 'bytes4', + }, + ], + name: 'supportsInterface', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'symbol', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalSupply', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'snapshotId', + type: 'uint256', + }, + ], + name: 'totalSupplyAt', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'transfer', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'from', + type: 'address', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'transferFrom', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'newOwner', + type: 'address', + }, + ], + name: 'transferOwnership', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'underlying', + outputs: [ + { + internalType: 'contract IERC20Upgradeable', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'withdrawTo', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; + +export default VotesERC20Wrapper; From f81960d6bee2b4f658338392a2c465730035885d Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sun, 5 May 2024 09:22:32 -0400 Subject: [PATCH 11/19] Remove new fractal-contracts package, that didn't work as I hoped it would --- package-lock.json | 7 ------- package.json | 1 - src/providers/NetworkConfig/networks/base.ts | 7 +++---- src/providers/NetworkConfig/networks/baseSepolia.ts | 7 +++---- src/providers/NetworkConfig/networks/mainnet.ts | 7 +++---- src/providers/NetworkConfig/networks/optimism.ts | 7 +++---- src/providers/NetworkConfig/networks/polygon.ts | 7 +++---- src/providers/NetworkConfig/networks/sepolia.ts | 7 +++---- 8 files changed, 18 insertions(+), 32 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7f5000d0b6..1227202c32 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,6 @@ "@fontsource/ibm-plex-mono": "^4.5.12", "@fontsource/ibm-plex-sans": "^4.5.13", "@fractal-framework/fractal-contracts": "^0.7.0", - "@fractal-framework/fractal-contracts-new": "npm:@fractal-framework/fractal-contracts@^1.1.0", "@graphprotocol/client-apollo": "^1.0.16", "@lido-sdk/contracts": "^3.0.2", "@netlify/blobs": "^6.5.0", @@ -4926,12 +4925,6 @@ "solidity-docgen": "^0.6.0-beta.35" } }, - "node_modules/@fractal-framework/fractal-contracts-new": { - "name": "@fractal-framework/fractal-contracts", - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@fractal-framework/fractal-contracts/-/fractal-contracts-1.1.0.tgz", - "integrity": "sha512-0VRR/g0lb1hFA73CgzFevGhGiL88IN+vd2N2vruOUzifOsytCw3sy4pZyLL2Vgc3/14qBLSH9Vf0VIbdh1tLLQ==" - }, "node_modules/@fractal-framework/fractal-contracts/node_modules/@noble/hashes": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.2.0.tgz", diff --git a/package.json b/package.json index 193da1bd2a..9175d797b3 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,6 @@ "@fontsource/ibm-plex-mono": "^4.5.12", "@fontsource/ibm-plex-sans": "^4.5.13", "@fractal-framework/fractal-contracts": "^0.7.0", - "@fractal-framework/fractal-contracts-new": "npm:@fractal-framework/fractal-contracts@^1.1.0", "@graphprotocol/client-apollo": "^1.0.16", "@lido-sdk/contracts": "^3.0.2", "@netlify/blobs": "^6.5.0", diff --git a/src/providers/NetworkConfig/networks/base.ts b/src/providers/NetworkConfig/networks/base.ts index 162c294cf2..86bb5b08f7 100644 --- a/src/providers/NetworkConfig/networks/base.ts +++ b/src/providers/NetworkConfig/networks/base.ts @@ -1,5 +1,3 @@ -import Deployments from '@fractal-framework/fractal-contracts-new/deployments'; - import Azorius from '@fractal-framework/fractal-contracts/deployments/base/Azorius.json'; import AzoriusFreezeGuard from '@fractal-framework/fractal-contracts/deployments/base/AzoriusFreezeGuard.json'; import ERC20Claim from '@fractal-framework/fractal-contracts/deployments/base/ERC20Claim.json'; @@ -14,12 +12,14 @@ import ModuleProxyFactory from '@fractal-framework/fractal-contracts/deployments import MultisigFreezeGuard from '@fractal-framework/fractal-contracts/deployments/base/MultisigFreezeGuard.json'; import MultisigFreezeVoting from '@fractal-framework/fractal-contracts/deployments/base/MultisigFreezeVoting.json'; import VotesERC20 from '@fractal-framework/fractal-contracts/deployments/base/VotesERC20.json'; +import VotesERC20Wrapper from '@fractal-framework/fractal-contracts/deployments/base/VotesERC20Wrapper.json'; import { getProxyFactoryDeployment, getMultiSendCallOnlyDeployment, getSafeL2SingletonDeployment, getCompatibilityFallbackHandlerDeployment, } from '@safe-global/safe-deployments'; +import { getAddress } from 'viem'; import { base } from 'wagmi/chains'; import { GovernanceType } from '../../../types'; import { NetworkConfig } from '../../../types/network'; @@ -27,7 +27,6 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; const chain = base; -const contracts = Deployments[chain.id][0].contracts; export const baseConfig: NetworkConfig = { order: 10, @@ -71,7 +70,7 @@ export const baseConfig: NetworkConfig = { version: SAFE_VERSION, network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, - votesERC20WrapperMasterCopy: contracts.VotesERC20Wrapper.address, + votesERC20WrapperMasterCopy: getAddress(VotesERC20Wrapper.address), keyValuePairs: KeyValuePairs.address, }, staking: {}, diff --git a/src/providers/NetworkConfig/networks/baseSepolia.ts b/src/providers/NetworkConfig/networks/baseSepolia.ts index 4ee9bc0e1e..3b9c9c9fcd 100644 --- a/src/providers/NetworkConfig/networks/baseSepolia.ts +++ b/src/providers/NetworkConfig/networks/baseSepolia.ts @@ -1,5 +1,3 @@ -import Deployments from '@fractal-framework/fractal-contracts-new/deployments'; - import Azorius from '@fractal-framework/fractal-contracts/deployments/baseSepolia/Azorius.json'; import AzoriusFreezeGuard from '@fractal-framework/fractal-contracts/deployments/baseSepolia/AzoriusFreezeGuard.json'; import ERC20Claim from '@fractal-framework/fractal-contracts/deployments/baseSepolia/ERC20Claim.json'; @@ -14,12 +12,14 @@ import ModuleProxyFactory from '@fractal-framework/fractal-contracts/deployments import MultisigFreezeGuard from '@fractal-framework/fractal-contracts/deployments/baseSepolia/MultisigFreezeGuard.json'; import MultisigFreezeVoting from '@fractal-framework/fractal-contracts/deployments/baseSepolia/MultisigFreezeVoting.json'; import VotesERC20 from '@fractal-framework/fractal-contracts/deployments/baseSepolia/VotesERC20.json'; +import VotesERC20Wrapper from '@fractal-framework/fractal-contracts/deployments/baseSepolia/VotesERC20Wrapper.json'; import { getProxyFactoryDeployment, getMultiSendCallOnlyDeployment, getSafeL2SingletonDeployment, getCompatibilityFallbackHandlerDeployment, } from '@safe-global/safe-deployments'; +import { getAddress } from 'viem'; import { baseSepolia } from 'wagmi/chains'; import { GovernanceType } from '../../../types'; import { NetworkConfig } from '../../../types/network'; @@ -27,7 +27,6 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; const chain = baseSepolia; -const contracts = Deployments[chain.id][0].contracts; export const baseSepoliaConfig: NetworkConfig = { order: 40, @@ -73,7 +72,7 @@ export const baseSepoliaConfig: NetworkConfig = { version: SAFE_VERSION, network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, - votesERC20WrapperMasterCopy: contracts.VotesERC20Wrapper.address, + votesERC20WrapperMasterCopy: getAddress(VotesERC20Wrapper.address), keyValuePairs: KeyValuePairs.address, }, staking: {}, diff --git a/src/providers/NetworkConfig/networks/mainnet.ts b/src/providers/NetworkConfig/networks/mainnet.ts index 48bc1a1650..785bef1a12 100644 --- a/src/providers/NetworkConfig/networks/mainnet.ts +++ b/src/providers/NetworkConfig/networks/mainnet.ts @@ -1,5 +1,3 @@ -import Deployments from '@fractal-framework/fractal-contracts-new/deployments'; - import Azorius from '@fractal-framework/fractal-contracts/deployments/mainnet/Azorius.json'; import AzoriusFreezeGuard from '@fractal-framework/fractal-contracts/deployments/mainnet/AzoriusFreezeGuard.json'; import ERC20Claim from '@fractal-framework/fractal-contracts/deployments/mainnet/ERC20Claim.json'; @@ -14,12 +12,14 @@ import ModuleProxyFactory from '@fractal-framework/fractal-contracts/deployments import MultisigFreezeGuard from '@fractal-framework/fractal-contracts/deployments/mainnet/MultisigFreezeGuard.json'; import MultisigFreezeVoting from '@fractal-framework/fractal-contracts/deployments/mainnet/MultisigFreezeVoting.json'; import VotesERC20 from '@fractal-framework/fractal-contracts/deployments/mainnet/VotesERC20.json'; +import VotesERC20Wrapper from '@fractal-framework/fractal-contracts/deployments/mainnet/VotesERC20Wrapper.json'; import { getProxyFactoryDeployment, getMultiSendCallOnlyDeployment, getSafeL2SingletonDeployment, getCompatibilityFallbackHandlerDeployment, } from '@safe-global/safe-deployments'; +import { getAddress } from 'viem'; import { mainnet } from 'wagmi/chains'; import { GovernanceType } from '../../../types'; import { NetworkConfig } from '../../../types/network'; @@ -27,7 +27,6 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; const chain = mainnet; -const contracts = Deployments[chain.id][0].contracts; export const mainnetConfig: NetworkConfig = { order: 0, @@ -71,7 +70,7 @@ export const mainnetConfig: NetworkConfig = { version: SAFE_VERSION, network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, - votesERC20WrapperMasterCopy: contracts.VotesERC20Wrapper.address, + votesERC20WrapperMasterCopy: getAddress(VotesERC20Wrapper.address), keyValuePairs: KeyValuePairs.address, }, staking: { diff --git a/src/providers/NetworkConfig/networks/optimism.ts b/src/providers/NetworkConfig/networks/optimism.ts index 6e245e98d3..7ebfea0c9b 100644 --- a/src/providers/NetworkConfig/networks/optimism.ts +++ b/src/providers/NetworkConfig/networks/optimism.ts @@ -1,5 +1,3 @@ -import Deployments from '@fractal-framework/fractal-contracts-new/deployments'; - import Azorius from '@fractal-framework/fractal-contracts/deployments/optimism/Azorius.json'; import AzoriusFreezeGuard from '@fractal-framework/fractal-contracts/deployments/optimism/AzoriusFreezeGuard.json'; import ERC20Claim from '@fractal-framework/fractal-contracts/deployments/optimism/ERC20Claim.json'; @@ -14,12 +12,14 @@ import ModuleProxyFactory from '@fractal-framework/fractal-contracts/deployments import MultisigFreezeGuard from '@fractal-framework/fractal-contracts/deployments/optimism/MultisigFreezeGuard.json'; import MultisigFreezeVoting from '@fractal-framework/fractal-contracts/deployments/optimism/MultisigFreezeVoting.json'; import VotesERC20 from '@fractal-framework/fractal-contracts/deployments/optimism/VotesERC20.json'; +import VotesERC20Wrapper from '@fractal-framework/fractal-contracts/deployments/optimism/VotesERC20Wrapper.json'; import { getProxyFactoryDeployment, getMultiSendCallOnlyDeployment, getSafeL2SingletonDeployment, getCompatibilityFallbackHandlerDeployment, } from '@safe-global/safe-deployments'; +import { getAddress } from 'viem'; import { optimism } from 'wagmi/chains'; import { GovernanceType } from '../../../types'; import { NetworkConfig } from '../../../types/network'; @@ -27,7 +27,6 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; const chain = optimism; -const contracts = Deployments[chain.id][0].contracts; export const optimismConfig: NetworkConfig = { order: 15, @@ -71,7 +70,7 @@ export const optimismConfig: NetworkConfig = { version: SAFE_VERSION, network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, - votesERC20WrapperMasterCopy: contracts.VotesERC20Wrapper.address, + votesERC20WrapperMasterCopy: getAddress(VotesERC20Wrapper.address), keyValuePairs: KeyValuePairs.address, }, staking: {}, diff --git a/src/providers/NetworkConfig/networks/polygon.ts b/src/providers/NetworkConfig/networks/polygon.ts index 7954428208..272d547a6c 100644 --- a/src/providers/NetworkConfig/networks/polygon.ts +++ b/src/providers/NetworkConfig/networks/polygon.ts @@ -1,5 +1,3 @@ -import Deployments from '@fractal-framework/fractal-contracts-new/deployments'; - import Azorius from '@fractal-framework/fractal-contracts/deployments/polygon/Azorius.json'; import AzoriusFreezeGuard from '@fractal-framework/fractal-contracts/deployments/polygon/AzoriusFreezeGuard.json'; import ERC20Claim from '@fractal-framework/fractal-contracts/deployments/polygon/ERC20Claim.json'; @@ -14,12 +12,14 @@ import ModuleProxyFactory from '@fractal-framework/fractal-contracts/deployments import MultisigFreezeGuard from '@fractal-framework/fractal-contracts/deployments/polygon/MultisigFreezeGuard.json'; import MultisigFreezeVoting from '@fractal-framework/fractal-contracts/deployments/polygon/MultisigFreezeVoting.json'; import VotesERC20 from '@fractal-framework/fractal-contracts/deployments/polygon/VotesERC20.json'; +import VotesERC20Wrapper from '@fractal-framework/fractal-contracts/deployments/polygon/VotesERC20Wrapper.json'; import { getProxyFactoryDeployment, getMultiSendCallOnlyDeployment, getSafeL2SingletonDeployment, getCompatibilityFallbackHandlerDeployment, } from '@safe-global/safe-deployments'; +import { getAddress } from 'viem'; import { polygon } from 'wagmi/chains'; import { GovernanceType } from '../../../types'; import { NetworkConfig } from '../../../types/network'; @@ -27,7 +27,6 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; const chain = polygon; -const contracts = Deployments[chain.id][0].contracts; export const polygonConfig: NetworkConfig = { order: 20, @@ -71,7 +70,7 @@ export const polygonConfig: NetworkConfig = { version: SAFE_VERSION, network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, - votesERC20WrapperMasterCopy: contracts.VotesERC20Wrapper.address, + votesERC20WrapperMasterCopy: getAddress(VotesERC20Wrapper.address), keyValuePairs: KeyValuePairs.address, }, staking: {}, diff --git a/src/providers/NetworkConfig/networks/sepolia.ts b/src/providers/NetworkConfig/networks/sepolia.ts index 7ca38ec0fd..5095962b66 100644 --- a/src/providers/NetworkConfig/networks/sepolia.ts +++ b/src/providers/NetworkConfig/networks/sepolia.ts @@ -1,5 +1,3 @@ -import Deployments from '@fractal-framework/fractal-contracts-new/deployments'; - import Azorius from '@fractal-framework/fractal-contracts/deployments/sepolia/Azorius.json'; import AzoriusFreezeGuard from '@fractal-framework/fractal-contracts/deployments/sepolia/AzoriusFreezeGuard.json'; import ERC20Claim from '@fractal-framework/fractal-contracts/deployments/sepolia/ERC20Claim.json'; @@ -14,12 +12,14 @@ import ModuleProxyFactory from '@fractal-framework/fractal-contracts/deployments import MultisigFreezeGuard from '@fractal-framework/fractal-contracts/deployments/sepolia/MultisigFreezeGuard.json'; import MultisigFreezeVoting from '@fractal-framework/fractal-contracts/deployments/sepolia/MultisigFreezeVoting.json'; import VotesERC20 from '@fractal-framework/fractal-contracts/deployments/sepolia/VotesERC20.json'; +import VotesERC20Wrapper from '@fractal-framework/fractal-contracts/deployments/sepolia/VotesERC20Wrapper.json'; import { getMultiSendCallOnlyDeployment, getProxyFactoryDeployment, getSafeL2SingletonDeployment, getCompatibilityFallbackHandlerDeployment, } from '@safe-global/safe-deployments'; +import { getAddress } from 'viem'; import { sepolia } from 'wagmi/chains'; import { GovernanceType } from '../../../types'; import { NetworkConfig } from '../../../types/network'; @@ -27,7 +27,6 @@ import { NetworkConfig } from '../../../types/network'; const SAFE_VERSION = '1.3.0'; const chain = sepolia; -const contracts = Deployments[chain.id][0].contracts; export const sepoliaConfig: NetworkConfig = { order: 30, @@ -71,7 +70,7 @@ export const sepoliaConfig: NetworkConfig = { version: SAFE_VERSION, network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, - votesERC20WrapperMasterCopy: contracts.VotesERC20Wrapper.address, + votesERC20WrapperMasterCopy: getAddress(VotesERC20Wrapper.address), keyValuePairs: KeyValuePairs.address, }, staking: {}, From 6fdb75a0fe48da78182c0880447a8e1c9e25b42d Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sun, 5 May 2024 09:24:17 -0400 Subject: [PATCH 12/19] Remove votesERC20WrapperMasterCopyContract from AzoriusContracts type and FractalContracts type --- src/types/fractal.ts | 2 -- src/types/strategyAzorius.ts | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/types/fractal.ts b/src/types/fractal.ts index 86770342cb..4b71576af9 100644 --- a/src/types/fractal.ts +++ b/src/types/fractal.ts @@ -11,7 +11,6 @@ import { MultisigFreezeVoting, VotesERC20, MultisigFreezeGuard, - VotesERC20Wrapper, KeyValuePairs, ERC721FreezeVoting, LinearERC721Voting, @@ -351,7 +350,6 @@ export interface FractalContracts { freezeERC721VotingMasterCopyContract: ContractConnection; votesTokenMasterCopyContract: ContractConnection; claimingMasterCopyContract: ContractConnection; - votesERC20WrapperMasterCopyContract: ContractConnection; keyValuePairsContract: ContractConnection; } diff --git a/src/types/strategyAzorius.ts b/src/types/strategyAzorius.ts index 8b3437db14..0e3388290e 100644 --- a/src/types/strategyAzorius.ts +++ b/src/types/strategyAzorius.ts @@ -4,7 +4,6 @@ import { AzoriusFreezeGuard, VotesERC20, ERC20Claim, - VotesERC20Wrapper, LinearERC721Voting, } from '@fractal-framework/fractal-contracts'; @@ -15,5 +14,4 @@ export interface AzoriusContracts { azoriusFreezeGuardMasterCopyContract: AzoriusFreezeGuard; votesTokenMasterCopyContract: VotesERC20; claimingMasterCopyContract: ERC20Claim; - votesERC20WrapperMasterCopyContract: VotesERC20Wrapper; } From 2a4304a8ae8d0776f1283cf81fb30bead6227a58 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sun, 5 May 2024 09:25:51 -0400 Subject: [PATCH 13/19] Remove VotesERC20WrapperMasterCopyContract "asSigner / asProvider" object from useSafeContracts --- src/hooks/safe/useSafeContracts.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/hooks/safe/useSafeContracts.ts b/src/hooks/safe/useSafeContracts.ts index 2ad2d8ee4a..9860758be7 100644 --- a/src/hooks/safe/useSafeContracts.ts +++ b/src/hooks/safe/useSafeContracts.ts @@ -11,7 +11,6 @@ import { LinearERC20Voting__factory, Azorius__factory, ERC20Claim__factory, - VotesERC20Wrapper__factory, KeyValuePairs__factory, LinearERC721Voting__factory, ERC721FreezeVoting__factory, @@ -44,7 +43,6 @@ export default function useSafeContracts() { erc721FreezeVotingMasterCopy, votesERC20MasterCopy, claimingMasterCopy, - votesERC20WrapperMasterCopy, linearVotingERC721MasterCopy, keyValuePairs, }, @@ -139,11 +137,6 @@ export default function useSafeContracts() { asProvider: ERC20Claim__factory.connect(claimingMasterCopy, provider), }; - const votesERC20WrapperMasterCopyContract = { - asSigner: VotesERC20Wrapper__factory.connect(votesERC20WrapperMasterCopy, signerOrProvider), - asProvider: VotesERC20Wrapper__factory.connect(votesERC20WrapperMasterCopy, provider), - }; - const keyValuePairsContract = { asSigner: KeyValuePairs__factory.connect(keyValuePairs, signerOrProvider), asProvider: KeyValuePairs__factory.connect(keyValuePairs, provider), @@ -165,7 +158,6 @@ export default function useSafeContracts() { freezeERC721VotingMasterCopyContract, votesTokenMasterCopyContract, claimingMasterCopyContract, - votesERC20WrapperMasterCopyContract, linearVotingERC721MasterCopyContract, keyValuePairsContract, }; @@ -184,7 +176,6 @@ export default function useSafeContracts() { erc20FreezeVotingMasterCopy, votesERC20MasterCopy, claimingMasterCopy, - votesERC20WrapperMasterCopy, linearVotingERC721MasterCopy, erc721FreezeVotingMasterCopy, keyValuePairs, From 3984d1c1cb14ba7483642a4f6f784822d743ded0 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sun, 5 May 2024 09:26:29 -0400 Subject: [PATCH 14/19] Fix all of the typescript errors from previous two commits --- src/components/ui/modals/UnwrapToken.tsx | 34 ++++++++++--------- src/components/ui/modals/WrapToken.tsx | 29 ++++++++++------ .../DAO/loaders/useGovernanceContracts.ts | 18 +++++----- src/hooks/DAO/useBuildDAOTx.ts | 6 ++-- src/hooks/DAO/useDeployAzorius.ts | 6 ++-- src/models/AzoriusTxBuilder.ts | 26 ++++++++------ src/models/TxBuilderFactory.ts | 5 +++ 7 files changed, 72 insertions(+), 52 deletions(-) diff --git a/src/components/ui/modals/UnwrapToken.tsx b/src/components/ui/modals/UnwrapToken.tsx index b25974e8c1..d74db3c061 100644 --- a/src/components/ui/modals/UnwrapToken.tsx +++ b/src/components/ui/modals/UnwrapToken.tsx @@ -1,18 +1,18 @@ import { Button, Flex, Input } from '@chakra-ui/react'; import { LabelWrapper } from '@decent-org/fractal-ui'; -import { VotesERC20Wrapper } from '@fractal-framework/fractal-contracts'; import { Formik, FormikProps } from 'formik'; import { useCallback } from 'react'; import { useTranslation } from 'react-i18next'; -import { useAccount } from 'wagmi'; +import { getAddress, getContract } from 'viem'; +import { useAccount, useWalletClient } from 'wagmi'; import * as Yup from 'yup'; +import VotesERC20Wrapper from '../../../assets/abi/VotesERC20Wrapper'; import { useERC20LinearToken } from '../../../hooks/DAO/loaders/governance/useERC20LinearToken'; import useSafeContracts from '../../../hooks/safe/useSafeContracts'; import useApproval from '../../../hooks/utils/useApproval'; import { useFormHelpers } from '../../../hooks/utils/useFormHelpers'; import { useTransaction } from '../../../hooks/utils/useTransaction'; import { useFractal } from '../../../providers/App/AppProvider'; -import { useEthersSigner } from '../../../providers/Ethers/hooks/useEthersSigner'; import { AzoriusGovernance, BigIntValuePair } from '../../../types'; import { formatCoin } from '../../../utils'; import { BigIntInput } from '../forms/BigIntInput'; @@ -20,12 +20,11 @@ import { BigIntInput } from '../forms/BigIntInput'; export function UnwrapToken({ close }: { close: () => void }) { const { governance, governanceContracts } = useFractal(); const azoriusGovernance = governance as AzoriusGovernance; - const signer = useEthersSigner(); const { address: account } = useAccount(); const baseContracts = useSafeContracts(); const { loadERC20TokenAccountData } = useERC20LinearToken({ onMount: false }); - const [contractCall, pending] = useTransaction(); + const [, pending, contractCallViem] = useTransaction(); const { approved, approveTransaction, @@ -40,17 +39,21 @@ export function UnwrapToken({ close }: { close: () => void }) { const { t } = useTranslation(['modals', 'treasury']); const { restrictChars } = useFormHelpers(); + const { data: walletClient } = useWalletClient(); + const handleFormSubmit = useCallback( (amount: BigIntValuePair) => { const { votesTokenContractAddress } = governanceContracts; - if (!votesTokenContractAddress || !signer || !account) return; - const votesTokenContract = - baseContracts?.votesERC20WrapperMasterCopyContract?.asSigner.attach( - votesTokenContractAddress, - ); - const wrapperTokenContract = votesTokenContract as VotesERC20Wrapper; - contractCall({ - contractFn: () => wrapperTokenContract.withdrawTo(account, amount.bigintValue!), + if (!votesTokenContractAddress || !account || !walletClient) return; + + const wrapperTokenContract = getContract({ + abi: VotesERC20Wrapper, + address: getAddress(votesTokenContractAddress), + client: walletClient, + }); + + contractCallViem({ + contractFn: () => wrapperTokenContract.write.withdrawTo([account, amount.bigintValue!]), pendingMessage: t('unwrapTokenPendingMessage'), failedMessage: t('unwrapTokenFailedMessage'), successMessage: t('unwrapTokenSuccessMessage'), @@ -64,13 +67,12 @@ export function UnwrapToken({ close }: { close: () => void }) { }, [ account, - contractCall, + contractCallViem, governanceContracts, - signer, + walletClient, close, t, loadERC20TokenAccountData, - baseContracts, ], ); diff --git a/src/components/ui/modals/WrapToken.tsx b/src/components/ui/modals/WrapToken.tsx index 289b14062e..7a2a49cdf9 100644 --- a/src/components/ui/modals/WrapToken.tsx +++ b/src/components/ui/modals/WrapToken.tsx @@ -3,9 +3,10 @@ import { LabelWrapper } from '@decent-org/fractal-ui'; import { Formik, FormikProps } from 'formik'; import { useCallback, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { erc20Abi, getContract } from 'viem'; -import { useAccount, usePublicClient } from 'wagmi'; +import { erc20Abi, getAddress, getContract } from 'viem'; +import { useAccount, usePublicClient, useWalletClient } from 'wagmi'; import * as Yup from 'yup'; +import VotesERC20Wrapper from '../../../assets/abi/VotesERC20Wrapper'; import { logError } from '../../../helpers/errorLogging'; import { useERC20LinearToken } from '../../../hooks/DAO/loaders/governance/useERC20LinearToken'; import useSafeContracts from '../../../hooks/safe/useSafeContracts'; @@ -22,6 +23,7 @@ export function WrapToken({ close }: { close: () => void }) { const { governance, governanceContracts } = useFractal(); const azoriusGovernance = governance as AzoriusGovernance; const signer = useEthersSigner(); + const { data: walletClient } = useWalletClient(); const publicClient = usePublicClient(); const { address: account } = useAccount(); const [userBalance, setUserBalance] = useState({ @@ -31,7 +33,7 @@ export function WrapToken({ close }: { close: () => void }) { const baseContracts = useSafeContracts(); const { loadERC20TokenAccountData } = useERC20LinearToken({ onMount: false }); - const [contractCall, pending] = useTransaction(); + const [, pending, contractCallViem] = useTransaction(); const { approved, approveTransaction, @@ -87,13 +89,17 @@ export function WrapToken({ close }: { close: () => void }) { const handleFormSubmit = useCallback( (amount: BigIntValuePair) => { const { votesTokenContractAddress } = governanceContracts; - if (!votesTokenContractAddress || !signer || !account || !baseContracts) return; - const wrapperTokenContract = - baseContracts.votesERC20WrapperMasterCopyContract.asSigner.attach( - votesTokenContractAddress, - ); - contractCall({ - contractFn: () => wrapperTokenContract.depositFor(account, amount.bigintValue!), + if (!votesTokenContractAddress || !signer || !account || !baseContracts || !walletClient) + return; + + const wrapperTokenContract = getContract({ + abi: VotesERC20Wrapper, + address: getAddress(votesTokenContractAddress), + client: walletClient, + }); + + contractCallViem({ + contractFn: () => wrapperTokenContract.write.depositFor([account, amount.bigintValue!]), pendingMessage: t('wrapTokenPendingMessage'), failedMessage: t('wrapTokenFailedMessage'), successMessage: t('wrapTokenSuccessMessage'), @@ -107,13 +113,14 @@ export function WrapToken({ close }: { close: () => void }) { }, [ account, - contractCall, + contractCallViem, governanceContracts, signer, close, t, loadERC20TokenAccountData, baseContracts, + walletClient, ], ); diff --git a/src/hooks/DAO/loaders/useGovernanceContracts.ts b/src/hooks/DAO/loaders/useGovernanceContracts.ts index cc5b67c6e8..698fe749b9 100644 --- a/src/hooks/DAO/loaders/useGovernanceContracts.ts +++ b/src/hooks/DAO/loaders/useGovernanceContracts.ts @@ -2,6 +2,7 @@ import { Azorius } from '@fractal-framework/fractal-contracts'; import { useCallback, useEffect, useRef } from 'react'; import { Address, getContract, getAddress } from 'viem'; import { usePublicClient } from 'wagmi'; +import VotesERC20Wrapper from '../../../assets/abi/VotesERC20Wrapper'; import { LockRelease__factory } from '../../../assets/typechain-types/dcnt'; import { useFractal } from '../../../providers/App/AppProvider'; import { GovernanceContractAction } from '../../../providers/App/governanceContracts/action'; @@ -23,11 +24,7 @@ export const useGovernanceContracts = () => { if (!baseContracts || !publicClient) { return; } - const { - fractalAzoriusMasterCopyContract, - votesERC20WrapperMasterCopyContract, - linearVotingMasterCopyContract, - } = baseContracts; + const { fractalAzoriusMasterCopyContract, linearVotingMasterCopyContract } = baseContracts; const azoriusModule = getAzoriusModuleFromModules(fractalModules); const azoriusModuleContract = azoriusModule?.moduleContract as Azorius; @@ -62,9 +59,14 @@ export const useGovernanceContracts = () => { ozLinearVotingContractAddress, ); govTokenAddress = await ozLinearVotingContract.governanceToken(); - const possibleERC20Wrapper = - votesERC20WrapperMasterCopyContract.asProvider.attach(govTokenAddress); - underlyingTokenAddress = await possibleERC20Wrapper.underlying().catch(() => { + + const possibleERC20Wrapper = getContract({ + abi: VotesERC20Wrapper, + address: getAddress(govTokenAddress), + client: publicClient, + }); + + underlyingTokenAddress = await possibleERC20Wrapper.read.underlying().catch(() => { // if the underlying token is not an ERC20Wrapper, this will throw an error, // so we catch it and return undefined return undefined; diff --git a/src/hooks/DAO/useBuildDAOTx.ts b/src/hooks/DAO/useBuildDAOTx.ts index eac2c6f127..6955f50bef 100644 --- a/src/hooks/DAO/useBuildDAOTx.ts +++ b/src/hooks/DAO/useBuildDAOTx.ts @@ -18,7 +18,7 @@ const useBuildDAOTx = () => { const signerOrProvider = useSignerOrProvider(); const { createOptions, - contracts: { fallbackHandler }, + contracts: { fallbackHandler, votesERC20WrapperMasterCopy }, } = useNetworkConfig(); const { @@ -56,7 +56,6 @@ const useBuildDAOTx = () => { freezeERC721VotingMasterCopyContract, votesTokenMasterCopyContract, claimingMasterCopyContract, - votesERC20WrapperMasterCopyContract, keyValuePairsContract, } = baseContracts; @@ -87,7 +86,6 @@ const useBuildDAOTx = () => { azoriusFreezeGuardMasterCopyContract: azoriusFreezeGuardMasterCopyContract.asSigner, votesTokenMasterCopyContract: votesTokenMasterCopyContract.asSigner, claimingMasterCopyContract: claimingMasterCopyContract.asSigner, - votesERC20WrapperMasterCopyContract: votesERC20WrapperMasterCopyContract.asSigner, }; } @@ -111,6 +109,7 @@ const useBuildDAOTx = () => { azoriusContracts, daoData, fallbackHandler, + votesERC20WrapperMasterCopy, parentAddress, parentTokenAddress, ); @@ -157,6 +156,7 @@ const useBuildDAOTx = () => { governance, createOptions, fallbackHandler, + votesERC20WrapperMasterCopy, ], ); diff --git a/src/hooks/DAO/useDeployAzorius.ts b/src/hooks/DAO/useDeployAzorius.ts index d509ffb847..c6dcf46905 100644 --- a/src/hooks/DAO/useDeployAzorius.ts +++ b/src/hooks/DAO/useDeployAzorius.ts @@ -21,7 +21,7 @@ const useDeployAzorius = () => { const signerOrProvider = useSignerOrProvider(); const navigate = useNavigate(); const { - contracts: { fallbackHandler }, + contracts: { fallbackHandler, votesERC20WrapperMasterCopy }, addressPrefix, } = useNetworkConfig(); const { @@ -56,7 +56,6 @@ const useDeployAzorius = () => { freezeERC20VotingMasterCopyContract, votesTokenMasterCopyContract, claimingMasterCopyContract, - votesERC20WrapperMasterCopyContract, keyValuePairsContract, } = baseContracts; let azoriusContracts; @@ -67,7 +66,6 @@ const useDeployAzorius = () => { azoriusFreezeGuardMasterCopyContract: azoriusFreezeGuardMasterCopyContract.asProvider, votesTokenMasterCopyContract: votesTokenMasterCopyContract.asProvider, claimingMasterCopyContract: claimingMasterCopyContract.asProvider, - votesERC20WrapperMasterCopyContract: votesERC20WrapperMasterCopyContract.asProvider, } as AzoriusContracts; const builderBaseContracts = { @@ -89,6 +87,7 @@ const useDeployAzorius = () => { azoriusContracts, daoData, fallbackHandler, + votesERC20WrapperMasterCopy, undefined, undefined, ); @@ -146,6 +145,7 @@ const useDeployAzorius = () => { safe, fallbackHandler, addressPrefix, + votesERC20WrapperMasterCopy, ], ); diff --git a/src/models/AzoriusTxBuilder.ts b/src/models/AzoriusTxBuilder.ts index e1e6189d38..893c5dbffe 100644 --- a/src/models/AzoriusTxBuilder.ts +++ b/src/models/AzoriusTxBuilder.ts @@ -19,7 +19,9 @@ import { getAddress, isAddress, isHex, + encodeFunctionData, } from 'viem'; +import VotesERC20Wrapper from '../assets/abi/VotesERC20Wrapper'; import { GnosisSafeL2 } from '../assets/typechain-types/usul/@gnosis.pm/safe-contracts/contracts'; import { buildContractCall, getRandomBytes } from '../helpers'; import { @@ -53,6 +55,8 @@ export class AzoriusTxBuilder extends BaseTxBuilder { public linearERC721VotingContract: LinearERC721Voting | undefined; public votesTokenContract: VotesERC20 | undefined; + private votesERC20WrapperMasterCopyAddress: string; + private tokenNonce: bigint; private strategyNonce: bigint; private azoriusNonce: bigint; @@ -64,6 +68,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { azoriusContracts: AzoriusContracts, daoData: AzoriusERC20DAO | AzoriusERC721DAO, safeContract: GnosisSafeL2, + votesERC20WrapperMasterCopyAddress: string, parentAddress?: Address, parentTokenAddress?: Address, ) { @@ -83,6 +88,8 @@ export class AzoriusTxBuilder extends BaseTxBuilder { this.strategyNonce = getRandomBytes(); this.azoriusNonce = getRandomBytes(); + this.votesERC20WrapperMasterCopyAddress = votesERC20WrapperMasterCopyAddress; + if (daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC20) { daoData = daoData as AzoriusERC20DAO; if (!daoData.isTokenImported) { @@ -251,11 +258,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { return buildContractCall( this.baseContracts.zodiacModuleProxyFactoryContract, 'deployModule', - [ - this.azoriusContracts!.votesERC20WrapperMasterCopyContract.address, - this.encodedSetupERC20WrapperData, - this.tokenNonce, - ], + [this.votesERC20WrapperMasterCopyAddress, this.encodedSetupERC20WrapperData, this.tokenNonce], 0, false, ); @@ -274,11 +277,12 @@ export class AzoriusTxBuilder extends BaseTxBuilder { tokenImportAddress, ]); - const encodedSetupERC20WrapperData = - this.azoriusContracts!.votesERC20WrapperMasterCopyContract.interface.encodeFunctionData( - 'setUp', - [encodedInitTokenData], - ); + const encodedSetupERC20WrapperData = encodeFunctionData({ + abi: VotesERC20Wrapper, + functionName: 'setUp', + args: [encodedInitTokenData], + }); + if (!isHex(encodedSetupERC20WrapperData)) { throw new Error('Error encoding setup ERC-20 Wrapper data - interface encoding failed'); } @@ -287,7 +291,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { public setPredictedERC20WrapperAddress() { const tokenByteCodeLinear = generateContractByteCodeLinear( - getAddress(this.azoriusContracts!.votesERC20WrapperMasterCopyContract.address), + getAddress(this.votesERC20WrapperMasterCopyAddress), ); const tokenSalt = generateSalt(this.encodedSetupERC20WrapperData!, this.tokenNonce); diff --git a/src/models/TxBuilderFactory.ts b/src/models/TxBuilderFactory.ts index 81682876f5..a45654eea2 100644 --- a/src/models/TxBuilderFactory.ts +++ b/src/models/TxBuilderFactory.ts @@ -29,12 +29,15 @@ export class TxBuilderFactory extends BaseTxBuilder { private safeContract: GnosisSafeL2 | undefined; public fallbackHandler: string; + private votesERC20WrapperMasterCopyAddress: string; + constructor( signerOrProvider: ethers.Signer | any, baseContracts: BaseContracts, azoriusContracts: AzoriusContracts | undefined, daoData: SafeMultisigDAO | AzoriusERC20DAO | AzoriusERC721DAO | SubDAO, fallbackHandler: string, + votesERC20WrapperMasterCopyAddress: string, parentAddress?: string, parentTokenAddress?: string, ) { @@ -49,6 +52,7 @@ export class TxBuilderFactory extends BaseTxBuilder { this.fallbackHandler = fallbackHandler; this.saltNum = getRandomBytes(); + this.votesERC20WrapperMasterCopyAddress = votesERC20WrapperMasterCopyAddress; } public setSafeContract(safeAddress: string) { @@ -130,6 +134,7 @@ export class TxBuilderFactory extends BaseTxBuilder { this.azoriusContracts!, this.daoData as AzoriusERC20DAO, this.safeContract!, + this.votesERC20WrapperMasterCopyAddress, this.parentAddress ? getAddress(this.parentAddress) : undefined, this.parentTokenAddress ? getAddress(this.parentTokenAddress) : undefined, ); From 8531ef7e9bfebe41b60bc2bee15bc1ab46791213 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sun, 5 May 2024 09:43:26 -0400 Subject: [PATCH 15/19] Remove unnecessary reference to VotesERC20Wrapper export from 'fractal-contracts' --- src/hooks/utils/useApproval.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/hooks/utils/useApproval.tsx b/src/hooks/utils/useApproval.tsx index e9dd48270b..923a1bd59b 100644 --- a/src/hooks/utils/useApproval.tsx +++ b/src/hooks/utils/useApproval.tsx @@ -1,15 +1,11 @@ -import { VotesERC20, VotesERC20Wrapper } from '@fractal-framework/fractal-contracts'; +import { VotesERC20 } from '@fractal-framework/fractal-contracts'; import { useCallback, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { maxUint256 } from 'viem'; import { useAccount } from 'wagmi'; import { useTransaction } from './useTransaction'; -const useApproval = ( - tokenContract?: VotesERC20 | VotesERC20Wrapper, - spenderAddress?: string, - userBalance?: bigint, -) => { +const useApproval = (tokenContract?: VotesERC20, spenderAddress?: string, userBalance?: bigint) => { const { address: account } = useAccount(); const [allowance, setAllowance] = useState(0n); const [approved, setApproved] = useState(false); From 8d624494791f2e51076dfd08d884bae7d77f2850 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sun, 5 May 2024 09:46:47 -0400 Subject: [PATCH 16/19] Remove VotesERC20 type, save this for another PR --- src/assets/abi/VotesERC20.ts | 757 ----------------------------------- 1 file changed, 757 deletions(-) delete mode 100644 src/assets/abi/VotesERC20.ts diff --git a/src/assets/abi/VotesERC20.ts b/src/assets/abi/VotesERC20.ts deleted file mode 100644 index c841daedf3..0000000000 --- a/src/assets/abi/VotesERC20.ts +++ /dev/null @@ -1,757 +0,0 @@ -const VotesERC20 = [ - { - inputs: [], - stateMutability: 'nonpayable', - type: 'constructor', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'owner', - type: 'address', - }, - { - indexed: true, - internalType: 'address', - name: 'spender', - type: 'address', - }, - { - indexed: false, - internalType: 'uint256', - name: 'value', - type: 'uint256', - }, - ], - name: 'Approval', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'delegator', - type: 'address', - }, - { - indexed: true, - internalType: 'address', - name: 'fromDelegate', - type: 'address', - }, - { - indexed: true, - internalType: 'address', - name: 'toDelegate', - type: 'address', - }, - ], - name: 'DelegateChanged', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'delegate', - type: 'address', - }, - { - indexed: false, - internalType: 'uint256', - name: 'previousBalance', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'newBalance', - type: 'uint256', - }, - ], - name: 'DelegateVotesChanged', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'uint8', - name: 'version', - type: 'uint8', - }, - ], - name: 'Initialized', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'previousOwner', - type: 'address', - }, - { - indexed: true, - internalType: 'address', - name: 'newOwner', - type: 'address', - }, - ], - name: 'OwnershipTransferred', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'uint256', - name: 'id', - type: 'uint256', - }, - ], - name: 'Snapshot', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'from', - type: 'address', - }, - { - indexed: true, - internalType: 'address', - name: 'to', - type: 'address', - }, - { - indexed: false, - internalType: 'uint256', - name: 'value', - type: 'uint256', - }, - ], - name: 'Transfer', - type: 'event', - }, - { - inputs: [], - name: 'DOMAIN_SEPARATOR', - outputs: [ - { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'owner', - type: 'address', - }, - { - internalType: 'address', - name: 'spender', - type: 'address', - }, - ], - name: 'allowance', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'spender', - type: 'address', - }, - { - internalType: 'uint256', - name: 'amount', - type: 'uint256', - }, - ], - name: 'approve', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'account', - type: 'address', - }, - ], - name: 'balanceOf', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'account', - type: 'address', - }, - { - internalType: 'uint256', - name: 'snapshotId', - type: 'uint256', - }, - ], - name: 'balanceOfAt', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'captureSnapShot', - outputs: [ - { - internalType: 'uint256', - name: 'snapId', - type: 'uint256', - }, - ], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'account', - type: 'address', - }, - { - internalType: 'uint32', - name: 'pos', - type: 'uint32', - }, - ], - name: 'checkpoints', - outputs: [ - { - components: [ - { - internalType: 'uint32', - name: 'fromBlock', - type: 'uint32', - }, - { - internalType: 'uint224', - name: 'votes', - type: 'uint224', - }, - ], - internalType: 'struct ERC20VotesUpgradeable.Checkpoint', - name: '', - type: 'tuple', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'decimals', - outputs: [ - { - internalType: 'uint8', - name: '', - type: 'uint8', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'spender', - type: 'address', - }, - { - internalType: 'uint256', - name: 'subtractedValue', - type: 'uint256', - }, - ], - name: 'decreaseAllowance', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'delegatee', - type: 'address', - }, - ], - name: 'delegate', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'delegatee', - type: 'address', - }, - { - internalType: 'uint256', - name: 'nonce', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'expiry', - type: 'uint256', - }, - { - internalType: 'uint8', - name: 'v', - type: 'uint8', - }, - { - internalType: 'bytes32', - name: 'r', - type: 'bytes32', - }, - { - internalType: 'bytes32', - name: 's', - type: 'bytes32', - }, - ], - name: 'delegateBySig', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'account', - type: 'address', - }, - ], - name: 'delegates', - outputs: [ - { - internalType: 'address', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'blockNumber', - type: 'uint256', - }, - ], - name: 'getPastTotalSupply', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'account', - type: 'address', - }, - { - internalType: 'uint256', - name: 'blockNumber', - type: 'uint256', - }, - ], - name: 'getPastVotes', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'account', - type: 'address', - }, - ], - name: 'getVotes', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'spender', - type: 'address', - }, - { - internalType: 'uint256', - name: 'addedValue', - type: 'uint256', - }, - ], - name: 'increaseAllowance', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [], - name: 'name', - outputs: [ - { - internalType: 'string', - name: '', - type: 'string', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'owner', - type: 'address', - }, - ], - name: 'nonces', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'account', - type: 'address', - }, - ], - name: 'numCheckpoints', - outputs: [ - { - internalType: 'uint32', - name: '', - type: 'uint32', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'owner', - outputs: [ - { - internalType: 'address', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'owner', - type: 'address', - }, - { - internalType: 'address', - name: 'spender', - type: 'address', - }, - { - internalType: 'uint256', - name: 'value', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'deadline', - type: 'uint256', - }, - { - internalType: 'uint8', - name: 'v', - type: 'uint8', - }, - { - internalType: 'bytes32', - name: 'r', - type: 'bytes32', - }, - { - internalType: 'bytes32', - name: 's', - type: 'bytes32', - }, - ], - name: 'permit', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [], - name: 'renounceOwnership', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'bytes', - name: 'initializeParams', - type: 'bytes', - }, - ], - name: 'setUp', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'bytes4', - name: 'interfaceId', - type: 'bytes4', - }, - ], - name: 'supportsInterface', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'symbol', - outputs: [ - { - internalType: 'string', - name: '', - type: 'string', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [], - name: 'totalSupply', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'snapshotId', - type: 'uint256', - }, - ], - name: 'totalSupplyAt', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'to', - type: 'address', - }, - { - internalType: 'uint256', - name: 'amount', - type: 'uint256', - }, - ], - name: 'transfer', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'from', - type: 'address', - }, - { - internalType: 'address', - name: 'to', - type: 'address', - }, - { - internalType: 'uint256', - name: 'amount', - type: 'uint256', - }, - ], - name: 'transferFrom', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'nonpayable', - type: 'function', - }, - { - inputs: [ - { - internalType: 'address', - name: 'newOwner', - type: 'address', - }, - ], - name: 'transferOwnership', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', - }, -] as const; - -export default VotesERC20; From 1fc3d78881b647c4169cff3ba94784bdc5340214 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sun, 5 May 2024 10:45:34 -0400 Subject: [PATCH 17/19] Standardize local Abi import naming --- src/components/ui/modals/UnwrapToken.tsx | 4 ++-- src/components/ui/modals/WrapToken.tsx | 4 ++-- src/hooks/DAO/loaders/useGovernanceContracts.ts | 4 ++-- src/models/AzoriusTxBuilder.ts | 4 ++-- src/models/helpers/safeData.ts | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/ui/modals/UnwrapToken.tsx b/src/components/ui/modals/UnwrapToken.tsx index d74db3c061..8f63305d3b 100644 --- a/src/components/ui/modals/UnwrapToken.tsx +++ b/src/components/ui/modals/UnwrapToken.tsx @@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next'; import { getAddress, getContract } from 'viem'; import { useAccount, useWalletClient } from 'wagmi'; import * as Yup from 'yup'; -import VotesERC20Wrapper from '../../../assets/abi/VotesERC20Wrapper'; +import VotesERC20WrapperAbi from '../../../assets/abi/VotesERC20Wrapper'; import { useERC20LinearToken } from '../../../hooks/DAO/loaders/governance/useERC20LinearToken'; import useSafeContracts from '../../../hooks/safe/useSafeContracts'; import useApproval from '../../../hooks/utils/useApproval'; @@ -47,7 +47,7 @@ export function UnwrapToken({ close }: { close: () => void }) { if (!votesTokenContractAddress || !account || !walletClient) return; const wrapperTokenContract = getContract({ - abi: VotesERC20Wrapper, + abi: VotesERC20WrapperAbi, address: getAddress(votesTokenContractAddress), client: walletClient, }); diff --git a/src/components/ui/modals/WrapToken.tsx b/src/components/ui/modals/WrapToken.tsx index 7a2a49cdf9..ccfec436d7 100644 --- a/src/components/ui/modals/WrapToken.tsx +++ b/src/components/ui/modals/WrapToken.tsx @@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next'; import { erc20Abi, getAddress, getContract } from 'viem'; import { useAccount, usePublicClient, useWalletClient } from 'wagmi'; import * as Yup from 'yup'; -import VotesERC20Wrapper from '../../../assets/abi/VotesERC20Wrapper'; +import VotesERC20WrapperAbi from '../../../assets/abi/VotesERC20Wrapper'; import { logError } from '../../../helpers/errorLogging'; import { useERC20LinearToken } from '../../../hooks/DAO/loaders/governance/useERC20LinearToken'; import useSafeContracts from '../../../hooks/safe/useSafeContracts'; @@ -93,7 +93,7 @@ export function WrapToken({ close }: { close: () => void }) { return; const wrapperTokenContract = getContract({ - abi: VotesERC20Wrapper, + abi: VotesERC20WrapperAbi, address: getAddress(votesTokenContractAddress), client: walletClient, }); diff --git a/src/hooks/DAO/loaders/useGovernanceContracts.ts b/src/hooks/DAO/loaders/useGovernanceContracts.ts index 698fe749b9..378f8e6272 100644 --- a/src/hooks/DAO/loaders/useGovernanceContracts.ts +++ b/src/hooks/DAO/loaders/useGovernanceContracts.ts @@ -2,7 +2,7 @@ import { Azorius } from '@fractal-framework/fractal-contracts'; import { useCallback, useEffect, useRef } from 'react'; import { Address, getContract, getAddress } from 'viem'; import { usePublicClient } from 'wagmi'; -import VotesERC20Wrapper from '../../../assets/abi/VotesERC20Wrapper'; +import VotesERC20WrapperAbi from '../../../assets/abi/VotesERC20Wrapper'; import { LockRelease__factory } from '../../../assets/typechain-types/dcnt'; import { useFractal } from '../../../providers/App/AppProvider'; import { GovernanceContractAction } from '../../../providers/App/governanceContracts/action'; @@ -61,7 +61,7 @@ export const useGovernanceContracts = () => { govTokenAddress = await ozLinearVotingContract.governanceToken(); const possibleERC20Wrapper = getContract({ - abi: VotesERC20Wrapper, + abi: VotesERC20WrapperAbi, address: getAddress(govTokenAddress), client: publicClient, }); diff --git a/src/models/AzoriusTxBuilder.ts b/src/models/AzoriusTxBuilder.ts index 893c5dbffe..e3f43526bb 100644 --- a/src/models/AzoriusTxBuilder.ts +++ b/src/models/AzoriusTxBuilder.ts @@ -21,7 +21,7 @@ import { isHex, encodeFunctionData, } from 'viem'; -import VotesERC20Wrapper from '../assets/abi/VotesERC20Wrapper'; +import VotesERC20WrapperAbi from '../assets/abi/VotesERC20Wrapper'; import { GnosisSafeL2 } from '../assets/typechain-types/usul/@gnosis.pm/safe-contracts/contracts'; import { buildContractCall, getRandomBytes } from '../helpers'; import { @@ -278,7 +278,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { ]); const encodedSetupERC20WrapperData = encodeFunctionData({ - abi: VotesERC20Wrapper, + abi: VotesERC20WrapperAbi, functionName: 'setUp', args: [encodedInitTokenData], }); diff --git a/src/models/helpers/safeData.ts b/src/models/helpers/safeData.ts index c7942b91af..622c229eba 100644 --- a/src/models/helpers/safeData.ts +++ b/src/models/helpers/safeData.ts @@ -10,7 +10,7 @@ import { isHex, hexToBigInt, } from 'viem'; -import GnosisSafeL2ABI from '../../assets/abi/GnosisSafeL2'; +import GnosisSafeL2Abi from '../../assets/abi/GnosisSafeL2'; import { MultiSend } from '../../assets/typechain-types/usul'; import { GnosisSafeL2 } from '../../assets/typechain-types/usul/@gnosis.pm/safe-contracts/contracts'; import { buildContractCall } from '../../helpers/crypto'; @@ -41,7 +41,7 @@ export const safeData = async ( 0n, zeroAddress, ], - abi: GnosisSafeL2ABI, + abi: GnosisSafeL2Abi, }); const safeFactoryContractProxyCreationCode = await safeFactoryContract.proxyCreationCode(); From 195070fe2894879b554a4666c56c7a9bc3d71ca1 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sun, 5 May 2024 11:00:58 -0400 Subject: [PATCH 18/19] Don't need to check type any longer --- src/models/AzoriusTxBuilder.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/models/AzoriusTxBuilder.ts b/src/models/AzoriusTxBuilder.ts index e3f43526bb..0efc8b9168 100644 --- a/src/models/AzoriusTxBuilder.ts +++ b/src/models/AzoriusTxBuilder.ts @@ -277,16 +277,11 @@ export class AzoriusTxBuilder extends BaseTxBuilder { tokenImportAddress, ]); - const encodedSetupERC20WrapperData = encodeFunctionData({ + this.encodedSetupERC20WrapperData = encodeFunctionData({ abi: VotesERC20WrapperAbi, functionName: 'setUp', args: [encodedInitTokenData], }); - - if (!isHex(encodedSetupERC20WrapperData)) { - throw new Error('Error encoding setup ERC-20 Wrapper data - interface encoding failed'); - } - this.encodedSetupERC20WrapperData = encodedSetupERC20WrapperData; } public setPredictedERC20WrapperAddress() { From 273235d14c3c022488fe99337397a874c366be94 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Sun, 5 May 2024 11:01:38 -0400 Subject: [PATCH 19/19] Fix Hash => Hex types --- src/models/AzoriusTxBuilder.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/models/AzoriusTxBuilder.ts b/src/models/AzoriusTxBuilder.ts index 0efc8b9168..ca4a7658b3 100644 --- a/src/models/AzoriusTxBuilder.ts +++ b/src/models/AzoriusTxBuilder.ts @@ -11,7 +11,7 @@ import { import { getCreate2Address, Address, - Hash, + Hex, encodePacked, keccak256, encodeAbiParameters, @@ -39,11 +39,11 @@ import { generateContractByteCodeLinear, generateSalt } from './helpers/utils'; export class AzoriusTxBuilder extends BaseTxBuilder { private readonly safeContract: GnosisSafeL2; - private encodedSetupTokenData: Address | undefined; - private encodedSetupERC20WrapperData: Hash | undefined; - private encodedStrategySetupData: Hash | undefined; - private encodedSetupAzoriusData: Hash | undefined; - private encodedSetupTokenClaimData: Hash | undefined; + private encodedSetupTokenData: Hex | undefined; + private encodedSetupERC20WrapperData: Hex | undefined; + private encodedStrategySetupData: Hex | undefined; + private encodedSetupAzoriusData: Hex | undefined; + private encodedSetupTokenClaimData: Hex | undefined; private predictedTokenAddress: Address | undefined; private predictedStrategyAddress: Address | undefined;