types

package
v1.13.3 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const FunctionSelectorLength = 4

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

View Source
const LegacyTxType = 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 = errors.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 added in v1.2.0

func MustGetABI(json string) abi.ABI

func ReceiptIndicatesRunLogFulfillment added in v1.2.0

func ReceiptIndicatesRunLogFulfillment(txr types.Receipt) bool

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

Types

type AddressArray added in v1.13.0

type AddressArray []common.Address

func (*AddressArray) Scan added in v1.13.0

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

type Block added in v1.10.0

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 added in v1.10.0

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

MarshalJSON implements json marshalling for Block

func (*Block) UnmarshalJSON added in v1.10.0

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

UnmarshalJSON unmarshals to a Block

type ChainCfg

type ChainCfg struct {
	BlockHistoryEstimatorBlockDelay                null.Int
	BlockHistoryEstimatorBlockHistorySize          null.Int
	BlockHistoryEstimatorEIP1559FeeCapBufferBlocks null.Int
	ChainType                                      null.String
	EthTxReaperThreshold                           *models.Duration
	EthTxResendAfterThreshold                      *models.Duration
	EvmEIP1559DynamicFees                          null.Bool
	EvmFinalityDepth                               null.Int
	EvmGasBumpPercent                              null.Int
	EvmGasBumpTxDepth                              null.Int
	EvmGasBumpWei                                  *assets.Wei
	EvmGasFeeCapDefault                            *assets.Wei
	EvmGasLimitDefault                             null.Int
	EvmGasLimitMax                                 null.Int
	EvmGasLimitMultiplier                          null.Float
	EvmGasLimitOCRJobType                          null.Int
	EvmGasLimitDRJobType                           null.Int
	EvmGasLimitVRFJobType                          null.Int
	EvmGasLimitFMJobType                           null.Int
	EvmGasLimitKeeperJobType                       null.Int
	EvmGasPriceDefault                             *assets.Wei
	EvmGasTipCapDefault                            *assets.Wei
	EvmGasTipCapMinimum                            *assets.Wei
	EvmHeadTrackerHistoryDepth                     null.Int
	EvmHeadTrackerMaxBufferSize                    null.Int
	EvmHeadTrackerSamplingInterval                 *models.Duration
	EvmLogBackfillBatchSize                        null.Int
	EvmLogPollInterval                             *models.Duration
	EvmLogKeepBlocksDepth                          null.Int
	EvmMaxGasPriceWei                              *assets.Wei
	EvmNonceAutoSync                               null.Bool
	EvmUseForwarders                               null.Bool
	EvmRPCDefaultBatchSize                         null.Int
	FlagsContractAddress                           null.String
	GasEstimatorMode                               null.String
	KeySpecific                                    map[string]ChainCfg
	LinkContractAddress                            null.String
	OperatorFactoryAddress                         null.String
	MinIncomingConfirmations                       null.Int
	MinimumContractPayment                         *assets.Link
	OCRObservationTimeout                          *models.Duration
	NodeNoNewHeadsThreshold                        *models.Duration
}

https://app.shortcut.com/chainlinklabs/story/33622/remove-legacy-config

func (*ChainCfg) Scan

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

func (*ChainCfg) Value

func (c *ChainCfg) Value() (driver.Value, error)

type ChainConfigORM added in v1.1.0

type ChainConfigORM interface {
	StoreString(chainID utils.Big, key, val string) error
	Clear(chainID utils.Big, key string) error
}

https://app.shortcut.com/chainlinklabs/story/33622/remove-legacy-config

type DBChain added in v1.5.0

type DBChain = chains.DBChain[utils.Big, *ChainCfg]

type FunctionSelector added in v1.2.0

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.2.0

func BytesToFunctionSelector(b []byte) FunctionSelector

BytesToFunctionSelector converts the given bytes to a FunctionSelector.

func HexToFunctionSelector added in v1.2.0

func HexToFunctionSelector(s string) FunctionSelector

HexToFunctionSelector converts the given string to a FunctionSelector.

func (FunctionSelector) Bytes added in v1.2.0

func (f FunctionSelector) Bytes() []byte

Bytes returns the FunctionSelector as a byte slice

func (FunctionSelector) MarshalJSON added in v1.2.0

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

MarshalJSON returns the JSON encoding of f

func (*FunctionSelector) Scan added in v1.2.0

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

Scan returns the selector from its serialization in the database

func (*FunctionSelector) SetBytes added in v1.2.0

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

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

func (FunctionSelector) String added in v1.2.0

func (f FunctionSelector) String() string

String returns the FunctionSelector as a string type.

func (*FunctionSelector) UnmarshalJSON added in v1.2.0

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

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

func (FunctionSelector) Value added in v1.2.0

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

Value returns this instance serialized for database storage

type HashArray added in v1.13.0

type HashArray []common.Hash

func (*HashArray) Scan added in v1.13.0

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       *utils.Big
	Timestamp        time.Time
	CreatedAt        time.Time
	BaseFeePerGas    *assets.Wei
	ReceiptsRoot     common.Hash
	TransactionsRoot common.Hash
	StateRoot        common.Hash
	Difficulty       *utils.Big
	TotalDifficulty  *utils.Big
}

