etherman

package
v0.10.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: Apache-2.0, MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExtraParamFieldName = "OpNodeURL"
)

Variables

View Source
var (
	// ErrGasRequiredExceedsAllowance gas required exceeds the allowance
	ErrGasRequiredExceedsAllowance = errors.New("gas required exceeds allowance")
	// ErrContentLengthTooLarge content length is too large
	ErrContentLengthTooLarge = errors.New("content length too large")
	// ErrTimestampMustBeInsideRange Timestamp must be inside range
	ErrTimestampMustBeInsideRange = errors.New("timestamp must be inside range")
	// ErrInsufficientAllowance insufficient allowance
	ErrInsufficientAllowance = errors.New("insufficient allowance")
	// ErrBothGasPriceAndMaxFeeGasAreSpecified both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified
	ErrBothGasPriceAndMaxFeeGasAreSpecified = errors.New(
		"both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified",
	)
	// ErrMaxFeeGasAreSpecifiedButLondonNotActive maxFeePerGas or maxPriorityFeePerGas
	// specified but london fork is not active yet
	ErrMaxFeeGasAreSpecifiedButLondonNotActive = errors.New(
		"maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet",
	)
	// ErrNoSigner no signer to authorize the transaction with
	ErrNoSigner = errors.New("no signer to authorize the transaction with")
	// ErrMissingTrieNode means that a node is missing on the trie
	ErrMissingTrieNode = errors.New("missing trie node")
	// ErrNotFound is used when the object is not found
	ErrNotFound = errors.New("not found")
	// ErrPrivateKeyNotFound used when the provided sender does not have a private key registered to be used
	ErrPrivateKeyNotFound = errors.New("can't find sender private key to sign tx")
)
View Source
var (
	ErrNotImplemented = errors.New("not implemented")
)

Functions

func DialWithRetry

DialWithRetry attempts to connect to an Ethereum client with retries and exponential backoff. It returns an EthClienter on success or an error if all attempts fail.

func IsErrNotFound

func IsErrNotFound(err error) bool

func NewRPCClient added in v0.1.0

NewRPCClient creates a new RPC client based on the provided configuration. It supports both basic RPC mode and OPNode mode. In basic mode, it simply creates a client with the given URL. In OPNode mode, it creates a client that uses the OPNode client to get the finalized block.

func NewRPCClientModeOp added in v0.1.0

NewRPCClientModeOp creates a new RPC client that uses the OPNode client to get the finalized block

func TryParseError

func TryParseError(err error) (error, bool)

Types

type BlockHeadersResult

type BlockHeadersResult struct {
	// Headers contiene los block headers recuperados exitosamente, mapeados por block number
	Headers map[uint64]*aggkittypes.BlockHeader

	// Errors contiene los errores de recuperación, mapeados por block number
	Errors map[uint64]error
}

BlockHeadersResult contiene los resultados de la recuperación de block headers, separando los exitosos de los fallidos

func NewBlockHeadersResult

func NewBlockHeadersResult() *BlockHeadersResult

NewBlockHeadersResult crea un nuevo BlockHeadersResult

func RetrieveBlockHeaders added in v0.8.0

func RetrieveBlockHeaders(ctx context.Context,
	log aggkitcommon.Logger,
	ethClient aggkittypes.BaseEthereumClienter,
	rpcClient aggkittypes.RPCClienter,
	blockNumbers []uint64,
	maxConcurrency int) (*BlockHeadersResult, error)

RetrieveBlockHeaders retrieves block headers for the given block numbers using batch requests if rpcClient is provided. Returns a BlockHeadersResult with successful headers and individual errors. The returned error is only for catastrophic failures (context cancelled, etc.)

func RetrieveBlockHeadersBatch added in v0.8.0

func RetrieveBlockHeadersBatch(ctx context.Context,
	log aggkitcommon.Logger,
	rpcClient aggkittypes.RPCClienter,
	blockNumbers []uint64,
	maxConcurrency int) (*BlockHeadersResult, error)

RetrieveBlockHeadersBatch retrieves block headers for the given block numbers using batch requests with concurrency control. Returns a BlockHeadersResult with successful headers and individual errors.

func RetrieveBlockHeadersLegacy added in v0.8.0

