chain

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package chain provides a wrapper around the Anvil blockchain used for on-chain operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

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

func New

func New(
	ctx context.Context,
	logger *zap.Logger,
	id string,
	opts ChainOptions,
) (*Chain, error)

func (*Chain) InternalRPCURL

func (c *Chain) InternalRPCURL() string

func (*Chain) InternalWsURL

func (c *Chain) InternalWsURL() string

func (*Chain) RPCURL

func (c *Chain) RPCURL() string

func (*Chain) Stop

func (c *Chain) Stop(ctx context.Context) error

func (*Chain) WsURL

func (c *Chain) WsURL() string

type ChainOptions

type ChainOptions struct {
	Image string
}

type Contracts

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

Contracts provides read-only access to on-chain contract state for E2E tests. It wraps an ethclient connection and ABI bindings for the PayerReportManager contract deployed on the Anvil chain.

func NewContracts

func NewContracts(
	ctx context.Context,
	logger *zap.Logger,
	rpcURL string,
) (*Contracts, error)

NewContracts creates a Contracts reader connected to the given RPC URL. Contract addresses are loaded from the embedded Anvil configuration.

func (*Contracts) Close

func (c *Contracts) Close()

Close releases the ethclient connection.

func (*Contracts) GetPayerReport

func (c *Contracts) GetPayerReport(
	ctx context.Context,
	originatorNodeID uint32,
	index uint64,
) (*OnChainPayerReport, error)

GetPayerReport reads a single payer report from the chain by originator node ID and report index.

func (*Contracts) WaitForSettledReport

func (c *Contracts) WaitForSettledReport(
	ctx context.Context,
	originatorNodeID uint32,
	index uint64,
	checkFn func(*OnChainPayerReport) bool,
	description string,
) error

WaitForSettledReport polls the chain until checkFn returns true for a payer report at the given originator node ID and index, or the context is cancelled. Use this to wait for settlement to complete on-chain.

type OnChainPayerReport

type OnChainPayerReport struct {
	StartSequenceID     uint64
	EndSequenceID       uint64
	EndMinuteSinceEpoch uint32
	IsSettled           bool
	FeesSettled         *big.Int
	Offset              uint32
	PayersMerkleRoot    [32]byte
	NodeIDs             []uint32
}

OnChainPayerReport is a simplified view of on-chain payer report state for use in E2E test assertions.

Jump to

Keyboard shortcuts

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