From 4d1e31d9ce53b7919b0487c130dc758b70ce2be2 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Tue, 7 May 2024 13:55:07 -0400 Subject: [PATCH 1/3] Update type of KeyValuePairs address in NetworkConfig to Address --- src/providers/NetworkConfig/networks/base.ts | 2 +- src/providers/NetworkConfig/networks/baseSepolia.ts | 2 +- src/providers/NetworkConfig/networks/mainnet.ts | 2 +- src/providers/NetworkConfig/networks/optimism.ts | 2 +- src/providers/NetworkConfig/networks/polygon.ts | 2 +- src/providers/NetworkConfig/networks/sepolia.ts | 2 +- src/types/network.ts | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/providers/NetworkConfig/networks/base.ts b/src/providers/NetworkConfig/networks/base.ts index 05a50696fe..458b3f6486 100644 --- a/src/providers/NetworkConfig/networks/base.ts +++ b/src/providers/NetworkConfig/networks/base.ts @@ -71,7 +71,7 @@ export const baseConfig: NetworkConfig = { network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, votesERC20WrapperMasterCopy: getAddress(VotesERC20Wrapper.address), - keyValuePairs: KeyValuePairs.address, + keyValuePairs: getAddress(KeyValuePairs.address), }, staking: {}, createOptions: [ diff --git a/src/providers/NetworkConfig/networks/baseSepolia.ts b/src/providers/NetworkConfig/networks/baseSepolia.ts index ce74e9ea1c..96d179f59b 100644 --- a/src/providers/NetworkConfig/networks/baseSepolia.ts +++ b/src/providers/NetworkConfig/networks/baseSepolia.ts @@ -73,7 +73,7 @@ export const baseSepoliaConfig: NetworkConfig = { network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, votesERC20WrapperMasterCopy: getAddress(VotesERC20Wrapper.address), - keyValuePairs: KeyValuePairs.address, + keyValuePairs: getAddress(KeyValuePairs.address), }, staking: {}, createOptions: [ diff --git a/src/providers/NetworkConfig/networks/mainnet.ts b/src/providers/NetworkConfig/networks/mainnet.ts index a1a7f94772..9592defc14 100644 --- a/src/providers/NetworkConfig/networks/mainnet.ts +++ b/src/providers/NetworkConfig/networks/mainnet.ts @@ -71,7 +71,7 @@ export const mainnetConfig: NetworkConfig = { network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, votesERC20WrapperMasterCopy: getAddress(VotesERC20Wrapper.address), - keyValuePairs: KeyValuePairs.address, + keyValuePairs: getAddress(KeyValuePairs.address), }, staking: { lido: { diff --git a/src/providers/NetworkConfig/networks/optimism.ts b/src/providers/NetworkConfig/networks/optimism.ts index 420c4de0cd..b07269f627 100644 --- a/src/providers/NetworkConfig/networks/optimism.ts +++ b/src/providers/NetworkConfig/networks/optimism.ts @@ -71,7 +71,7 @@ export const optimismConfig: NetworkConfig = { network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, votesERC20WrapperMasterCopy: getAddress(VotesERC20Wrapper.address), - keyValuePairs: KeyValuePairs.address, + keyValuePairs: getAddress(KeyValuePairs.address), }, staking: {}, createOptions: [ diff --git a/src/providers/NetworkConfig/networks/polygon.ts b/src/providers/NetworkConfig/networks/polygon.ts index 98800188a0..35173b9d2b 100644 --- a/src/providers/NetworkConfig/networks/polygon.ts +++ b/src/providers/NetworkConfig/networks/polygon.ts @@ -71,7 +71,7 @@ export const polygonConfig: NetworkConfig = { network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, votesERC20WrapperMasterCopy: getAddress(VotesERC20Wrapper.address), - keyValuePairs: KeyValuePairs.address, + keyValuePairs: getAddress(KeyValuePairs.address), }, staking: {}, createOptions: [GovernanceType.MULTISIG, GovernanceType.AZORIUS_ERC20], diff --git a/src/providers/NetworkConfig/networks/sepolia.ts b/src/providers/NetworkConfig/networks/sepolia.ts index acf29eda6b..2c350b4a35 100644 --- a/src/providers/NetworkConfig/networks/sepolia.ts +++ b/src/providers/NetworkConfig/networks/sepolia.ts @@ -71,7 +71,7 @@ export const sepoliaConfig: NetworkConfig = { network: chain.id.toString(), })?.networkAddresses[chain.id.toString()]!, votesERC20WrapperMasterCopy: getAddress(VotesERC20Wrapper.address), - keyValuePairs: KeyValuePairs.address, + keyValuePairs: getAddress(KeyValuePairs.address), }, staking: {}, createOptions: [ diff --git a/src/types/network.ts b/src/types/network.ts index 88f8f8edd1..2f14920699 100644 --- a/src/types/network.ts +++ b/src/types/network.ts @@ -40,7 +40,7 @@ export type NetworkConfig = { erc20FreezeVotingMasterCopy: string; erc721FreezeVotingMasterCopy: string; votesERC20WrapperMasterCopy: Address; - keyValuePairs: string; + keyValuePairs: Address; }; staking: { lido?: { From 8b5ea282c04418f77d58d531413d7a3d49fa2df2 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Tue, 7 May 2024 13:55:08 -0400 Subject: [PATCH 2/3] Add KeyValuePairs ABI --- src/assets/abi/KeyValuePairs.ts | 52 +++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/assets/abi/KeyValuePairs.ts diff --git a/src/assets/abi/KeyValuePairs.ts b/src/assets/abi/KeyValuePairs.ts new file mode 100644 index 0000000000..2ac0d44af0 --- /dev/null +++ b/src/assets/abi/KeyValuePairs.ts @@ -0,0 +1,52 @@ +const KeyValuePairsAbi = [ + { + inputs: [], + name: 'IncorrectValueCount', + type: 'error', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'theAddress', + type: 'address', + }, + { + indexed: false, + internalType: 'string', + name: 'key', + type: 'string', + }, + { + indexed: false, + internalType: 'string', + name: 'value', + type: 'string', + }, + ], + name: 'ValueUpdated', + type: 'event', + }, + { + inputs: [ + { + internalType: 'string[]', + name: '_keys', + type: 'string[]', + }, + { + internalType: 'string[]', + name: '_values', + type: 'string[]', + }, + ], + name: 'updateValues', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; + +export default KeyValuePairsAbi; From ff9339f5b40f5a0e8f9437febef60033ed433fd9 Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Tue, 7 May 2024 13:55:08 -0400 Subject: [PATCH 3/3] Remove keyValuePairsContract from BaseContracts interface, deal with all downstream typescript issues --- src/hooks/DAO/useBuildDAOTx.ts | 9 ++++++++- src/hooks/DAO/useDeployAzorius.ts | 11 ++++++++--- src/models/DaoTxBuilder.ts | 15 +++++++++++---- src/models/TxBuilderFactory.ts | 4 ++++ src/types/contract.ts | 2 -- 5 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/hooks/DAO/useBuildDAOTx.ts b/src/hooks/DAO/useBuildDAOTx.ts index 7a0c90c18b..23c846641e 100644 --- a/src/hooks/DAO/useBuildDAOTx.ts +++ b/src/hooks/DAO/useBuildDAOTx.ts @@ -19,7 +19,12 @@ const useBuildDAOTx = () => { const signerOrProvider = useSignerOrProvider(); const { createOptions, - contracts: { fallbackHandler, votesERC20WrapperMasterCopy, votesERC20MasterCopy }, + contracts: { + fallbackHandler, + votesERC20WrapperMasterCopy, + votesERC20MasterCopy, + keyValuePairs, + }, } = useNetworkConfig(); const { @@ -111,6 +116,7 @@ const useBuildDAOTx = () => { fallbackHandler, votesERC20WrapperMasterCopy, votesERC20MasterCopy, + keyValuePairs, parentAddress, parentTokenAddress, ); @@ -160,6 +166,7 @@ const useBuildDAOTx = () => { fallbackHandler, votesERC20WrapperMasterCopy, votesERC20MasterCopy, + keyValuePairs, ], ); diff --git a/src/hooks/DAO/useDeployAzorius.ts b/src/hooks/DAO/useDeployAzorius.ts index 58fc7ddb1f..11789c75a8 100644 --- a/src/hooks/DAO/useDeployAzorius.ts +++ b/src/hooks/DAO/useDeployAzorius.ts @@ -22,7 +22,12 @@ const useDeployAzorius = () => { const signerOrProvider = useSignerOrProvider(); const navigate = useNavigate(); const { - contracts: { fallbackHandler, votesERC20WrapperMasterCopy, votesERC20MasterCopy }, + contracts: { + fallbackHandler, + votesERC20WrapperMasterCopy, + votesERC20MasterCopy, + keyValuePairs, + }, addressPrefix, } = useNetworkConfig(); const { @@ -58,7 +63,6 @@ const useDeployAzorius = () => { freezeMultisigVotingMasterCopyContract, freezeERC20VotingMasterCopyContract, claimingMasterCopyContract, - keyValuePairsContract, } = baseContracts; let azoriusContracts; @@ -79,7 +83,6 @@ const useDeployAzorius = () => { freezeERC20VotingMasterCopyContract: freezeERC20VotingMasterCopyContract.asProvider, freezeMultisigVotingMasterCopyContract: freezeMultisigVotingMasterCopyContract.asProvider, zodiacModuleProxyFactoryContract: zodiacModuleProxyFactoryContract.asProvider, - keyValuePairsContract: keyValuePairsContract.asProvider, } as BaseContracts; const txBuilderFactory = new TxBuilderFactory( @@ -91,6 +94,7 @@ const useDeployAzorius = () => { fallbackHandler, votesERC20WrapperMasterCopy, votesERC20MasterCopy, + keyValuePairs, undefined, undefined, ); @@ -151,6 +155,7 @@ const useDeployAzorius = () => { addressPrefix, votesERC20WrapperMasterCopy, votesERC20MasterCopy, + keyValuePairs, ], ); diff --git a/src/models/DaoTxBuilder.ts b/src/models/DaoTxBuilder.ts index 5bc726442c..df2cd83588 100644 --- a/src/models/DaoTxBuilder.ts +++ b/src/models/DaoTxBuilder.ts @@ -1,7 +1,8 @@ import { ethers } from 'ethers'; -import { PublicClient, zeroAddress } from 'viem'; +import { PublicClient, getAddress, zeroAddress } from 'viem'; +import KeyValuePairsAbi from '../assets/abi/KeyValuePairs'; import { GnosisSafeL2 } from '../assets/typechain-types/usul/@gnosis.pm/safe-contracts/contracts'; -import { buildContractCall, encodeMultiSend } from '../helpers'; +import { buildContractCall, buildContractCallViem, encodeMultiSend } from '../helpers'; import { BaseContracts, SafeMultisigDAO, @@ -32,6 +33,8 @@ export class DaoTxBuilder extends BaseTxBuilder { private internalTxs: SafeTransaction[] = []; + private readonly keyValuePairsAddress: string; + constructor( signerOrProvider: ethers.Signer | any, publicClient: PublicClient, @@ -42,6 +45,7 @@ export class DaoTxBuilder extends BaseTxBuilder { createSafeTx: SafeTransaction, safeContract: GnosisSafeL2, txBuilderFactory: TxBuilderFactory, + keyValuePairsAddress: string, parentAddress?: string, parentTokenAddress?: string, parentStrategyType?: VotingStrategyType, @@ -64,6 +68,8 @@ export class DaoTxBuilder extends BaseTxBuilder { this.parentStrategyType = parentStrategyType; this.parentStrategyAddress = parentStrategyAddress; + this.keyValuePairsAddress = keyValuePairsAddress; + // Prep fractal module txs for setting up subDAOs this.setFractalModuleTxs(); } @@ -231,8 +237,9 @@ export class DaoTxBuilder extends BaseTxBuilder { } private buildUpdateDAOSnapshotENSTx(): SafeTransaction { - return buildContractCall( - this.baseContracts.keyValuePairsContract, + return buildContractCallViem( + KeyValuePairsAbi, + getAddress(this.keyValuePairsAddress), 'updateValues', [['snapshotENS'], [this.daoData.snapshotENS]], 0, diff --git a/src/models/TxBuilderFactory.ts b/src/models/TxBuilderFactory.ts index 80a31d8c18..4a5a98c0f3 100644 --- a/src/models/TxBuilderFactory.ts +++ b/src/models/TxBuilderFactory.ts @@ -31,6 +31,7 @@ export class TxBuilderFactory extends BaseTxBuilder { private votesERC20WrapperMasterCopyAddress: string; private votesERC20MasterCopyAddress: string; + private keyValuePairsAddress: string; constructor( signerOrProvider: ethers.Signer | any, @@ -41,6 +42,7 @@ export class TxBuilderFactory extends BaseTxBuilder { fallbackHandler: string, votesERC20WrapperMasterCopyAddress: string, votesERC20MasterCopyAddress: string, + keyValuePairsAddress: string, parentAddress?: string, parentTokenAddress?: string, ) { @@ -58,6 +60,7 @@ export class TxBuilderFactory extends BaseTxBuilder { this.saltNum = getRandomBytes(); this.votesERC20WrapperMasterCopyAddress = votesERC20WrapperMasterCopyAddress; this.votesERC20MasterCopyAddress = votesERC20MasterCopyAddress; + this.keyValuePairsAddress = keyValuePairsAddress; } public setSafeContract(safeAddress: string) { @@ -96,6 +99,7 @@ export class TxBuilderFactory extends BaseTxBuilder { this.createSafeTx!, this.safeContract!, this, + this.keyValuePairsAddress, this.parentAddress, this.parentTokenAddress, parentStrategyType, diff --git a/src/types/contract.ts b/src/types/contract.ts index 5947349e24..881eb564c1 100644 --- a/src/types/contract.ts +++ b/src/types/contract.ts @@ -6,7 +6,6 @@ import { MultisigFreezeGuard, MultisigFreezeVoting, ERC20FreezeVoting, - KeyValuePairs, ERC721FreezeVoting, } from '@fractal-framework/fractal-contracts'; import { MultiSend } from '../assets/typechain-types/usul'; @@ -32,5 +31,4 @@ export interface BaseContracts { freezeERC721VotingMasterCopyContract: ERC721FreezeVoting; freezeMultisigVotingMasterCopyContract: MultisigFreezeVoting; zodiacModuleProxyFactoryContract: ModuleProxyFactory; - keyValuePairsContract: KeyValuePairs; }