@@ -8,14 +8,14 @@ import {
88 Abi ,
99 AddTransactionResponse ,
1010 Call ,
11- EstimateFeeResponse ,
1211 InvocationsDetails ,
1312 InvocationsSignerDetails ,
1413 InvokeFunctionTransaction ,
1514 KeyPair ,
1615 Signature ,
1716 Transaction ,
1817} from '../types' ;
18+ import { EstimateFee } from '../types/account' ;
1919import { sign } from '../utils/ellipticCurve' ;
2020import {
2121 computeHashOnElements ,
@@ -60,7 +60,7 @@ export class Account extends Provider implements AccountInterface {
6060 nonce : providedNonce ,
6161 blockIdentifier = 'pending' ,
6262 } : { nonce ?: BigNumberish ; blockIdentifier ?: BlockIdentifier } = { }
63- ) : Promise < EstimateFeeResponse > {
63+ ) : Promise < EstimateFee > {
6464 const transactions = Array . isArray ( calls ) ? calls : [ calls ] ;
6565 const nonce = providedNonce ?? ( await this . getNonce ( ) ) ;
6666 const version = toBN ( feeTransactionVersion ) ;
@@ -76,7 +76,7 @@ export class Account extends Provider implements AccountInterface {
7676 const signature = await this . signer . signTransaction ( transactions , signerDetails ) ;
7777
7878 const calldata = fromCallsToExecuteCalldataWithNonce ( transactions , nonce ) ;
79- return this . fetchEndpoint (
79+ const fetchedEstimate = await this . fetchEndpoint (
8080 'estimate_fee' ,
8181 { blockIdentifier } ,
8282 {
@@ -87,14 +87,22 @@ export class Account extends Provider implements AccountInterface {
8787 signature : bigNumberishArrayToDecimalStringArray ( signature ) ,
8888 }
8989 ) ;
90+ const suggestedMaxFee = estimatedFeeToMaxFee ( fetchedEstimate . amount ) ;
91+
92+ return {
93+ ...fetchedEstimate ,
94+ suggestedMaxFee,
95+ } ;
9096 }
9197
9298 /**
9399 * Invoke execute function in account contract
94100 *
95101 * [Reference](https://github.com/starkware-libs/cairo-lang/blob/f464ec4797361b6be8989e36e02ec690e74ef285/src/starkware/starknet/services/api/gateway/gateway_client.py#L13-L17)
96102 *
97- * @param transaction - transaction to be invoked
103+ * @param calls - one or more calls to be executed
104+ * @param abis - one or more abis which can be used to display the calls
105+ * @param transactionsDetail - optional transaction details
98106 * @returns a confirmation of invoking a function on the starknet contract
99107 */
100108 public async execute (
@@ -108,8 +116,8 @@ export class Account extends Provider implements AccountInterface {
108116 if ( transactionsDetail . maxFee || transactionsDetail . maxFee === 0 ) {
109117 maxFee = transactionsDetail . maxFee ;
110118 } else {
111- const estimatedFee = ( await this . estimateFee ( transactions , { nonce } ) ) . amount ;
112- maxFee = estimatedFeeToMaxFee ( estimatedFee ) . toString ( ) ;
119+ const { suggestedMaxFee } = await this . estimateFee ( transactions , { nonce } ) ;
120+ maxFee = suggestedMaxFee . toString ( ) ;
113121 }
114122
115123 const signerDetails : InvocationsSignerDetails = {
0 commit comments