Skip to content

Commit c154442

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

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎internal/ethapi/api.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,9 @@ func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash
963963
if err != nil {
964964
return 0, err
965965
}
966+
if block == nil {
967+
return 0, errors.New("block not found")
968+
}
966969
hi = block.GasLimit()
967970
}
968971
// Recap the highest gas limit with account's available balance.

‎internal/web3ext/web3ext.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,13 @@ web3._extend({
500500
params: 1,
501501
inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
502502
}),
503+
new web3._extend.Method({
504+
name: 'estimateGas',
505+
call: 'eth_estimateGas',
506+
params: 2,
507+
inputFormatter: [web3._extend.formatters.inputCallFormatter, web3._extend.formatters.inputBlockNumberFormatter],
508+
outputFormatter: web3._extend.utils.toDecimal
509+
}),
503510
new web3._extend.Method({
504511
name: 'submitTransaction',
505512
call: 'eth_submitTransaction',

0 commit comments

Comments
 (0)