types

package
v2.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 26 Imported by: 9

Documentation

Index

Constants

View Source
const FunctionSelectorLength = 4

FunctionSelectorLength should always be a length of 4 as a byte.

View Source
const LegacyTxType = blocks.TxType(0x0)

Variables

View Source
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

View Source
var ErrMissingBlock = pkgerrors.New("missing block")
View Source
var WeiPerEth = new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)

WeiPerEth is amount of Wei currency units in one Eth.

Functions

func MustGetABI

func MustGetABI(json string) abi.ABI

func ReceiptIndicatesRunLogFulfillment

func ReceiptIndicatesRunLogFulfillment(txr types.Receipt) bool

ReceiptIndicatesRunLogFulfillment returns true if this tx receipt is the result of a fulfilled run log.

Types

type AddressArray

type AddressArray []common.Address

func (*AddressArray) Scan

func (a *AddressArray) Scan(src interface{}) error

type Block

type Block struct {
	Number        int64
	Hash          common.Hash
	ParentHash    common.Hash
	BaseFeePerGas *assets.Wei
	Timestamp     time.Time
	Transactions  []Transaction
}

Block represents an ethereum block This type is only used for the block history estimator, and can be expensive to unmarshal. Don't add unnecessary fields here.

func (Block) MarshalJSON

func (b Block) MarshalJSON() ([]byte, error)

MarshalJSON implements json marshalling for Block

func (*Block) UnmarshalJSON

func (b *Block) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals to a Block

type Configs

type Configs interface {
	Chains(ids ...string) ([]types.ChainStatus, int, error)
	Node(name string) (Node, error)
	Nodes(chainID string) (nodes []Node, err error)
	NodeStatus(name string) (types.NodeStatus, error)
}

type FunctionSelector

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

func BytesToFunctionSelector(b []byte) FunctionSelector

BytesToFunctionSelector converts the given bytes to a FunctionSelector.

func HexToFunctionSelector

func HexToFunctionSelector(s string) FunctionSelector

HexToFunctionSelector converts the given string to a FunctionSelector.

func (FunctionSelector) Bytes

func (f FunctionSelector) Bytes() []byte

Bytes returns the FunctionSelector as a byte slice

func (FunctionSelector) MarshalJSON

func (f FunctionSelector) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of f

func (*FunctionSelector) Scan

func (f *FunctionSelector) Scan(value interface{}) error

Scan returns the selector from its serialization in the database

func (*FunctionSelector) SetBytes

func (f *FunctionSelector) SetBytes(b []byte)

SetBytes sets the FunctionSelector to that of the given bytes (will trim).

func (FunctionSelector) String

func (f FunctionSelector) String() string

String returns the FunctionSelector as a string type.

func (*FunctionSelector) UnmarshalJSON

func (f *FunctionSelector) UnmarshalJSON(input []byte) error

UnmarshalJSON parses the raw FunctionSelector and sets the FunctionSelector type to the given input.

func (FunctionSelector) Value

func (f FunctionSelector) Value() (driver.Value, error)

Value returns this instance serialized for database storage

type HashArray

type HashArray []common.Hash

func (*HashArray) Scan

func (h *HashArray) Scan(src interface{}) error
type Head struct {
	ID               uint64
	Hash             common.Hash
	Number           int64
	L1BlockNumber    null.Int64
	ParentHash       common.Hash
	Parent           *Head
	EVMChainID       *ubig.Big
	Timestamp        time.Time
	CreatedAt        time.Time
	BaseFeePerGas    *assets.Wei
	ReceiptsRoot     common.Hash
	TransactionsRoot common.Hash
	StateRoot        common.Hash
	Difficulty       *big.Int
	TotalDifficulty  *big.Int
}

Head represents a BlockNumber, BlockHash.

func NewHead

func NewHead(number *big.Int, blockHash common.Hash, parentHash common.Hash, timestamp uint64, chainID *ubig.Big) Head

NewHead returns a Head instance.

func (*Head) AsSlice added in v2.8.0

func (h *Head) AsSlice(k int) (heads []*Head)

AsSlice returns a slice of heads up to length k len(heads) may be less than k if the available chain is not long enough

func (*Head) BlockDifficulty added in v2.8.0

