client

package
v0.0.0-...-fa14253 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsParityQueriedReceiptTooEarly

func IsParityQueriedReceiptTooEarly(e error) bool

Parity can return partially hydrated Log entries if you query a receipt while the transaction is still in the mempool. Go-ethereum's built-in client raises an error since this is a required field. There is no easy way to ignore the error or pass in a custom struct, so we use this hack to detect it instead.

Types

type Client

type Client interface {
	GethClient

	Dial(ctx context.Context) error
	Close()

	Call(result interface{}, method string, args ...interface{}) error
	CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
}

Client is the interface used to interact with an ethereum node.

type GethClient

type GethClient interface {
	ethereum.TransactionSender
	ethereum.LogFilterer
	ethereum.GasPricer
	ethereum.GasEstimator
	ethereum.ChainReader
	ethereum.PendingStateReader

	ChainID(ctx context.Context) (*big.Int, error)
	TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
	BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
	BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
	CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
	CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)

	// SuggestGasTipCap retrieves the currently suggested 1559 priority fee to allow
	// a timely execution of a transaction.
	SuggestGasTipCap(ctx context.Context) (*big.Int, error)

	FeeHistory(ctx context.Context, blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64) (*ethereum.FeeHistory, error)
}

GethClient is an interface that represents go-ethereum's own ethclient https://github.com/ethereum/go-ethereum/blob/master/ethclient/ethclient.go

type Impl

type Impl struct {
	GethClient
	RPCClient

	SecondaryGethClients []GethClient
	SecondaryRPCClients  []RPCClient
	// contains filtered or unexported fields
}

Impl implements the ethereum Client interface using a CallerSubscriber instance.

func NewImpl

func NewImpl(config *esTypes.Config) (*Impl, error)

NewImpl creates a new client implementation

func (*Impl) BalanceAt

func (client *Impl) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)

func (*Impl) BlockByNumber

func (client *Impl) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)

func (*Impl) Call

func (client *Impl) Call(result interface{}, method string, args ...interface{}) error

func (*Impl) CallContext

func (client *Impl) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error

func (*Impl) ChainID

func (client *Impl) ChainID(ctx context.Context) (*big.Int, error)

func (*Impl) Dial

func (client *Impl) Dial(ctx context.Context) error

func (*Impl) EstimateGas

func (client *Impl) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)

func (*Impl) FeeHistory

func (client *Impl) FeeHistory(ctx context.Context, blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64) (*ethereum.FeeHistory, error)

FeeHistory returns the collection of historical gas information

func (*Impl) FilterLogs

func (client *Impl) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)

func (*Impl) HeaderByNumber

func (client *Impl) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)

func (*Impl) PendingCodeAt

func (client *Impl) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)

func (*Impl) PendingNonceAt

func (client *Impl) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)

func (*Impl) SendRawTx

func (client *Impl) SendRawTx(bytes []byte) (common.Hash, error)

SendRawTx sends a signed transaction to the transaction pool.

func (*Impl) SendTransaction

func (client *Impl) SendTransaction(ctx context.Context, tx *types.Transaction) error

SendTransaction also uses the secondary HTTP RPC URL if set

func (*Impl) SubscribeFilterLogs

func (client *Impl) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)

func (*Impl) SubscribeNewHead

func (client *Impl) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)

func (*Impl) SuggestGasPrice

func (client *Impl) SuggestGasPrice(ctx context.Context) (*big.Int, error)

func (*Impl) SuggestGasTipCap

func (client *Impl) SuggestGasTipCap(ctx context.Context) (*big.Int, error)

SuggestGasTipCap retrieves the currently suggested 1559 priority fee to allow a timely execution of a transaction.

func (*Impl) TransactionReceipt

func (client *Impl) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)

TransactionReceipt wraps the GethClient's `TransactionReceipt` method so that we can ignore the error that arises when we're talking to a Parity node that has no receipt yet.

type RPCClient

type RPCClient interface {
	Call(result interface{}, method string, args ...interface{}) error
	CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
	BatchCallContext(ctx context.Context, b []rpc.BatchElem) error
	EthSubscribe(ctx context.Context, channel interface{}, args ...interface{}) (ethereum.Subscription, error)
	Close()
}

RPCClient is an interface that represents go-ethereum's own rpc.Client. https://github.com/ethereum/go-ethereum/blob/master/rpc/client.go

type SendError

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

func NewFatalSendError

func NewFatalSendError(e error) *SendError

func NewFatalSendErrorS

func NewFatalSendErrorS(s string) *SendError

func NewSendError

func NewSendError(e error) *SendError

func NewSendErrorS

func NewSendErrorS(s string) *SendError

func (*SendError) Error

func (s *SendError) Error() string

func (*SendError) Fatal

func (s *SendError) Fatal() bool

Fatal indicates whether the error should be considered fatal or not Fatal errors mean that no matter how many times the send is retried, no node will ever accept it

func (*SendError) IsInsufficientEth

func (s *SendError) IsInsufficientEth() bool

func (*SendError) IsNonceTooLowError

func (s *SendError) IsNonceTooLowError() bool

func (*SendError) IsReplacementUnderpriced

func (s *SendError) IsReplacementUnderpriced() bool

IsReplacementUnderpriced indicates that a transaction already exists in the mempool with this nonce but a different gas price or payload

func (*SendError) IsTemporarilyUnderpriced

func (s *SendError) IsTemporarilyUnderpriced() bool

func (*SendError) IsTerminallyUnderpriced

func (s *SendError) IsTerminallyUnderpriced() bool

IsTerminallyUnderpriced indicates that this transaction is so far underpriced the node won't even accept it in the first place

func (*SendError) IsTransactionAlreadyInMempool

func (s *SendError) IsTransactionAlreadyInMempool() bool

Geth/parity returns this error if the transaction is already in the node's mempool

func (*SendError) StrPtr

func (s *SendError) StrPtr() *string

Jump to

Keyboard shortcuts

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