@chain-registry/client 1.19.2 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/main/registry.js DELETED
@@ -1,88 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.ChainRegistryClient = void 0;
8
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
16
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
- var _chainUtil = require("./chain-util");
18
- var _fetcher = require("./fetcher");
19
- var _excluded = ["chainNames", "assetListNames", "ibcNamePairs", "baseUrl"];
20
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
22
- function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
23
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
24
- var ChainRegistryClient = exports.ChainRegistryClient = /*#__PURE__*/function (_ChainRegistryFetcher) {
25
- (0, _inherits2["default"])(ChainRegistryClient, _ChainRegistryFetcher);
26
- function ChainRegistryClient(options) {
27
- var _this;
28
- (0, _classCallCheck2["default"])(this, ChainRegistryClient);
29
- var chainNames = options.chainNames,
30
- assetListNames = options.assetListNames,
31
- ibcNamePairs = options.ibcNamePairs,
32
- baseUrl = options.baseUrl,
33
- restOptions = (0, _objectWithoutProperties2["default"])(options, _excluded);
34
- _this = _callSuper(this, ChainRegistryClient, [restOptions]);
35
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_options", {
36
- chainNames: [],
37
- baseUrl: 'https://raw.githubusercontent.com/cosmos/chain-registry/master'
38
- });
39
- _this._options = _objectSpread(_objectSpread({}, _this._options), {}, {
40
- chainNames: chainNames || _this._options.chainNames,
41
- assetListNames: assetListNames || _this._options.assetListNames,
42
- ibcNamePairs: ibcNamePairs || _this._options.ibcNamePairs,
43
- baseUrl: baseUrl || _this._options.baseUrl
44
- });
45
- _this.generateUrls();
46
- return _this;
47
- }
48
- (0, _createClass2["default"])(ChainRegistryClient, [{
49
- key: "generateUrls",
50
- value: function generateUrls() {
51
- var _this$_options = this._options,
52
- chainNames = _this$_options.chainNames,
53
- assetListNames = _this$_options.assetListNames,
54
- ibcNamePairs = _this$_options.ibcNamePairs,
55
- baseUrl = _this$_options.baseUrl;
56
- var chainUrls = chainNames.map(function (chain) {
57
- return "".concat(baseUrl, "/").concat(chain, "/chain.json");
58
- });
59
- var assetlistUrls = (assetListNames || chainNames).map(function (chain) {
60
- return "".concat(baseUrl, "/").concat(chain, "/assetlist.json");
61
- });
62
- var namePairs = ibcNamePairs;
63
- if (!namePairs) {
64
- namePairs = [];
65
- for (var i = 0; i < chainNames.length; i++) {
66
- for (var j = i + 1; j < chainNames.length; j++) {
67
- namePairs.push([chainNames[i], chainNames[j]]);
68
- }
69
- }
70
- }
71
- var ibcUrls = namePairs.map(function (namePair) {
72
- var fileName = namePair[0].localeCompare(namePair[1]) <= 0 ? "".concat(namePair[0], "-").concat(namePair[1], ".json") : "".concat(namePair[1], "-").concat(namePair[0], ".json");
73
- return "".concat(baseUrl, "/_IBC/").concat(fileName);
74
- });
75
- this.urls = (0, _toConsumableArray2["default"])(new Set([].concat((0, _toConsumableArray2["default"])(chainUrls), (0, _toConsumableArray2["default"])(assetlistUrls), (0, _toConsumableArray2["default"])(ibcUrls), (0, _toConsumableArray2["default"])(this.urls || []))));
76
- }
77
- }, {
78
- key: "getChainUtil",
79
- value: function getChainUtil(chainName) {
80
- var chainInfo = this.getChainInfo(chainName);
81
- return new _chainUtil.ChainRegistryChainUtil({
82
- chainName: chainName,
83
- chainInfo: chainInfo
84
- });
85
- }
86
- }]);
87
- return ChainRegistryClient;
88
- }(_fetcher.ChainRegistryFetcher);
@@ -1,19 +0,0 @@
1
- import { AssetList, Chain, IBCInfo } from '@chain-registry/types';
2
- import { ChainRegistryFetcher } from './fetcher';
3
- export interface ChainInfoOptions {
4
- chainName: string;
5
- fetcher: ChainRegistryFetcher;
6
- }
7
- export declare class ChainInfo {
8
- chainName: string;
9
- fetcher: ChainRegistryFetcher;
10
- protected _chain: Chain;
11
- protected _assetList: AssetList;
12
- protected _assetLists: AssetList[];
13
- protected _ibcData: IBCInfo[];
14
- constructor(options: ChainInfoOptions);
15
- refresh(): void;
16
- get chain(): Chain;
17
- get nativeAssetList(): AssetList;
18
- get assetLists(): any[];
19
- }
@@ -1,24 +0,0 @@
1
- import { Asset } from '@chain-registry/types';
2
- import type { CoinDenom, CoinGeckoUSD, Exponent, PriceHash } from '@chain-registry/utils';
3
- import { ChainInfo } from './chain-info';
4
- export interface ChainRegistryChainUtilOptions {
5
- chainName: string;
6
- chainInfo: ChainInfo;
7
- }
8
- export declare class ChainRegistryChainUtil {
9
- chainName: string;
10
- chainInfo: ChainInfo;
11
- private _assets;
12
- constructor(options: ChainRegistryChainUtilOptions);
13
- getAssetByDenom(denom: CoinDenom): Asset;
14
- getDenomByCoinGeckoId(coinGeckoId: string): CoinDenom;
15
- getCoinGeckoIdByDenom(coinGeckoId: string): CoinDenom;
16
- getSymbolByChainDenom(denom: CoinDenom): string;
17
- getChainDenomBySymbol(token: string): CoinDenom;
18
- getExponentByDenom(denom: CoinDenom): Exponent;
19
- convertCoinGeckoPricesToDenomPriceMap(prices: Record<string, CoinGeckoUSD>): PriceHash;
20
- noDecimals(num: number | string): string;
21
- convertBaseUnitsToDollarValue(prices: PriceHash, symbol: string, amount: string | number): string;
22
- convertDollarValueToDenomUnits(prices: PriceHash, symbol: string, value: string | number): string;
23
- convertBaseUnitsToDisplayUnits(symbol: string, amount: string | number): string;
24
- }
@@ -1,30 +0,0 @@
1
- import { AssetList, Chain, ChainRegistry, IBCInfo } from '@chain-registry/types';
2
- import { ChainInfo } from './chain-info';
3
- export interface ChainRegistryFetcherOptions {
4
- assetLists?: AssetList[];
5
- chains?: Chain[];
6
- ibcData?: IBCInfo[];
7
- urls?: string[];
8
- }
9
- export declare class ChainRegistryFetcher implements ChainRegistry {
10
- urls: string[];
11
- protected _assetLists: AssetList[];
12
- protected _chains: Chain[];
13
- protected _ibcData: IBCInfo[];
14
- private chainInfoList;
15
- constructor(options?: ChainRegistryFetcherOptions);
16
- get chains(): Chain[];
17
- get assetLists(): AssetList[];
18
- get ibcData(): IBCInfo[];
19
- getChain(chainName: string): Chain;
20
- getChainAssetList(chainName: string): AssetList;
21
- getGeneratedAssetLists(chainName: string): AssetList[];
22
- getChainIbcData(chainName: string): IBCInfo[];
23
- getChainInfo(chainName: string): ChainInfo;
24
- upsertChain(data: Chain): void;
25
- updateAssetList(data: AssetList): void;
26
- upsertIbcData(data: IBCInfo): void;
27
- update(data: Chain | AssetList | IBCInfo): void;
28
- fetch(url: any): Promise<void>;
29
- fetchUrls(): Promise<void[]>;
30
- }
@@ -1,14 +0,0 @@
1
- import { ChainRegistryChainUtil } from './chain-util';
2
- import { ChainRegistryFetcher, ChainRegistryFetcherOptions } from './fetcher';
3
- export interface ChainRegistryClientOptions extends ChainRegistryFetcherOptions {
4
- chainNames: string[];
5
- assetListNames?: string[];
6
- ibcNamePairs?: string[][];
7
- baseUrl?: string;
8
- }
9
- export declare class ChainRegistryClient extends ChainRegistryFetcher {
10
- protected _options: ChainRegistryClientOptions;
11
- constructor(options: ChainRegistryClientOptions);
12
- generateUrls(): void;
13
- getChainUtil(chainName: string): ChainRegistryChainUtil;
14
- }