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 (
|
2020-07-02 15:19:48 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/client/context"
|
2020-07-06 17:03:34 +00:00
|
|
|
emintcrypto "github.com/cosmos/ethermint/crypto"
|
2019-07-15 14:13:59 +00:00
|
|
|
"github.com/ethereum/go-ethereum/rpc"
|
|
|
|
)
|
|
|
|
|
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-07-06 17:03:34 +00:00
|
|
|
func GetRPCAPIs(cliCtx context.CLIContext, keys []emintcrypto.PrivKeySecp256k1) []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-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-07-06 17:03:34 +00:00
|
|
|
Service: NewPublicEthAPI(cliCtx, backend, nonceLock, keys),
|
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,
|
2019-09-20 13:30:20 +00:00
|
|
|
Service: NewPersonalEthAPI(cliCtx, nonceLock),
|
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
|
|
|
}
|
|
|
|
}
|