eth

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: Apache-2.0 Imports: 56 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheOfEthCallLru = 40960

	FlagFastQueryThreshold = "fast-query-threshold"

	EvmHookGasEstimate = uint64(60000)
	EvmDefaultGasLimit = uint64(21000)
)
View Source
const (
	FlagEnableTxPool      = "enable-tx-pool"
	TxPoolCap             = "tx-pool-cap"
	BroadcastPeriodSecond = "broadcast-period-second"
)
View Source
const (
	DefaultEVMErrorCode          = -32000
	VMExecuteException           = -32015
	VMExecuteExceptionInEstimate = 3
	AccountNotExistsCode         = 9

	RPCEthCall           = "eth_call"
	RPCEthEstimateGas    = "eth_estimateGas"
	RPCEthGetBlockByHash = "eth_getBlockByHash"

	RPCUnknowErr = "unknow"
	RPCNullData  = "null"
)
View Source
const (
	FlagEnableMultiCall = "rpc.enable-multi-call"
)

Variables

This section is empty.

Functions

func CheckError

func CheckError(txRes sdk.TxResponse) (common.Hash, error)

func ParseGasPrice

func ParseGasPrice() *hexutil.Big

gasPrice: to get "minimum-gas-prices" config or to get ethermint.DefaultGasPrice

func TransformDataError

func TransformDataError(err error, method string) error

Types

type DataError

type DataError struct {
	Msg string `json:"msg"`
	// contains filtered or unexported fields
}

func (DataError) Error

func (d DataError) Error() string

func (DataError) ErrorCode

func (d DataError) ErrorCode() int

func (DataError) ErrorData

func (d DataError) ErrorData() interface{}

type PublicEthereumAPI

type PublicEthereumAPI struct {
	Metrics map[string]*monitor.RpcMetrics
	// contains filtered or unexported fields
}

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

func NewAPI

func NewAPI(
	clientCtx clientcontext.CLIContext, log log.Logger, backend backend.Backend, nonceLock *rpctypes.AddrLocker,
	keys ...ethsecp256k1.PrivKey,
) *PublicEthereumAPI

NewAPI creates an instance of the public ETH Web3 API.

func (*PublicEthereumAPI) Accounts

func (api *PublicEthereumAPI) Accounts() ([]common.Address, error)

Accounts returns the list of accounts available to this node.

func (*PublicEthereumAPI) BlockNumber

func (api *PublicEthereumAPI) BlockNumber() (hexutil.Uint64, error)

BlockNumber returns the current block number.

func (*PublicEthereumAPI) Call

Call performs a raw contract call.

func (*PublicEthereumAPI) ChainId

func (api *PublicEthereumAPI) ChainId() (hexutil.Uint, error)

ChainId returns the chain's identifier in hex format

func (*PublicEthereumAPI) ClientCtx

func (api *PublicEthereumAPI) ClientCtx() clientcontext.CLIContext

ClientCtx returns the Cosmos SDK client context.

func (*PublicEthereumAPI) Coinbase

func (api *PublicEthereumAPI) Coinbase() (common.Address, error)

Coinbase is the address that staking rewards will be send to (alias for Etherbase).

func (*PublicEthereumAPI) EstimateGas

func (api *PublicEthereumAPI) EstimateGas(args rpctypes.CallArgs) (hexutil.Uint64, error)

EstimateGas returns an estimate of gas usage for the given smart contract call.

func (*PublicEthereumAPI) FeeHistory

func (api *PublicEthereumAPI) FeeHistory(blockCount rpc.DecimalOrHex, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*rpctypes.FeeHistoryResult, error)

func (*PublicEthereumAPI) FillTransaction

FillTransaction fills the defaults (nonce, gas, gasPrice or 1559 fields) on a given unsigned transaction, and returns it to the caller for further processing (signing + broadcast).

func (*PublicEthereumAPI) GasPrice

func (api *PublicEthereumAPI) GasPrice() *hexutil.Big

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

func (*PublicEthereumAPI) GetAccount

func (api *PublicEthereumAPI) GetAccount(address common.Address) (*ethermint.EthAccount, error)

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

func (*PublicEthereumAPI) GetAllTransactionResultsByBlock

func (api *PublicEthereumAPI) GetAllTransactionResultsByBlock(blockNrOrHash rpctypes.BlockNumberOrHash, offset, limit hexutil.Uint) ([]*watcher.TransactionResult, error)

