Skip to content

Commit

Permalink
Implements estimation for approve tally with execution
Browse files Browse the repository at this point in the history
  • Loading branch information
emmdim committed Jan 9, 2024
1 parent a241f2a commit b451db8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/js-client/src/internal/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export interface IGaslessVotingClientEstimation {
results: bigint[][]
): Promise<GasFeeEstimation>;
approve(proposalId: string): Promise<GasFeeEstimation>;
approveTally(proposalId: string, tryExecution: boolean): Promise<GasFeeEstimation>;
executeProposal(proposalId: string): Promise<GasFeeEstimation>;
// Add any estimation methods that you need
}
Expand Down
22 changes: 22 additions & 0 deletions packages/js-client/src/internal/modules/estimation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,28 @@ export class GaslessVotingClientEstimation
return this.web3.getApproximateGasFee(estimatedGasFee.toBigInt());
}

/**
* Estimates the gas fee of creating a proposal on the plugin
*
* @param {ApproveParams} params
* @return {*} {Promise<GasFeeEstimation>}
* @memberof GaslessVotingClientEstimation
*/
public async approveTally(proposalId: string, tryExecution=false): Promise<GasFeeEstimation> {
const signer = this.web3.getConnectedSigner();
const { pluginAddress, id } = decodeProposalId(proposalId);

const gaslessVotingContract = VocdoniVoting__factory.connect(
pluginAddress,
signer
);


const estimatedGasFee = await gaslessVotingContract.estimateGas.approveTally(id, tryExecution);

return this.web3.getApproximateGasFee(estimatedGasFee.toBigInt());
}

/**
* Estimates the gas fee of creating a proposal on the plugin
*
Expand Down

0 comments on commit b451db8

Please sign in to comment.