system

package
v1.13.5 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultGasLimitMarginPercent = 20 // 20% margin for gas limit
	DefaultFeeCapMultiplier      = 2  // 2x gas price for fee cap
)

Default values for gas calculations

Variables

This section is empty.

Functions

func NewWallet added in v1.13.0

func NewWallet(pk string, addr types.Address, chain Chain) (*wallet, error)

func NewWalletV2 added in v1.13.0

func NewWalletV2(ctx context.Context, rpcURL string, priv *ecdsa.PrivateKey, clCfg *sources.EthClientConfig, log log.Logger) (*walletV2, error)

Types

type AddressMap added in v1.12.2

type AddressMap descriptors.AddressMap

type Chain

type Chain interface {
	ID() types.ChainID
	Nodes() []Node // The node at index 0 will always be the sequencer node
	Config() (*params.ChainConfig, error)

	// The wallets and addresses below are for use on the chain that the instance represents.
	// If the instance also implements L2Chain, then the wallets and addresses below are still for the L2.
	Wallets() WalletMap
	Addresses() AddressMap
}

Chain represents an Ethereum chain (L1 or L2)

type EthClient added in v1.11.2

type EthClient interface {
	SendTransaction(ctx context.Context, tx *types.Transaction) error
}

EthClient defines the interface for interacting with Ethereum node

type EthReceipt added in v1.12.2

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

EthReceipt is the default implementation of Receipt that wraps types.Receipt

func (*EthReceipt) BlockNumber added in v1.12.2

func (t *EthReceipt) BlockNumber() *big.Int

func (*EthReceipt) Logs added in v1.12.2

func (t *EthReceipt) Logs() []*types.Log

func (*EthReceipt) TxHash added in v1.12.2

func (t *EthReceipt) TxHash() common.Hash

type EthTx added in v1.11.2

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

EthTx is the default implementation of Transaction that wraps types.Transaction

func (*EthTx) AccessList added in v1.12.2

func (t *EthTx) AccessList() types.AccessList

func (*EthTx) Data added in v1.11.2

func (t *EthTx) Data() []byte

func (*EthTx) From added in v1.11.2

func (t *EthTx) From() common.Address

func (*EthTx) Hash added in v1.11.2

func (t *EthTx) Hash() common.Hash

func (*EthTx) Raw added in v1.11.2

func (t *EthTx) Raw() *types.Transaction

func (*EthTx) To added in v1.11.2

func (t *EthTx) To() *common.Address

func (*EthTx) Type added in v1.11.2

func (t *EthTx) Type() uint8

func (*EthTx) Value added in v1.11.2

func (t *EthTx) Value() *big.Int

type InteropSet

type InteropSet interface {
	L2s() []L2Chain
}

InteropSet provides access to L2 chains in an interop environment

type InteropSystem

type InteropSystem interface {
	System
	InteropSet() InteropSet
	Supervisor(context.Context) (Supervisor, error)
}

InteropSystem extends System with interoperability features

type L2Chain added in v1.12.2

type L2Chain interface {
	Chain

	// The wallets and addresses below are for use on the L1 chain that this L2Chain instance settles to.
	L1Addresses() AddressMap
	L1Wallets() WalletMap
}

type Node added in v1.12.0

type Node interface {
	Name() string
	GasPrice(ctx context.Context) (*big.Int, error)
	GasLimit(ctx context.Context, tx TransactionData) (uint64, error)
	PendingNonceAt(ctx context.Context, address common.Address) (uint64, error)
	BlockByNumber(ctx context.Context, number *big.Int) (eth.BlockInfo, error)
	ContractsRegistry() interfaces.ContractsRegistry
	SupportsEIP(ctx context.Context, eip uint64) bool
	RPCURL() string
	Client() (*sources.EthClient, error)
	GethClient() (*ethclient.Client, error)
}

type RawTransaction added in v1.11.2

type RawTransaction interface {
	Raw() *coreTypes.Transaction
}

RawTransaction is an optional interface that can be implemented by a Transaction to provide access to the raw transaction data. It is currently necessary to perform processing operations (signing, sending) on the transaction. We would need to do better here.

type Receipt added in v1.12.2

type Receipt interface {
	BlockNumber() *big.Int
	Logs() []*coreTypes.Log
	TxHash() common.Hash
}

type Supervisor added in v1.12.2

type Supervisor interface {
	LocalUnsafe(context.Context, eth.ChainID) (eth.BlockID, error)
	CrossSafe(context.Context, eth.ChainID) (supervisorTypes.DerivedIDPair, error)
	Finalized(context.Context, eth.ChainID) (eth.BlockID, error)
	FinalizedL1(context.Context) (eth.BlockRef, error)
	CrossDerivedToSource(context.Context, eth.ChainID, eth.BlockID) (eth.BlockRef, error)
	UpdateLocalUnsafe(context.Context, eth.ChainID, eth.BlockRef) error
	UpdateLocalSafe(context.Context, eth.ChainID, eth.L1BlockRef, eth.BlockRef) error
	SuperRootAtTimestamp(context.Context, hexutil.Uint64) (eth.SuperRootResponse, error)
	AllSafeDerivedAt(context.Context, eth.BlockID) (derived map[eth.ChainID]eth.BlockID, err error)
	SyncStatus(context.Context) (eth.SupervisorSyncStatus, error)
}

Supervisor provides access to the query interface of the supervisor

type System

type System interface {
	Identifier() string
	L1() Chain
	L2s() []L2Chain
}

func NewSystemFromURL added in v1.11.1

func NewSystemFromURL(url string) (System, error)

type Transaction added in v1.11.2

