@@ -38,13 +38,18 @@ import {
3838} from '../../utils/transaction/assertRequest.js'
3939import {
4040 type PrepareTransactionRequestParameters ,
41+ type PrepareTransactionRequestParameterType ,
4142 prepareTransactionRequest ,
4243} from '../wallet/prepareTransactionRequest.js'
4344
4445export type EstimateGasParameters <
4546 chain extends Chain | undefined = Chain | undefined ,
4647> = UnionOmit < FormattedEstimateGas < chain > , 'from' > & {
4748 account ?: Account | Address | undefined
49+ prepare ?:
50+ | boolean
51+ | readonly PrepareTransactionRequestParameterType [ ]
52+ | undefined
4853 stateOverride ?: StateOverride | undefined
4954} & (
5055 | {
@@ -106,7 +111,7 @@ export async function estimateGas<
106111 client : Client < Transport , chain , account > ,
107112 args : EstimateGasParameters < chain > ,
108113) : Promise < EstimateGasReturnType > {
109- const { account : account_ = client . account } = args
114+ const { account : account_ = client . account , prepare = true } = args
110115 const account = account_ ? parseAccount ( account_ ) : undefined
111116
112117 try {
@@ -127,13 +132,16 @@ export async function estimateGas<
127132 value,
128133 stateOverride,
129134 ...rest
130- } = ( await prepareTransactionRequest ( client , {
131- ...args ,
132- parameters :
133- // Some RPC Providers do not compute versioned hashes from blobs. We will need
134- // to compute them.
135- account ?. type === 'local' ? undefined : [ 'blobVersionedHashes' ] ,
136- } as PrepareTransactionRequestParameters ) ) as EstimateGasParameters
135+ } = prepare
136+ ? ( ( await prepareTransactionRequest ( client , {
137+ ...args ,
138+ parameters :
139+ prepare ??
140+ // Some RPC Providers do not compute versioned hashes from blobs. We will need
141+ // to compute them.
142+ ( account ?. type === 'local' ? undefined : [ 'blobVersionedHashes' ] ) ,
143+ } as PrepareTransactionRequestParameters ) ) as EstimateGasParameters )
144+ : args
137145
138146 const blockNumberHex =
139147 typeof blockNumber === 'bigint' ? numberToHex ( blockNumber ) : undefined
0 commit comments