@@ -24,6 +24,7 @@ import {
2424 InvokeFunctionResponse ,
2525 KeyPair ,
2626 MultiDeployContractResponse ,
27+ Sequencer ,
2728 Signature ,
2829 UniversalDeployerContractPayload ,
2930} from '../types' ;
@@ -498,4 +499,36 @@ export class Account extends Provider implements AccountInterface {
498499
499500 return feeEstimate . suggestedMaxFee . toString ( ) ;
500501 }
502+
503+ public async simulateTransaction (
504+ calls : AllowArray < Call > ,
505+ { nonce : providedNonce , blockIdentifier } : EstimateFeeDetails = { }
506+ ) : Promise < Sequencer . TransactionSimulationResponse > {
507+ const transactions = Array . isArray ( calls ) ? calls : [ calls ] ;
508+ const nonce = toBN ( providedNonce ?? ( await this . getNonce ( ) ) ) ;
509+ const version = toBN ( feeTransactionVersion ) ;
510+ const chainId = await this . getChainId ( ) ;
511+
512+ const signerDetails : InvocationsSignerDetails = {
513+ walletAddress : this . address ,
514+ nonce,
515+ maxFee : ZERO ,
516+ version,
517+ chainId,
518+ } ;
519+
520+ const signature = await this . signer . signTransaction ( transactions , signerDetails ) ;
521+
522+ const calldata = fromCallsToExecuteCalldata ( transactions ) ;
523+ const response : any = await super . getSimulateTransaction (
524+ { contractAddress : this . address , calldata, signature } ,
525+ { version, nonce } ,
526+ blockIdentifier
527+ ) ;
528+
529+ const suggestedMaxFee = estimatedFeeToMaxFee ( response . fee_estimation . overall_fee ) ;
530+ response . fee_estimation . suggestedMaxFee = suggestedMaxFee ;
531+
532+ return response ;
533+ }
501534}
0 commit comments