2019-07-15 14:13:59 +00:00
|
|
|
// Package rpc contains RPC handler methods and utilities to start
|
|
|
|
// Ethermint's Web3-compatibly JSON-RPC server.
|
|
|
|
package rpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/rpc"
|
2020-10-06 18:57:55 +00:00
|
|
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/client/context"
|
|
|
|
|
|
|
|
"github.com/cosmos/ethermint/crypto/ethsecp256k1"
|
2019-07-15 14:13:59 +00:00
|
|
|
)
|
|
|
|
|
2020-07-03 15:40:00 +00:00
|
|
|
// RPC namespaces and API version
|
|
|
|
const (
|
|
|
|
Web3Namespace = "web3"
|
|
|
|
EthNamespace = "eth"
|
|
|
|
PersonalNamespace = "personal"
|
|
|
|
NetNamespace = "net"
|
|
|
|
|
|
|
|
apiVersion = "1.0"
|
|
|
|
)
|
2020-04-02 00:43:59 +00:00
|
|
|
|
2019-07-15 14:13:59 +00:00
|
|
|
// GetRPCAPIs returns the list of all APIs
|
2020-10-06 18:57:55 +00:00
|
|
|
func GetRPCAPIs(cliCtx context.CLIContext, keys []ethsecp256k1.PrivKey) []rpc.API {
|
2019-09-20 13:30:20 +00:00
|
|
|
nonceLock := new(AddrLocker)
|
2020-04-02 00:43:59 +00:00
|
|
|
backend := NewEthermintBackend(cliCtx)
|
2020-08-13 17:14:48 +00:00
|
|
|
ethAPI := NewPublicEthAPI(cliCtx, backend, nonceLock, keys)
|
2020-07-06 17:23:35 +00:00
|
|
|
|
2019-07-15 14:13:59 +00:00
|
|
|
return []rpc.API{
|
|
|
|
{
|
2020-04-02 00:43:59 +00:00
|
|
|
Namespace: Web3Namespace,
|
2020-07-03 15:40:00 +00:00
|
|
|
Version: apiVersion,
|
2019-07-15 14:13:59 +00:00
|
|
|
Service: NewPublicWeb3API(),
|
2019-09-18 18:45:21 +00:00
|
|
|
Public: true,
|
2019-07-15 14:13:59 +00:00
|
|
|
},
|
|
|
|
{
|
2020-04-02 00:43:59 +00:00
|
|
|
Namespace: EthNamespace,
|
2020-07-03 15:40:00 +00:00
|
|
|
Version: apiVersion,
|
2020-08-13 17:14:48 +00:00
|
|
|
Service: ethAPI,
|
2019-09-18 18:45:21 +00:00
|
|
|
Public: true,
|
|
|
|
},
|
|
|
|
{
|
2020-04-02 00:43:59 +00:00
|
|
|
Namespace: PersonalNamespace,
|
2020-07-03 15:40:00 +00:00
|
|
|
Version: apiVersion,
|
2020-09-30 00:34:01 +00:00
|
|
|
Service: NewPersonalEthAPI(ethAPI),
|
2019-09-18 18:45:21 +00:00
|
|
|
Public: false,
|
2019-07-15 14:13:59 +00:00
|
|
|
},
|
2019-10-08 03:32:28 +00:00
|
|
|
{
|
2020-04-02 00:43:59 +00:00
|
|
|
Namespace: EthNamespace,
|
2020-07-03 15:40:00 +00:00
|
|
|
Version: apiVersion,
|
2020-04-02 00:43:59 +00:00
|
|
|
Service: NewPublicFilterAPI(cliCtx, backend),
|
2019-10-08 03:32:28 +00:00
|
|
|
Public: true,
|
|
|
|
},
|
2019-10-15 01:20:35 +00:00
|
|
|
{
|
2020-04-02 00:43:59 +00:00
|
|
|
Namespace: NetNamespace,
|
2020-07-03 15:40:00 +00:00
|
|
|
Version: apiVersion,
|
2019-10-15 01:20:35 +00:00
|
|
|
Service: NewPublicNetAPI(cliCtx),
|
|
|
|
Public: true,
|
|
|
|
},
|
2019-07-15 14:13:59 +00:00
|
|
|
}
|
|
|
|
}
|