Documentation
¶
Index ¶
- func LoadEnabledBlockchains(configDirPath string) (map[uint64]BlockchainConfig, error)
- type AssetConfig
- type AssetsConfig
- type BlockchainConfig
- type BlockchainsConfig
- type MemoryStore
- type MemoryStoreV1
- func (ms *MemoryStoreV1) GetAssetDecimals(asset string) (uint8, error)
- func (ms *MemoryStoreV1) GetAssets(blockchainID *uint64) ([]core.Asset, error)
- func (ms *MemoryStoreV1) GetBlockchains() ([]core.Blockchain, error)
- func (ms *MemoryStoreV1) GetChannelSigValidators(blockchainID uint64) (map[uint8]string, error)
- func (ms *MemoryStoreV1) GetTokenAddress(asset string, blockchainID uint64) (string, error)
- func (ms *MemoryStoreV1) GetTokenDecimals(blockchainID uint64, tokenAddress string) (uint8, error)
- func (ms *MemoryStoreV1) IsAssetSupported(asset, tokenAddress string, blockchainID uint64) (bool, error)
- type TokenConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadEnabledBlockchains ¶
func LoadEnabledBlockchains(configDirPath string) (map[uint64]BlockchainConfig, error)
LoadEnabledBlockchains loads and validates blockchain configurations from a YAML file. It reads from <configDirPath>/blockchains.yaml, validates all settings, verifies RPC connections, and returns a map of enabled blockchains indexed by chain ID.
The function performs the following validations: - Contract addresses format (0x + 40 hex chars) - Blockchain names (lowercase with underscores) - RPC endpoint availability and chain ID matching - Required contract addresses (using defaults when not specified)
Types ¶
type AssetConfig ¶
type AssetConfig struct {
// Name is the human-readable name of the asset (e.g., "USD Coin")
// If empty, it will inherit the Symbol value during validation
Name string `yaml:"name"`
// Symbol is the ticker symbol for the asset (e.g., "USDC")
// This field is required for enabled assets
Symbol string `yaml:"symbol"`
// Decimals is the number of decimal places for the asset
Decimals uint8
// SuggestedBlockchainID is the chain ID of the blockchain where this asset is primarily used
SuggestedBlockchainID uint64 `yaml:"suggested_blockchain_id"`
// Disabled determines if this asset should be processed
Disabled bool `yaml:"disabled"`
// Tokens contains the blockchain-specific token implementations
Tokens []TokenConfig `yaml:"tokens"`
}
AssetConfig represents configuration for a single asset (e.g., USDC, USDT). An asset can have multiple token representations across different blockchains.
type AssetsConfig ¶
type AssetsConfig struct {
Assets []AssetConfig `yaml:"assets"`
}
AssetsConfig represents the root configuration structure for all asset settings. It contains a list of assets, each of which can have multiple token representations across different blockchains.
func LoadAssets ¶
func LoadAssets(configDirPath string) (AssetsConfig, error)
LoadAssets loads and validates asset configurations from a YAML file. It reads from <configDirPath>/assets.yaml, validates all settings, and returns the parsed configuration.
The function performs the following validations: - Asset symbols are required for enabled assets - Token addresses must be valid Ethereum addresses - Inheritance of names and symbols from asset to token level
type BlockchainConfig ¶
type BlockchainConfig struct {
// Name is the blockchain identifier (e.g., "polygon_amoy", "base_sepolia")
// Must match pattern: lowercase letters and underscores only
Name string `yaml:"name"`
// ID is the chain ID used for RPC validation
ID uint64 `yaml:"id"`
// TODO: blockchains must not be disabled in prod deployment
Disabled bool `yaml:"disabled"`
// BlockStep defines the block range for scanning (default: 10000)
BlockStep uint64 `yaml:"block_step"`
// ChannelHubAddress is the address of the ChannelHub contract on this blockchain
ChannelHubAddress string `yaml:"channel_hub_address"`
// ChannelHubSigValidators maps validator IDs to the addresses of signature validators for the ChannelHub contract on this blockchain
ChannelHubSigValidators map[uint8]string `yaml:"channel_hub_sig_validators"`
// LockingContractAddress is the address of the locking contract on this blockchain
LockingContractAddress string `yaml:"locking_contract_address"`
}
BlockchainConfig represents configuration for a single blockchain. It includes connection details, contract addresses, and scanning parameters.
type BlockchainsConfig ¶
type BlockchainsConfig struct {
Blockchains []BlockchainConfig `yaml:"blockchains"`
}
BlockchainsConfig represents the root configuration structure for all blockchain settings. It contains default contract addresses that apply to all blockchains unless overridden, and a list of individual blockchain configurations.
type MemoryStore ¶
type MemoryStore interface {
// GetBlockchains retrieves the list of supported blockchains.
GetBlockchains() ([]core.Blockchain, error)
// GetAssets retrieves the list of supported assets.
// If blockchainID is provided, filters assets to only include tokens on that blockchain.
GetAssets(blockchainID *uint64) ([]core.Asset, error)
// GetChannelSigValidators retrieves the channel signature validators for a specific blockchain.
GetChannelSigValidators(blockchainID uint64) (map[uint8]string, error)
// GetTokenAddress retrieves the token address for a given asset on a specific blockchain.
GetTokenAddress(asset string, blockchainID uint64) (string, error)
// IsAssetSupported checks if a given asset (token) is supported on the specified blockchain.
IsAssetSupported(asset, tokenAddress string, blockchainID uint64) (bool, error)
// GetAssetDecimals checks if an asset exists and returns its decimals in YN
GetAssetDecimals(asset string) (uint8, error)
// GetTokenDecimals returns the decimals for a token on a specific blockchain
GetTokenDecimals(blockchainID uint64, tokenAddress string) (uint8, error)
}
MemoryStore defines an in-memory data store interface for retrieving supported blockchains and assets.
func NewMemoryStoreV1 ¶
func NewMemoryStoreV1(assetsConfig AssetsConfig, blockchainsConfig map[uint64]BlockchainConfig) (MemoryStore, error)
func NewMemoryStoreV1FromConfig ¶
func NewMemoryStoreV1FromConfig(configDirPath string) (MemoryStore, error)
type MemoryStoreV1 ¶
type MemoryStoreV1 struct {
// contains filtered or unexported fields
}
func (*MemoryStoreV1) GetAssetDecimals ¶
func (ms *MemoryStoreV1) GetAssetDecimals(asset string) (uint8, error)
GetAssetDecimals checks if an asset exists and returns its decimals in YN
func (*MemoryStoreV1) GetAssets ¶
func (ms *MemoryStoreV1) GetAssets(blockchainID *uint64) ([]core.Asset, error)
GetAssets retrieves the list of supported assets. If blockchainID is provided, filters assets to only include tokens on that blockchain.
func (*MemoryStoreV1) GetBlockchains ¶
func (ms *MemoryStoreV1) GetBlockchains() ([]core.Blockchain, error)
GetBlockchains retrieves the list of supported blockchains.
func (*MemoryStoreV1) GetChannelSigValidators ¶
func (ms *MemoryStoreV1) GetChannelSigValidators(blockchainID uint64) (map[uint8]string, error)
func (*MemoryStoreV1) GetTokenAddress ¶
func (ms *MemoryStoreV1) GetTokenAddress(asset string, blockchainID uint64) (string, error)
func (*MemoryStoreV1) GetTokenDecimals ¶
func (ms *MemoryStoreV1) GetTokenDecimals(blockchainID uint64, tokenAddress string) (uint8, error)
GetTokenDecimals returns the decimals for a token on a specific blockchain
func (*MemoryStoreV1) IsAssetSupported ¶
func (ms *MemoryStoreV1) IsAssetSupported(asset, tokenAddress string, blockchainID uint64) (bool, error)
IsAssetSupported checks if a given asset (token) is supported on the specified blockchain.
type TokenConfig ¶
type TokenConfig struct {
// Name is the token name on this blockchain (e.g., "Bridged USDC")
// If empty, it will inherit from the parent asset's Name
Name string `yaml:"name"`
// Symbol is the token symbol on this blockchain
// If empty, it will inherit from the parent asset's Symbol
Symbol string `yaml:"symbol"`
// BlockchainID is the chain ID where this token is deployed
BlockchainID uint64 `yaml:"blockchain_id"`
// Disabled determines if this token should be processed
Disabled bool `yaml:"disabled"`
// Address is the token's contract address on the blockchain
// Must be a valid Ethereum address (0x followed by 40 hex characters)
Address string `yaml:"address"`
// Decimals is the number of decimal places for the token
Decimals uint8 `yaml:"decimals"`
}
TokenConfig represents a specific token implementation on a blockchain. Each token is associated with a parent asset and deployed on a specific blockchain.