rpc

package
v0.0.0-...-9687111 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2020 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Overview

Package rpc contains RPC handler methods and utilities to start Ethermint's Web3-compatibly JSON-RPC server.

Index

Constants

View Source
const (
	// LatestBlockNumber mapping from "latest" to 0 for tm query
	LatestBlockNumber = BlockNumber(0)

	// EarliestBlockNumber mapping from "earliest" to 1 for tm query (earliest query not supported)
	EarliestBlockNumber = BlockNumber(1)
)

Variables

This section is empty.

Functions

func EmintServeCmd

func EmintServeCmd(cdc *codec.Codec) *cobra.Command

EmintServeCmd creates a CLI command to start Cosmos LCD server with web3 RPC API and Cosmos rest-server endpoints

func GetRPCAPIs

func GetRPCAPIs(cliCtx context.CLIContext, key emintcrypto.PrivKeySecp256k1) []rpc.API

GetRPCAPIs returns the list of all APIs

Types

type AccountResult

type AccountResult struct {
	Address      common.Address  `json:"address"`
	AccountProof []string        `json:"accountProof"`
	Balance      *hexutil.Big    `json:"balance"`
	CodeHash     common.Hash     `json:"codeHash"`
	Nonce        hexutil.Uint64  `json:"nonce"`
	StorageHash  common.Hash     `json:"storageHash"`
	StorageProof []StorageResult `json:"storageProof"`
}

AccountResult struct for account proof

type AddrLocker

type AddrLocker struct {
	// contains filtered or unexported fields
}

AddrLocker is a mutex structure used to avoid querying outdated account data

func (*AddrLocker) LockAddr

func (l *AddrLocker) LockAddr(address common.Address)

LockAddr locks an account's mutex. This is used to prevent another tx getting the same nonce until the lock is released. The mutex prevents the (an identical nonce) from being read again during the time that the first transaction is being signed.

func (*AddrLocker) UnlockAddr

func (l *AddrLocker) UnlockAddr(address common.Address)

UnlockAddr unlocks the mutex of the given account.

type BlockNumber

type BlockNumber int64

BlockNumber represents decoding hex string to block values

func (BlockNumber) Int64

func (bn BlockNumber) Int64() int64

Int64 converts block number to primitive type

func (*BlockNumber) UnmarshalJSON

func (bn *BlockNumber) UnmarshalJSON(data []byte) error

UnmarshalJSON parses the given JSON fragment into a BlockNumber. It supports: - "latest", "earliest" or "pending" as string arguments - the block number Returned errors: - an invalid block number error when the given argument isn't a known strings - an out of range error when the given block number is either too little or too large

type CallArgs

type CallArgs struct {
	From     *common.Address `json:"from"`
	To       *common.Address `json:"to"`
	Gas      *hexutil.Uint64 `json:"gas"`
	GasPrice *hexutil.Big    `json:"gasPrice"`
	Value    *hexutil.Big    `json:"value"`
	Data     *hexutil.Bytes  `json:"data"`
}

CallArgs represents the arguments for a call.

type Config

type Config struct {
	// EnableRPC defines whether or not to enable the RPC server
	EnableRPC bool
	// RPCAddr defines the IP address to listen on
	RPCAddr string
	// RPCPort defines the port to listen on
	RPCPort int
	// RPCCORSDomains defines list of domains to enable CORS headers for (used by browsers)
	RPCCORSDomains []string
	// RPCVhosts defines list of domains to listen on (useful if Tendermint is addressable via DNS)
	RPCVHosts []string
}

Config contains configuration fields that determine the behavior of the RPC HTTP server. TODO: These may become irrelevant if HTTP config is handled by the SDK

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter can be used to retrieve and filter logs.

func NewBlockFilter

func NewBlockFilter(block common.Hash, addresses []common.Address, topics [][]common.Hash) *Filter

NewBlockFilter creates a new filter which directly inspects the contents of a block to figure out whether it is interesting or not.

type PersonalEthAPI

type PersonalEthAPI struct {
	// contains filtered or unexported fields
}

PersonalEthAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec.

func NewPersonalEthAPI

func NewPersonalEthAPI(cliCtx sdkcontext.CLIContext, nonceLock *AddrLocker) *PersonalEthAPI

NewPersonalEthAPI creates an instance of the public ETH Web3 API.

func (*PersonalEthAPI) Sign

func (e *PersonalEthAPI) Sign(ctx context.Context, data hexutil.Bytes, addr common.Address, passwd string) (hexutil.Bytes, error)

Sign calculates an Ethereum ECDSA signature for: keccack256("\x19Ethereum Signed Message:\n" + len(message) + message))