func RetrieveBlockHeadersLegacy(ctx context.Context,
	log aggkitcommon.Logger,
	ethClient aggkittypes.BaseEthereumClienter,
	blockNumbers []uint64,
	maxConcurrency int) (*BlockHeadersResult, error)

RetrieveBlockHeadersLegacy retrieves block headers for the given block numbers using individual requests this is used in simulated environments where batch requests are not supported Returns a BlockHeadersResult with successful headers and individual errors for failed blocks

func (*BlockHeadersResult) AddError

func (r *BlockHeadersResult) AddError(blockNumber uint64, err error)

AddError añade un error para un block number específico

func (*BlockHeadersResult) AddHeader

func (r *BlockHeadersResult) AddHeader(blockNumber uint64, header *aggkittypes.BlockHeader)

AddHeader añade un header exitoso al resultado

func (*BlockHeadersResult) AreAllErrorsNotFound

func (r *BlockHeadersResult) AreAllErrorsNotFound() bool

func (*BlockHeadersResult) ComposeError

func (r *BlockHeadersResult) ComposeError() error

ComposeError returns a single error summarizing the errors in the result, or nil if there are no errors

func (*BlockHeadersResult) GetOrderedHeaders

func (r *BlockHeadersResult) GetOrderedHeaders(blockNumbers []uint64) []*aggkittypes.BlockHeader

GetOrderedHeaders retorna los headers en el orden de blockNumbers solicitados, solo para los bloques que se recuperaron exitosamente

func (*BlockHeadersResult) ListBlocksNumberNotFound

func (r *BlockHeadersResult) ListBlocksNumberNotFound() []uint64

ListBlocksNumberNotFound returns the list of not found block numbers in the result ordered by block number

func (*BlockHeadersResult) Merge

func (r *BlockHeadersResult) Merge(other *BlockHeadersResult)

Merge combina otro BlockHeadersResult en este

func (*BlockHeadersResult) PartialSuccess

func (r *BlockHeadersResult) PartialSuccess() bool

PartialSuccess retorna true si al menos un bloque se recuperó exitosamente

func (*BlockHeadersResult) Success

func (r *BlockHeadersResult) Success() bool

Success retorna true si todos los bloques se recuperaron exitosamente

type DefaultEthClient

type DefaultEthClient struct {
	aggkittypes.EthereumClienter
	aggkittypes.RPCClienter

	// If true, the block Hash is getted from JSON RPC
	// if false, the block Hash is getted from go-ethereum RLP hashing of header
	HashFromJSON bool
	// contains filtered or unexported fields
}

func NewDefaultEthClient

This function is for legacy code that doesn't use logger

func (*DefaultEthClient) BatchCallContext

func (c *DefaultEthClient) BatchCallContext(ctx context.Context, b []rpc.BatchElem) error

func (*DefaultEthClient) Call

func (c *DefaultEthClient) Call(result any, method string, args ...any) error

func (*DefaultEthClient) CallContext

func (c *DefaultEthClient) CallContext(ctx context.Context,
	result interface{}, method string, args ...interface{}) error

func (*DefaultEthClient) CustomBlockNumber

func (c *DefaultEthClient) CustomBlockNumber(ctx context.Context, number aggkittypes.BlockName) (uint64, error)

func (*DefaultEthClient) CustomHeaderByNumber

func (c *DefaultEthClient) CustomHeaderByNumber(ctx context.Context,
	number *aggkittypes.BlockNumberFinality) (*aggkittypes.BlockHeader, error)

type OpNodeClienter added in v0.1.0

type OpNodeClienter interface {
	FinalizedL2Block() (*opnode.BlockInfo, error)
}

type RPCOpNodeDecorator added in v0.1.0

type RPCOpNodeDecorator struct {
	aggkittypes.EthClienter
	OpNodeClient OpNodeClienter
}

RPCOpNodeDecorator is a decorator for the ethclient.Client that intercepts calls to the HeaderByNumber method and if the block number is the FinalizedBlockNumber, it will ask the OpNodeClient for the finalized block instead of asking the ethclient.Client

func NewRPCOpNodeDecorator added in v0.1.0

func NewRPCOpNodeDecorator(client aggkittypes.EthClienter, opNodeClient OpNodeClienter) *RPCOpNodeDecorator

func (*RPCOpNodeDecorator) HeaderByNumber added in v0.1.0

func (f *RPCOpNodeDecorator) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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