Documentation
¶
Index ¶
- type BaseChainClient
- func (b *BaseChainClient) Cancel()
- func (b *BaseChainClient) ChainID() string
- func (b *BaseChainClient) Context() context.Context
- func (b *BaseChainClient) GetChainSpecificConfig() *config.ChainSpecificConfig
- func (b *BaseChainClient) GetCleanupSettings() (cleanupInterval, retentionPeriod int)
- func (b *BaseChainClient) GetConfig() *uregistrytypes.ChainConfig
- func (b *BaseChainClient) GetGasOracleFetchInterval() time.Duration
- func (b *BaseChainClient) GetRPCURLs() []string
- func (b *BaseChainClient) SetContext(ctx context.Context)
- type ChainClient
- type ConfirmationTracker
- func (ct *ConfirmationTracker) GetConfirmedTransactions(chainID string) ([]store.ChainTransaction, error)
- func (ct *ConfirmationTracker) GetGatewayTransaction(txHash string) (*store.ChainTransaction, error)
- func (ct *ConfirmationTracker) GetRequiredConfirmations(mode string) uint64
- func (ct *ConfirmationTracker) IsConfirmed(txHash string) (bool, error)
- func (ct *ConfirmationTracker) MarkTransactionFailed(txHash string) error
- func (ct *ConfirmationTracker) SetVoteHandler(handler VoteHandler)
- func (ct *ConfirmationTracker) TrackTransaction(txHash string, blockNumber uint64, eventID string, confirmationType string, ...) (err error)
- func (ct *ConfirmationTracker) UpdateConfirmations(currentBlock uint64) (err error)
- type GasPrice
- type GasPriceFetcher
- type GatewayEvent
- type GatewayOperations
- type RetryConfig
- type RetryManager
- type UniversalTx
- type VoteHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseChainClient ¶
type BaseChainClient struct {
// contains filtered or unexported fields
}
BaseChainClient provides common functionality for all chain implementations
func NewBaseChainClient ¶
func NewBaseChainClient(chainConfig *uregistrytypes.ChainConfig, appConfig *config.Config) *BaseChainClient
NewBaseChainClient creates a new base chain client
func (*BaseChainClient) Cancel ¶
func (b *BaseChainClient) Cancel()
Cancel cancels the chain client's context
func (*BaseChainClient) ChainID ¶
func (b *BaseChainClient) ChainID() string
ChainID returns the CAIP-2 format chain identifier
func (*BaseChainClient) Context ¶
func (b *BaseChainClient) Context() context.Context
Context returns the chain client's context
func (*BaseChainClient) GetChainSpecificConfig ¶
func (b *BaseChainClient) GetChainSpecificConfig() *config.ChainSpecificConfig
GetChainSpecificConfig returns the complete configuration for this chain
func (*BaseChainClient) GetCleanupSettings ¶
func (b *BaseChainClient) GetCleanupSettings() (cleanupInterval, retentionPeriod int)
GetCleanupSettings returns cleanup settings for this chain Falls back to global defaults if no chain-specific settings exist
func (*BaseChainClient) GetConfig ¶
func (b *BaseChainClient) GetConfig() *uregistrytypes.ChainConfig
GetConfig returns the chain configuration
func (*BaseChainClient) GetGasOracleFetchInterval ¶
func (b *BaseChainClient) GetGasOracleFetchInterval() time.Duration
GetGasOracleFetchInterval returns the onchain gas oracle fetch interval Returns the duration from ChainConfig if available, otherwise defaults to 30 seconds
func (*BaseChainClient) GetRPCURLs ¶
func (b *BaseChainClient) GetRPCURLs() []string
GetRPCURLs returns the list of RPC URLs for this chain
func (*BaseChainClient) SetContext ¶
func (b *BaseChainClient) SetContext(ctx context.Context)
SetContext sets the context for the chain client
type ChainClient ¶
type ChainClient interface {
// ChainID returns the CAIP-2 format chain identifier
ChainID() string
// Start initializes and starts the chain client
Start(ctx context.Context) error
// Stop gracefully shuts down the chain client
Stop() error
// IsHealthy checks if the chain client is operational
IsHealthy() bool
// GetConfig returns the chain configuration
GetConfig() *uregistrytypes.ChainConfig
// SetVoteHandler sets the vote handler for confirmed transactions
SetVoteHandler(handler VoteHandler)
// GetGasPrice fetches the current gas price from the chain
GetGasPrice(ctx context.Context) (*big.Int, error)
// Configuration access methods
GetRPCURLs() []string
GetCleanupSettings() (cleanupInterval, retentionPeriod int)
GetGasOracleFetchInterval() time.Duration
GetChainSpecificConfig() *config.ChainSpecificConfig
// Gateway operations (optional - clients can implement GatewayOperations)
GatewayOperations
}
ChainClient defines the interface for chain-specific implementations
type ConfirmationTracker ¶
type ConfirmationTracker struct {
// contains filtered or unexported fields
}
ConfirmationTracker tracks transaction confirmations for gateway events
func NewConfirmationTracker ¶
func NewConfirmationTracker( database *db.DB, config *uregistrytypes.BlockConfirmation, logger zerolog.Logger, ) *ConfirmationTracker
NewConfirmationTracker creates a new confirmation tracker
func (*ConfirmationTracker) GetConfirmedTransactions ¶
func (ct *ConfirmationTracker) GetConfirmedTransactions(chainID string) ([]store.ChainTransaction, error)
GetConfirmedTransactions returns all confirmed transactions for a chain
func (*ConfirmationTracker) GetGatewayTransaction ¶
func (ct *ConfirmationTracker) GetGatewayTransaction(txHash string) (*store.ChainTransaction, error)
GetGatewayTransaction retrieves a gateway transaction by hash
func (*ConfirmationTracker) GetRequiredConfirmations ¶
func (ct *ConfirmationTracker) GetRequiredConfirmations(mode string) uint64
GetRequiredConfirmations returns the required confirmations for a mode
func (*ConfirmationTracker) IsConfirmed ¶
func (ct *ConfirmationTracker) IsConfirmed( txHash string, ) (bool, error)
IsConfirmed checks if a transaction has enough confirmations
func (*ConfirmationTracker) MarkTransactionFailed ¶
func (ct *ConfirmationTracker) MarkTransactionFailed(txHash string) error
MarkTransactionFailed marks a transaction as failed
func (*ConfirmationTracker) SetVoteHandler ¶
func (ct *ConfirmationTracker) SetVoteHandler(handler VoteHandler)
SetVoteHandler sets the vote handler for the confirmation tracker
func (*ConfirmationTracker) TrackTransaction ¶
func (ct *ConfirmationTracker) TrackTransaction( txHash string, blockNumber uint64, eventID string, confirmationType string, data []byte, ) (err error)
TrackTransaction starts tracking a new transaction for confirmations
func (*ConfirmationTracker) UpdateConfirmations ¶
func (ct *ConfirmationTracker) UpdateConfirmations( currentBlock uint64, ) (err error)
UpdateConfirmations updates confirmation counts for all pending transactions
type GasPrice ¶
type GasPrice struct {
ChainID string `json:"chain_id"`
Price *big.Int `json:"price"`
Unit string `json:"unit"` // "wei" for EVM, "lamports/cu" for Solana
Timestamp int64 `json:"timestamp"`
}
GasPrice represents a gas price data point
type GasPriceFetcher ¶
type GasPriceFetcher interface {
// GetGasPrice fetches the current gas price from the chain
// For EVM chains, returns the price in Wei
// For Solana, returns the price in lamports per compute unit
GetGasPrice(ctx context.Context) (*big.Int, error)
}
GasPriceFetcher defines the interface for fetching gas prices from different chains
type GatewayEvent ¶
type GatewayEvent struct {
ChainID string
TxHash string
BlockNumber uint64
EventID string
Payload []byte
Confirmations uint64
ConfirmationType string // "STANDARD" or "FAST" - from gateway method config
}
GatewayEvent represents a cross-chain gateway event
type GatewayOperations ¶
type GatewayOperations interface {
// GetLatestBlock returns the latest block/slot number
GetLatestBlock(ctx context.Context) (uint64, error)
// WatchGatewayEvents starts watching for gateway events from a specific block
WatchGatewayEvents(ctx context.Context, fromBlock uint64) (<-chan *GatewayEvent, error)
// GetTransactionConfirmations returns the number of confirmations for a transaction
GetTransactionConfirmations(ctx context.Context, txHash string) (uint64, error)
// IsConfirmed checks if a transaction has enough confirmations
IsConfirmed(ctx context.Context, txHash string) (bool, error)
}
GatewayOperations defines gateway-specific operations for chain clients
type RetryConfig ¶
type RetryConfig struct {
MaxRetries int // Maximum number of retry attempts
InitialDelay time.Duration // Initial delay between retries
MaxDelay time.Duration // Maximum delay between retries
BackoffFactor float64 // Exponential backoff factor (e.g., 2.0)
RetryableError func(error) bool // Function to determine if error is retryable
}
RetryConfig holds retry configuration
func DefaultRetryConfig ¶
func DefaultRetryConfig() *RetryConfig
DefaultRetryConfig returns default retry configuration
type RetryManager ¶
type RetryManager struct {
// contains filtered or unexported fields
}
RetryManager handles retry logic with exponential backoff
func NewRetryManager ¶
func NewRetryManager(config *RetryConfig, logger zerolog.Logger) *RetryManager
NewRetryManager creates a new retry manager
func (*RetryManager) CalculateBackoff ¶
func (r *RetryManager) CalculateBackoff(attempt int) time.Duration
CalculateBackoff calculates the next backoff delay
func (*RetryManager) ExecuteWithRetry ¶
func (r *RetryManager) ExecuteWithRetry( ctx context.Context, operation string, fn func() error, ) error
ExecuteWithRetry executes a function with retry logic
type UniversalTx ¶
type UniversalTx struct {
SourceChain string `json:"sourceChain"`
LogIndex uint `json:"logIndex"`
Sender string `json:"sender"`
Recipient string `json:"recipient"`
Token string `json:"bridgeToken"`
Amount string `json:"bridgeAmount"` // uint256 as decimal string
Payload uetypes.UniversalPayload `json:"universalPayload"`
VerificationData string `json:"verificationData"`
RevertFundRecipient string `json:"revertFundRecipient,omitempty"`
RevertMsg string `json:"revertMsg,omitempty"` // hex-encoded bytes (0x…)
TxType uint `json:"txType"` // enum backing uint as decimal string
}
type VoteHandler ¶
type VoteHandler interface {
VoteAndConfirm(ctx context.Context, tx *store.ChainTransaction) error
}
VoteHandler interface for voting on confirmed transactions