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/cosmos/cosmos-sdk/client/context"
|
2019-09-18 18:45:21 +00:00
|
|
|
emintcrypto "github.com/cosmos/ethermint/crypto"
|
2019-07-15 14:13:59 +00:00
|
|
|
"github.com/ethereum/go-ethereum/rpc"
|
|
|
|
)
|
|
|
|
|
2020-04-02 00:43:59 +00:00
|
|
|
const Web3Namespace = "web3"
|
|
|
|
const EthNamespace = "eth"
|
|
|
|
const PersonalNamespace = "personal"
|
|
|
|
const NetNamespace = "net"
|
|
|
|
|
2019-07-15 14:13:59 +00:00
|
|
|
// GetRPCAPIs returns the list of all APIs
|
2019-09-18 18:45:21 +00:00
|
|
|
func GetRPCAPIs(cliCtx context.CLIContext, key 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)
|
2019-07-15 14:13:59 +00:00
|
|
|
return []rpc.API{
|
|
|
|
{
|
2020-04-02 00:43:59 +00:00
|
|
|
Namespace: Web3Namespace,
|
2019-07-15 14:13:59 +00:00
|
|
|
Version: "1.0",
|
|
|
|
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,
|
2019-07-15 14:13:59 +00:00
|
|
|
Version: "1.0",
|
2020-04-02 00:43:59 +00:00
|
|
|
Service: NewPublicEthAPI(cliCtx, backend, nonceLock, key),
|
2019-09-18 18:45:21 +00:00
|
|
|
Public: true,
|
|
|
|
},
|
|
|
|
{
|
2020-04-02 00:43:59 +00:00
|
|
|
Namespace: PersonalNamespace,
|
2019-09-18 18:45:21 +00:00
|
|
|
Version: "1.0",
|
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,
|
2019-10-08 03:32:28 +00:00
|
|
|
Version: "1.0",
|
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,
|
2019-10-15 01:20:35 +00:00
|
|
|
Version: "1.0",
|
|
|
|
Service: NewPublicNetAPI(cliCtx),
|
|
|
|
Public: true,
|
|
|
|
},
|
2019-07-15 14:13:59 +00:00
|
|
|
}
|
|
|
|
}
|