Socket
Socket
Sign inDemoInstall

@chain-registry/client

Package Overview
Dependencies
5
Maintainers
3
Versions
139
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chain-registry/client


Version published
Weekly downloads
7.9K
increased by7.07%
Maintainers
3
Created
Weekly downloads
 

Readme

Source

@chain-registry/client

A Client for chain-registry that allows you to dynamically fetch data.

Usage

import { ChainRegistryFetcher, ChainRegistryFetcherOptions } from '@chain-registry/client';

const options: ChainRegistryFetcherOptions = {
  urls: [
    'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/chain.json',
    'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/assetlist.json',
    'https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/assetlist.json',
    'https://raw.githubusercontent.com/cosmos/chain-registry/master/secretnetwork/assetlist.json',
    'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/juno-osmosis.json',
    'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/osmosis-secretnetwork.json'
  ]
};
const registry = new ChainRegistryFetcher(options);
await registry.fetchUrls();

Fetching Schemata

We currently only support fetching JSON schemas as defined in https://github.com/cosmos/chain-registry. Supported are assetlist.schema.json, chain.schema.json and ibc_data.schema.json.

fetchUrls

You can set the ChainRegistry.urls property and call ChainRegistry.fetchUrls()

registry.urls = [
  // urls to fetch
];
await registry.fetchUrls();

fetch

Or, you can simply call ChainRegistry.fetch()

await registry.fetch('https://some-json-schema.com/some-schema.json');

Asset lists

You can get generated asset lists directly from the registry:

// generated asset lists
const generated: AssetList[] = registry.getGeneratedAssetLists('osmosis');

You can get generated AssetList[] objects directly from the ChainRegistry via the assetLists method:

// you can also get generated assets from ChainInfo object
const chainInfo: Chain = registry.getChainInfo('osmosis');
const generatedAssets: AssetList[] = chainInfo.assetLists;

Chain info

You can get Chain object directly from the ChainRegistry via the getChain method:

// get Chain from registry
const chain: Chain = registry.getChain('osmosis');

or get the ChainInfo object:

const chainInfo: ChainInfo = registry.getChainInfo('osmosis');

// AssetList[] of the generated assets
const assets: AssetList[] = chainInfo.assetLists;

// Chain 
const chain: Chain = chainInfo.chain;

// Native asset list
const nativeAssetList: AssetList = chainInfo.nativeAssetList;

Checkout these related projects:

  • @cosmwasm/ts-codegen for generated CosmWasm contract Typescript classes
  • @cosmology/telescope a "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs.
  • chain-registry an npm module for the official Cosmos chain-registry.
  • cosmos-kit A wallet connector for the Cosmos ⚛️
  • create-cosmos-app set up a modern Cosmos app by running one command.
  • starship a k8s-based unified development environment for Cosmos Ecosystem

Credits

🛠 Built by Cosmology — if you like our tools, please consider delegating to our validator ⚛️

FAQs

Last updated on 20 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc