remote

package
v1.0.92 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
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
)

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 EvmChainByEvmChainID

func EvmChainByEvmChainID(ctx context.Context, evmChainID uint64, opts ...Option) (chain_selectors.Chain, bool, error)

EvmChainByEvmChainID fetches chain data from GitHub and returns the EVM chain for a given EVM chain ID

func EvmChainBySelector

func EvmChainBySelector(ctx context.Context, sel uint64, opts ...Option) (chain_selectors.Chain, bool, error)

EvmChainBySelector fetches chain data from GitHub and returns the EVM chain for a given selector

func EvmChainIdFromName

func EvmChainIdFromName(ctx context.Context, name string, opts ...Option) (uint64, error)

EvmChainIdFromName fetches chain data from GitHub and returns the EVM chain ID for a given chain name

func EvmChainIdToChainSelector

func EvmChainIdToChainSelector(ctx context.Context, opts ...Option) (map[uint64]uint64, error)

EvmChainIdToChainSelector fetches chain data from GitHub and returns a map of EVM chain ID to chain selector

func GetChainDetailsByChainIDAndFamily

func GetChainDetailsByChainIDAndFamily(ctx context.Context, chainID string, family string, opts ...Option) (chain_selectors.ChainDetails, error)

GetChainDetailsByChainIDAndFamily fetches chain data from GitHub and returns chain details for a given chain ID and family

func IsEvm

func IsEvm(ctx context.Context, chainSel uint64, opts ...Option) (bool, error)

IsEvm fetches chain data from GitHub and checks if a chain selector is for an EVM chain

Types

type ChainDetailsWithMetadata

type ChainDetailsWithMetadata struct {
	chain_selectors.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 Option

type Option func(*Config)

Option is a functional option for configuring remote API calls

func WithCacheTTL

func WithCacheTTL(ttl time.Duration) Option

WithCacheTTL sets the cache time-to-live. Default is 5 minutes. Set to 0 to disable caching (always fetch fresh data).

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the HTTP request timeout. If not provided, DefaultRemoteFetchTimeout will be used.

func WithURL

func WithURL(url string) Option

WithURL sets a custom URL for fetching the all_selectors.yml file. If not provided, DefaultGitHubRawURL will be used.

Jump to

Keyboard shortcuts

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