cregistry

package
v2.3.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsHealthyRPC

func IsHealthyRPC(ctx context.Context, endpoint string) error

IsHealthyRPC returns an error if the specified endpoint is not caught up with the current chain tip. Otherwise it returns nil.

Types

type AssetList

type AssetList struct {
	Schema  string `json:"$schema"`
	ChainID string `json:"chain_id"`
	Assets  []struct {
		Description string `json:"description"`
		DenomUnits  []struct {
			Denom    string `json:"denom"`
			Exponent int    `json:"exponent"`
		} `json:"denom_units"`
		Base     string `json:"base"`
		Name     string `json:"name"`
		Display  string `json:"display"`
		Symbol   string `json:"symbol"`
		LogoURIs struct {
			Png string `json:"png"`
			Svg string `json:"svg"`
		} `json:"logo_URIs"`
		CoingeckoID string `json:"coingecko_id"`
	} `json:"assets"`
}

AssetList describes the various chain asset metadata found in the cosmos chain registry.

type ChainInfo

type ChainInfo struct {
	Schema       string `json:"$schema"`
	ChainName    string `json:"chain_name"`
	Status       string `json:"status"`
	NetworkType  string `json:"network_type"`
	PrettyName   string `json:"pretty_name"`
	ChainID      string `json:"chain_id"`
	Bech32Prefix string `json:"bech32_prefix"`
	DaemonName   string `json:"daemon_name"`
	NodeHome     string `json:"node_home"`
	Genesis      struct {
		GenesisURL string `json:"genesis_url"`
	} `json:"genesis"`
	Slip44   int `json:"slip44"`
	Codebase struct {
		GitRepo            string   `json:"git_repo"`
		RecommendedVersion string   `json:"recommended_version"`
		CompatibleVersions []string `json:"compatible_versions"`
	} `json:"codebase"`
	Peers struct {
		Seeds []struct {
			ID       string `json:"id"`
			Address  string `json:"address"`
			Provider string `json:"provider,omitempty"`
		} `json:"seeds"`
		PersistentPeers []struct {
			ID      string `json:"id"`
			Address string `json:"address"`
		} `json:"persistent_peers"`
	} `json:"peers"`
	Apis struct {
		RPC []struct {
			Address  string `json:"address"`
			Provider string `json:"provider"`
		} `json:"rpc"`
		Rest []struct {
			Address  string `json:"address"`
			Provider string `json:"provider"`
		} `json:"rest"`
	} `json:"apis"`
	// contains filtered or unexported fields
}

ChainInfo describes the canonical chain metadata found in the cosmos chain registry.

func NewChainInfo

func NewChainInfo(log *zap.Logger) ChainInfo

NewChainInfo returns a ChainInfo that is uninitialized other than the provided zap.Logger. Typically, the caller will unmarshal JSON content into the ChainInfo after initialization.

func (ChainInfo) GetAllRPCEndpoints

func (c ChainInfo) GetAllRPCEndpoints() (out []string, err error)

GetAllRPCEndpoints returns a slice of strings representing the available RPC endpoints found in the cosmos chain registry for this particular chain.

func (ChainInfo) GetAssetList

func (c ChainInfo) GetAssetList(ctx context.Context) (AssetList, error)

GetAssetList returns the asset metadata from the cosmos chain registry for this particular chain.

func (ChainInfo) GetChainConfig

func (c ChainInfo) GetChainConfig(ctx context.Context) (*cosmos.CosmosProviderConfig, error)

GetChainConfig returns a CosmosProviderConfig composed from the details found in the cosmos chain registry for this particular chain.

func (ChainInfo) GetRPCEndpoints

func (c ChainInfo) GetRPCEndpoints(ctx context.Context) (out []string, err error)

GetRPCEndpoints returns a slice of strings representing the healthy available RPC endpoints found in the cosmos chain registry for this particular chain.

func (ChainInfo) GetRandomRPCEndpoint

func (c ChainInfo) GetRandomRPCEndpoint(ctx context.Context) (string, error)

GetRandomRPCEndpoint returns a string representing a random RPC endpoint from the cosmos chain registry for this chain.

type ChainRegistry

type ChainRegistry interface {
	GetChain(ctx context.Context, name string) (ChainInfo, error)
	ListChains(ctx context.Context) ([]string, error)
	SourceLink() string
}

ChainRegistry is a slim interface that can be implemented to interact with a repository of chain info/metadata.

func DefaultChainRegistry

func DefaultChainRegistry(log *zap.Logger) ChainRegistry

DefaultChainRegistry initializes a new instance of CosmosGithubRegistry for interacting with the Cosmos chain registry.

type CosmosGithubRegistry

type CosmosGithubRegistry struct {
	// contains filtered or unexported fields
}

CosmosGithubRegistry provides an API for interacting with the Cosmos chain registry. See: https://github.com/cosmos/chain-registry

func NewCosmosGithubRegistry

func NewCosmosGithubRegistry(log *zap.Logger) CosmosGithubRegistry

NewCosmosGithubRegistry initializes a new instance of CosmosGithubRegistry.

func (CosmosGithubRegistry) GetChain

func (c CosmosGithubRegistry) GetChain(ctx context.Context, name string) (ChainInfo, error)

GetChain attempts to fetch ChainInfo for the specified chain name from the cosmos chain registry.

func (CosmosGithubRegistry) ListChains

func (c CosmosGithubRegistry) ListChains(ctx context.Context) ([]string, error)

ListChains attempts to connect to GitHub and get the tree object for the cosmos chain registry. It then builds a slice of chain names using the entries in the tree.

func (c CosmosGithubRegistry) SourceLink() string

SourceLink returns the string representation of the cosmos chain registry URL.

Jump to

Keyboard shortcuts

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