remote

package
v1.0.96 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 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 returns the EVM chain for a given EVM chain ID. It first checks local embedded data, then falls back to remote if not found.

func EvmChainBySelector

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

EvmChainBySelector returns the EVM chain for a given selector. It first checks local embedded data, then falls back to remote if not found.

func EvmChainIdFromName

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

EvmChainIdFromName returns the EVM chain ID for a given chain name. It first checks local embedded data, then falls back to remote if not found.

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 and returns chain details for a given chain ID and family. It first checks local embedded data, then falls back to remote if not found locally.

func IsEvm

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

IsEvm checks if a chain selector is for an EVM chain. It first checks local embedded data, then falls back to remote if not found.

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 and returns chain details for a given selector. It first checks local embedded data, then falls back to remote if not found locally.

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