eth

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NonceTooLow = iota
	ReplacementTransactionUnderpriced
	LimitReached
	TransactionAlreadyInMempool
	TerminallyUnderpriced
	InsufficientEth
	TooExpensive
	FeeTooLow
	FeeTooHigh
	Fatal
)
View Source
const NullClientChainID = 0

NullClientChainID the ChainID that nullclient will return 0 is never used as a real chain ID so makes sense as a dummy value here

Variables

This section is empty.

Functions

func DefaultQueryCtx added in v0.10.4

func DefaultQueryCtx(ctxs ...context.Context) (ctx context.Context, cancel context.CancelFunc)

DefaultQueryCtx returns a context with a sensible sanity limit timeout for queries to the eth node

func ExtractRevertReasonFromRPCError added in v0.10.7

func ExtractRevertReasonFromRPCError(err error) (string, error)

ExtractRevertReasonFromRPCError attempts to extract the revert reason from the response of an RPC eth_call that reverted by parsing the message from the "data" field ex: kovan (parity) { "error": { "code" : -32015, "data": "Reverted 0xABC123...", "message": "VM execution error." } } // revert reason always omitted rinkeby / ropsten (geth) { "error": { "code": 3, "data": "0x0xABC123...", "message": "execution reverted: hello world" } } // revert reason included in message

func MustGetABI added in v0.10.3

func MustGetABI(json string) abi.ABI

func NewClient added in v0.8.13

func NewClient(logger *logger.Logger, rpcUrl string, rpcHTTPURL *url.URL, secondaryRPCURLs []url.URL) (*client, error)

Types

type CallArgs added in v0.8.8

type CallArgs struct {
	To   common.Address `json:"to"`
	Data hexutil.Bytes  `json:"data"`
}

CallArgs represents the data used to call the balance method of a contract. "To" is the address of the ERC contract. "Data" is the message sent to the contract.

type Client added in v0.8.8

type Client interface {
	Dial(ctx context.Context) error
	Close()

	GetERC20Balance(address common.Address, contractAddress common.Address) (*big.Int, error)
	GetLINKBalance(linkAddress common.Address, address common.Address) (*assets.Link, error)
	GetEthBalance(ctx context.Context, account common.Address, blockNumber *big.Int) (*assets.Eth, error)

	// Wrapped RPC methods
	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
	RoundRobinBatchCallContext(ctx context.Context, b []rpc.BatchElem) error

	// HeadByNumber is a reimplemented version of HeaderByNumber due to a
	// difference in how block header hashes are calculated by Parity nodes
	// running on Kovan.  We have to return our own wrapper type to capture the
	// correct hash from the RPC response.
	HeadByNumber(ctx context.Context, n *big.Int) (*models.Head, error)
	SubscribeNewHead(ctx context.Context, ch chan<- *models.Head) (ethereum.Subscription, error)

	// Wrapped Geth client methods
	ChainID(ctx context.Context) (*big.Int, error)
	SendTransaction(ctx context.Context, tx *types.Transaction) error
	PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
	PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
	NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, 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)
	FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
	SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
	EstimateGas(ctx context.Context, call ethereum.CallMsg) (uint64, error)
	SuggestGasPrice(ctx context.Context) (*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)

	// bind.ContractBackend methods
	HeaderByNumber(context.Context, *big.Int) (*types.Header, error)
	SuggestGasTipCap(ctx context.Context) (*big.Int, error)
}

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

type ClientErrors added in v0.10.9

type ClientErrors = map[int]*regexp.Regexp

type JsonError added in v0.10.7

type JsonError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

go-ethereum@v1.10.0/rpc/json.go

func (*JsonError) Error added in v0.10.7

func (err *JsonError) Error() string

type NullClient added in v0.9.3

type NullClient struct{}

NullClient satisfies the Client but has no side effects

func (*NullClient) BalanceAt added in v0.9.3

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

func (*NullClient) BatchCallContext added in v0.10.0

func (nc *NullClient) BatchCallContext(ctx context.Context, b []rpc.BatchElem) error

func (*NullClient) BlockByNumber added in v0.9.3

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

func (*NullClient) Call added in v0.9.3

func (nc *NullClient) Call(result interface{}, method string, args ...interface{}) error

func (*NullClient) CallContext added in v0.9.3

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

func (*NullClient) CallContract added in v0.9.3

func (nc *NullClient) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)

func (*NullClient) ChainID added in v0.9.3

func (nc *NullClient) ChainID(ctx context.Context) (*big.Int, error)

func (*NullClient) Close added in v0.9.3

func (nc *NullClient) Close()

func (*NullClient) CodeAt added in v0.9.3

func (nc *NullClient) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)

