Skip to content

Commit

Permalink
Remove linearVotingERC721MasterCopyContract from FractalContracts, Az…
Browse files Browse the repository at this point in the history
…oriusContracts, useSafeContracts
  • Loading branch information
adamgall committed May 15, 2024
1 parent 9f7c09c commit 060a635
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 56 deletions.
13 changes: 3 additions & 10 deletions src/hooks/DAO/useBuildDAOTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import useSignerOrProvider from '../utils/useSignerOrProvider';
const useBuildDAOTx = () => {
const signerOrProvider = useSignerOrProvider();
const {
createOptions,
contracts: {
fallbackHandler,
votesERC20WrapperMasterCopy,
Expand All @@ -32,6 +31,7 @@ const useBuildDAOTx = () => {
claimingMasterCopy: erc20ClaimMasterCopy,
fractalModuleMasterCopy,
linearVotingMasterCopy: linearERC20VotingMasterCopy,
linearVotingERC721MasterCopy: linearERC721VotingMasterCopy,
},
} = useNetworkConfig();

Expand All @@ -55,7 +55,6 @@ const useBuildDAOTx = () => {
return;
}
const {
linearVotingERC721MasterCopyContract,
fractalAzoriusMasterCopyContract,
fractalModuleMasterCopyContract,
multisigFreezeGuardMasterCopyContract,
Expand All @@ -65,12 +64,6 @@ const useBuildDAOTx = () => {
freezeERC721VotingMasterCopyContract,
} = baseContracts;

if (
createOptions.includes(GovernanceType.AZORIUS_ERC721) &&
(!freezeERC721VotingMasterCopyContract || !linearVotingERC721MasterCopyContract)
) {
return;
}
if (
daoData.governance === GovernanceType.AZORIUS_ERC20 ||
daoData.governance === GovernanceType.AZORIUS_ERC721
Expand All @@ -81,7 +74,6 @@ const useBuildDAOTx = () => {

azoriusContracts = {
fractalAzoriusMasterCopyContract: fractalAzoriusMasterCopyContract.asSigner,
linearVotingERC721MasterCopyContract: linearVotingERC721MasterCopyContract.asSigner,
azoriusFreezeGuardMasterCopyContract: azoriusFreezeGuardMasterCopyContract.asSigner,
};
}
Expand Down Expand Up @@ -112,6 +104,7 @@ const useBuildDAOTx = () => {
erc20ClaimMasterCopy,
fractalModuleMasterCopy,
linearERC20VotingMasterCopy,
linearERC721VotingMasterCopy,
parentAddress,
parentTokenAddress,
);
Expand Down Expand Up @@ -157,7 +150,6 @@ const useBuildDAOTx = () => {
erc721LinearVotingContractAddress,
dao,
governance,
createOptions,
fallbackHandler,
votesERC20WrapperMasterCopy,
votesERC20MasterCopy,
Expand All @@ -170,6 +162,7 @@ const useBuildDAOTx = () => {
erc20ClaimMasterCopy,
fractalModuleMasterCopy,
linearERC20VotingMasterCopy,
linearERC721VotingMasterCopy,
],
);

Expand Down
5 changes: 3 additions & 2 deletions src/hooks/DAO/useDeployAzorius.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const useDeployAzorius = () => {
claimingMasterCopy: erc20ClaimMasterCopy,
fractalModuleMasterCopy,
linearVotingMasterCopy: linearERC20VotingMasterCopy,
linearVotingERC721MasterCopy: linearERC721VotingMasterCopy,
},
addressPrefix,
} = useNetworkConfig();
Expand All @@ -60,7 +61,6 @@ const useDeployAzorius = () => {
return;
}
const {
linearVotingERC721MasterCopyContract,
fractalAzoriusMasterCopyContract,
fractalModuleMasterCopyContract,
multisigFreezeGuardMasterCopyContract,
Expand All @@ -73,7 +73,6 @@ const useDeployAzorius = () => {

azoriusContracts = {
fractalAzoriusMasterCopyContract: fractalAzoriusMasterCopyContract.asProvider,
linearVotingERC721MasterCopyContract: linearVotingERC721MasterCopyContract.asProvider,
azoriusFreezeGuardMasterCopyContract: azoriusFreezeGuardMasterCopyContract.asProvider,
};

Expand Down Expand Up @@ -103,6 +102,7 @@ const useDeployAzorius = () => {
erc20ClaimMasterCopy,
fractalModuleMasterCopy,
linearERC20VotingMasterCopy,
linearERC721VotingMasterCopy,
undefined,
undefined,
);
Expand Down Expand Up @@ -173,6 +173,7 @@ const useDeployAzorius = () => {
erc20ClaimMasterCopy,
fractalModuleMasterCopy,
linearERC20VotingMasterCopy,
linearERC721VotingMasterCopy,
],
);

Expand Down
9 changes: 0 additions & 9 deletions src/hooks/safe/useSafeContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
MultisigFreezeGuard__factory,
MultisigFreezeVoting__factory,
Azorius__factory,
LinearERC721Voting__factory,
ERC721FreezeVoting__factory,
} from '@fractal-framework/fractal-contracts';
import { useMemo } from 'react';
Expand All @@ -26,7 +25,6 @@ export default function useSafeContracts() {
multisigFreezeVotingMasterCopy,
erc20FreezeVotingMasterCopy,
erc721FreezeVotingMasterCopy,
linearVotingERC721MasterCopy,
},
} = useNetworkConfig();

Expand All @@ -40,11 +38,6 @@ export default function useSafeContracts() {
asProvider: Azorius__factory.connect(fractalAzoriusMasterCopy, provider),
};

const linearVotingERC721MasterCopyContract = {
asSigner: LinearERC721Voting__factory.connect(linearVotingERC721MasterCopy, signerOrProvider),
asProvider: LinearERC721Voting__factory.connect(linearVotingERC721MasterCopy, provider),
};

const fractalModuleMasterCopyContract = {
asSigner: FractalModule__factory.connect(fractalModuleMasterCopy, signerOrProvider),
asProvider: FractalModule__factory.connect(fractalModuleMasterCopy, provider),
Expand Down Expand Up @@ -89,7 +82,6 @@ export default function useSafeContracts() {
freezeMultisigVotingMasterCopyContract,
freezeERC20VotingMasterCopyContract,
freezeERC721VotingMasterCopyContract,
linearVotingERC721MasterCopyContract,
};
}, [
fractalAzoriusMasterCopy,
Expand All @@ -98,7 +90,6 @@ export default function useSafeContracts() {
azoriusFreezeGuardMasterCopy,
multisigFreezeVotingMasterCopy,
erc20FreezeVotingMasterCopy,
linearVotingERC721MasterCopy,
erc721FreezeVotingMasterCopy,
signerOrProvider,
provider,
Expand Down
43 changes: 18 additions & 25 deletions src/models/AzoriusTxBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
Azorius,
Azorius__factory,
LinearERC721Voting,
LinearERC721Voting__factory,
} from '@fractal-framework/fractal-contracts';
import { Azorius, Azorius__factory } from '@fractal-framework/fractal-contracts';
import {
getCreate2Address,
Address,
Expand All @@ -22,11 +17,12 @@ import {
import ERC20ClaimAbi from '../assets/abi/ERC20Claim';
import GnosisSafeL2Abi from '../assets/abi/GnosisSafeL2';
import LinearERC20VotingAbi from '../assets/abi/LinearERC20Voting';
import LinearERC721VotingAbi from '../assets/abi/LinearERC721Voting';
import ModuleProxyFactoryAbi from '../assets/abi/ModuleProxyFactory';
import VotesERC20Abi from '../assets/abi/VotesERC20';
import VotesERC20WrapperAbi from '../assets/abi/VotesERC20Wrapper';
import { SENTINEL_ADDRESS } from '../constants/common';
import { buildContractCall, buildContractCallViem, getRandomBytes } from '../helpers';
import { buildContractCallViem, getRandomBytes } from '../helpers';
import {
BaseContracts,
SafeTransaction,
Expand Down Expand Up @@ -55,7 +51,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder {

public azoriusContract: Azorius | undefined;
public linearERC20VotingAddress: Address | undefined;
public linearERC721VotingContract: LinearERC721Voting | undefined;
public linearERC721VotingAddress: Address | undefined;
public votesTokenAddress: Address | undefined;

private votesERC20WrapperMasterCopyAddress: string;
Expand All @@ -64,6 +60,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
private multiSendCallOnlyAddress: Address;
private erc20ClaimMasterCopyAddress: Address;
private linearERC20VotingMasterCopyAddress: Address;
private linearERC721VotingMasterCopyAddress: Address;

private tokenNonce: bigint;
private strategyNonce: bigint;
Expand All @@ -83,6 +80,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
multiSendCallOnlyAddress: Address,
erc20ClaimMasterCopyAddress: Address,
linearERC20VotingMasterCopyAddress: Address,
linearERC721VotingMasterCopyAddress: Address,
parentAddress?: Address,
parentTokenAddress?: Address,
) {
Expand All @@ -109,6 +107,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
this.multiSendCallOnlyAddress = multiSendCallOnlyAddress;
this.erc20ClaimMasterCopyAddress = erc20ClaimMasterCopyAddress;
this.linearERC20VotingMasterCopyAddress = linearERC20VotingMasterCopyAddress;
this.linearERC721VotingMasterCopyAddress = linearERC721VotingMasterCopyAddress;

if (daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC20) {
daoData = daoData as AzoriusERC20DAO;
Expand Down Expand Up @@ -174,8 +173,9 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
false,
);
} else if (daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC721) {
return buildContractCall(
this.linearERC721VotingContract!,
return buildContractCallViem(
LinearERC721VotingAbi,
this.linearERC721VotingAddress!,
'setAzorius', // contract function name
[this.azoriusContract!.address],
0,
Expand Down Expand Up @@ -240,7 +240,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
[
daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC20
? this.linearERC20VotingMasterCopyAddress
: this.azoriusContracts!.linearVotingERC721MasterCopyContract.address,
: this.linearERC721VotingMasterCopyAddress,
this.encodedStrategySetupData,
this.strategyNonce,
],
Expand Down Expand Up @@ -512,18 +512,14 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
],
);

const encodedStrategySetupData =
this.azoriusContracts!.linearVotingERC721MasterCopyContract.interface.encodeFunctionData(
'setUp',
[encodedStrategyInitParams],
);

if (!isHex(encodedStrategySetupData)) {
throw new Error('Error encoding strategy setup data');
}
const encodedStrategySetupData = encodeFunctionData({
abi: LinearERC721VotingAbi,
functionName: 'setUp',
args: [encodedStrategyInitParams],
});

const strategyByteCodeLinear = generateContractByteCodeLinear(
getAddress(this.azoriusContracts!.linearVotingERC721MasterCopyContract.address),
this.linearERC721VotingMasterCopyAddress,
);

const strategySalt = keccak256(
Expand Down Expand Up @@ -596,10 +592,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
this.votesTokenAddress = this.predictedTokenAddress;
this.linearERC20VotingAddress = this.predictedStrategyAddress;
} else if (daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC721) {
this.linearERC721VotingContract = LinearERC721Voting__factory.connect(
this.predictedStrategyAddress!,
this.signerOrProvider,
);
this.linearERC721VotingAddress = this.predictedStrategyAddress;
}
}
}
3 changes: 1 addition & 2 deletions src/models/DaoTxBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ export class DaoTxBuilder extends BaseTxBuilder {
if (this.parentAddress) {
const freezeGuardTxBuilder = this.txBuilderFactory.createFreezeGuardTxBuilder(
azoriusTxBuilder.azoriusContract!.address,
azoriusTxBuilder.linearERC20VotingAddress ??
azoriusTxBuilder.linearERC721VotingContract?.address,
azoriusTxBuilder.linearERC20VotingAddress ?? azoriusTxBuilder.linearERC721VotingAddress,
this.parentStrategyType,
this.parentStrategyAddress,
);
Expand Down
4 changes: 4 additions & 0 deletions src/models/TxBuilderFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class TxBuilderFactory extends BaseTxBuilder {
private erc20ClaimMasterCopyAddress: string;
private fractalModuleMasterCopyAddress: string;
private linearERC20VotingMasterCopyAddress: string;
private linearERC721VotingMasterCopyAddress: string;

constructor(
signerOrProvider: ethers.Signer | any,
Expand All @@ -59,6 +60,7 @@ export class TxBuilderFactory extends BaseTxBuilder {
erc20ClaimMasterCopyAddress: string,
fractalModuleMasterCopyAddress: string,
linearERC20VotingMasterCopyAddress: string,
linearERC721VotingMasterCopyAddress: string,
parentAddress?: string,
parentTokenAddress?: string,
) {
Expand All @@ -85,6 +87,7 @@ export class TxBuilderFactory extends BaseTxBuilder {
this.erc20ClaimMasterCopyAddress = erc20ClaimMasterCopyAddress;
this.fractalModuleMasterCopyAddress = fractalModuleMasterCopyAddress;
this.linearERC20VotingMasterCopyAddress = linearERC20VotingMasterCopyAddress;
this.linearERC721VotingMasterCopyAddress = linearERC721VotingMasterCopyAddress;
}

public setSafeContract(safeAddress: Address) {
Expand Down Expand Up @@ -190,6 +193,7 @@ export class TxBuilderFactory extends BaseTxBuilder {
getAddress(this.multiSendCallOnlyAddress),
getAddress(this.erc20ClaimMasterCopyAddress),
getAddress(this.linearERC20VotingMasterCopyAddress),
getAddress(this.linearERC721VotingMasterCopyAddress),
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 @@ -6,7 +6,6 @@ import {
MultisigFreezeVoting,
MultisigFreezeGuard,
ERC721FreezeVoting,
LinearERC721Voting,
} from '@fractal-framework/fractal-contracts';
import {
SafeMultisigTransactionWithTransfersResponse,
Expand Down Expand Up @@ -318,7 +317,6 @@ export interface NodeHierarchy {

export interface FractalContracts {
fractalAzoriusMasterCopyContract: ContractConnection<Azorius>;
linearVotingERC721MasterCopyContract: ContractConnection<LinearERC721Voting>;
fractalModuleMasterCopyContract: ContractConnection<FractalModule>;
multisigFreezeGuardMasterCopyContract: ContractConnection<MultisigFreezeGuard>;
azoriusFreezeGuardMasterCopyContract: ContractConnection<AzoriusFreezeGuard>;
Expand Down
7 changes: 1 addition & 6 deletions src/types/strategyAzorius.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import {
Azorius,
AzoriusFreezeGuard,
LinearERC721Voting,
} from '@fractal-framework/fractal-contracts';
import { Azorius, AzoriusFreezeGuard } from '@fractal-framework/fractal-contracts';

export interface AzoriusContracts {
fractalAzoriusMasterCopyContract: Azorius;
linearVotingERC721MasterCopyContract: LinearERC721Voting;
azoriusFreezeGuardMasterCopyContract: AzoriusFreezeGuard;
}

0 comments on commit 060a635

Please sign in to comment.