Skip to content

Commit d1f95d5

Browse files
MariusVanDerWijdenunclezoro
authored andcommitted
internal/ethapi: fix nil deref + fix estimateGas console bindings (ethereum#21601)
* tried to fix * fix for js api * fix for nil pointer ex * rev space * rev space * input call formatter
1 parent ad3ff64 commit d1f95d5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

internal/ethapi/api.go

+3
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,9 @@ func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash
900900
if err != nil {
901901
return 0, err
902902
}
903+
if block == nil {
904+
return 0, errors.New("block not found")
905+
}
903906
hi = block.GasLimit()
904907
}
905908
// Recap the highest gas limit with account's available balance.

internal/web3ext/web3ext.go

+7
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,13 @@ web3._extend({
493493
params: 1,
494494
inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
495495
}),
496+
new web3._extend.Method({
497+
name: 'estimateGas',
498+
call: 'eth_estimateGas',
499+
params: 2,
500+
inputFormatter: [web3._extend.formatters.inputCallFormatter, web3._extend.formatters.inputBlockNumberFormatter],
501+
outputFormatter: web3._extend.utils.toDecimal
502+
}),
496503
new web3._extend.Method({
497504
name: 'submitTransaction',
498505
call: 'eth_submitTransaction',

0 commit comments

Comments
 (0)