func (*NullClient) Dial added in v0.9.3

func (nc *NullClient) Dial(ctx context.Context) error

func (*NullClient) EstimateGas added in v0.9.3

func (nc *NullClient) EstimateGas(ctx context.Context, call ethereum.CallMsg) (uint64, error)

func (*NullClient) FilterLogs added in v0.9.3

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

func (*NullClient) GetERC20Balance added in v0.9.3

func (nc *NullClient) GetERC20Balance(address common.Address, contractAddress common.Address) (*big.Int, error)

func (*NullClient) GetEthBalance added in v0.9.9

func (nc *NullClient) GetEthBalance(context.Context, common.Address, *big.Int) (*assets.Eth, error)

func (*NullClient) GetLINKBalance added in v0.9.6

func (nc *NullClient) GetLINKBalance(linkAddress common.Address, address common.Address) (*assets.Link, error)

func (*NullClient) HeadByNumber added in v0.10.10

func (nc *NullClient) HeadByNumber(ctx context.Context, n *big.Int) (*models.Head, error)

func (*NullClient) HeaderByNumber added in v0.9.3

func (nc *NullClient) HeaderByNumber(ctx context.Context, n *big.Int) (*types.Header, error)

func (*NullClient) NonceAt added in v0.10.6

func (nc *NullClient) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)

func (*NullClient) PendingCodeAt added in v0.9.3

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

func (*NullClient) PendingNonceAt added in v0.9.3

func (nc *NullClient) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)

func (*NullClient) RoundRobinBatchCallContext added in v0.10.4

func (nc *NullClient) RoundRobinBatchCallContext(ctx context.Context, b []rpc.BatchElem) error

func (*NullClient) SendTransaction added in v0.9.3

func (nc *NullClient) SendTransaction(ctx context.Context, tx *types.Transaction) error

func (*NullClient) SubscribeFilterLogs added in v0.9.3

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

func (*NullClient) SubscribeNewHead added in v0.9.3

func (nc *NullClient) SubscribeNewHead(ctx context.Context, ch chan<- *models.Head) (ethereum.Subscription, error)

func (*NullClient) SuggestGasPrice added in v0.9.3

func (nc *NullClient) SuggestGasPrice(ctx context.Context) (*big.Int, error)

func (*NullClient) SuggestGasTipCap added in v0.10.10

func (nc *NullClient) SuggestGasTipCap(ctx context.Context) (tipCap *big.Int, err error)

func (*NullClient) TransactionReceipt added in v0.9.3

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

type SendError added in v0.9.0

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

fatal means this transaction can never be accepted even with a different nonce or higher gas price

func NewFatalSendError added in v0.9.0

func NewFatalSendError(e error) *SendError

func NewFatalSendErrorS added in v0.9.0

func NewFatalSendErrorS(s string) *SendError

func NewSendError added in v0.9.0

func NewSendError(e error) *SendError

func NewSendErrorS added in v0.9.0

func NewSendErrorS(s string) *SendError

func (*SendError) CauseStr added in v0.10.6

func (s *SendError) CauseStr() string

CauseStr returns the string of the original error

func (*SendError) Error added in v0.9.0

func (s *SendError) Error() string

func (*SendError) Fatal added in v0.9.0

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) IsFeeTooHigh added in v0.10.10

func (s *SendError) IsFeeTooHigh() bool

IsFeeTooHigh is an optimism-specific error returned when total fee is too high

func (*SendError) IsFeeTooLow added in v0.10.10

func (s *SendError) IsFeeTooLow() bool

IsFeeTooLow is an optimism-specific error returned when total fee is too low

func (*SendError) IsInsufficientEth added in v0.9.0

func (s *SendError) IsInsufficientEth() bool

func (*SendError) IsNonceTooLowError added in v0.9.0

func (s *SendError) IsNonceTooLowError() bool

func (*SendError) IsReplacementUnderpriced added in v0.9.0

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 added in v0.9.0

func (s *SendError) IsTemporarilyUnderpriced() bool

func (*SendError) IsTerminallyUnderpriced added in v0.9.0

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) IsTooExpensive added in v0.10.3

func (s *SendError) IsTooExpensive() bool

IsTooExpensive returns true if the transaction and gas price are combined in some way that makes the total transaction too expensive for the eth node to accept at all. No amount of retrying at this or higher gas prices can ever succeed.

func (*SendError) IsTransactionAlreadyInMempool added in v0.9.0

func (s *SendError) IsTransactionAlreadyInMempool() bool

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

type Subscription added in v0.8.8

type Subscription interface {
	Err() <-chan error
	Unsubscribe()
}

This interface only exists so that we can generate a mock for it. It is identical to `ethereum.Subscription`.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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