diff --git a/rpc/apis.go b/rpc/apis.go index da130ad0a1..e214368a71 100644 --- a/rpc/apis.go +++ b/rpc/apis.go @@ -24,9 +24,13 @@ import ( ethermint "github.com/evmos/ethermint/types" rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client" "github.com/zeta-chain/zetacore/rpc/backend" + "github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/debug" "github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/eth" "github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/eth/filters" + "github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/miner" "github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/net" + "github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/personal" + "github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/txpool" "github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/web3" ) @@ -105,66 +109,65 @@ func init() { }, } }, - // Disabled // NOTE: Public field of API is deprecated and defined only for compatibility. - //PersonalNamespace: func(ctx *server.Context, - // clientCtx client.Context, - // _ *rpcclient.WSClient, - // allowUnprotectedTxs bool, - // indexer ethermint.EVMTxIndexer, - //) []rpc.API { - // evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer) - // return []rpc.API{ - // { - // Namespace: PersonalNamespace, - // Version: apiVersion, - // Service: personal.NewAPI(ctx.Logger, evmBackend), - // Public: false, - // }, - // } - //}, - //TxPoolNamespace: func(ctx *server.Context, _ client.Context, _ *rpcclient.WSClient, _ bool, _ ethermint.EVMTxIndexer) []rpc.API { - // return []rpc.API{ - // { - // Namespace: TxPoolNamespace, - // Version: apiVersion, - // Service: txpool.NewPublicAPI(ctx.Logger), - // Public: true, - // }, - // } - //}, - //DebugNamespace: func(ctx *server.Context, - // clientCtx client.Context, - // _ *rpcclient.WSClient, - // allowUnprotectedTxs bool, - // indexer ethermint.EVMTxIndexer, - //) []rpc.API { - // evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer) - // return []rpc.API{ - // { - // Namespace: DebugNamespace, - // Version: apiVersion, - // Service: debug.NewAPI(ctx, evmBackend), - // Public: true, - // }, - // } - //}, - //MinerNamespace: func(ctx *server.Context, - // clientCtx client.Context, - // _ *rpcclient.WSClient, - // allowUnprotectedTxs bool, - // indexer ethermint.EVMTxIndexer, - //) []rpc.API { - // evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer) - // return []rpc.API{ - // { - // Namespace: MinerNamespace, - // Version: apiVersion, - // Service: miner.NewPrivateAPI(ctx, evmBackend), - // Public: false, - // }, - // } - //}, + PersonalNamespace: func(ctx *server.Context, + clientCtx client.Context, + _ *rpcclient.WSClient, + allowUnprotectedTxs bool, + indexer ethermint.EVMTxIndexer, + ) []rpc.API { + evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer) + return []rpc.API{ + { + Namespace: PersonalNamespace, + Version: apiVersion, + Service: personal.NewAPI(ctx.Logger, evmBackend), + Public: false, + }, + } + }, + TxPoolNamespace: func(ctx *server.Context, _ client.Context, _ *rpcclient.WSClient, _ bool, _ ethermint.EVMTxIndexer) []rpc.API { + return []rpc.API{ + { + Namespace: TxPoolNamespace, + Version: apiVersion, + Service: txpool.NewPublicAPI(ctx.Logger), + Public: true, + }, + } + }, + DebugNamespace: func(ctx *server.Context, + clientCtx client.Context, + _ *rpcclient.WSClient, + allowUnprotectedTxs bool, + indexer ethermint.EVMTxIndexer, + ) []rpc.API { + evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer) + return []rpc.API{ + { + Namespace: DebugNamespace, + Version: apiVersion, + Service: debug.NewAPI(ctx, evmBackend), + Public: true, + }, + } + }, + MinerNamespace: func(ctx *server.Context, + clientCtx client.Context, + _ *rpcclient.WSClient, + allowUnprotectedTxs bool, + indexer ethermint.EVMTxIndexer, + ) []rpc.API { + evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, indexer) + return []rpc.API{ + { + Namespace: MinerNamespace, + Version: apiVersion, + Service: miner.NewPrivateAPI(ctx, evmBackend), + Public: false, + }, + } + }, } } diff --git a/rpc/namespaces/ethereum/eth/api.go b/rpc/namespaces/ethereum/eth/api.go index 5200e26495..1de121c024 100644 --- a/rpc/namespaces/ethereum/eth/api.go +++ b/rpc/namespaces/ethereum/eth/api.go @@ -117,7 +117,7 @@ type EthereumAPI interface { // eth_submitWork (on Ethereum.org) // eth_submitHashrate (on Ethereum.org) - // Disabled APIs for security reasons + // Disabled //SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error) //Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error) //SignTypedData(address common.Address, typedData apitypes.TypedData) (hexutil.Bytes, error) @@ -507,9 +507,7 @@ func (e *PublicAPI) GetPendingTransactions() ([]*rpctypes.RPCTransaction, error) return result, nil } -/////////////////////////////////////////////////////////////////////////////// -/// Disabled /// -/////////////////////////////////////////////////////////////////////////////// +// Disabled //// SendTransaction sends an Ethereum transaction. //func (e *PublicAPI) SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error) {