Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultQueryCtx(ctxs ...context.Context) (ctx context.Context, cancel context.CancelFunc)
- func ExtractRevertReasonFromRPCError(err error) (string, error)
- func MustGetABI(json string) abi.ABI
- func NewClientWithNodes(logger logger.Logger, primaryNodes []Node, sendOnlyNodes []SendOnlyNode, ...) (*client, error)
- func ReceiptIndicatesRunLogFulfillment(txr types.Receipt) bool
- func ReceiptIsUnconfirmed(txr *types.Receipt) bool
- func ToBlockNumArg(number *big.Int) string
- type CallArgs
- type Client
- type ClientErrors
- type FunctionSelector
- func (f FunctionSelector) Bytes() []byte
- func (f FunctionSelector) MarshalJSON() ([]byte, error)
- func (f *FunctionSelector) Scan(value interface{}) error
- func (f *FunctionSelector) SetBytes(b []byte)
- func (f FunctionSelector) String() string
- func (f *FunctionSelector) UnmarshalJSON(input []byte) error
- func (f FunctionSelector) Value() (driver.Value, error)
- type Head
- func (h *Head) ChainHashes() []common.Hash
- func (h *Head) ChainLength() uint32
- func (h *Head) ChainString() string
- func (h *Head) EarliestInChain() Head
- func (h *Head) GreaterThan(r *Head) bool
- func (h *Head) HashAtHeight(blockNum int64) common.Hash
- func (h *Head) IsInChain(blockHash common.Hash) bool
- func (h *Head) MarshalJSON() ([]byte, error)
- func (h *Head) NextInt() *big.Int
- func (h Head) String() string
- func (h *Head) ToInt() *big.Int
- func (h *Head) UnmarshalJSON(bs []byte) error
- type JsonError
- type Node
- type NullClient
- func (nc *NullClient) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
- func (nc *NullClient) BatchCallContext(ctx context.Context, b []rpc.BatchElem) error
- func (nc *NullClient) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
- func (nc *NullClient) Call(result interface{}, method string, args ...interface{}) error
- func (nc *NullClient) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
- func (nc *NullClient) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (nc *NullClient) ChainID() *big.Int
- func (nc *NullClient) Close()
- func (nc *NullClient) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
- func (nc *NullClient) Dial(context.Context) error
- func (nc *NullClient) EstimateGas(ctx context.Context, call ethereum.CallMsg) (uint64, error)
- func (nc *NullClient) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
- func (nc *NullClient) GetERC20Balance(address common.Address, contractAddress common.Address) (*big.Int, error)
- func (nc *NullClient) GetEthBalance(context.Context, common.Address, *big.Int) (*assets.Eth, error)
- func (nc *NullClient) GetLINKBalance(linkAddress common.Address, address common.Address) (*assets.Link, error)
- func (nc *NullClient) HeadByNumber(ctx context.Context, n *big.Int) (*Head, error)
- func (nc *NullClient) HeaderByNumber(ctx context.Context, n *big.Int) (*types.Header, error)
- func (nc *NullClient) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
- func (nc *NullClient) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
- func (nc *NullClient) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
- func (nc *NullClient) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (nc *NullClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
- func (nc *NullClient) SubscribeNewHead(ctx context.Context, ch chan<- *Head) (ethereum.Subscription, error)
- func (nc *NullClient) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- func (nc *NullClient) SuggestGasTipCap(ctx context.Context) (tipCap *big.Int, err error)
- func (nc *NullClient) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
- type Pool
- func (p *Pool) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
- func (p *Pool) BatchCallContext(ctx context.Context, b []rpc.BatchElem) error
- func (p *Pool) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
- func (p *Pool) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
- func (p *Pool) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (p *Pool) ChainID() *big.Int
- func (p *Pool) Close()
- func (p *Pool) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
- func (p *Pool) Dial(ctx context.Context) (err error)
- func (p *Pool) EstimateGas(ctx context.Context, call ethereum.CallMsg) (uint64, error)
- func (p *Pool) EthSubscribe(ctx context.Context, channel interface{}, args ...interface{}) (ethereum.Subscription, error)
- func (p *Pool) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
- func (p *Pool) HeaderByNumber(ctx context.Context, n *big.Int) (*types.Header, error)
- func (p *Pool) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
- func (p *Pool) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
- func (p *Pool) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
- func (p *Pool) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (p *Pool) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
- func (p *Pool) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- func (p *Pool) SuggestGasTipCap(ctx context.Context) (*big.Int, error)
- func (p *Pool) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
- type SendError
- func (s *SendError) CauseStr() string
- func (s *SendError) Error() string
- func (s *SendError) Fatal() bool
- func (s *SendError) IsFeeTooHigh() bool
- func (s *SendError) IsFeeTooLow() bool
- func (s *SendError) IsInsufficientEth() bool
- func (s *SendError) IsNonceTooLowError() bool
- func (s *SendError) IsReplacementUnderpriced() bool
- func (s *SendError) IsTemporarilyUnderpriced() bool
- func (s *SendError) IsTerminallyUnderpriced() bool
- func (s *SendError) IsTooExpensive() bool
- func (s *SendError) IsTransactionAlreadyInMempool() bool
- type SendOnlyNode
- type Subscription
- type UntrustedBytes
Constants ¶
const ( NonceTooLow = iota ReplacementTransactionUnderpriced LimitReached TransactionAlreadyInMempool TerminallyUnderpriced InsufficientEth TooExpensive FeeTooLow FeeTooHigh Fatal )
const FunctionSelectorLength = 4
FunctionSelectorLength should always be a length of 4 as a byte.
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 ¶
var ChainlinkFulfilledTopic = utils.MustHash("ChainlinkFulfilled(bytes32)")
ChainlinkFulfilledTopic is the signature for the event emitted after calling ChainlinkClient.validateChainlinkCallback(requestId). See ../../contracts/src/v0.6/ChainlinkClient.sol
WeiPerEth is amount of Wei currency units in one Eth.
Functions ¶
func DefaultQueryCtx ¶
DefaultQueryCtx returns a context with a sensible sanity limit timeout for queries to the eth node
func ExtractRevertReasonFromRPCError ¶
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 ¶
func NewClientWithNodes ¶ added in v1.10.17
func NewClientWithNodes(logger logger.Logger, primaryNodes []Node, sendOnlyNodes []SendOnlyNode, chainID *big.Int) (*client, error)
NewClientWithNodes instantiates a client from a list of nodes Currently only supports one primary
func ReceiptIndicatesRunLogFulfillment ¶ added in v1.10.17
ReceiptIndicatesRunLogFulfillment returns true if this tx receipt is the result of a fulfilled run log.
func ReceiptIsUnconfirmed ¶ added in v1.10.17
Unconfirmed returns true if the transaction is not confirmed.
func ToBlockNumArg ¶ added in v1.10.17
Types ¶
type CallArgs ¶
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 ¶
type Client interface { Dial(ctx context.Context) error Close() ChainID() *big.Int 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 // 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) (*Head, error) SubscribeNewHead(ctx context.Context, ch chan<- *Head) (ethereum.Subscription, error) // Wrapped Geth client methods 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 ¶
type FunctionSelector ¶ added in v1.10.17
type FunctionSelector [FunctionSelectorLength]byte
FunctionSelector is the first four bytes of the call data for a function call and specifies the function to be called.
func BytesToFunctionSelector ¶ added in v1.10.17
func BytesToFunctionSelector(b []byte) FunctionSelector
BytesToFunctionSelector converts the given bytes to a FunctionSelector.
func HexToFunctionSelector ¶ added in v1.10.17
func HexToFunctionSelector(s string) FunctionSelector
HexToFunctionSelector converts the given string to a FunctionSelector.
func (FunctionSelector) Bytes ¶ added in v1.10.17
func (f FunctionSelector) Bytes() []byte
Bytes returns the FunctionSelector as a byte slice
func (FunctionSelector) MarshalJSON ¶ added in v1.10.17
func (f FunctionSelector) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of f
func (*FunctionSelector) Scan ¶ added in v1.10.17
func (f *FunctionSelector) Scan(value interface{}) error
Scan returns the selector from its serialization in the database
func (*FunctionSelector) SetBytes ¶ added in v1.10.17
func (f *FunctionSelector) SetBytes(b []byte)
SetBytes sets the FunctionSelector to that of the given bytes (will trim).
func (FunctionSelector) String ¶ added in v1.10.17
func (f FunctionSelector) String() string
String returns the FunctionSelector as a string type.
func (*FunctionSelector) UnmarshalJSON ¶ added in v1.10.17
func (f *FunctionSelector) UnmarshalJSON(input []byte) error
UnmarshalJSON parses the raw FunctionSelector and sets the FunctionSelector type to the given input.
type Head ¶ added in v1.10.17
type Head struct { ID uint64 Hash common.Hash Number int64 L1BlockNumber null.Int64 ParentHash common.Hash Parent *Head `gorm:"-"` EVMChainID *utils.Big `gorm:"column:evm_chain_id"` Timestamp time.Time CreatedAt time.Time BaseFeePerGas *utils.Big }
Head represents a BlockNumber, BlockHash.
func NewHead ¶ added in v1.10.17
func NewHead(number *big.Int, blockHash common.Hash, parentHash common.Hash, timestamp uint64, chainID *utils.Big) Head
NewHead returns a Head instance.
func (*Head) ChainHashes ¶ added in v1.10.17
ChainHashes returns an array of block hashes by recursively looking up parents
func (*Head) ChainLength ¶ added in v1.10.17
ChainLength returns the length of the chain followed by recursively looking up parents
func (*Head) ChainString ¶ added in v1.10.17
func (*Head) EarliestInChain ¶ added in v1.10.17
EarliestInChain recurses through parents until it finds the earliest one
func (*Head) GreaterThan ¶ added in v1.10.17
GreaterThan compares BlockNumbers and returns true if the receiver BlockNumber is greater than the supplied BlockNumber
func (*Head) HashAtHeight ¶ added in v1.10.17
HashAtHeight returns the hash of the block at the given heigh, if it is in the chain. If not in chain, returns the zero hash
func (*Head) IsInChain ¶ added in v1.10.17
IsInChain returns true if the given hash matches the hash of a head in the chain
func (*Head) MarshalJSON ¶ added in v1.10.17
func (*Head) NextInt ¶ added in v1.10.17
NextInt returns the next BlockNumber as big.int, or nil if nil to represent latest.
func (*Head) ToInt ¶ added in v1.10.17
ToInt return the height as a *big.Int. Also handles nil by returning nil.
func (*Head) UnmarshalJSON ¶ added in v1.10.17
type JsonError ¶
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 ExtractRPCError ¶ added in v1.10.17
type Node ¶ added in v1.10.17
type Node interface { Dial(ctx context.Context) error Close() Verify(ctx context.Context, expectedChainID *big.Int) (err error) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error BatchCallContext(ctx context.Context, b []rpc.BatchElem) 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) HeaderByNumber(context.Context, *big.Int) (*types.Header, error) SuggestGasTipCap(ctx context.Context) (*big.Int, error) EthSubscribe(ctx context.Context, channel interface{}, args ...interface{}) (ethereum.Subscription, error) String() string }
type NullClient ¶
type NullClient struct {
// contains filtered or unexported fields
}
NullClient satisfies the Client but has no side effects
func NewNullClient ¶ added in v1.10.17
func NewNullClient(cid *big.Int, lggr logger.Logger) *NullClient
func (*NullClient) BatchCallContext ¶
func (*NullClient) BlockByNumber ¶
func (*NullClient) Call ¶
func (nc *NullClient) Call(result interface{}, method string, args ...interface{}) error
func (*NullClient) CallContext ¶
func (nc *NullClient) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
func (*NullClient) CallContract ¶
func (*NullClient) ChainID ¶
func (nc *NullClient) ChainID() *big.Int
func (*NullClient) Close ¶
func (nc *NullClient) Close()
func (*NullClient) EstimateGas ¶
func (*NullClient) FilterLogs ¶
func (nc *NullClient) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
func (*NullClient) GetERC20Balance ¶
func (*NullClient) GetEthBalance ¶
func (*NullClient) GetLINKBalance ¶
func (*NullClient) HeadByNumber ¶
func (*NullClient) HeaderByNumber ¶
func (*NullClient) PendingCodeAt ¶
func (*NullClient) PendingNonceAt ¶
func (*NullClient) SendTransaction ¶
func (nc *NullClient) SendTransaction(ctx context.Context, tx *types.Transaction) error
func (*NullClient) SubscribeFilterLogs ¶
func (nc *NullClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
func (*NullClient) SubscribeNewHead ¶
func (nc *NullClient) SubscribeNewHead(ctx context.Context, ch chan<- *Head) (ethereum.Subscription, error)
func (*NullClient) SuggestGasPrice ¶
func (*NullClient) SuggestGasTipCap ¶
func (*NullClient) TransactionReceipt ¶
type Pool ¶ added in v1.10.17
type Pool struct {
// contains filtered or unexported fields
}
Pool represents an abstraction over one or more primary nodes It is responsible for liveness checking and balancing queries across live nodes
func (*Pool) BatchCallContext ¶ added in v1.10.17
func (*Pool) BlockByNumber ¶ added in v1.10.17
func (*Pool) CallContext ¶ added in v1.10.17
func (*Pool) CallContract ¶ added in v1.10.17
func (*Pool) EstimateGas ¶ added in v1.10.17
func (*Pool) EthSubscribe ¶ added in v1.10.17
func (*Pool) FilterLogs ¶ added in v1.10.17
func (*Pool) HeaderByNumber ¶ added in v1.10.17
bind.ContractBackend methods
func (*Pool) PendingCodeAt ¶ added in v1.10.17
func (*Pool) PendingNonceAt ¶ added in v1.10.17
func (*Pool) SendTransaction ¶ added in v1.10.17
Wrapped Geth client methods
func (*Pool) SubscribeFilterLogs ¶ added in v1.10.17
func (p *Pool) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
func (*Pool) SuggestGasPrice ¶ added in v1.10.17
func (*Pool) SuggestGasTipCap ¶ added in v1.10.17
type SendError ¶
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 ¶
func NewFatalSendErrorS ¶
func NewSendError ¶
func NewSendErrorS ¶
func (*SendError) Fatal ¶
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 ¶
IsFeeTooHigh is an optimism-specific error returned when total fee is too high
func (*SendError) IsFeeTooLow ¶
IsFeeTooLow is an optimism-specific error returned when total fee is too low
func (*SendError) IsInsufficientEth ¶
func (*SendError) IsNonceTooLowError ¶
func (*SendError) IsReplacementUnderpriced ¶
IsReplacementUnderpriced indicates that a transaction already exists in the mempool with this nonce but a different gas price or payload
func (*SendError) IsTemporarilyUnderpriced ¶
func (*SendError) IsTerminallyUnderpriced ¶
IsTerminallyUnderpriced indicates that this transaction is so far underpriced the node won't even accept it in the first place
func (*SendError) IsTooExpensive ¶
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 ¶
Geth/parity returns this error if the transaction is already in the node's mempool
type SendOnlyNode ¶ added in v1.10.17
type SendOnlyNode interface { Dial(context.Context) error Verify(ctx context.Context, expectedChainID *big.Int) (err error) SendTransaction(ctx context.Context, tx *types.Transaction) error BatchCallContext(ctx context.Context, b []rpc.BatchElem) error String() string }
SendOnlyNode represents one ethereum node used as a sendonly
func NewSendOnlyNode ¶ added in v1.10.17
type Subscription ¶
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`.
type UntrustedBytes ¶ added in v1.10.17
type UntrustedBytes []byte
This data can contain anything and is submitted by user on-chain, so we must be extra careful how we interact with it
func (UntrustedBytes) SafeByteSlice ¶ added in v1.10.17
func (ary UntrustedBytes) SafeByteSlice(start int, end int) ([]byte, error)
SafeByteSlice returns an error on out of bounds access to a byte array, where a normal slice would panic instead