types

package
v0.0.0-...-3c6a880 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: MIT Imports: 32 Imported by: 7

Documentation

Index

Constants

View Source
const (
	Finalized   = Confirmations(-1)
	Unconfirmed = Confirmations(0)
)
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.8/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 Backend

type Backend interface {
	Close() error
	Commit() common.Hash
	Rollback()
	Fork(parentHash common.Hash) error
	AdjustTime(adjustment time.Duration) error
	Client() simulated.Client
}

Interface which is satisfied by simulated.Backend. Defined here so that default geth behavior can be overridden in tests, and injected into our SimulatedBackend wrapper. This can be used to simulate rpc servers with quirky behavior that differs from geth

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 Confirmations

type Confirmations int

type EIP55Address

type EIP55Address string

EIP55Address is a new type for string which persists an ethereum address in its original string representation which includes a leading 0x, and EIP55 checksum which is represented by the case of digits A-F.

func EIP55AddressFromAddress

func EIP55AddressFromAddress(a common.Address) EIP55Address

EIP55AddressFromAddress forces an address into EIP55Address format It is safe to panic on error since address.Hex() should ALWAYS generate EIP55Address-compatible hex strings

func MustEIP55Address

func MustEIP55Address(s string) EIP55Address

func NewEIP55Address

func NewEIP55Address(s string) (EIP55Address, error)

NewEIP55Address creates an EIP55Address from a string, an error is returned if:

1) There is no leading 0x 2) The length is wrong 3) There are any non hexadecimal characters 4) The checksum fails

func (EIP55Address) Address

func (a EIP55Address) Address() common.Address

Address returns EIP55Address as a go-ethereum Address type

func (EIP55Address) Big

func (a EIP55Address) Big() *big.Int

Big returns a big.Int representation

func (EIP55Address) Bytes

func (a EIP55Address) Bytes() []byte

Bytes returns the raw bytes

func (EIP55Address) Format

func (a EIP55Address) Format(s fmt.State, c rune)

Format implements fmt.Formatter

func (EIP55Address) Hash

func (a EIP55Address) Hash() common.Hash

Hash returns the Hash

func (EIP55Address) Hex

func (a EIP55Address) Hex() string

Hex is identical to String but makes the API similar to common.Address

func (EIP55Address) IsZero

func (a EIP55Address) IsZero() bool

IsZeroAddress determines whether the address is 0x0000... or not

func (*EIP55Address) Scan

func (a *EIP55Address) Scan(value interface{}) error

Scan reads the database value and returns an instance.

func (EIP55Address) String

func (a EIP55Address) String() string

String implements the stringer interface and is used also by the logger.

func (*EIP55Address) UnmarshalJSON

func (a *EIP55Address) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a hash from a JSON string

func (*EIP55Address) UnmarshalText

func (a *EIP55Address) UnmarshalText(input []byte) error

UnmarshalText parses a hash from plain text

func (EIP55Address) Value

func (a EIP55Address) Value() (driver.Value, error)

Value returns this instance serialized for database storage.

type EIP55AddressCollection

type EIP55AddressCollection []EIP55Address

EIP55AddressCollection is an array of EIP55Addresses.

func (*EIP55AddressCollection) Scan

func (c *EIP55AddressCollection) Scan(value interface{}) error

Scan reads the database value and returns an instance.

func (EIP55AddressCollection) Value

Value returns this instance serialized for database storage.

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    sql.NullInt64
	ParentHash       common.Hash
	Parent           atomic.Pointer[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
	IsFinalized      atomic.Bool
}

Head represents a BlockNumber, BlockHash.

func NewHead

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

NewHead returns a Head instance.

func (*Head) AsSlice

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

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

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() chains.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() chains.Head[common.Hash]

func (*Head) GetParentHash

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

func (*Head) GetTimestamp

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

func (*Head) GetTotalDifficulty

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

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

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) HeadAtHeight

func (h *Head) HeadAtHeight(blockNum int64) (chains.Head[common.Hash], error)

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

func (h *Head) IsValid() bool

func (*Head) LatestFinalizedHead

func (h *Head) LatestFinalizedHead() chains.Head[common.Hash]

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) SetFromHeader

func (h *Head) SetFromHeader(header *types.Header)

func (*Head) String

func (h *Head) String() string

String returns a string representation of this head

func (*Head) ToChainAgnosticHead

func (h *Head) ToChainAgnosticHead() *chainagnostictypes.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

type Nonce int64

Nonce wraps an EVM nonce into a stringable type

func (Nonce) Int64

func (n Nonce) Int64() int64

func (Nonce) String

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"`
	RevertReason      []byte          `json:"revertReason,omitempty"` // Only provided by Hedera
}

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

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

func (*Receipt) GetBlockNumber

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

func (*Receipt) GetFeeUsed

func (r *Receipt) GetFeeUsed() uint64

func (*Receipt) GetRevertReason

func (r *Receipt) GetRevertReason() *string

func (*Receipt) GetStatus

func (r *Receipt) GetStatus() uint64

func (*Receipt) GetTransactionIndex

func (r *Receipt) GetTransactionIndex() uint

func (*Receipt) GetTxHash

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

Jump to

Keyboard shortcuts

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