Skip to content

Commit

Permalink
Remove votesTokenMasterCopyContract from AzoriusContracts interface a…
Browse files Browse the repository at this point in the history
…nd FractalContracts interface, fix all typescript issues
  • Loading branch information
adamgall committed May 6, 2024
1 parent 047f3c7 commit e00e034
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 25 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: 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: 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 e00e034

Please sign in to comment.