Skip to content

Commit

Permalink
Remove one more reference to LinearERC20Voting typechain
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgall committed May 14, 2024
1 parent 98ee06f commit 543aa26
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
49 changes: 28 additions & 21 deletions src/models/AzoriusTxBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
Azorius,
Azorius__factory,
LinearERC20Voting,
LinearERC20Voting__factory,
LinearERC721Voting,
LinearERC721Voting__factory,
} from '@fractal-framework/fractal-contracts';
Expand Down Expand Up @@ -55,9 +53,9 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
private predictedTokenClaimAddress: Address | undefined;

public azoriusContract: Azorius | undefined;
public linearVotingContract: LinearERC20Voting | undefined;
public linearERC20VotingAddress: Address | undefined;
public linearERC721VotingContract: LinearERC721Voting | undefined;
public votesTokenContractAddress: Address | undefined;
public votesTokenAddress: Address | undefined;

private votesERC20WrapperMasterCopyAddress: string;
private votesERC20MasterCopyAddress: string;
Expand Down Expand Up @@ -164,15 +162,27 @@ export class AzoriusTxBuilder extends BaseTxBuilder {

public buildVotingContractSetupTx(): SafeTransaction {
const daoData = this.daoData as AzoriusGovernanceDAO;
return buildContractCall(
daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC20
? this.linearVotingContract!
: this.linearERC721VotingContract!,
'setAzorius', // contract function name
[this.azoriusContract!.address],
0,
false,
);

if (daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC20) {
return buildContractCallViem(
LinearERC20VotingAbi,
this.linearERC20VotingAddress!,
'setAzorius', // contract function name
[this.azoriusContract!.address],
0,
false,
);
} else if (daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC721) {
return buildContractCall(
this.linearERC721VotingContract!,
'setAzorius', // contract function name
[this.azoriusContract!.address],
0,
false,
);
} else {
throw new Error('voting strategy type unknown');
}
}

public buildEnableAzoriusModuleTx(): SafeTransaction {
Expand Down Expand Up @@ -265,14 +275,14 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
}

public buildApproveClaimAllocation() {
if (!this.votesTokenContractAddress) {
if (!this.votesTokenAddress) {
return;
}

const azoriusGovernanceDaoData = this.daoData as AzoriusERC20DAO;
return buildContractCallViem(
VotesERC20Abi,
this.votesTokenContractAddress,
this.votesTokenAddress,
'approve',
[this.predictedTokenClaimAddress, azoriusGovernanceDaoData.parentAllocationAmount],
0,
Expand Down Expand Up @@ -572,7 +582,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
}

private setContracts() {
if (!this.predictedTokenAddress) {
if (!this.predictedTokenAddress || !this.predictedStrategyAddress) {
return;
}

Expand All @@ -582,11 +592,8 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
this.signerOrProvider,
);
if (daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC20) {
this.linearVotingContract = LinearERC20Voting__factory.connect(
this.predictedStrategyAddress!,
this.signerOrProvider,
);
this.votesTokenContractAddress = this.predictedTokenAddress;
this.votesTokenAddress = this.predictedTokenAddress;
this.linearERC20VotingAddress = this.predictedStrategyAddress;
} else if (daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC721) {
this.linearERC721VotingContract = LinearERC721Voting__factory.connect(
this.predictedStrategyAddress!,
Expand Down
2 changes: 1 addition & 1 deletion src/models/DaoTxBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class DaoTxBuilder extends BaseTxBuilder {
if (this.parentAddress) {
const freezeGuardTxBuilder = this.txBuilderFactory.createFreezeGuardTxBuilder(
azoriusTxBuilder.azoriusContract!.address,
azoriusTxBuilder.linearVotingContract?.address ??
azoriusTxBuilder.linearERC20VotingAddress ??
azoriusTxBuilder.linearERC721VotingContract?.address,
this.parentStrategyType,
this.parentStrategyAddress,
Expand Down

0 comments on commit 543aa26

Please sign in to comment.