svm

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: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UniversalTxDiscriminator = strings.ToLower("6C9AD829B5EA1D7C")
)

Constants for event parsing

Functions

func CreateSVMClientFactory

func CreateSVMClientFactory() rpcpool.ClientFactory

CreateSVMClientFactory returns a ClientFactory for SVM endpoints

func CreateSVMHealthChecker

func CreateSVMHealthChecker(expectedGenesisHash string) rpcpool.HealthChecker

CreateSVMHealthChecker creates a health checker for SVM endpoints

func GetSolanaClientFromPool

func GetSolanaClientFromPool(endpoint *rpcpool.Endpoint) (*rpc.Client, error)

GetSolanaClientFromPool extracts the rpc.Client from a pool endpoint

Types

type Client

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

Client implements the ChainClient interface for Solana chains

func NewClient

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

NewClient creates a new Solana chain client

func (*Client) GetGasPrice

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

GetGasPrice fetches the current gas price from the Solana chain Returns the median priority fee in lamports per compute unit

func (*Client) GetGenesisHash

func (c *Client) GetGenesisHash() string

GetGenesisHash returns the genesis hash

func (*Client) GetLatestBlock

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

GetLatestBlock returns the latest slot number

func (*Client) GetRPCURL

func (c *Client) GetRPCURL() string

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

func (*Client) GetSlot

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

GetSlot returns the current slot

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 Solana 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 Solana chain client

func (*Client) Stop

func (c *Client) Stop() error

Stop gracefully shuts down the Solana 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 SVM gateway events

func NewEventParser

func NewEventParser(
	gatewayAddr solana.PublicKey,
	config *uregistrytypes.ChainConfig,
	logger zerolog.Logger,
) *EventParser

NewEventParser creates a new event parser

func (*EventParser) ParseGatewayEvent

func (ep *EventParser) ParseGatewayEvent(log string, signature string, slot uint64, logIndex uint) *common.GatewayEvent

ParseGatewayEvent parses a single log into a GatewayEvent Only processes UniversalTxDiscriminator events

type EventWatcher

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

EventWatcher handles watching for events on Solana chains

func NewEventWatcher

func NewEventWatcher(
	parentClient *Client,
	gatewayAddr solana.PublicKey,
	eventParser *EventParser,
	tracker *common.ConfirmationTracker,
	txVerifier *TransactionVerifier,
	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,
	fromSlot uint64,
	updateLastSlot func(uint64) error,
	verifyTransactions func(context.Context) error,
) (<-chan *common.GatewayEvent, error)

WatchEvents starts watching for events from a specific slot

type GatewayHandler

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

GatewayHandler handles gateway operations for Solana 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 Solana 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 slot number

func (*GatewayHandler) GetStartSlot

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

GetStartSlot returns the slot to start watching from

func (*GatewayHandler) GetTransactionConfirmations

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

func (*GatewayHandler) IsConfirmed

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

IsConfirmed delegates to transaction verifier

func (*GatewayHandler) SetVoteHandler

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

SetVoteHandler sets the vote handler on the confirmation tracker

func (*GatewayHandler) UpdateLastProcessedSlot

func (h *GatewayHandler) UpdateLastProcessedSlot(slotNumber uint64) error

UpdateLastProcessedSlot updates the last processed slot in the database

func (*GatewayHandler) WatchGatewayEvents

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

WatchGatewayEvents starts watching for gateway events from a specific slot

type MethodExtractionInfo

type MethodExtractionInfo struct {
	ReceiverInstructionIndex int
	AmountEventPosition      int
	LastVerified             time.Time
}

MethodExtractionInfo caches discovered positions for each method

type TransactionStatus

type TransactionStatus struct {
	Exists             bool   `json:"exists"`
	Status             string `json:"status"`
	Slot               uint64 `json:"slot"`
	Confirmations      uint64 `json:"confirmations"`
	ConfirmationStatus string `json:"confirmation_status"`
	Error              string `json:"error,omitempty"`
}

TransactionStatus holds detailed transaction status information

type TransactionVerifier

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

TransactionVerifier handles transaction verification for Solana

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) GetTransactionStatus

func (tv *TransactionVerifier) GetTransactionStatus(ctx context.Context, txHash string) (*TransactionStatus, error)

GetTransactionStatus returns detailed status of a transaction

func (*TransactionVerifier) IsConfirmed

func (tv *TransactionVerifier) IsConfirmed(ctx context.Context, txHash string) (bool, error)

IsConfirmed checks if a transaction has enough confirmations

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 a Solana transaction still exists on chain

func (*TransactionVerifier) WaitForTransaction

func (tv *TransactionVerifier) WaitForTransaction(
	ctx context.Context,
	txHash string,
	confirmationLevel string,
) error

WaitForTransaction waits for a transaction to reach a specific confirmation level

Jump to

Keyboard shortcuts

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