evm

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddFundsEventID = "0xb28f49668e7e76dc96d7aabe5b7f63fecfbd1c3574774c05e8204e749fd96fbd"
)

Variables

This section is empty.

Functions

func CreateEVMClientFactory

func CreateEVMClientFactory() rpcpool.ClientFactory

CreateEVMClientFactory returns a ClientFactory for EVM endpoints

func CreateEVMHealthChecker

func CreateEVMHealthChecker(expectedChainID int64) rpcpool.HealthChecker

CreateEVMHealthChecker creates a health checker for EVM endpoints

func GetEthClientFromPool

func GetEthClientFromPool(endpoint *rpcpool.Endpoint) (*ethclient.Client, error)

GetEthClientFromPool extracts the ethclient.Client from a pool endpoint

Types

type Client

type Client struct {
	*common.BaseChainClient
	// contains filtered or unexported fields
}

Client implements the ChainClient interface for EVM chains

func NewClient

func NewClient(config *uregistrytypes.ChainConfig, database *db.DB, appConfig *config.Config, logger zerolog.Logger) (*Client, error)

NewClient creates a new EVM chain client

func (*Client) GetChainID

func (c *Client) GetChainID() int64

GetChainID returns the numeric chain ID

func (*Client) GetGasPrice

func (c *Client) GetGasPrice(ctx context.Context) (*big.Int, error)

GetGasPrice fetches the current gas price from the EVM chain Returns the price in Wei

func (*Client) GetLatestBlock

func (c *Client) GetLatestBlock(ctx context.Context) (uint64, error)

GetLatestBlock returns the latest block number

func (*Client) GetLatestBlockNumber

func (c *Client) GetLatestBlockNumber(ctx context.Context) (*big.Int, error)

GetLatestBlockNumber returns the latest block number with automatic failover

func (*Client) GetRPCURL

func (c *Client) GetRPCURL() string

GetRPCURL returns the first RPC endpoint URL from config or empty string

func (*Client) GetTransactionConfirmations

func (c *Client) GetTransactionConfirmations(ctx context.Context, txHash string) (uint64, error)

GetTransactionConfirmations returns the number of confirmations for a transaction

func (*Client) IsConfirmed

func (c *Client) IsConfirmed(ctx context.Context, txHash string) (bool, error)

IsConfirmed checks if a transaction has enough confirmations

func (*Client) IsHealthy

func (c *Client) IsHealthy() bool

IsHealthy checks if the EVM chain client is operational

func (*Client) SetVoteHandler

func (c *Client) SetVoteHandler(handler common.VoteHandler)

SetVoteHandler sets the vote handler for confirmed transactions

func (*Client) Start

func (c *Client) Start(ctx context.Context) error

Start initializes and starts the EVM chain client

func (*Client) Stop

func (c *Client) Stop() error

Stop gracefully shuts down the EVM chain client

func (*Client) WatchGatewayEvents

func (c *Client) WatchGatewayEvents(ctx context.Context, fromBlock uint64) (<-chan *common.GatewayEvent, error)

WatchGatewayEvents starts watching for gateway events

type EventParser

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

EventParser handles parsing of EVM gateway events

func NewEventParser

func NewEventParser(
	gatewayAddr ethcommon.Address,
	config *uregistrytypes.ChainConfig,
	logger zerolog.Logger,
) *EventParser

NewEventParser creates a new event parser

func (*EventParser) GetEventTopics

func (ep *EventParser) GetEventTopics() []ethcommon.Hash

GetEventTopics returns the configured event topics

func (*EventParser) ParseGatewayEvent

func (ep *EventParser) ParseGatewayEvent(log *types.Log) *common.GatewayEvent

ParseGatewayEvent parses a log into a GatewayEvent

type EventWatcher

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

EventWatcher handles watching for events on EVM chains

func NewEventWatcher

func NewEventWatcher(
	parentClient *Client,
	gatewayAddr ethcommon.Address,
	eventParser *EventParser,
	tracker *common.ConfirmationTracker,
	appConfig *config.Config,
	chainID string,
	logger zerolog.Logger,
) *EventWatcher

NewEventWatcher creates a new event watcher

func (*EventWatcher) WatchEvents

func (ew *EventWatcher) WatchEvents(
	ctx context.Context,
	fromBlock uint64,
	updateLastBlock func(uint64) error,
	verifyTransactions func(context.Context) error,
) (<-chan *common.GatewayEvent, error)

WatchEvents starts watching for events from a specific block

type GatewayHandler

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

GatewayHandler handles gateway operations for EVM chains

func NewGatewayHandler

func NewGatewayHandler(
	parentClient *Client,
	config *uregistrytypes.ChainConfig,
	database *db.DB,
	appConfig *config.Config,
	logger zerolog.Logger,
) (*GatewayHandler, error)

NewGatewayHandler creates a new EVM gateway handler

func (*GatewayHandler) GetConfirmationTracker

func (h *GatewayHandler) GetConfirmationTracker() *common.ConfirmationTracker

GetConfirmationTracker returns the confirmation tracker

func (*GatewayHandler) GetLatestBlock

func (h *GatewayHandler) GetLatestBlock(ctx context.Context) (uint64, error)

GetLatestBlock returns the latest block number

func (*GatewayHandler) GetStartBlock

func (h *GatewayHandler) GetStartBlock(ctx context.Context) (uint64, error)

GetStartBlock returns the block to start watching from

func (*GatewayHandler) GetTransactionConfirmations

func (h *GatewayHandler) GetTransactionConfirmations(ctx context.Context, txHash string) (uint64, error)

GetTransactionConfirmations returns the number of confirmations for a transaction

func (*GatewayHandler) IsConfirmed

func (h *GatewayHandler) IsConfirmed(ctx context.Context, txHash string) (bool, error)

IsConfirmed checks if a transaction has enough confirmations

func (*GatewayHandler) SetVoteHandler

func (h *GatewayHandler) SetVoteHandler(handler common.VoteHandler)

SetVoteHandler sets the vote handler on the confirmation tracker

func (*GatewayHandler) UpdateLastProcessedBlock

func (h *GatewayHandler) UpdateLastProcessedBlock(blockNumber uint64) error

UpdateLastProcessedBlock updates the last processed block in the database

func (*GatewayHandler) WatchGatewayEvents

func (h *GatewayHandler) WatchGatewayEvents(ctx context.Context, fromBlock uint64) (<-chan *common.GatewayEvent, error)

WatchGatewayEvents delegates to event watcher

type TransactionVerifier

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

TransactionVerifier handles transaction verification for EVM

func NewTransactionVerifier

func NewTransactionVerifier(
	parentClient *Client,
	config *uregistrytypes.ChainConfig,
	database *db.DB,
	tracker *common.ConfirmationTracker,
	logger zerolog.Logger,
) *TransactionVerifier

NewTransactionVerifier creates a new transaction verifier

func (*TransactionVerifier) GetTransactionConfirmations

func (tv *TransactionVerifier) GetTransactionConfirmations(ctx context.Context, txHash string) (uint64, error)

GetTransactionConfirmations returns the number of confirmations for a transaction

func (*TransactionVerifier) VerifyPendingTransactions

func (tv *TransactionVerifier) VerifyPendingTransactions(ctx context.Context) error

VerifyPendingTransactions checks all pending transactions for reorgs

func (*TransactionVerifier) VerifyTransactionExistence

func (tv *TransactionVerifier) VerifyTransactionExistence(
	ctx context.Context,
	tx *store.ChainTransaction,
) (bool, error)

VerifyTransactionExistence checks if an EVM transaction still exists on chain (reorg detection)

Jump to

Keyboard shortcuts

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