diff --git a/packages/js-client/src/internal/interfaces.ts b/packages/js-client/src/internal/interfaces.ts index a67413bb..fd784021 100644 --- a/packages/js-client/src/internal/interfaces.ts +++ b/packages/js-client/src/internal/interfaces.ts @@ -64,8 +64,12 @@ export interface IOffchainVotingClientMethods { getMembers(pluginAddress: string): Promise; } export interface IOffchainVotingClientEstimation { - prepareInstallation( - params: PrepareInstallationParams + // prepareInstallation( + // params: PrepareInstallationParams + // ): Promise; + // createProposal + createProposal( + params: CreateGasslessProposalParams ): Promise; // Add any estimation methods that you need } diff --git a/packages/js-client/src/internal/modules/estimation.ts b/packages/js-client/src/internal/modules/estimation.ts index cc87e09c..aab172b6 100644 --- a/packages/js-client/src/internal/modules/estimation.ts +++ b/packages/js-client/src/internal/modules/estimation.ts @@ -1,11 +1,15 @@ +import { + CreateGasslessProposalParams, + GaslessProposalParametersContractStruct, +} from '../../types'; import { OffchainVotingClientCore } from '../core'; import { IOffchainVotingClientEstimation } from '../interfaces'; -import { PluginRepo__factory } from '@aragon/osx-ethers'; +import { GasFeeEstimation } from '@aragon/sdk-client-common'; import { - GasFeeEstimation, - prepareGenericInstallationEstimation, -} from '@aragon/sdk-client-common'; -import { SizeMismatchError, boolArrayToBitmap } from '@aragon/sdk-common'; + SizeMismatchError, + boolArrayToBitmap, + hexToBytes, +} from '@aragon/sdk-common'; import { VocdoniVoting__factory } from '@vocdoni/offchain-voting-ethers'; export class OffchainVotingClientEstimation @@ -15,16 +19,16 @@ export class OffchainVotingClientEstimation /** * Estimates the gas fee of creating a proposal on the plugin * - * @param {CreateMajorityVotingProposalParams} params + * @param {CreateGasslessProposalParams} params * @return {*} {Promise} - * @memberof TokenVotingClientEstimation + * @memberof OffchainVotingClientEstimation */ public async createProposal( - params: CreateMajorityVotingProposalParams + params: CreateGasslessProposalParams ): Promise { const signer = this.web3.getConnectedSigner(); - const tokenVotingContract = VocdoniVoting__factory.connect( + const gaslessVotingContract = VocdoniVoting__factory.connect( params.pluginAddress, signer ); @@ -37,9 +41,6 @@ export class OffchainVotingClientEstimation } const allowFailureMap = boolArrayToBitmap(params.failSafeActions); - const startTimestamp = params.startDate?.getTime() || 0; - const endTimestamp = params.endDate?.getTime() || 0; - const votingParams: GaslessProposalParametersContractStruct = { censusBlock: [] as string[], startDate: BigInt(params.startDate), @@ -47,25 +48,15 @@ export class OffchainVotingClientEstimation expirationDate: BigInt(0), securityBlock: BigInt(0), }; - const tx = await gaslessVotingContract.createProposal( - // toUtf8Bytes(params.metadataUri), - hexToBytes(params.vochainProposalId), - allowFailureMap, - votingParams, - params.actions || [] - // params.creatorVote || 0, - // params.executeOnPass || false, - ); - const estimatedGasFee = - await tokenVotingContract.estimateGas.createProposal( - toUtf8Bytes(params.metadataUri), - params.actions || [], + await gaslessVotingContract.estimateGas.createProposal( + // toUtf8Bytes(params.metadataUri), + hexToBytes(params.vochainProposalId), allowFailureMap, - Math.round(startTimestamp / 1000), - Math.round(endTimestamp / 1000), - params.creatorVote || 0, - params.executeOnPass || false + votingParams, + params.actions || [] + // params.creatorVote || 0, + // params.executeOnPass || false, ); return this.web3.getApproximateGasFee(estimatedGasFee.toBigInt()); } diff --git a/packages/js-client/src/internal/modules/methods.ts b/packages/js-client/src/internal/modules/methods.ts index 38d8951f..48baf374 100644 --- a/packages/js-client/src/internal/modules/methods.ts +++ b/packages/js-client/src/internal/modules/methods.ts @@ -42,7 +42,6 @@ import { hexToBytes, } from '@aragon/sdk-common'; import { isAddress } from '@ethersproject/address'; -import { BigNumber } from '@ethersproject/bignumber'; import { VocdoniVoting__factory } from '@vocdoni/offchain-voting-ethers'; import { EnvOptions, diff --git a/packages/js-client/src/internal/utils.ts b/packages/js-client/src/internal/utils.ts index 075ea533..fd8f3aeb 100644 --- a/packages/js-client/src/internal/utils.ts +++ b/packages/js-client/src/internal/utils.ts @@ -7,7 +7,6 @@ import { VoteOption, ProposalFromSC, GaslessProposalParametersStruct, - GaslessProposalParametersContractStruct, InvalidResults, GaslessVotingProposalFromSC, } from '../types';