Skip to content

Commit

Permalink
Merge pull request #1643 from decentdao/remove-votestokenmastercopyco…
Browse files Browse the repository at this point in the history
…ntract-from-interfaces

Remove votesTokenMasterCopyContract from interfaces
  • Loading branch information
adamgall committed May 8, 2024
1 parent ade5f50 commit a34c2cf
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 32 deletions.
7 changes: 3 additions & 4 deletions src/hooks/DAO/useBuildDAOTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const useBuildDAOTx = () => {
const signerOrProvider = useSignerOrProvider();
const {
createOptions,
contracts: { fallbackHandler, votesERC20WrapperMasterCopy },
contracts: { fallbackHandler, votesERC20WrapperMasterCopy, votesERC20MasterCopy },
} = useNetworkConfig();

const {
Expand Down Expand Up @@ -54,7 +54,6 @@ const useBuildDAOTx = () => {
freezeMultisigVotingMasterCopyContract,
freezeERC20VotingMasterCopyContract,
freezeERC721VotingMasterCopyContract,
votesTokenMasterCopyContract,
claimingMasterCopyContract,
keyValuePairsContract,
} = baseContracts;
Expand All @@ -72,7 +71,6 @@ const useBuildDAOTx = () => {
if (
!fractalAzoriusMasterCopyContract ||
!linearVotingMasterCopyContract ||
!votesTokenMasterCopyContract ||
!azoriusFreezeGuardMasterCopyContract ||
!claimingMasterCopyContract
) {
Expand All @@ -84,7 +82,6 @@ const useBuildDAOTx = () => {
linearVotingMasterCopyContract: linearVotingMasterCopyContract.asSigner,
linearVotingERC721MasterCopyContract: linearVotingERC721MasterCopyContract.asSigner,
azoriusFreezeGuardMasterCopyContract: azoriusFreezeGuardMasterCopyContract.asSigner,
votesTokenMasterCopyContract: votesTokenMasterCopyContract.asSigner,
claimingMasterCopyContract: claimingMasterCopyContract.asSigner,
};
}
Expand All @@ -110,6 +107,7 @@ const useBuildDAOTx = () => {
daoData,
fallbackHandler,
votesERC20WrapperMasterCopy,
votesERC20MasterCopy,
parentAddress,
parentTokenAddress,
);
Expand Down Expand Up @@ -157,6 +155,7 @@ const useBuildDAOTx = () => {
createOptions,
fallbackHandler,
votesERC20WrapperMasterCopy,
votesERC20MasterCopy,
],
);

Expand Down
6 changes: 3 additions & 3 deletions src/hooks/DAO/useDeployAzorius.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const useDeployAzorius = () => {
const signerOrProvider = useSignerOrProvider();
const navigate = useNavigate();
const {
contracts: { fallbackHandler, votesERC20WrapperMasterCopy },
contracts: { fallbackHandler, votesERC20WrapperMasterCopy, votesERC20MasterCopy },
addressPrefix,
} = useNetworkConfig();
const {
Expand Down Expand Up @@ -54,7 +54,6 @@ const useDeployAzorius = () => {
azoriusFreezeGuardMasterCopyContract,
freezeMultisigVotingMasterCopyContract,
freezeERC20VotingMasterCopyContract,
votesTokenMasterCopyContract,
claimingMasterCopyContract,
keyValuePairsContract,
} = baseContracts;
Expand All @@ -64,7 +63,6 @@ const useDeployAzorius = () => {
fractalAzoriusMasterCopyContract: fractalAzoriusMasterCopyContract.asProvider,
linearVotingMasterCopyContract: linearVotingMasterCopyContract.asProvider,
azoriusFreezeGuardMasterCopyContract: azoriusFreezeGuardMasterCopyContract.asProvider,
votesTokenMasterCopyContract: votesTokenMasterCopyContract.asProvider,
claimingMasterCopyContract: claimingMasterCopyContract.asProvider,
} as AzoriusContracts;

Expand All @@ -88,6 +86,7 @@ const useDeployAzorius = () => {
daoData,
fallbackHandler,
votesERC20WrapperMasterCopy,
votesERC20MasterCopy,
undefined,
undefined,
);
Expand Down Expand Up @@ -146,6 +145,7 @@ const useDeployAzorius = () => {
fallbackHandler,
addressPrefix,
votesERC20WrapperMasterCopy,
votesERC20MasterCopy,
],
);

Expand Down
25 changes: 11 additions & 14 deletions src/models/AzoriusTxBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
isHex,
encodeFunctionData,
} from 'viem';
import VotesERC20Abi from '../assets/abi/VotesERC20';
import VotesERC20WrapperAbi from '../assets/abi/VotesERC20Wrapper';
import { GnosisSafeL2 } from '../assets/typechain-types/usul/@gnosis.pm/safe-contracts/contracts';
import { SENTINEL_ADDRESS } from '../constants/common';
Expand Down Expand Up @@ -57,6 +58,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
public votesTokenContract: VotesERC20 | undefined;

private votesERC20WrapperMasterCopyAddress: string;
private votesERC20MasterCopyAddress: string;

private tokenNonce: bigint;
private strategyNonce: bigint;
Expand All @@ -70,6 +72,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
daoData: AzoriusERC20DAO | AzoriusERC721DAO,
safeContract: GnosisSafeL2,
votesERC20WrapperMasterCopyAddress: string,
votesERC20MasterCopyAddress: string,
parentAddress?: Address,
parentTokenAddress?: Address,
) {
Expand All @@ -90,6 +93,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
this.azoriusNonce = getRandomBytes();

this.votesERC20WrapperMasterCopyAddress = votesERC20WrapperMasterCopyAddress;
this.votesERC20MasterCopyAddress = votesERC20MasterCopyAddress;

if (daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC20) {
daoData = daoData as AzoriusERC20DAO;
Expand Down Expand Up @@ -188,11 +192,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
return buildContractCall(
this.baseContracts.zodiacModuleProxyFactoryContract,
'deployModule',
[
this.azoriusContracts!.votesTokenMasterCopyContract.address,
this.encodedSetupTokenData,
this.tokenNonce,
],
[this.votesERC20MasterCopyAddress, this.encodedSetupTokenData, this.tokenNonce],
0,
false,
);
Expand Down Expand Up @@ -346,19 +346,16 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
],
);

const encodedSetupTokenData =
this.azoriusContracts!.votesTokenMasterCopyContract.interface.encodeFunctionData('setUp', [
encodedInitTokenData,
]);
if (!isHex(encodedSetupTokenData)) {
throw new Error('Error encoding setup token data');
}
this.encodedSetupTokenData = encodedSetupTokenData;
this.encodedSetupTokenData = encodeFunctionData({
abi: VotesERC20Abi,
functionName: 'setUp',
args: [encodedInitTokenData],
});
}