type Transaction interface {
	Type() uint8
	Hash() common.Hash
	TransactionData
}

Transaction is the instantiated transaction object.

type TransactionData added in v1.11.2

type TransactionData interface {
	From() common.Address
	To() *common.Address
	Value() *big.Int
	Data() []byte
	AccessList() coreTypes.AccessList
}

TransactionData is the input for a transaction creation.

type TransactionProcessor added in v1.11.2

type TransactionProcessor interface {
	Sign(tx Transaction) (Transaction, error)
	Send(ctx context.Context, tx Transaction) error
}

TransactionProcessor is a helper interface for signing and sending transactions.

func NewEthTransactionProcessor added in v1.11.2

func NewEthTransactionProcessor(client *ethclient.Client, chainID *big.Int) TransactionProcessor

NewEthTransactionProcessor creates a new transaction processor with an ethclient

func NewTransactionProcessor added in v1.11.2

func NewTransactionProcessor(client EthClient, chainID *big.Int) TransactionProcessor

NewTransactionProcessor creates a new transaction processor

type TxBuilder added in v1.11.2

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

TxBuilder helps construct Ethereum transactions

func NewTxBuilder added in v1.11.2

func NewTxBuilder(ctx context.Context, chain Chain, opts ...TxBuilderOption) *TxBuilder

NewTxBuilder creates a new transaction builder

func (*TxBuilder) BuildTx added in v1.11.2

func (b *TxBuilder) BuildTx(options ...TxOption) (Transaction, error)

BuildTx creates a new transaction, using the appropriate type for the network

type TxBuilderOption added in v1.11.2

type TxBuilderOption func(*TxBuilder)

TxBuilderOption is a function that configures a TxBuilder

func WithFeeCapMultiplier added in v1.11.2

func WithFeeCapMultiplier(multiplier uint64) TxBuilderOption

WithFeeCapMultiplier sets the multiplier for calculating fee cap from gas price

func WithGasLimitMargin added in v1.11.2

func WithGasLimitMargin(marginPercent uint64) TxBuilderOption

WithGasLimitMargin sets the margin percentage to add to estimated gas limit

func WithTxType added in v1.11.2

func WithTxType(txType uint8) TxBuilderOption

WithTxType sets the transaction type to use, overriding automatic detection

type TxOption added in v1.11.2

type TxOption func(*TxOpts)

TxOption is a function that configures TxOpts

func WithAccessList added in v1.11.2

func WithAccessList(accessList types.AccessList) TxOption

WithAccessList sets the access list for EIP-2930 transactions

func WithBlobCommitments added in v1.11.2

func WithBlobCommitments(commitments []kzg4844.Commitment) TxOption

WithBlobCommitments sets the blob commitments

func WithBlobHashes added in v1.11.2

func WithBlobHashes(hashes []common.Hash) TxOption

WithBlobHashes sets the blob hashes

func WithBlobProofs added in v1.11.2

func WithBlobProofs(proofs []kzg4844.Proof) TxOption

WithBlobProofs sets the blob proofs

func WithBlobs added in v1.11.2

func WithBlobs(blobs []kzg4844.Blob) TxOption

WithBlobs sets the blob transaction fields

func WithData added in v1.11.2

func WithData(data []byte) TxOption

WithData sets the transaction data

func WithFrom added in v1.11.2

func WithFrom(from common.Address) TxOption

WithFrom sets the sender address

func WithGasLimit added in v1.11.2

func WithGasLimit(gasLimit uint64) TxOption

WithGasLimit sets an explicit gas limit

func WithTo added in v1.11.2

func WithTo(to common.Address) TxOption

WithTo sets the recipient address

func WithValue added in v1.11.2

func WithValue(value *big.Int) TxOption

WithValue sets the transaction value

type TxOpts added in v1.11.2

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

TxOpts is a struct that holds all transaction options

func (*TxOpts) AccessList added in v1.12.2

func (opts *TxOpts) AccessList() types.AccessList

func (*TxOpts) Data added in v1.11.2

func (opts *TxOpts) Data() []byte

func (*TxOpts) From added in v1.11.2

func (opts *TxOpts) From() common.Address

func (*TxOpts) To added in v1.11.2

func (opts *TxOpts) To() *common.Address

func (*TxOpts) Validate added in v1.11.2

func (opts *TxOpts) Validate() error

Validate checks that all required fields are set and consistent

func (*TxOpts) Value added in v1.11.2

func (opts *TxOpts) Value() *big.Int

type Wallet added in v1.11.2

type Wallet interface {
	PrivateKey() types.Key
	Address() types.Address
	SendETH(to types.Address, amount types.Balance) types.WriteInvocation[any]
	InitiateMessage(chainID types.ChainID, target common.Address, message []byte) types.WriteInvocation[any]
	ExecuteMessage(identifier bindings.Identifier, sentMessage []byte) types.WriteInvocation[any]
	Balance() types.Balance
	Nonce() uint64

	TransactionProcessor
}

Wallet represents a chain wallet. In particular it can process transactions.

type WalletMap added in v1.12.2

type WalletMap map[string]Wallet

type WalletV2 added in v1.13.0

type WalletV2 interface {
	PrivateKey() *ecdsa.PrivateKey
	Address() common.Address
	Client() *sources.EthClient
	GethClient() *ethclient.Client
	Ctx() context.Context
}

WalletV2 is a temporary interface for integrating txplan and txintent

func NewWalletV2FromWalletAndChain added in v1.13.0

func NewWalletV2FromWalletAndChain(ctx context.Context, wallet Wallet, chain Chain) (WalletV2, error)

Directories

Path Synopsis
periphery

Jump to

Keyboard shortcuts

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