GetTransactionReceiptsByBlock returns the transaction receipt identified by block hash or number.

func (*PublicEthereumAPI) GetBalance

func (api *PublicEthereumAPI) GetBalance(address common.Address, blockNrOrHash rpctypes.BlockNumberOrHash) (*hexutil.Big, error)

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

func (*PublicEthereumAPI) GetBalanceBatch

func (api *PublicEthereumAPI) GetBalanceBatch(addresses []common.Address, blockNrOrHash rpctypes.BlockNumberOrHash) (interface{}, error)

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

func (*PublicEthereumAPI) GetBlockByHash

func (api *PublicEthereumAPI) GetBlockByHash(hash common.Hash, fullTx bool) (*watcher.Block, error)

GetBlockByHash returns the block identified by hash.

func (*PublicEthereumAPI) GetBlockByNumber

func (api *PublicEthereumAPI) GetBlockByNumber(blockNum rpctypes.BlockNumber, fullTx bool) (*watcher.Block, error)

GetBlockByNumber returns the block identified by number.

func (*PublicEthereumAPI) GetBlockTransactionCountByHash

func (api *PublicEthereumAPI) GetBlockTransactionCountByHash(hash common.Hash) *hexutil.Uint

GetBlockTransactionCountByHash returns the number of transactions in the block identified by hash.

func (*PublicEthereumAPI) GetBlockTransactionCountByNumber

func (api *PublicEthereumAPI) GetBlockTransactionCountByNumber(blockNum rpctypes.BlockNumber) *hexutil.Uint

GetBlockTransactionCountByNumber returns the number of transactions in the block identified by its height.

func (*PublicEthereumAPI) GetCode

func (api *PublicEthereumAPI) GetCode(address common.Address, blockNrOrHash rpctypes.BlockNumberOrHash) (hexutil.Bytes, error)

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

func (*PublicEthereumAPI) GetCodeByHash

func (api *PublicEthereumAPI) GetCodeByHash(hash common.Hash) (hexutil.Bytes, error)

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

func (*PublicEthereumAPI) GetCodec

func (api *PublicEthereumAPI) GetCodec() *codec.Codec

func (*PublicEthereumAPI) GetKeyringInfo

func (api *PublicEthereumAPI) GetKeyringInfo() error

GetKeyringInfo checks if the keyring is present on the client context. If not, it creates a new instance and sets it to the client context for later usage.

func (*PublicEthereumAPI) GetKeys

func (api *PublicEthereumAPI) GetKeys() []ethsecp256k1.PrivKey

GetKeys returns the Cosmos SDK client context.

func (*PublicEthereumAPI) GetProof

func (api *PublicEthereumAPI) GetProof(address common.Address, storageKeys []string, blockNrOrHash rpctypes.BlockNumberOrHash) (*rpctypes.AccountResult, error)

GetProof returns an account object with proof and any storage proofs

func (*PublicEthereumAPI) GetStorageAt

func (api *PublicEthereumAPI) GetStorageAt(address common.Address, key string, blockNrOrHash rpctypes.BlockNumberOrHash) (hexutil.Bytes, error)

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

func (*PublicEthereumAPI) GetStorageAtInternal

func (api *PublicEthereumAPI) GetStorageAtInternal(address common.Address, key []byte) (hexutil.Bytes, error)

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

func (*PublicEthereumAPI) GetTransactionByBlockHashAndIndex

func (api *PublicEthereumAPI) GetTransactionByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) (*watcher.Transaction, error)

GetTransactionByBlockHashAndIndex returns the transaction identified by hash and index.

func (*PublicEthereumAPI) GetTransactionByBlockNumberAndIndex

func (api *PublicEthereumAPI) GetTransactionByBlockNumberAndIndex(blockNum rpctypes.BlockNumber, idx hexutil.Uint) (*watcher.Transaction, error)

GetTransactionByBlockNumberAndIndex returns the transaction identified by number and index.

func (*PublicEthereumAPI) GetTransactionByHash

func (api *PublicEthereumAPI) GetTransactionByHash(hash common.Hash) (*watcher.Transaction, error)

GetTransactionByHash returns the transaction identified by hash.

func (*PublicEthereumAPI) GetTransactionCount

