@@ -932,7 +932,11 @@ export abstract class BaseProvider extends AbstractProvider {
932932    transaction : Deferrable < TransactionRequest > , 
933933    blockTag ?: BlockTag  |  Promise < BlockTag > 
934934  ) : Promise < BigNumber >  =>  { 
935-     const  {  usedGas,  gasLimit,  usedStorage }  =  await  this . estimateResources ( transaction ,  blockTag ) ; 
935+     const  blockHash  =  blockTag  &&  blockTag  !==  'latest' 
936+       ? await  this . _getBlockHash ( blockTag ) 
937+       : undefined ;   // if blockTag is latest, avoid explicit blockhash for better performance 
938+ 
939+     const  {  usedGas,  gasLimit,  usedStorage }  =  await  this . estimateResources ( transaction ,  blockHash ) ; 
936940
937941    const  tx  =  await  resolveProperties ( transaction ) ; 
938942    const  data  =  tx . data ?. toString ( )  ??  '0x' ; 
@@ -968,9 +972,13 @@ export abstract class BaseProvider extends AbstractProvider {
968972    return  encodeGasLimit ( txFee ,  gasPrice ,  gasLimit ,  usedStorage ,  isTokenTransfer ) ; 
969973  } ; 
970974
971-   _estimateGasCost  =  async  ( extrinsic : SubmittableExtrinsic < 'promise' ,  ISubmittableResult > )  =>  { 
975+   _estimateGasCost  =  async  ( 
976+     extrinsic : SubmittableExtrinsic < 'promise' ,  ISubmittableResult > , 
977+     at ?: string , 
978+   )  =>  { 
979+     const  apiAt  =  await  this . api . at ( at  ??  await  this . bestBlockHash ) ; 
980+ 
972981    const  u8a  =  extrinsic . toU8a ( ) ; 
973-     const  apiAt  =  await  this . api . at ( await  this . bestBlockHash ) ; 
974982    const  lenIncreaseAfterSignature  =  100 ;     // approximate length increase after signature 
975983    const  feeDetails  =  await  apiAt . call . transactionPaymentApi . queryFeeDetails ( 
976984      u8a , 
@@ -1102,7 +1110,7 @@ export abstract class BaseProvider extends AbstractProvider {
11021110   */ 
11031111  estimateResources  =  async  ( 
11041112    transaction : Deferrable < TransactionRequest > , 
1105-     blockTag ?: BlockTag   |   Promise < BlockTag > , 
1113+     blockHash ?: string , 
11061114  ) : Promise < { 
11071115    usedGas : BigNumber ; 
11081116    gasLimit : BigNumber ; 
@@ -1120,10 +1128,6 @@ export abstract class BaseProvider extends AbstractProvider {
11201128      storageLimit : STORAGE_LIMIT , 
11211129    } ; 
11221130
1123-     const  blockHash  =  blockTag  &&  blockTag  !==  'latest' 
1124-       ? await  this . _getBlockHash ( blockTag ) 
1125-       : undefined ;   // if blockTag is latest, avoid explicit blockhash for better performance 
1126- 
11271131    const  gasInfo  =  await  this . _ethCall ( txRequest ,  blockHash ) ; 
11281132    const  usedGas  =  BigNumber . from ( gasInfo . used_gas ) . toNumber ( ) ; 
11291133    const  usedStorage  =  gasInfo . used_storage ; 
0 commit comments