Skip to content

Commit

Permalink
Remove keyValuePairsContract from FractalContracts interface, deal wi…
Browse files Browse the repository at this point in the history
…th downstream typescript issues
  • Loading branch information
adamgall committed May 6, 2024
1 parent d119449 commit 3167bfa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
27 changes: 13 additions & 14 deletions src/components/pages/DaoSettings/components/Metadata/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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) {
Expand Down Expand Up @@ -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],
};
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/DAO/useBuildDAOTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ const useBuildDAOTx = () => {
freezeERC20VotingMasterCopyContract,
freezeERC721VotingMasterCopyContract,
claimingMasterCopyContract,
keyValuePairsContract,
} = baseContracts;

if (
Expand Down Expand Up @@ -104,7 +103,6 @@ const useBuildDAOTx = () => {
freezeERC721VotingMasterCopyContract: freezeERC721VotingMasterCopyContract.asSigner,
freezeMultisigVotingMasterCopyContract: freezeMultisigVotingMasterCopyContract.asSigner,
zodiacModuleProxyFactoryContract: zodiacModuleProxyFactoryContract.asSigner,
keyValuePairsContract: keyValuePairsContract.asSigner,
} as BaseContracts;

const txBuilderFactory = new TxBuilderFactory(
Expand Down
2 changes: 0 additions & 2 deletions src/types/fractal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
ERC20FreezeVoting,
MultisigFreezeVoting,
MultisigFreezeGuard,
KeyValuePairs,
ERC721FreezeVoting,
LinearERC721Voting,
} from '@fractal-framework/fractal-contracts';
Expand Down Expand Up @@ -347,7 +346,6 @@ export interface FractalContracts {
freezeERC20VotingMasterCopyContract: ContractConnection<ERC20FreezeVoting>;
freezeERC721VotingMasterCopyContract: ContractConnection<ERC721FreezeVoting>;
claimingMasterCopyContract: ContractConnection<ERC20Claim>;
keyValuePairsContract: ContractConnection<KeyValuePairs>;
}

export type FractalProposal = AzoriusProposal | MultisigProposal | SnapshotProposal;
Expand Down

0 comments on commit 3167bfa

Please sign in to comment.