@chain-registry/utils
Utility functions for the chain-registry
Usage
import { ChainRegistry, ChainRegistryOptions } from '@chain-registry/utils';
const options: ChainRegistryOptions = {
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 ChainRegistry(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 = [
];
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:
const generated: AssetList[] = registry.getGeneratedAssetLists('osmosis');
You can get generated AssetList[]
objects directly from the ChainRegistry
via the assetLists
method:
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:
const chain: Chain = registry.getChain('osmosis');
or get the ChainInfo
object:
const chainInfo: ChainInfo = registry.getChainInfo('osmosis');
const assetes: AssetList[] = chainInfo.assetLists();
const chain: Chain = chainInfo.chain();
const assetes: AssetList[] = chainInfo.nativeAssetLists();
Credits
Built by Cosmology — if you like our tools, please consider delegating to our validator