Skip to content

Commit

Permalink
Merge pull request #1650 from decentdao/remove-keyValuePairsContract-…
Browse files Browse the repository at this point in the history
…from-BaseContracts

Remove key value pairs contract from base contracts
  • Loading branch information
adamgall authored May 7, 2024
2 parents a50f6d7 + ff9339f commit 84a6e2e
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 17 deletions.
52 changes: 52 additions & 0 deletions src/assets/abi/KeyValuePairs.ts
Original file line number Diff line number Diff line change
@@ -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;
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: 1 addition & 1 deletion src/providers/NetworkConfig/networks/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
2 changes: 1 addition & 1 deletion src/providers/NetworkConfig/networks/baseSepolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
2 changes: 1 addition & 1 deletion src/providers/NetworkConfig/networks/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion src/providers/NetworkConfig/networks/optimism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
2 changes: 1 addition & 1 deletion src/providers/NetworkConfig/networks/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion src/providers/NetworkConfig/networks/sepolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
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;
}
2 changes: 1 addition & 1 deletion src/types/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export type NetworkConfig = {
erc20FreezeVotingMasterCopy: string;
erc721FreezeVotingMasterCopy: string;
votesERC20WrapperMasterCopy: Address;
keyValuePairs: string;
keyValuePairs: Address;
};
staking: {
lido?: {
Expand Down

0 comments on commit 84a6e2e

Please sign in to comment.