Skip to content

Commit 09bd020

Browse files
authored
add params to estimateGas api (#3304)
* add params to estimateGas api * fix UT
1 parent 580a0d9 commit 09bd020

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

app/rpc/namespaces/eth/api.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ func (api *PublicEthereumAPI) simDoCall(args rpctypes.CallArgs, cap uint64) (uin
11461146
}
11471147

11481148
// EstimateGas returns an estimate of gas usage for the given smart contract call.
1149-
func (api *PublicEthereumAPI) EstimateGas(args rpctypes.CallArgs) (hexutil.Uint64, error) {
1149+
func (api *PublicEthereumAPI) EstimateGas(args rpctypes.CallArgs, blockNrOrHash rpctypes.BlockNumberOrHash) (hexutil.Uint64, error) {
11501150
monitor := monitor.GetMonitor("eth_estimateGas", api.logger, api.Metrics).OnBegin()
11511151
defer monitor.OnEnd("args", args)
11521152
rateLimiter := api.GetRateLimiter("eth_estimateGas")
@@ -1715,7 +1715,7 @@ func (api *PublicEthereumAPI) generateFromArgs(args rpctypes.SendTxArgs) (*evmty
17151715
Value: args.Value,
17161716
Data: &input,
17171717
}
1718-
gl, err := api.EstimateGas(callArgs)
1718+
gl, err := api.EstimateGas(callArgs, rpctypes.BlockNumberOrHash{})
17191719
if err != nil {
17201720
return nil, err
17211721
}

app/rpc/tests/rpc_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ func (suite *RPCTestSuite) TestEth_EstimateGas_WithoutArgs() {
913913
}
914914

915915
func (suite *RPCTestSuite) TestEth_EstimateGas_Transfer() {
916-
param := make([]map[string]string, 1)
916+
param := make([]map[string]string, 2)
917917
param[0] = make(map[string]string)
918918
param[0]["from"] = senderAddr.Hex()
919919
param[0]["to"] = "0x1122334455667788990011223344556677889900"
@@ -933,7 +933,7 @@ func (suite *RPCTestSuite) TestEth_EstimateGas_Transfer() {
933933
func (suite *RPCTestSuite) TestEth_EstimateGas_ContractDeployment() {
934934
bytecode := "0x608060405234801561001057600080fd5b5060117f775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd73889860405160405180910390a260d08061004d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063eb8ac92114602d575b600080fd5b606060048036036040811015604157600080fd5b8101908080359060200190929190803590602001909291905050506062565b005b8160008190555080827ff3ca124a697ba07e8c5e80bebcfcc48991fc16a63170e8a9206e30508960d00360405160405180910390a3505056fea265627a7a723158201d94d2187aaf3a6790527b615fcc40970febf0385fa6d72a2344848ebd0df3e964736f6c63430005110032"
935935

936-
param := make([]map[string]string, 1)
936+
param := make([]map[string]string, 2)
937937
param[0] = make(map[string]string)
938938
param[0]["from"] = senderAddr.Hex()
939939
param[0]["data"] = bytecode

0 commit comments

Comments
 (0)