Note, the produced signature conforms to the secp256k1 curve R, S and V values, where the V value will be 27 or 28 for legacy reasons.

The key used to calculate the signature is decrypted with the given password.

https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign

type PublicEthAPI

type PublicEthAPI struct {
	// contains filtered or unexported fields
}

PublicEthAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec.

func NewPublicEthAPI

func NewPublicEthAPI(cliCtx context.CLIContext, nonceLock *AddrLocker,
	key emintcrypto.PrivKeySecp256k1) *PublicEthAPI

NewPublicEthAPI creates an instance of the public ETH Web3 API.

func (*PublicEthAPI) Accounts

func (e *PublicEthAPI) Accounts() ([]common.Address, error)

Accounts returns the list of accounts available to this node.

func (*PublicEthAPI) BlockNumber

func (e *PublicEthAPI) BlockNumber() (hexutil.Uint64, error)

BlockNumber returns the current block number.

func (*PublicEthAPI) Coinbase

func (e *PublicEthAPI) Coinbase() (addr common.Address)

Coinbase returns this node's coinbase address. Not used in Ethermint.

func (*PublicEthAPI) EstimateGas

func (e *PublicEthAPI) EstimateGas(args CallArgs) (hexutil.Uint64, error)

EstimateGas estimates gas usage for the given smart contract call.

func (*PublicEthAPI) GasPrice

func (e *PublicEthAPI) GasPrice() *hexutil.Big

GasPrice returns the current gas price based on Ethermint's gas price oracle.

func (*PublicEthAPI) GetBalance

func (e *PublicEthAPI) GetBalance(address common.Address, blockNum BlockNumber) (*hexutil.Big, error)

GetBalance returns the provided account's balance up to the provided block number.

func (*PublicEthAPI) GetBlockByHash

func (e *PublicEthAPI) GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error)

GetBlockByHash returns the block identified by hash.

func (*PublicEthAPI) GetBlockByNumber

func (e *PublicEthAPI) GetBlockByNumber(blockNum BlockNumber, fullTx bool) (map[string]interface{}, error)

GetBlockByNumber returns the block identified by number.

func (*PublicEthAPI) GetCode

func (e *PublicEthAPI) GetCode(address common.Address, blockNumber BlockNumber) (hexutil.Bytes, error)

GetCode returns the contract code at the given address and block number.

func (*PublicEthAPI) GetProof

func (e *PublicEthAPI) GetProof(address common.Address, storageKeys []string, block BlockNumber) (*AccountResult, error)

GetProof returns an account object with proof and any storage proofs

func (*PublicEthAPI) GetStorageAt

func (e *PublicEthAPI) GetStorageAt(address common.Address, key string, blockNum BlockNumber) (hexutil.Bytes, error)

GetStorageAt returns the contract storage at the given address, block number, and key.

func (*PublicEthAPI) GetTransactionByBlockHashAndIndex

func (e *PublicEthAPI) GetTransactionByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) (*Transaction, error)

GetTransactionByBlockHashAndIndex returns the transaction identified by hash and index.

func (*PublicEthAPI) GetTransactionByBlockNumberAndIndex

func (e *PublicEthAPI) GetTransactionByBlockNumberAndIndex(blockNum BlockNumber, idx hexutil.Uint) (*Transaction, error)

GetTransactionByBlockNumberAndIndex returns the transaction identified by number and index.

func (*PublicEthAPI) GetTransactionByHash

func (e *PublicEthAPI) GetTransactionByHash(hash common.Hash) (*Transaction, error)

GetTransactionByHash returns the transaction identified by hash.

func (*PublicEthAPI) GetTransactionCount

func (e *PublicEthAPI) GetTransactionCount(address common.Address, blockNum BlockNumber) (*hexutil.Uint64, error)

GetTransactionCount returns the number of transactions at the given address up to the given block number.

func (*PublicEthAPI) GetTransactionReceipt

func (e *PublicEthAPI) GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error)

GetTransactionReceipt returns the transaction receipt identified by hash.

func (*PublicEthAPI) GetUncleByBlockHashAndIndex

func (e *PublicEthAPI) GetUncleByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) map[string]interface{}

GetUncleByBlockHashAndIndex returns the uncle identified by hash and index. Always returns nil.

func (*PublicEthAPI) GetUncleByBlockNumberAndIndex

func (e *PublicEthAPI) GetUncleByBlockNumberAndIndex(number hexutil.Uint, idx hexutil.Uint) map[string]interface{}

GetUncleByBlockNumberAndIndex returns the uncle identified by number and index. Always returns nil.

func (*PublicEthAPI) GetUncleCountByBlockHash

func (e *PublicEthAPI) GetUncleCountByBlockHash(hash common.Hash) hexutil.Uint

