-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove VotesERC20 from AzoriusTxBuilder #1645
Changes from all commits
9d402b3
1f0e490
3863404
b72f908
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ import { | |
bytesToBigInt, | ||
Hex, | ||
isHex, | ||
encodeFunctionData, | ||
Abi, | ||
} from 'viem'; | ||
import { ContractConnection } from '../types'; | ||
import { MetaTransaction, SafePostTransaction, SafeTransaction } from '../types/transaction'; | ||
|
@@ -161,20 +163,18 @@ export const buildSafeAPIPost = async ( | |
}; | ||
}; | ||
|
||
export const buildContractCall = ( | ||
contract: Contract, | ||
method: string, | ||
params: any[], | ||
const finishBuildingConractCall = ( | ||
data: Hex, | ||
nonce: number, | ||
contractAddress: Address, | ||
delegateCall?: boolean, | ||
overrides?: Partial<SafeTransaction>, | ||
): SafeTransaction => { | ||
const data = contract.interface.encodeFunctionData(method, params); | ||
) => { | ||
const operation: 0 | 1 = delegateCall ? 1 : 0; | ||
return buildSafeTransaction( | ||
Object.assign( | ||
{ | ||
to: contract.address, | ||
to: contractAddress, | ||
data, | ||
operation, | ||
nonce, | ||
|
@@ -184,6 +184,45 @@ export const buildContractCall = ( | |
); | ||
}; | ||
|
||
export const buildContractCall = ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this meant to go away at some point? Noticing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure is! |
||
contract: Contract, | ||
method: string, | ||
params: any[], | ||
nonce: number, | ||
delegateCall?: boolean, | ||
overrides?: Partial<SafeTransaction>, | ||
): SafeTransaction => { | ||
const data = contract.interface.encodeFunctionData(method, params); | ||
if (!isHex(data)) { | ||
throw new Error('encoded function data not hexadecimal'); | ||
} | ||
return finishBuildingConractCall( | ||
data, | ||
nonce, | ||
getAddress(contract.address), | ||
delegateCall, | ||
overrides, | ||
); | ||
}; | ||
|
||
export const buildContractCallViem = ( | ||
contractAbi: Abi, | ||
contractAddress: Address, | ||
method: string, | ||
params: any[], | ||
nonce: number, | ||
delegateCall?: boolean, | ||
overrides?: Partial<SafeTransaction>, | ||
): SafeTransaction => { | ||
const data = encodeFunctionData({ | ||
abi: contractAbi, | ||
functionName: method, | ||
args: params, | ||
}); | ||
|
||
return finishBuildingConractCall(data, nonce, contractAddress, delegateCall, overrides); | ||
}; | ||
|
||
const encodeMetaTransaction = (tx: MetaTransaction): string => { | ||
const txDataBytes = toBytes(tx.data); | ||
const txDataHex = toHex(txDataBytes); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,6 @@ import { | |
LinearERC20Voting__factory, | ||
LinearERC721Voting, | ||
LinearERC721Voting__factory, | ||
VotesERC20, | ||
VotesERC20__factory, | ||
} from '@fractal-framework/fractal-contracts'; | ||
import { | ||
getCreate2Address, | ||
|
@@ -20,12 +18,13 @@ import { | |
isAddress, | ||
isHex, | ||
encodeFunctionData, | ||
PublicClient, | ||
} 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'; | ||
import { buildContractCall, getRandomBytes } from '../helpers'; | ||
import { buildContractCall, buildContractCallViem, getRandomBytes } from '../helpers'; | ||
import { | ||
BaseContracts, | ||
SafeTransaction, | ||
|
@@ -55,7 +54,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { | |
public azoriusContract: Azorius | undefined; | ||
public linearVotingContract: LinearERC20Voting | undefined; | ||
public linearERC721VotingContract: LinearERC721Voting | undefined; | ||
public votesTokenContract: VotesERC20 | undefined; | ||
public votesTokenContractAddress: Address | undefined; | ||
|
||
private votesERC20WrapperMasterCopyAddress: string; | ||
private votesERC20MasterCopyAddress: string; | ||
|
@@ -67,6 +66,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { | |
|
||
constructor( | ||
signerOrProvider: any, | ||
publicClient: PublicClient, | ||
baseContracts: BaseContracts, | ||
azoriusContracts: AzoriusContracts, | ||
daoData: AzoriusERC20DAO | AzoriusERC721DAO, | ||
|
@@ -78,6 +78,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { | |
) { | ||
super( | ||
signerOrProvider, | ||
publicClient, | ||
baseContracts, | ||
azoriusContracts, | ||
daoData, | ||
|
@@ -245,9 +246,14 @@ export class AzoriusTxBuilder extends BaseTxBuilder { | |
} | ||
|
||
public buildApproveClaimAllocation() { | ||
if (!this.votesTokenContractAddress) { | ||
return; | ||
} | ||
|
||
const azoriusGovernanceDaoData = this.daoData as AzoriusERC20DAO; | ||
return buildContractCall( | ||
this.votesTokenContract!, | ||
return buildContractCallViem( | ||
VotesERC20Abi, | ||
this.votesTokenContractAddress, | ||
'approve', | ||
[this.predictedTokenClaimAddress, azoriusGovernanceDaoData.parentAllocationAmount], | ||
0, | ||
|
@@ -547,6 +553,10 @@ export class AzoriusTxBuilder extends BaseTxBuilder { | |
} | ||
|
||
private setContracts() { | ||
if (!this.predictedTokenAddress) { | ||
return; | ||
} | ||
Comment on lines
+556
to
+558
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this defined when existing token is used for DAO Creation? Ie set to the existing token's address There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TBH not sure. I assumed (perhaps incorrectly?) that this check here was safe, because if you look at the old code on line 561, we were forcing the value to be valid ( I could just put that I suppose I should go and manually test this out, huh There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the case when a user brings their own token to new Azorius DAO creation, |
||
|
||
const daoData = this.daoData as AzoriusGovernanceDAO; | ||
this.azoriusContract = Azorius__factory.connect( | ||
this.predictedAzoriusAddress!, | ||
|
@@ -557,10 +567,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder { | |
this.predictedStrategyAddress!, | ||
this.signerOrProvider, | ||
); | ||
this.votesTokenContract = VotesERC20__factory.connect( | ||
this.predictedTokenAddress!, | ||
this.signerOrProvider, | ||
); | ||
this.votesTokenContractAddress = this.predictedTokenAddress; | ||
} else if (daoData.votingStrategyType === VotingStrategyType.LINEAR_ERC721) { | ||
this.linearERC721VotingContract = LinearERC721Voting__factory.connect( | ||
this.predictedStrategyAddress!, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo:
finishBuildingConractCall
->finishBuildingContractCall
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gah. i almost just want to leave it as is for now, because fixing this will cause me to need to rebase all of the branches above this one 😅
i plan on consolidating this back into one function anyway, once the the ethers-style function can be removed. I'll deal with it then.