Documentation
¶
Index ¶
- Constants
- func ClearCache()
- func EvmChainIdFromName(ctx context.Context, name string, opts ...Option) (uint64, error)
- func EvmChainIdToChainSelector(ctx context.Context, opts ...Option) (map[uint64]uint64, error)
- func IsEvm(ctx context.Context, chainSel uint64, opts ...Option) (bool, error)
- type AptosChain
- type Chain
- type ChainDetails
- type ChainDetailsWithMetadata
- type Config
- type ExtraSelectorsData
- type Option
- type SolanaChain
- type StarknetChain
- type SuiChain
Constants ¶
const ( // DefaultGitHubRawURL is the default URL for the all_selectors.yml file on GitHub main branch DefaultGitHubRawURL = "https://raw.githubusercontent.com/smartcontractkit/chain-selectors/main/all_selectors.yml" // DefaultRemoteFetchTimeout is the default timeout for remote HTTP requests DefaultRemoteFetchTimeout = 10 * time.Second // DefaultCacheTTL is the default time-to-live for cached remote data DefaultCacheTTL = 5 * time.Minute )
const ( FamilyEVM = "evm" FamilySolana = "solana" FamilyAptos = "aptos" FamilySui = "sui" FamilyTon = "ton" FamilyTron = "tron" FamilyStarknet = "starknet" )
Family constants for blockchain types
Variables ¶
This section is empty.
Functions ¶
func ClearCache ¶
func ClearCache()
ClearCache clears the remote data cache, forcing the next remote call to fetch fresh data
func EvmChainIdFromName ¶
EvmChainIdFromName fetches chain data from GitHub and returns the EVM chain ID for a given chain name
func EvmChainIdToChainSelector ¶
EvmChainIdToChainSelector fetches chain data from GitHub and returns a map of EVM chain ID to chain selector
Types ¶
type AptosChain ¶
AptosChain represents an Aptos chain
type Chain ¶
Chain represents an EVM chain
type ChainDetails ¶
type ChainDetails struct {
ChainSelector uint64 `yaml:"selector" json:"chainSelector"`
ChainName string `yaml:"name" json:"chainName"`
}
ChainDetails represents the basic chain information
func GetChainDetailsByChainIDAndFamily ¶
func GetChainDetailsByChainIDAndFamily(ctx context.Context, chainID string, family string, opts ...Option) (ChainDetails, error)
GetChainDetailsByChainIDAndFamily fetches chain data from GitHub and returns chain details for a given chain ID and family
type ChainDetailsWithMetadata ¶
type ChainDetailsWithMetadata struct {
ChainDetails
Family string
ChainID string
}
ChainDetailsWithMetadata extends ChainDetails with additional metadata
func GetChainDetailsBySelector ¶
func GetChainDetailsBySelector(ctx context.Context, selector uint64, opts ...Option) (ChainDetailsWithMetadata, error)
GetChainDetailsBySelector fetches chain data from GitHub and returns chain details for a given selector
type Config ¶
type Config struct {
// URL is the raw GitHub URL to fetch the all_selectors.yml file
// If empty, DefaultGitHubRawURL will be used
URL string
// Timeout for the HTTP request
// If zero, DefaultRemoteFetchTimeout will be used
Timeout time.Duration
// CacheTTL is the time-to-live for cached remote data
// If zero, no caching will be used (always fetch fresh data)
CacheTTL time.Duration
}
Config holds configuration for remote API calls
type ExtraSelectorsData ¶
type ExtraSelectorsData struct {
Evm map[uint64]ChainDetails `yaml:"evm"`
Solana map[string]ChainDetails `yaml:"solana"`
Aptos map[uint64]ChainDetails `yaml:"aptos"`
Sui map[uint64]ChainDetails `yaml:"sui"`
Ton map[int32]ChainDetails `yaml:"ton"`
Tron map[uint64]ChainDetails `yaml:"tron"`
Starknet map[string]ChainDetails `yaml:"starknet"`
}
ExtraSelectorsData represents the structure of the all_selectors.yml file
type Option ¶
type Option func(*Config)
Option is a functional option for configuring remote API calls
func WithCacheTTL ¶
WithCacheTTL sets the cache time-to-live. Default is 5 minutes. Set to 0 to disable caching (always fetch fresh data).
func WithTimeout ¶
WithTimeout sets the HTTP request timeout. If not provided, DefaultRemoteFetchTimeout will be used.
type SolanaChain ¶
SolanaChain represents a Solana chain
type StarknetChain ¶
StarknetChain represents a Starknet chain