diff --git a/.changeset/fuzzy-onions-destroy.md b/.changeset/fuzzy-onions-destroy.md new file mode 100644 index 000000000..8c76f049a --- /dev/null +++ b/.changeset/fuzzy-onions-destroy.md @@ -0,0 +1,5 @@ +--- +"@snapshot-labs/sx": patch +--- + +overestimate fee when using nonce in StarknetTx client diff --git a/packages/sx.js/src/clients/starknet/starknet-tx/index.ts b/packages/sx.js/src/clients/starknet/starknet-tx/index.ts index c674b8191..a8d617dec 100644 --- a/packages/sx.js/src/clients/starknet/starknet-tx/index.ts +++ b/packages/sx.js/src/clients/starknet/starknet-tx/index.ts @@ -1,4 +1,4 @@ -import { Account, CallData, shortString, uint256, hash } from 'starknet'; +import { stark, Account, CallData, shortString, uint256, hash } from 'starknet'; import { ContractFactory } from '@ethersproject/contracts'; import { Signer } from '@ethersproject/abstract-signer'; import { poseidonHashMany } from 'micro-starknet'; @@ -204,7 +204,8 @@ export class StarknetTx { const calls = [call]; const fee = opts?.nonce ? await account.estimateFee(calls) : null; - return account.execute(calls, undefined, fee ? { maxFee: fee.suggestedMaxFee } : undefined); + const maxFee = fee ? stark.estimatedFeeToMaxFee(fee.suggestedMaxFee, 1.5) : undefined; + return account.execute(calls, undefined, fee ? { maxFee } : undefined); } async updateProposal(account: Account, envelope: Envelope, opts?: Opts) { @@ -226,7 +227,8 @@ export class StarknetTx { }); const fee = opts?.nonce ? await account.estimateFee(call) : null; - return account.execute(call, undefined, fee ? { maxFee: fee.suggestedMaxFee } : undefined); + const maxFee = fee ? stark.estimatedFeeToMaxFee(fee.suggestedMaxFee, 1.5) : undefined; + return account.execute(call, undefined, fee ? { maxFee } : undefined); } async vote(account: Account, envelope: Envelope, opts?: Opts) { @@ -254,7 +256,8 @@ export class StarknetTx { }); const fee = opts?.nonce ? await account.estimateFee(call) : null; - return account.execute(call, undefined, fee ? { maxFee: fee.suggestedMaxFee } : undefined); + const maxFee = fee ? stark.estimatedFeeToMaxFee(fee.suggestedMaxFee, 1.5) : undefined; + return account.execute(call, undefined, fee ? { maxFee } : undefined); } execute({