From 2cf84086b1358264dc6178cce4780260a04d00bc Mon Sep 17 00:00:00 2001 From: Adam Gall Date: Tue, 7 May 2024 13:55:26 -0400 Subject: [PATCH] Remove keyValuePairsContract from FractalContracts interface, deal with downstream typescript issues --- .../DaoSettings/components/Metadata/index.tsx | 27 +++++++++---------- src/hooks/DAO/useBuildDAOTx.ts | 2 -- src/types/fractal.ts | 2 -- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/components/pages/DaoSettings/components/Metadata/index.tsx b/src/components/pages/DaoSettings/components/Metadata/index.tsx index 42d6470950..19c3853333 100644 --- a/src/components/pages/DaoSettings/components/Metadata/index.tsx +++ b/src/components/pages/DaoSettings/components/Metadata/index.tsx @@ -3,8 +3,9 @@ import { Flex, Text, Button, Divider } from '@chakra-ui/react'; import { useState, useEffect, ChangeEventHandler } from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router-dom'; -import { isHex, getAddress } from 'viem'; +import { isHex, getAddress, encodeFunctionData } from 'viem'; import { SettingsSection } from '..'; +import KeyValuePairsAbi from '../../../../../assets/abi/KeyValuePairs'; import { DAO_ROUTES } from '../../../../../constants/routes'; import useSubmitProposal from '../../../../../hooks/DAO/proposal/useSubmitProposal'; import { useCanUserCreateProposal } from '../../../../../hooks/utils/useCanUserSubmitProposal'; @@ -30,7 +31,10 @@ export default function MetadataContainer() { user: { votingWeight }, }, } = useFractal(); - const { addressPrefix } = useNetworkConfig(); + const { + addressPrefix, + contracts: { keyValuePairs }, + } = useNetworkConfig(); useEffect(() => { if (daoName && daoAddress && createAccountSubstring(daoAddress) !== daoName) { @@ -94,24 +98,19 @@ export default function MetadataContainer() { }; const handleEditDAOSnapshotENS = () => { - if (!baseContracts) { - return; - } - const { keyValuePairsContract } = baseContracts; - const encodedUpdateValues = keyValuePairsContract.asProvider.interface.encodeFunctionData( - 'updateValues', - [['snapshotENS'], [snapshotENS]], - ); - if (!isHex(encodedUpdateValues)) { - return; - } + const encodedUpdateValues = encodeFunctionData({ + abi: KeyValuePairsAbi, + functionName: 'updateValues', + args: [['snapshotENS'], [snapshotENS]], + }); + const proposalData: ProposalExecuteData = { metaData: { title: t('Update Snapshot Space', { ns: 'proposalMetadata' }), description: '', documentationUrl: '', }, - targets: [getAddress(keyValuePairsContract.asProvider.address)], + targets: [keyValuePairs], values: [0n], calldatas: [encodedUpdateValues], }; diff --git a/src/hooks/DAO/useBuildDAOTx.ts b/src/hooks/DAO/useBuildDAOTx.ts index 23c846641e..3f0ceff487 100644 --- a/src/hooks/DAO/useBuildDAOTx.ts +++ b/src/hooks/DAO/useBuildDAOTx.ts @@ -62,7 +62,6 @@ const useBuildDAOTx = () => { freezeERC20VotingMasterCopyContract, freezeERC721VotingMasterCopyContract, claimingMasterCopyContract, - keyValuePairsContract, } = baseContracts; if ( @@ -104,7 +103,6 @@ const useBuildDAOTx = () => { freezeERC721VotingMasterCopyContract: freezeERC721VotingMasterCopyContract.asSigner, freezeMultisigVotingMasterCopyContract: freezeMultisigVotingMasterCopyContract.asSigner, zodiacModuleProxyFactoryContract: zodiacModuleProxyFactoryContract.asSigner, - keyValuePairsContract: keyValuePairsContract.asSigner, } as BaseContracts; const txBuilderFactory = new TxBuilderFactory( diff --git a/src/types/fractal.ts b/src/types/fractal.ts index c4cb228a12..0e9446b64e 100644 --- a/src/types/fractal.ts +++ b/src/types/fractal.ts @@ -10,7 +10,6 @@ import { ERC20FreezeVoting, MultisigFreezeVoting, MultisigFreezeGuard, - KeyValuePairs, ERC721FreezeVoting, LinearERC721Voting, } from '@fractal-framework/fractal-contracts'; @@ -347,7 +346,6 @@ export interface FractalContracts { freezeERC20VotingMasterCopyContract: ContractConnection; freezeERC721VotingMasterCopyContract: ContractConnection; claimingMasterCopyContract: ContractConnection; - keyValuePairsContract: ContractConnection; } export type FractalProposal = AzoriusProposal | MultisigProposal | SnapshotProposal;