client

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 21 Imported by: 18

Documentation

Overview

Package client implements the Ethereum RPC API client with tracing and batch requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EVM

type EVM interface {
	// ContractBackend defines the methods needed to work with contracts on a read-write basis.
	// this is used for deploying an interacting with contracts
	bind.ContractBackend
	// ChainReader ethereum.ChainReader for getting transactions
	ethereum.ChainReader
	// TransactionReader is used for reading txes by hash
	ethereum.TransactionReader
	// ChainStateReader gets the chain state reader
	ethereum.ChainStateReader
	// PendingStateReader handles pending state calls
	ethereum.PendingStateReader
	// ChainSyncReader tracks state head
	ethereum.ChainSyncReader
	// PendingContractCaller tracks pending contract calls
	ethereum.PendingContractCaller
	// FeeHistory gets the fee history for a given block
	FeeHistory(ctx context.Context, blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64) (*ethereum.FeeHistory, error)
	// NetworkID returns the network ID (also known as the chain ID) for this chain.
	NetworkID(ctx context.Context) (*big.Int, error)
	// ChainID gets the chain id from the rpc server
	ChainID(ctx context.Context) (*big.Int, error)
	// CallContext is used for manual overrides
	CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
	// BatchCallContext is used for manual overrides
	BatchCallContext(ctx context.Context, b []rpc.BatchElem) error
	// BlockNumber gets the latest block number
	BlockNumber(ctx context.Context) (uint64, error)
	// BatchWithContext batches multiple w3type calls
	BatchWithContext(ctx context.Context, calls ...w3types.Caller) error
	// Web3Version gets the web3 version
	Web3Version(ctx context.Context) (version string, err error)
}

EVM is the set of functions that the scribe needs from a client.

func DialBackend

func DialBackend(ctx context.Context, url string, handler metrics.Handler, opts ...Options) (_ EVM, err error)

DialBackend returns a scribe backend.

type HarmonyVM added in v0.7.0

type HarmonyVM interface {
	EVM
	// FilterHarmonyLogs returns the logs that satisfy the supplied filter query.
	FilterHarmonyLogs(ctx context.Context, query ethereum.FilterQuery) (logs []types.Log, err error)
	// HarmonyTransactionReceipt returns the receipt of a transaction by transaction hash.
	HarmonyTransactionReceipt(ctx context.Context, txHash common.Hash) (receipt *types.Receipt, err error)
}

HarmonyVM is a strict superset of evm w/ custom harmony methods.

func DialHarmonyBackend added in v0.7.0

func DialHarmonyBackend(ctx context.Context, url string, handler metrics.Handler, ops ...Options) (HarmonyVM, error)

DialHarmonyBackend dials a harmony backend.

type Options added in v0.0.66

type Options func(c *clientImpl)

Options is a type for client options.

func Capture added in v0.0.66

func Capture(captureReqRes bool) Options

Capture option allows for capturing the request and response data.

type RPCMethod

type RPCMethod string

RPCMethod is an enum type for an rpc method.

const (
	// ChainIDMethod is used to retrieve the current chain ID for transaction replay protection.
	ChainIDMethod RPCMethod = "eth_chainId"
	// BlockByHashMethod gets a block by hash.
	BlockByHashMethod RPCMethod = "eth_getBlockByHash"
	// BlockByNumberMethod gets a block by number.
	BlockByNumberMethod RPCMethod = "eth_getBlockByNumber"
	// BlockNumberMethod gets the latest block number.
	BlockNumberMethod RPCMethod = "eth_blockNumber"
	// TransactionByHashMethod returns the transaction with the given hash.
	TransactionByHashMethod RPCMethod = "eth_getTransactionByHash"
	// TransactionByBlockHashAndIndexMethod returns a transaction by its hash and index.
	TransactionByBlockHashAndIndexMethod RPCMethod = "eth_getTransactionByBlockHashAndIndex"
	// TransactionCountByHashMethod get sthe transaction count by hash.
	TransactionCountByHashMethod RPCMethod = "eth_getBlockTransactionCountByHash"
	// TransactionReceiptByHashMethod gets the transaction receipt from a hash.
	TransactionReceiptByHashMethod RPCMethod = "eth_getTransactionReceipt"
	// SyncProgressMethod gets the sync progress.
	SyncProgressMethod RPCMethod = "eth_syncing"
	// GetBalanceMethod gets the balance for a given address.
	GetBalanceMethod RPCMethod = "eth_getBalance"
	// StorageAtMethod returns the value of key in the contract storage of the given account.
	StorageAtMethod RPCMethod = "eth_getStorageAt"
	// GetCodeMethod returns the contract code of the given account.
	GetCodeMethod RPCMethod = "eth_getCode"
	// TransactionCountMethod returns the account nonce of the given account.
	TransactionCountMethod RPCMethod = "eth_getTransactionCount"
	// GetLogsMethod filters logs.
	GetLogsMethod RPCMethod = "eth_getLogs"
	// CallMethod calls a contract.
	CallMethod RPCMethod = "eth_call"
	// GasPriceMethod gets the gas price.
	GasPriceMethod RPCMethod = "eth_gasPrice"
	// MaxPriorityMethod gets the max priority fee.
	MaxPriorityMethod RPCMethod = "eth_maxPriorityFeePerGas"
	// FeeHistoryMethod gets the fee history.
	FeeHistoryMethod RPCMethod = "eth_feeHistory"
	// EstimateGasMethod tries to estimate the gas needed to execute a specific transaction.
	EstimateGasMethod RPCMethod = "eth_estimateGas"
	// PendingTransactionCountMethod gets the pending transaction count.
	PendingTransactionCountMethod RPCMethod = "eth_getBlockTransactionCountByNumber"
	// SendRawTransactionMethod sends a raw tx.
	SendRawTransactionMethod RPCMethod = "eth_sendRawTransaction"
	// SubscribeMethod subscribes to an event.
	SubscribeMethod RPCMethod = "eth_subscribe"
)

ETH METHODS:.

const (
	// HarmonyGetLogsMethod filters logs on harmony.
	HarmonyGetLogsMethod RPCMethod = "hmy_getLogs"
	// HarmonyGetReceiptMethod gets a receipt on harmony
	// this should always return Hash rather than Ethereum Hash.
	HarmonyGetReceiptMethod RPCMethod = "hmy_getTransactionReceipt"
)

Harmony Methods:.

const (
	// NetVersionMethod gets the network version.
	NetVersionMethod  RPCMethod = "net_version"
	Web3VersionMethod RPCMethod = "web3_clientVersion"
)

NetMethods:.

func (RPCMethod) Comparable

func (r RPCMethod) Comparable() string

Comparable converts an rpc method to lowercase based on a preset map can be used for case sensitive comparison.

func (RPCMethod) String

func (r RPCMethod) String() string

String returns the string representation of an rpc method.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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