func (h *Head) BlockDifficulty() *big.Int

func (*Head) BlockHash

func (h *Head) BlockHash() common.Hash

func (*Head) BlockNumber

func (h *Head) BlockNumber() int64

func (*Head) ChainHashes

func (h *Head) ChainHashes() []common.Hash

ChainHashes returns an array of block hashes by recursively looking up parents

func (*Head) ChainID added in v2.3.0

func (h *Head) ChainID() *big.Int

func (*Head) ChainLength

func (h *Head) ChainLength() uint32

ChainLength returns the length of the chain followed by recursively looking up parents

func (*Head) ChainString

func (h *Head) ChainString() string

func (*Head) EarliestHeadInChain

func (h *Head) EarliestHeadInChain() commontypes.Head[common.Hash]

EarliestHeadInChain recurses through parents until it finds the earliest one

func (*Head) EarliestInChain

func (h *Head) EarliestInChain() *Head

EarliestInChain recurses through parents until it finds the earliest one

func (*Head) GetParent

func (h *Head) GetParent() commontypes.Head[common.Hash]

func (*Head) GetParentHash added in v2.3.0

func (h *Head) GetParentHash() common.Hash

func (*Head) GetTimestamp added in v2.8.0

func (h *Head) GetTimestamp() time.Time

func (*Head) GreaterThan

func (h *Head) GreaterThan(r *Head) bool

GreaterThan compares BlockNumbers and returns true if the receiver BlockNumber is greater than the supplied BlockNumber

func (*Head) HasChainID added in v2.3.0

func (h *Head) HasChainID() bool

func (*Head) HashAtHeight

func (h *Head) HashAtHeight(blockNum int64) common.Hash

HashAtHeight returns the hash of the block at the given height, if it is in the chain. If not in chain, returns the zero hash

func (*Head) IsInChain

func (h *Head) IsInChain(blockHash common.Hash) bool

IsInChain returns true if the given hash matches the hash of a head in the chain

func (*Head) IsValid added in v2.3.0

func (h *Head) IsValid() bool

func (*Head) MarshalJSON

func (h *Head) MarshalJSON() ([]byte, error)

func (*Head) NextInt

func (h *Head) NextInt() *big.Int

NextInt returns the next BlockNumber as big.int, or nil if nil to represent latest.

func (*Head) String

func (h *Head) String() string

String returns a string representation of this head

func (*Head) ToInt

func (h *Head) ToInt() *big.Int

ToInt return the height as a *big.Int. Also handles nil by returning nil.

func (*Head) UnmarshalJSON

func (h *Head) UnmarshalJSON(bs []byte) error

type Log

type Log struct {
	Address     common.Address `json:"address"`
	Topics      []common.Hash  `json:"topics"`
	Data        []byte         `json:"data"`
	BlockNumber uint64         `json:"blockNumber"`
	TxHash      common.Hash    `json:"transactionHash"`
	TxIndex     uint           `json:"transactionIndex"`
	BlockHash   common.Hash    `json:"blockHash"`
	Index       uint           `json:"logIndex"`
	Removed     bool           `json:"removed"`
}

Log represents a contract log event.

Copied from go-ethereum: https://github.com/ethereum/go-ethereum/blob/ce9a289fa48e0d2593c4aaa7e207c8a5dd3eaa8a/core/types/log.go

We use our own version because Geth's version specifies various gencodec:"required" fields which cause unhelpful errors when unmarshalling from an empty JSON object which can happen in the batch fetcher.

func FromGethLog

func FromGethLog(gl *gethTypes.Log) *Log

FromGethLog converts a gethTypes.Log to a Log

func (Log) MarshalJSON

func (l Log) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*Log) UnmarshalJSON

func (l *Log) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type Node

type Node struct {
	Name       string
	EVMChainID ubig.Big
	WSURL      null.String
	HTTPURL    null.String
	SendOnly   bool
	Order      int32

	State string
}

type Nonce added in v2.1.0

type Nonce int64

Nonce wraps an EVM nonce into a stringable type

func GenerateNextNonce added in v2.7.0

func GenerateNextNonce(prev Nonce) Nonce

func (Nonce) Int64 added in v2.1.0

func (n Nonce) Int64() int64

