Giter Club home page Giter Club logo

cosmos-chain-resolver's Introduction

COSMOS CHAIN RESOLVER ๐Ÿ”—

GitHub contributors GitHub repo size Twitter Follow Medium

NodeJSTypeScript


An SDK to fetch and filter chain information


This repo and product is intentionally managed as Open Source and we aim to use this guide to light our way https://opensource.guide/. Let us know how we are doing!

๐Ÿ”จ Install

npm install @ixo/cosmos-chain-resolver

yarn add  @ixo/cosmos-chain-resolver

๐Ÿ’ป Usage

To use the Cosmos Chain Resolver, you can import the function(s) you want to use and execute it with the appropriate parameters.

import {
	getRegistryChainInfo,
	getActiveRpcFromRegistryChainInfo,
	getActiveRpcFromChainName,
	getChainExplorer,
	getChainExplorerAsync,
	getKeplrChainInfoFromRegistryChainInfo,
	getKeplrChainInfo,
} from '@ixo/cosmos-chain-resolver';

The Cosmos Chain Resolver SDK expose the following functions:

getRegistryChainInfo

getRegistryChainInfo(chainName: string, chainNetwork?: ChainNetwork): Promise<RegistryChainInfo>

This function fetches the chain info for the provided chainName and chainNetwork. If chainNetwork is not provided, it defaults to mainnet.

getActiveRpcFromRegistryChainInfo

getActiveRpcFromRegistryChainInfo(chainInfo: RegistryChainInfo): Promise<string>

This function filters through and fetches an active RPC endpoint from the provided chainInfo.

getActiveRpcFromChainName

getActiveRpcFromChainName(chainName: string, chainNetwork?: ChainNetwork): Promise<string>

This function fetches an active RPC endpoint for the provided chainName and chainNetwork. If chainNetwork is not provided, it defaults to mainnet.

getChainExplorer

getChainExplorer(chainName: string, chainNetwork: ChainNetwork, chainExplorers?: ChainExplorer[]): KeplrChainExplorer | undefined

This function fetches the tx explorer info for the provided chainName, chainNetwork and chainExplorers.

getChainExplorerAsync

getChainExplorerAsync(chainName: string, chainNetwork: ChainNetwork): Promise<KeplrChainExplorer | undefined>

This function fetches the tx explorer info for the provided chainName and chainNetwork via the Cosmos Chain Registry.

getKeplrChainInfoFromRegistryChainInfo

getKeplrChainInfoFromRegistryChainInfo(chainInfo: RegistryChainInfo): Promise<KeplrChainInfo>

This function fetches the keplr chain info for the provided chainInfo.

getKeplrChainInfo

getKeplrChainInfo(chainNameOrId: string, chainNetwork: ChainNetwork = MAINNET, ): Promise<KeplrChainInfo>

This function fetches the keplr chain info for the provided chain id or the chain name-and-network.

๐Ÿ“ฑ Example

import { getKeplrChainInfo } from '@ixo/cosmos-chain-resolver';

// fetch chain info via chain id
const ixoKeplrChainInfo = await getKeplrChainInfo('ixo-5');

// fetch chain info via chain name and network
const ixoTestnetKeplrChainInfo = await getKeplrChainInfo('impacthub', 'testnet');
import { getRegistryChainInfo, getKeplrChainInfoFromRegistryChainInfo } from '@ixo/cosmos-chain-resolver';

// fetch chain info via chain id
const ixoRegistryChainInfo = await getRegistryChainInfo('impacthub', 'mainnet');

// fetch chain info via chain name and network
const ixoKeplrChainInfo = await getKeplrChainInfoFromRegistryChainInfo(ixoRegistryChainInfo);

๐Ÿ“ƒ License

This SDK is licensed under the Apache 2 License. See the LICENSE file for more information.

cosmos-chain-resolver's People

Contributors

gssuper avatar michael-ixo avatar michaelpretorius avatar pieter-ixo avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.