Skip to content

Commit

Permalink
Remove keyValuePairsContract from BaseContracts interface, deal with …
Browse files Browse the repository at this point in the history
…all downstream typescript issues
  • Loading branch information
adamgall committed May 6, 2024
1 parent 9c0d3c8 commit 5771ef6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
9 changes: 8 additions & 1 deletion src/hooks/DAO/useBuildDAOTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ const useBuildDAOTx = () => {
const signerOrProvider = useSignerOrProvider();
const {
createOptions,
contracts: { fallbackHandler, votesERC20WrapperMasterCopy, votesERC20MasterCopy },
contracts: {
fallbackHandler,
votesERC20WrapperMasterCopy,
votesERC20MasterCopy,
keyValuePairs,
},
} = useNetworkConfig();

const {
Expand Down Expand Up @@ -111,6 +116,7 @@ const useBuildDAOTx = () => {
fallbackHandler,
votesERC20WrapperMasterCopy,
votesERC20MasterCopy,
keyValuePairs,
parentAddress,
parentTokenAddress,
);
Expand Down Expand Up @@ -160,6 +166,7 @@ const useBuildDAOTx = () => {
fallbackHandler,
votesERC20WrapperMasterCopy,
votesERC20MasterCopy,
keyValuePairs,
],
);

Expand Down
11 changes: 8 additions & 3 deletions src/hooks/DAO/useDeployAzorius.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -58,7 +63,6 @@ const useDeployAzorius = () => {
freezeMultisigVotingMasterCopyContract,
freezeERC20VotingMasterCopyContract,
claimingMasterCopyContract,
keyValuePairsContract,
} = baseContracts;
let azoriusContracts;

Expand All @@ -79,7 +83,6 @@ const useDeployAzorius = () => {
freezeERC20VotingMasterCopyContract: freezeERC20VotingMasterCopyContract.asProvider,
freezeMultisigVotingMasterCopyContract: freezeMultisigVotingMasterCopyContract.asProvider,
zodiacModuleProxyFactoryContract: zodiacModuleProxyFactoryContract.asProvider,
keyValuePairsContract: keyValuePairsContract.asProvider,
} as BaseContracts;

const txBuilderFactory = new TxBuilderFactory(
Expand All @@ -91,6 +94,7 @@ const useDeployAzorius = () => {
fallbackHandler,
votesERC20WrapperMasterCopy,
votesERC20MasterCopy,
keyValuePairs,
undefined,
undefined,
);
Expand Down Expand Up @@ -151,6 +155,7 @@ const useDeployAzorius = () => {
addressPrefix,
votesERC20WrapperMasterCopy,
votesERC20MasterCopy,
keyValuePairs,
],
);

Expand Down
15 changes: 11 additions & 4 deletions src/models/DaoTxBuilder.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -32,6 +33,8 @@ export class DaoTxBuilder extends BaseTxBuilder {

private internalTxs: SafeTransaction[] = [];

private readonly keyValuePairsAddress: string;

constructor(
signerOrProvider: ethers.Signer | any,
publicClient: PublicClient,
Expand All @@ -42,6 +45,7 @@ export class DaoTxBuilder extends BaseTxBuilder {
createSafeTx: SafeTransaction,
safeContract: GnosisSafeL2,
txBuilderFactory: TxBuilderFactory,
keyValuePairsAddress: string,
parentAddress?: string,
parentTokenAddress?: string,
parentStrategyType?: VotingStrategyType,
Expand All @@ -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();
}
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/models/TxBuilderFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class TxBuilderFactory extends BaseTxBuilder {

private votesERC20WrapperMasterCopyAddress: string;
private votesERC20MasterCopyAddress: string;
private keyValuePairsAddress: string;

constructor(
signerOrProvider: ethers.Signer | any,
Expand All @@ -41,6 +42,7 @@ export class TxBuilderFactory extends BaseTxBuilder {
fallbackHandler: string,
votesERC20WrapperMasterCopyAddress: string,
votesERC20MasterCopyAddress: string,
keyValuePairsAddress: string,
parentAddress?: string,
parentTokenAddress?: string,
) {
Expand All @@ -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) {
Expand Down Expand Up @@ -96,6 +99,7 @@ export class TxBuilderFactory extends BaseTxBuilder {
this.createSafeTx!,
this.safeContract!,
this,
this.keyValuePairsAddress,
this.parentAddress,
this.parentTokenAddress,
parentStrategyType,
Expand Down
2 changes: 0 additions & 2 deletions src/types/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
MultisigFreezeGuard,
MultisigFreezeVoting,
ERC20FreezeVoting,
KeyValuePairs,
ERC721FreezeVoting,
} from '@fractal-framework/fractal-contracts';
import { MultiSend } from '../assets/typechain-types/usul';
Expand All @@ -32,5 +31,4 @@ export interface BaseContracts {
freezeERC721VotingMasterCopyContract: ERC721FreezeVoting;
freezeMultisigVotingMasterCopyContract: MultisigFreezeVoting;
zodiacModuleProxyFactoryContract: ModuleProxyFactory;
keyValuePairsContract: KeyValuePairs;
}

0 comments on commit 5771ef6

Please sign in to comment.