laconicd/server/rpc/apis.go

46 lines
1.1 KiB
Go
Raw Normal View History

2018-08-09 10:36:47 +00:00
// Package rpc contains RPC handler methods and utilities to start
// Ethermint's Web3-compatibly JSON-RPC server.
package rpc
import (
2018-08-09 10:36:47 +00:00
"github.com/cosmos/ethermint/version"
2018-08-09 10:36:47 +00:00
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rpc"
)
// returns the master list of public APIs for use with StartHTTPEndpoint
func GetRPCAPIs() []rpc.API {
return []rpc.API{
{
Namespace: "web3",
Version: "1.0",
Service: NewPublicWeb3API(),
},
2018-08-09 10:36:47 +00:00
{
Namespace: "eth",
Version: "1.0",
Service: NewPublicEthAPI(),
},
2018-08-09 10:36:47 +00:00
}
}
2018-08-09 10:36:47 +00:00
// PublicWeb3API is the web3_ prefixed set of APIs in the Web3 JSON-RPC spec.
2018-08-09 10:36:47 +00:00
type PublicWeb3API struct {
}
2018-08-09 10:36:47 +00:00
// NewPublicWeb3API creates an instance of the Web3 API.
2018-08-09 10:36:47 +00:00
func NewPublicWeb3API() *PublicWeb3API {
return &PublicWeb3API{}
}
// ClientVersion returns the client version in the Web3 user agent format.
func (a *PublicWeb3API) ClientVersion() string {
return version.ClientVersion()
}
// Sha3 returns the keccak-256 hash of the passed-in input.
func (a *PublicWeb3API) Sha3(input hexutil.Bytes) hexutil.Bytes {
return crypto.Keccak256(input)
}