func (api *PublicEthereumAPI) GetTransactionCount(address common.Address, blockNrOrHash rpctypes.BlockNumberOrHash) (*hexutil.Uint64, error)

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

func (*PublicEthereumAPI) GetTransactionLogs

func (api *PublicEthereumAPI) GetTransactionLogs(txHash common.Hash) ([]*ethtypes.Log, error)

GetTransactionLogs returns the logs given a transaction hash.

func (*PublicEthereumAPI) GetTransactionReceipt

func (api *PublicEthereumAPI) GetTransactionReceipt(hash common.Hash) (*watcher.TransactionReceipt, error)

GetTransactionReceipt returns the transaction receipt identified by hash.

func (*PublicEthereumAPI) GetTransactionReceiptsByBlock

func (api *PublicEthereumAPI) GetTransactionReceiptsByBlock(blockNrOrHash rpctypes.BlockNumberOrHash, offset, limit hexutil.Uint) ([]*watcher.TransactionReceipt, error)

GetTransactionReceiptsByBlock returns the transaction receipt identified by block hash or number.

func (*PublicEthereumAPI) GetTransactionsByBlock

func (api *PublicEthereumAPI) GetTransactionsByBlock(blockNrOrHash rpctypes.BlockNumberOrHash, offset, limit hexutil.Uint) ([]*watcher.Transaction, error)

GetTransactionsByBlock returns some transactions identified by number or hash.

func (*PublicEthereumAPI) GetUncleByBlockHashAndIndex

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

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

func (*PublicEthereumAPI) GetUncleByBlockNumberAndIndex

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

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

func (*PublicEthereumAPI) GetUncleCountByBlockHash

func (api *PublicEthereumAPI) GetUncleCountByBlockHash(_ common.Hash) hexutil.Uint

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

func (*PublicEthereumAPI) GetUncleCountByBlockNumber

func (api *PublicEthereumAPI) GetUncleCountByBlockNumber(_ rpctypes.BlockNumber) hexutil.Uint

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

func (*PublicEthereumAPI) Hashrate

func (api *PublicEthereumAPI) Hashrate() hexutil.Uint64

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

func (*PublicEthereumAPI) JudgeEvm2CmTx

func (api *PublicEthereumAPI) JudgeEvm2CmTx(toAddr, payLoad []byte) bool

func (*PublicEthereumAPI) Mining

func (api *PublicEthereumAPI) Mining() bool

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

func (*PublicEthereumAPI) MultiCall

func (api *PublicEthereumAPI) MultiCall(args []rpctypes.CallArgs, blockNr rpctypes.BlockNumber, _ *[]evmtypes.StateOverrides) ([]hexutil.Bytes, error)

MultiCall performs multiple raw contract call.

func (*PublicEthereumAPI) PendingTransactions

func (api *PublicEthereumAPI) PendingTransactions() ([]*watcher.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 (*PublicEthereumAPI) PendingTransactionsByHash

func (api *PublicEthereumAPI) PendingTransactionsByHash(target common.Hash) (*watcher.Transaction, error)

func (*PublicEthereumAPI) ProtocolVersion

func (api *PublicEthereumAPI) ProtocolVersion() hexutil.Uint

ProtocolVersion returns the supported Ethereum protocol version.

func (*PublicEthereumAPI) SendRawTransaction

func (api *PublicEthereumAPI) SendRawTransaction(data hexutil.Bytes) (common.Hash, error)

SendRawTransaction send a raw Ethereum transaction.

func (*PublicEthereumAPI) SendTransaction

func (api *PublicEthereumAPI) SendTransaction(args rpctypes.SendTxArgs) (common.Hash, error)

SendTransaction sends an Ethereum transaction.

func (*PublicEthereumAPI) SetKeys

func (api *PublicEthereumAPI) SetKeys(keys []ethsecp256k1.PrivKey)

SetKeys sets the given key slice to the set of private keys

func (*PublicEthereumAPI) Sign

func (api *PublicEthereumAPI) 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 (*PublicEthereumAPI) Syncing

func (api *PublicEthereumAPI) 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 TxPool

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

func NewTxPool

func NewTxPool(clientCtx clientcontext.CLIContext, api *PublicEthereumAPI) *TxPool

func (*TxPool) CacheAndBroadcastTx

func (pool *TxPool) CacheAndBroadcastTx(api *PublicEthereumAPI, address common.Address, tx *evmtypes.MsgEthereumTx) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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