diff --git a/baseapp/abci.go b/baseapp/abci.go index b8c48adc66..4124d6a38a 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -38,12 +38,18 @@ const ( // Supported EVM json-rpc requests const ( - EthBlockNumber = "eth_blockNumber" - EthGetBlockByNumber = "eth_getBlockByNumber" - EthGetBalance = "eth_getBalance" - EthChainID = "eth_chainId" - NetVersion = "net_version" - EthNetworkID = "eth_networkId" + EthBlockNumber = "eth_blockNumber" + EthGetBlockByNumber = "eth_getBlockByNumber" + EthGetBalance = "eth_getBalance" + EthChainID = "eth_chainId" + NetVersion = "net_version" + EthNetworkID = "eth_networkId" + EthGasPrice = "eth_gasPrice" + EthGetCode = "eth_getCode" + EthEstimateGas = "eth_estimateGas" + EthCall = "eth_call" + EthGetTransactionCount = "eth_getTransactionCount" + EthSendRawTransaction = "eth_sendRawTransaction" ) // InitChain implements the ABCI interface. It runs the initialization logic diff --git a/baseapp/ethrouter.go b/baseapp/ethrouter.go index 37abbf7cbb..35c3228cf4 100644 --- a/baseapp/ethrouter.go +++ b/baseapp/ethrouter.go @@ -64,6 +64,12 @@ func (e *EthQueryRouter) RegisterConstHandler() { e.AddRoute(EthNetworkID, chainIdHandler) e.AddRoute(EthChainID, chainIdHandler) e.AddRoute(NetVersion, chainIdHandler) + e.AddRoute(EthGasPrice, gasPriceHandler) + e.AddRoute(EthGetCode, chainIdHandler) // return dummy result + e.AddRoute(EthEstimateGas, estimateGasHandler) // return dummy result + e.AddRoute(EthCall, chainIdHandler) // return dummy result + e.AddRoute(EthGetTransactionCount, getTransactionCountHandler) // return dummy result + e.AddRoute(EthSendRawTransaction, chainIdHandler) // return dummy result } func blockNumberHandler(ctx sdk.Context, req cmtrpctypes.RPCRequest) (abci.ResponseEthQuery, error) { @@ -72,6 +78,24 @@ func blockNumberHandler(ctx sdk.Context, req cmtrpctypes.RPCRequest) (abci.Respo return res, nil } +func gasPriceHandler(ctx sdk.Context, req cmtrpctypes.RPCRequest) (abci.ResponseEthQuery, error) { + var res abci.ResponseEthQuery + res.Response = big.NewInt(5e9).Bytes() + return res, nil +} + +func estimateGasHandler(ctx sdk.Context, req cmtrpctypes.RPCRequest) (abci.ResponseEthQuery, error) { + var res abci.ResponseEthQuery + res.Response = big.NewInt(21000).Bytes() + return res, nil +} + +func getTransactionCountHandler(ctx sdk.Context, req cmtrpctypes.RPCRequest) (abci.ResponseEthQuery, error) { + var res abci.ResponseEthQuery + res.Response = big.NewInt(1).Bytes() + return res, nil +} + func chainIdHandler(ctx sdk.Context, req cmtrpctypes.RPCRequest) (abci.ResponseEthQuery, error) { var res abci.ResponseEthQuery eip155ChainID, err := sdk.ParseChainID(ctx.ChainID()) diff --git a/go.mod b/go.mod index aa80dac225..bdb857990d 100644 --- a/go.mod +++ b/go.mod @@ -170,7 +170,7 @@ replace ( github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 github.com/btcsuite/btcd => github.com/btcsuite/btcd v0.23.0 - github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.3 + github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.0-20231030090949-99ef7dbd1e62 github.com/cometbft/cometbft-db => github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1 github.com/cosmos/iavl => github.com/bnb-chain/greenfield-iavl v0.20.1 diff --git a/go.sum b/go.sum index 6933a0f068..0204cd5903 100644 --- a/go.sum +++ b/go.sum @@ -228,8 +228,8 @@ github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsy github.com/bkielbasa/cyclop v1.2.0/go.mod h1:qOI0yy6A7dYC4Zgsa72Ppm9kONl0RoIlPbzot9mhmeI= github.com/blizzy78/varnamelen v0.8.0/go.mod h1:V9TzQZ4fLJ1DSrjVDfl89H7aMnTvKkApdHeyESmyR7k= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= -github.com/bnb-chain/greenfield-cometbft v0.0.3 h1:tv8NMy3bzX/1urqXGQIIAZSLy83loiI+dG0VKeyh1CY= -github.com/bnb-chain/greenfield-cometbft v0.0.3/go.mod h1:f35mk/r5ab6yvzlqEWZt68LfUje68sYgMpVlt2CUYMk= +github.com/bnb-chain/greenfield-cometbft v0.0.0-20231030090949-99ef7dbd1e62 h1:pakuREXV/XfWNwgsTXUQwYirem12Tt+2LGGHIar0z8o= +github.com/bnb-chain/greenfield-cometbft v0.0.0-20231030090949-99ef7dbd1e62/go.mod h1:43yICrTxu90VjEUpQN23bsqi9mua5m5sFQq/ekHwN9s= github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1 h1:XcWulGacHVRiSCx90Q8Y//ajOrLNBQWR/KDB89dy3cU= github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1/go.mod h1:ey1CiK4bYo1RBNJLRiVbYr5CMdSxci9S/AZRINLtppI= github.com/bnb-chain/greenfield-iavl v0.20.1 h1:y3L64GU99otNp27/xLVBTDbv4eroR6CzoYz0rbaVotM=