File tree 1 file changed +11
-6
lines changed
packages/abstract-provider/src.ts
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -227,17 +227,22 @@ export abstract class Provider implements OnceBlockable {
227
227
abstract getGasPrice ( ) : Promise < BigNumber > ;
228
228
async getFeeData ( ) : Promise < FeeData > {
229
229
const { block, gasPrice } = await resolveProperties ( {
230
- block : this . getBlock ( - 1 ) ,
231
- gasPrice : this . getGasPrice ( )
230
+ block : this . getBlock ( "latest" ) ,
231
+ gasPrice : this . getGasPrice ( ) . catch ( ( error ) => {
232
+ // @TODO : Why is this now failing on Calaveras?
233
+ //console.log(error);
234
+ return null ;
235
+ } )
232
236
} ) ;
233
237
234
238
let maxFeePerGas = null , maxPriorityFeePerGas = null ;
235
239
236
240
if ( block && block . baseFee ) {
237
- maxFeePerGas = block . baseFee . mul ( 2 ) ;
238
- //maxPriorityFeePerGas = BigNumber.from("1000000000");
239
- // @TODO : This needs to come from somewhere.
240
- maxPriorityFeePerGas = BigNumber . from ( "1" ) ;
241
+ // We may want to compute this more accurately in the future,
242
+ // using the formula "check if the base fee is correct".
243
+ // See: https://eips.ethereum.org/EIPS/eip-1559
244
+ maxPriorityFeePerGas = BigNumber . from ( "1000000000" ) ;
245
+ maxFeePerGas = block . baseFee . mul ( 2 ) . add ( maxPriorityFeePerGas ) ;
241
246
}
242
247
243
248
return { maxFeePerGas, maxPriorityFeePerGas, gasPrice } ;
You can’t perform that action at this time.
0 commit comments