Head represents a BlockNumber, BlockHash.

func NewHead added in v1.2.0

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.2.0

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

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

func (*Head) ChainLength added in v1.2.0

func (h *Head) ChainLength() uint32

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

func (*Head) ChainString added in v1.2.0

func (h *Head) ChainString() string

func (*Head) EarliestInChain added in v1.2.0

func (h *Head) EarliestInChain() *Head

EarliestInChain recurses through parents until it finds the earliest one

func (*Head) GreaterThan added in v1.2.0

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) HashAtHeight added in v1.2.0

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 added in v1.2.0

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) MarshalJSON added in v1.2.0

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

func (*Head) NextInt added in v1.2.0

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

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

func (Head) String added in v1.2.0

func (h Head) String() string

String returns a string representation of this head

func (*Head) ToInt added in v1.2.0

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

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

func (*Head) UnmarshalJSON added in v1.2.0

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

type Log added in v1.2.0

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 added in v1.2.0

func FromGethLog(gl *gethTypes.Log) *Log

FromGethLog converts a gethTypes.Log to a Log

func (Log) MarshalJSON added in v1.2.0

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

MarshalJSON marshals as JSON.

func (*Log) UnmarshalJSON added in v1.2.0

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

UnmarshalJSON unmarshals from JSON.

type NewNode added in v1.1.0

type NewNode struct {
	Name       string      `json:"name"`
	EVMChainID utils.Big   `json:"evmChainId"`
	WSURL      null.String `json:"wsURL" db:"ws_url"`
	HTTPURL    null.String `json:"httpURL" db:"http_url"`
	SendOnly   bool        `json:"sendOnly"`
}

https://app.shortcut.com/chainlinklabs/story/33622/remove-legacy-config

type Node

type Node struct {
	ID         int32
	Name       string
	EVMChainID utils.Big
	WSURL      null.String `db:"ws_url"`
	HTTPURL    null.String `db:"http_url"`
	SendOnly   bool
	CreatedAt  time.Time
	UpdatedAt  time.Time
	// State doesn't exist in the DB, it's used to hold an in-memory state for
	// rendering
	State string `db:"-"`
}

TODO: https://app.shortcut.com/chainlinklabs/story/33622/remove-legacy-config

type ORM added in v1.1.0

type ORM interface {
	Chain(id utils.Big, qopts ...pg.QOpt) (chain DBChain, err error)
	Chains(offset, limit int, qopts ...pg.QOpt) ([]DBChain, int, error)
	CreateChain(id utils.Big, config *ChainCfg, qopts ...pg.QOpt) (DBChain, error)
	UpdateChain(id utils.Big, enabled bool, config *ChainCfg, qopts ...pg.QOpt) (DBChain, error)
	DeleteChain(id utils.Big, qopts ...pg.QOpt) error
	GetChainsByIDs(ids []utils.Big) (chains []DBChain, err error)
	EnabledChains(...pg.QOpt) ([]DBChain, error)

	CreateNode(data Node, qopts ...pg.QOpt) (Node, error)
	DeleteNode(id int32, qopts ...pg.QOpt) error
	GetNodesByChainIDs(chainIDs []utils.Big, qopts ...pg.QOpt) (nodes []Node, err error)
	NodeNamed(string, ...pg.QOpt) (Node, error)
	Nodes(offset, limit int, qopts ...pg.QOpt) ([]Node, int, error)
	NodesForChain(chainID utils.Big, offset, limit int, qopts ...pg.QOpt) ([]Node, int, error)

	ChainConfigORM

	SetupNodes([]Node, []utils.Big) error
	EnsureChains([]utils.Big, ...pg.QOpt) error
}

type Receipt added in v1.2.0

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 added in v1.2.0

func FromGethReceipt(gr *gethTypes.Receipt) *Receipt

FromGethReceipt converts a gethTypes.Receipt to a Receipt

func (Receipt) IsUnmined added in v1.2.0

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 added in v1.2.0

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 added in v1.2.0

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 added in v1.5.0

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

func (*Receipt) UnmarshalJSON added in v1.2.0

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

UnmarshalJSON unmarshals from JSON.

func (*Receipt) Value added in v1.5.0

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

type Transaction added in v1.10.0

type Transaction struct {
	GasPrice             *assets.Wei
	GasLimit             uint32
	MaxFeePerGas         *assets.Wei
	MaxPriorityFeePerGas *assets.Wei
	Type                 TxType
	Hash                 common.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) UnmarshalJSON added in v1.10.0

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

UnmarshalJSON unmarshals a Transaction

type TxType added in v1.10.0

type TxType uint8

func (*TxType) UnmarshalJSON added in v1.10.0

func (txt *TxType) UnmarshalJSON(data []byte) error

NOTE: Need to roll our own unmarshaller since geth's hexutil.Uint64 does not handle double zeroes e.g. 0x00

type UntrustedBytes added in v1.2.0

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.2.0

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

Jump to

Keyboard shortcuts

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