func (Nonce) String added in v2.1.0

func (n Nonce) String() string

type Receipt

type Receipt struct {
	PostState         []byte          `json:"root"`
	Status            uint64          `json:"status"`
	CumulativeGasUsed uint64          `json:"cumulativeGasUsed"`
	Bloom             gethTypes.Bloom `json:"logsBloom"`
	Logs              []*Log          `json:"logs"`
	TxHash            common.Hash     `json:"transactionHash"`
	ContractAddress   common.Address  `json:"contractAddress"`
	GasUsed           uint64          `json:"gasUsed"`
	BlockHash         common.Hash     `json:"blockHash,omitempty"`
	BlockNumber       *big.Int        `json:"blockNumber,omitempty"`
	TransactionIndex  uint            `json:"transactionIndex"`
}

Receipt represents an ethereum receipt.

Copied from go-ethereum: https://github.com/ethereum/go-ethereum/blob/ce9a289fa48e0d2593c4aaa7e207c8a5dd3eaa8a/core/types/receipt.go#L50

We use our own version because Geth's version specifies various gencodec:"required" fields which cause unhelpful errors when unmarshalling from an empty JSON object which can happen in the batch fetcher.

func FromGethReceipt

func FromGethReceipt(gr *gethTypes.Receipt) *Receipt

FromGethReceipt converts a gethTypes.Receipt to a Receipt

func (*Receipt) GetBlockHash added in v2.2.0

func (r *Receipt) GetBlockHash() common.Hash

func (*Receipt) GetBlockNumber added in v2.2.0

func (r *Receipt) GetBlockNumber() *big.Int

func (*Receipt) GetFeeUsed added in v2.2.0

func (r *Receipt) GetFeeUsed() uint64

func (*Receipt) GetStatus added in v2.2.0

func (r *Receipt) GetStatus() uint64

func (*Receipt) GetTransactionIndex added in v2.2.0

func (r *Receipt) GetTransactionIndex() uint

func (*Receipt) GetTxHash added in v2.2.0

func (r *Receipt) GetTxHash() common.Hash

func (*Receipt) IsUnmined

func (r *Receipt) IsUnmined() bool

IsUnmined returns true if the receipt is for a TX that has not been mined yet. Supposedly according to the spec this should never happen, but Parity does it anyway.

func (*Receipt) IsZero

func (r *Receipt) IsZero() bool

IsZero returns true if receipt is the zero receipt Batch calls to the RPC will return a pointer to an empty Receipt struct Easiest way to check if the receipt was missing is to see if the hash is 0x0 Real receipts will always have the TxHash set

func (Receipt) MarshalJSON

func (r Receipt) MarshalJSON() ([]byte, error)

MarshalJSON marshals Receipt as JSON. Copied from: https://github.com/ethereum/go-ethereum/blob/ce9a289fa48e0d2593c4aaa7e207c8a5dd3eaa8a/core/types/gen_receipt_json.go

func (*Receipt) Scan

func (r *Receipt) Scan(value interface{}) error

func (*Receipt) UnmarshalJSON

func (r *Receipt) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

func (*Receipt) Value

func (r *Receipt) Value() (driver.Value, error)

type Transaction

type Transaction struct {
	GasPrice             *assets.Wei `json:"gasPrice"`
	GasLimit             uint32      `json:"gasLimit"`
	MaxFeePerGas         *assets.Wei `json:"maxFeePerGas"`
	MaxPriorityFeePerGas *assets.Wei `json:"maxPriorityFeePerGas"`
	Type                 TxType      `json:"type"`
	Hash                 common.Hash `json:"hash"`
}

Transaction represents an ethereum transaction Use our own type because geth's type has validation failures on e.g. zero gas used, which can occur on other chains. This type is only used for the block history estimator, and can be expensive to unmarshal. Don't add unnecessary fields here.

func (*Transaction) MarshalJSON

func (t *Transaction) MarshalJSON() ([]byte, error)

func (*Transaction) UnmarshalJSON

func (t *Transaction) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a Transaction

type TxType

type TxType uint8

thin public wrapper for internal type of the same name and which has to be internal for JSON un/marshal'ing code gen consistency

type UntrustedBytes

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

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

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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