GetUncleCountByBlockHash returns the number of uncles in the block idenfied by hash. Always zero.

func (*PublicEthAPI) GetUncleCountByBlockNumber

func (e *PublicEthAPI) GetUncleCountByBlockNumber(blockNum BlockNumber) hexutil.Uint

GetUncleCountByBlockNumber returns the number of uncles in the block idenfied by number. Always zero.

func (*PublicEthAPI) Hashrate

func (e *PublicEthAPI) Hashrate() hexutil.Uint64

Hashrate returns the current node's hashrate. Always 0.

func (*PublicEthAPI) Mining

func (e *PublicEthAPI) Mining() bool

Mining returns whether or not this node is currently mining. Always false.

func (*PublicEthAPI) PendingTransactions

func (e *PublicEthAPI) PendingTransactions() ([]*Transaction, error)

PendingTransactions returns the transactions that are in the transaction pool and have a from address that is one of the accounts this node manages.

func (*PublicEthAPI) ProtocolVersion

func (e *PublicEthAPI) ProtocolVersion() hexutil.Uint

ProtocolVersion returns the supported Ethereum protocol version.

func (*PublicEthAPI) SendRawTransaction

func (e *PublicEthAPI) SendRawTransaction(data hexutil.Bytes) (common.Hash, error)

SendRawTransaction send a raw Ethereum transaction.

func (*PublicEthAPI) SendTransaction

func (e *PublicEthAPI) SendTransaction(args params.SendTxArgs) (common.Hash, error)

SendTransaction sends an Ethereum transaction.

func (*PublicEthAPI) Sign

func (e *PublicEthAPI) Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error)

Sign signs the provided data using the private key of address via Geth's signature standard.

func (*PublicEthAPI) Syncing

func (e *PublicEthAPI) Syncing() (interface{}, error)

Syncing returns whether or not the current node is syncing with other peers. Returns false if not, or a struct outlining the state of the sync if it is.

type PublicFilterAPI

type PublicFilterAPI struct {
	// contains filtered or unexported fields
}

PublicFilterAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec.

func NewPublicFilterAPI

func NewPublicFilterAPI(cliCtx context.CLIContext) *PublicFilterAPI

NewPublicEthAPI creates an instance of the public ETH Web3 API.

func (*PublicFilterAPI) GetLogs

func (e *PublicFilterAPI) GetLogs(criteria filters.FilterCriteria) ([]*ethtypes.Log, error)

GetLogs returns logs matching the given argument that are stored within the state.

https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getlogs

type PublicNetAPI

type PublicNetAPI struct {
	// contains filtered or unexported fields
}

PublicNetAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec.

func NewPublicNetAPI

func NewPublicNetAPI(cliCtx context.CLIContext) *PublicNetAPI

NewPersonalEthAPI creates an instance of the public ETH Web3 API.

func (*PublicNetAPI) Version

func (s *PublicNetAPI) Version() string

Version returns the current ethereum protocol version.

type PublicWeb3API

type PublicWeb3API struct{}

PublicWeb3API is the web3_ prefixed set of APIs in the Web3 JSON-RPC spec.

func NewPublicWeb3API

func NewPublicWeb3API() *PublicWeb3API

NewPublicWeb3API creates an instance of the Web3 API.

func (*PublicWeb3API) ClientVersion

func (a *PublicWeb3API) ClientVersion() string

ClientVersion returns the client version in the Web3 user agent format.

func (*PublicWeb3API) Sha3

func (a *PublicWeb3API) Sha3(input hexutil.Bytes) hexutil.Bytes

Sha3 returns the keccak-256 hash of the passed-in input.

type StorageResult

type StorageResult struct {
	Key   string       `json:"key"`
	Value *hexutil.Big `json:"value"`
	Proof []string     `json:"proof"`
}

StorageResult defines the format for storage proof return

type Transaction

type Transaction struct {
	BlockHash        *common.Hash    `json:"blockHash"`
	BlockNumber      *hexutil.Big    `json:"blockNumber"`
	From             common.Address  `json:"from"`
	Gas              hexutil.Uint64  `json:"gas"`
	GasPrice         *hexutil.Big    `json:"gasPrice"`
	Hash             common.Hash     `json:"hash"`
	Input            hexutil.Bytes   `json:"input"`
	Nonce            hexutil.Uint64  `json:"nonce"`
	To               *common.Address `json:"to"`
	TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`
	Value            *hexutil.Big    `json:"value"`
	V                *hexutil.Big    `json:"v"`
	R                *hexutil.Big    `json:"r"`
	S                *hexutil.Big    `json:"s"`
}

Transaction represents a transaction returned to RPC clients.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL