laconicd/ethereum/rpc/apis.go

62 lines
1.4 KiB
Go
Raw Normal View History

2021-04-18 16:39:15 +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"
"github.com/cosmos/ethermint/ethereum/rpc/types"
"github.com/ethereum/go-ethereum/rpc"
2021-04-19 10:49:55 +00:00
2021-04-18 16:39:15 +00:00
rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
)
// RPC namespaces and API version
const (
Web3Namespace = "web3"
EthNamespace = "eth"
PersonalNamespace = "personal"
NetNamespace = "net"
apiVersion = "1.0"
)
// GetRPCAPIs returns the list of all APIs
func GetRPCAPIs(clientCtx client.Context, tmWSClient *rpcclient.WSClient) []rpc.API {
nonceLock := new(types.AddrLocker)
backend := NewEVMBackend(clientCtx)
ethAPI := NewPublicEthAPI(clientCtx, backend, nonceLock)
return []rpc.API{
{
Namespace: Web3Namespace,
Version: apiVersion,
Service: NewPublicWeb3API(),
Public: true,
},
{
Namespace: EthNamespace,
Version: apiVersion,
Service: ethAPI,
Public: true,
},
{
Namespace: EthNamespace,
Version: apiVersion,
Service: NewPublicFilterAPI(tmWSClient, backend),
Public: true,
},
{
Namespace: NetNamespace,
Version: apiVersion,
Service: NewPublicNetAPI(clientCtx),
Public: true,
},
{
Namespace: PersonalNamespace,
Version: apiVersion,
Service: NewPersonalAPI(ethAPI),
Public: true,
},
2021-04-18 16:39:15 +00:00
}
}