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 7, 2024
1 parent b90a766 commit 759e980
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
41 changes: 24 additions & 17 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 @@ -57,7 +55,7 @@ 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 votesTokenContract: GetContractReturnType<typeof VotesERC20Abi> | undefined;

Expand Down Expand Up @@ -166,15 +164,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 @@ -574,7 +584,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
}

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

Expand All @@ -584,10 +594,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
this.signerOrProvider,
);
if (daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC20) {
this.linearVotingContract = LinearERC20Voting__factory.connect(
this.predictedStrategyAddress!,
this.signerOrProvider,
);
this.linearERC20VotingAddress = this.predictedStrategyAddress;
this.votesTokenContract = getContract({
abi: VotesERC20Abi,
address: this.predictedTokenAddress,
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 759e980

Please sign in to comment.