nimbus-eth1/fluffy/rpc/rpc_eth_api.nim

100 lines
3.6 KiB
Nim
Raw Normal View History

# Nimbus
# Copyright (c) 2021 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
{.push raises: [Defect].}
import
2021-07-07 12:13:27 +00:00
json_rpc/rpcproxy
# Subset of Eth JSON-RPC API: https://eth.wiki/json-rpc/API
# Supported subset will eventually be found here:
# https://github.com/ethereum/stateless-ethereum-specs/blob/master/portal-network.md#json-rpc-api
#
# In order to already support these calls before every part of the Portal
# Network is up, one plan is to get the data directly from an external client
# through RPC calls. Practically just playing a proxy to that client.
# Can be done by just forwarding the rpc call, or by adding a call here, but
# that would introduce a unnecessary serializing/deserializing step.
2021-08-05 06:14:25 +00:00
proc installEthApiHandlers*(rpcServerWithProxy: var RpcProxy)
{.raises: [Defect, CatchableError].} =
# Supported API
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_blockNumber")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_call")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_chainId")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_estimateGas")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_feeHistory")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getBalance")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getBlockByHash")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getBlockByNumber")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getBlockTransactionCountByHash")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getBlockTransactionCountByNumber")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getCode")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getRawTransactionByHash")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getRawTransactionByBlockHashAndIndex")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getRawTransactionByBlockNumberAndIndex")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getStorageAt")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getTransactionByBlockHashAndIndex")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getTransactionByBlockNumberAndIndex")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getTransactionByHash")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getTransactionCount")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getTransactionReceipt")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getUncleByBlockHashAndIndex")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getUncleByBlockNumberAndIndex")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getUncleCountByBlockHash")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getUncleCountByBlockNumber")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getProof")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_sendRawTransaction")
# Optional API
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_gasPrice")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getFilterChanges")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getFilterLogs")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_getLogs")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_newBlockFilter")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_newFilter")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_newPendingTransactionFilter")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_pendingTransactions")
2021-07-07 12:13:27 +00:00
rpcServerWithProxy.registerProxyMethod("eth_syncing")
2021-08-05 06:14:25 +00:00
rpcServerWithProxy.registerProxyMethod("eth_uninstallFilter")