private setPredictedTokenAddress() {
const tokenByteCodeLinear = generateContractByteCodeLinear(
getAddress(this.azoriusContracts!.votesTokenMasterCopyContract.address),
getAddress(this.votesERC20MasterCopyAddress),
);

const tokenSalt = generateSalt(this.encodedSetupTokenData!, this.tokenNonce);
Expand Down
4 changes: 4 additions & 0 deletions src/models/TxBuilderFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class TxBuilderFactory extends BaseTxBuilder {
public fallbackHandler: string;

private votesERC20WrapperMasterCopyAddress: string;
private votesERC20MasterCopyAddress: string;

constructor(
signerOrProvider: ethers.Signer | any,
Expand All @@ -38,6 +39,7 @@ export class TxBuilderFactory extends BaseTxBuilder {
daoData: SafeMultisigDAO | AzoriusERC20DAO | AzoriusERC721DAO | SubDAO,
fallbackHandler: string,
votesERC20WrapperMasterCopyAddress: string,
votesERC20MasterCopyAddress: string,
parentAddress?: string,
parentTokenAddress?: string,
) {
Expand All @@ -53,6 +55,7 @@ export class TxBuilderFactory extends BaseTxBuilder {
this.fallbackHandler = fallbackHandler;
this.saltNum = getRandomBytes();
this.votesERC20WrapperMasterCopyAddress = votesERC20WrapperMasterCopyAddress;
this.votesERC20MasterCopyAddress = votesERC20MasterCopyAddress;
}

public setSafeContract(safeAddress: string) {
Expand Down Expand Up @@ -135,6 +138,7 @@ export class TxBuilderFactory extends BaseTxBuilder {
this.daoData as AzoriusERC20DAO,
this.safeContract!,
this.votesERC20WrapperMasterCopyAddress,
this.votesERC20MasterCopyAddress,
this.parentAddress ? getAddress(this.parentAddress) : undefined,
this.parentTokenAddress ? getAddress(this.parentTokenAddress) : undefined,
);
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 @@ -46,7 +46,7 @@ export const baseConfig: NetworkConfig = {
fractalAzoriusMasterCopy: Azorius.address,
fractalModuleMasterCopy: FractalModule.address,
fractalRegistry: FractalRegistry.address,
votesERC20MasterCopy: VotesERC20.address,
votesERC20MasterCopy: getAddress(VotesERC20.address),
linearVotingERC721MasterCopy: LinearVotingERC721.address,
claimingMasterCopy: ERC20Claim.address,
azoriusFreezeGuardMasterCopy: AzoriusFreezeGuard.address,
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 @@ -46,7 +46,7 @@ export const baseSepoliaConfig: NetworkConfig = {
fractalAzoriusMasterCopy: Azorius.address,
fractalModuleMasterCopy: FractalModule.address,
fractalRegistry: FractalRegistry.address,
votesERC20MasterCopy: VotesERC20.address,
votesERC20MasterCopy: getAddress(VotesERC20.address),
linearVotingERC721MasterCopy: LinearVotingERC721.address,
claimingMasterCopy: ERC20Claim.address,
azoriusFreezeGuardMasterCopy: AzoriusFreezeGuard.address,
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 @@ -46,7 +46,7 @@ export const mainnetConfig: NetworkConfig = {
fractalAzoriusMasterCopy: Azorius.address,
fractalModuleMasterCopy: FractalModule.address,
fractalRegistry: FractalRegistry.address,
votesERC20MasterCopy: VotesERC20.address,
votesERC20MasterCopy: getAddress(VotesERC20.address),
linearVotingERC721MasterCopy: '', // TODO - Add actual address once contract is deployed on mainnet
claimingMasterCopy: ERC20Claim.address,
azoriusFreezeGuardMasterCopy: AzoriusFreezeGuard.address,
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 @@ -46,7 +46,7 @@ export const optimismConfig: NetworkConfig = {
fractalAzoriusMasterCopy: Azorius.address,
fractalModuleMasterCopy: FractalModule.address,
fractalRegistry: FractalRegistry.address,
votesERC20MasterCopy: VotesERC20.address,
votesERC20MasterCopy: getAddress(VotesERC20.address),
linearVotingERC721MasterCopy: LinearVotingERC721.address,
claimingMasterCopy: ERC20Claim.address,
azoriusFreezeGuardMasterCopy: AzoriusFreezeGuard.address,
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 @@ -46,7 +46,7 @@ export const polygonConfig: NetworkConfig = {
fractalAzoriusMasterCopy: Azorius.address,
fractalModuleMasterCopy: FractalModule.address,
fractalRegistry: FractalRegistry.address,
votesERC20MasterCopy: VotesERC20.address,
votesERC20MasterCopy: getAddress(VotesERC20.address),
linearVotingERC721MasterCopy: '', // TODO - Add actual address once contract is deployed on polygon
claimingMasterCopy: ERC20Claim.address,
azoriusFreezeGuardMasterCopy: AzoriusFreezeGuard.address,
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 @@ -46,7 +46,7 @@ export const sepoliaConfig: NetworkConfig = {
fractalAzoriusMasterCopy: Azorius.address,
fractalModuleMasterCopy: FractalModule.address,
fractalRegistry: FractalRegistry.address,
votesERC20MasterCopy: VotesERC20.address,
votesERC20MasterCopy: getAddress(VotesERC20.address),
linearVotingERC721MasterCopy: LinearVotingERC721.address,
claimingMasterCopy: ERC20Claim.address,
azoriusFreezeGuardMasterCopy: AzoriusFreezeGuard.address,
Expand Down
2 changes: 0 additions & 2 deletions src/types/fractal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
ERC20Claim,
ERC20FreezeVoting,
MultisigFreezeVoting,
VotesERC20,
MultisigFreezeGuard,
KeyValuePairs,
ERC721FreezeVoting,
Expand Down Expand Up @@ -347,7 +346,6 @@ export interface FractalContracts {
freezeMultisigVotingMasterCopyContract: ContractConnection<MultisigFreezeVoting>;
freezeERC20VotingMasterCopyContract: ContractConnection<ERC20FreezeVoting>;
freezeERC721VotingMasterCopyContract: ContractConnection<ERC721FreezeVoting>;
votesTokenMasterCopyContract: ContractConnection<VotesERC20>;
claimingMasterCopyContract: ContractConnection<ERC20Claim>;
keyValuePairsContract: ContractConnection<KeyValuePairs>;
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type NetworkConfig = {
fractalAzoriusMasterCopy: string;
fractalModuleMasterCopy: string;
fractalRegistry: string;
votesERC20MasterCopy: string;
votesERC20MasterCopy: Address;
linearVotingERC721MasterCopy: string;
claimingMasterCopy: string;
multisigFreezeGuardMasterCopy: string;
Expand Down
2 changes: 0 additions & 2 deletions src/types/strategyAzorius.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
Azorius,
LinearERC20Voting,
AzoriusFreezeGuard,
VotesERC20,
ERC20Claim,
LinearERC721Voting,
} from '@fractal-framework/fractal-contracts';
Expand All @@ -12,6 +11,5 @@ export interface AzoriusContracts {
linearVotingMasterCopyContract: LinearERC20Voting;
linearVotingERC721MasterCopyContract: LinearERC721Voting;
azoriusFreezeGuardMasterCopyContract: AzoriusFreezeGuard;
votesTokenMasterCopyContract: VotesERC20;
claimingMasterCopyContract: ERC20Claim;
}

0 comments on commit a34c2cf

Please sign in to comment.