system

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: MIT Imports: 21 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

This section is empty.

Types

type Chain

type Chain interface {
	ID() types.ChainID
	Wallets(ctx context.Context) ([]Wallet, error)
	ContractsRegistry() interfaces.ContractsRegistry
	SupportsEIP(ctx context.Context, eip uint64) bool

	GasPrice(ctx context.Context) (*big.Int, error)
	GasLimit(ctx context.Context, tx TransactionData) (uint64, error)
	PendingNonceAt(ctx context.Context, address common.Address) (uint64, error)
}

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 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) 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() []Chain
}

InteropSet provides access to L2 chains in an interop environment

type InteropSystem

type InteropSystem interface {
	System
	InteropSet() InteropSet
}

InteropSystem extends System with interoperability features

type LowLevelChain added in v1.11.2

type LowLevelChain interface {
	Chain
	RPCURL() string
	Client() (*ethclient.Client, error)
}

LowLevelChain is a Chain that gives direct access to the low level RPC client.

type LowLevelSystem added in v1.11.2

type LowLevelSystem = genSystem[LowLevelChain]

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 System

type System = genSystem[Chain]

System represents a complete Optimism system with L1 and L2 chains

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
}

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) 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]
	Balance() types.Balance
	Nonce() uint64

	TransactionProcessor
}

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

Jump to

Keyboard shortcuts

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