@chain-registry/client 1.14.0 → 1.14.2
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/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/main/chain-info.js +12 -12
- package/main/chain-util.js +16 -16
- package/main/fetcher.js +17 -17
- package/main/registry.js +3 -3
- package/package.json +6 -3
- package/types/chain-info.d.ts +13 -16
- package/types/chain-util.d.ts +17 -38
- package/types/fetcher.d.ts +25 -33
- package/types/registry.d.ts +9 -11
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.14.2](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/client@1.14.1...@chain-registry/client@1.14.2) (2023-07-30)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @chain-registry/client
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [1.14.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/client@1.14.0...@chain-registry/client@1.14.1) (2023-07-12)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @chain-registry/client
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [1.14.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/client@1.13.0...@chain-registry/client@1.14.0) (2023-07-11)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @chain-registry/client
|
package/README.md
CHANGED
|
@@ -101,7 +101,7 @@ const assetes: AssetList[] = chainInfo.nativeAssetLists;
|
|
|
101
101
|
Checkout these related projects:
|
|
102
102
|
|
|
103
103
|
* [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen) for generated CosmWasm contract Typescript classes
|
|
104
|
-
* [@
|
|
104
|
+
* [@cosmology/telescope](https://github.com/cosmology-tech/telescope) a "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs.
|
|
105
105
|
* [chain-registry](https://github.com/cosmology-tech/chain-registry) an npm module for the official Cosmos chain-registry.
|
|
106
106
|
* [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit) A wallet connector for the Cosmos ⚛️
|
|
107
107
|
* [create-cosmos-app](https://github.com/cosmology-tech/create-cosmos-app) set up a modern Cosmos app by running one command.
|
package/main/chain-info.js
CHANGED
|
@@ -12,28 +12,28 @@ var _utils = require("@chain-registry/utils");
|
|
|
12
12
|
var ChainInfo = /*#__PURE__*/function () {
|
|
13
13
|
function ChainInfo(options) {
|
|
14
14
|
(0, _classCallCheck2["default"])(this, ChainInfo);
|
|
15
|
-
(0, _defineProperty2["default"])(this, "
|
|
15
|
+
(0, _defineProperty2["default"])(this, "chainName", void 0);
|
|
16
16
|
(0, _defineProperty2["default"])(this, "fetcher", void 0);
|
|
17
17
|
(0, _defineProperty2["default"])(this, "_chain", void 0);
|
|
18
|
-
(0, _defineProperty2["default"])(this, "
|
|
19
|
-
(0, _defineProperty2["default"])(this, "
|
|
20
|
-
(0, _defineProperty2["default"])(this, "
|
|
21
|
-
this.
|
|
18
|
+
(0, _defineProperty2["default"])(this, "_assetList", void 0);
|
|
19
|
+
(0, _defineProperty2["default"])(this, "_assetLists", void 0);
|
|
20
|
+
(0, _defineProperty2["default"])(this, "_ibcData", []);
|
|
21
|
+
this.chainName = options.chainName;
|
|
22
22
|
this.fetcher = options.fetcher;
|
|
23
23
|
this.refresh();
|
|
24
24
|
}
|
|
25
25
|
(0, _createClass2["default"])(ChainInfo, [{
|
|
26
26
|
key: "refresh",
|
|
27
27
|
value: function refresh() {
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
30
|
-
this._chain = this.fetcher.getChain(this.
|
|
31
|
-
var supportedChains = this.
|
|
28
|
+
this._assetList = this.fetcher.getChainAssetList(this.chainName);
|
|
29
|
+
this._ibcData = this.fetcher.getChainIbcData(this.chainName);
|
|
30
|
+
this._chain = this.fetcher.getChain(this.chainName);
|
|
31
|
+
var supportedChains = this._ibcData.reduce(function (m, v) {
|
|
32
32
|
if (!m.includes(v.chain_1.chain_name)) m.push(v.chain_1.chain_name);
|
|
33
33
|
if (!m.includes(v.chain_2.chain_name)) m.push(v.chain_2.chain_name);
|
|
34
34
|
return m;
|
|
35
35
|
}, []);
|
|
36
|
-
this.
|
|
36
|
+
this._assetLists = this.fetcher.assetLists.filter(function (list) {
|
|
37
37
|
return supportedChains.includes(list.chain_name);
|
|
38
38
|
});
|
|
39
39
|
}
|
|
@@ -45,12 +45,12 @@ var ChainInfo = /*#__PURE__*/function () {
|
|
|
45
45
|
}, {
|
|
46
46
|
key: "nativeAssetLists",
|
|
47
47
|
get: function get() {
|
|
48
|
-
return this.
|
|
48
|
+
return this._assetList;
|
|
49
49
|
}
|
|
50
50
|
}, {
|
|
51
51
|
key: "assetLists",
|
|
52
52
|
get: function get() {
|
|
53
|
-
return (0, _utils.getAssetLists)(this.
|
|
53
|
+
return (0, _utils.getAssetLists)(this.chainName, this._ibcData, this._assetLists);
|
|
54
54
|
}
|
|
55
55
|
}]);
|
|
56
56
|
return ChainInfo;
|
package/main/chain-util.js
CHANGED
|
@@ -13,45 +13,45 @@ var _utils = require("@chain-registry/utils");
|
|
|
13
13
|
var ChainRegistryChainUtil = /*#__PURE__*/function () {
|
|
14
14
|
function ChainRegistryChainUtil(options) {
|
|
15
15
|
(0, _classCallCheck2["default"])(this, ChainRegistryChainUtil);
|
|
16
|
-
(0, _defineProperty2["default"])(this, "
|
|
17
|
-
(0, _defineProperty2["default"])(this, "
|
|
18
|
-
(0, _defineProperty2["default"])(this, "
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
16
|
+
(0, _defineProperty2["default"])(this, "chainName", void 0);
|
|
17
|
+
(0, _defineProperty2["default"])(this, "chainInfo", void 0);
|
|
18
|
+
(0, _defineProperty2["default"])(this, "allAsset", void 0);
|
|
19
|
+
this.chainName = options.chainName;
|
|
20
|
+
this.chainInfo = options.chainInfo;
|
|
21
|
+
this.allAsset = this.chainInfo.assetLists.reduce(function (m, it) {
|
|
22
22
|
[].push.apply(m, it.assets);
|
|
23
23
|
return m;
|
|
24
|
-
}, (0, _toConsumableArray2["default"])(this.
|
|
24
|
+
}, (0, _toConsumableArray2["default"])(this.chainInfo.nativeAssetLists.assets));
|
|
25
25
|
}
|
|
26
26
|
(0, _createClass2["default"])(ChainRegistryChainUtil, [{
|
|
27
27
|
key: "getAssetByDenom",
|
|
28
28
|
value: function getAssetByDenom(denom) {
|
|
29
|
-
return (0, _utils.getAssetByDenom)(this.
|
|
29
|
+
return (0, _utils.getAssetByDenom)(this.allAsset, denom);
|
|
30
30
|
}
|
|
31
31
|
}, {
|
|
32
32
|
key: "getDenomByCoinGeckoId",
|
|
33
33
|
value: function getDenomByCoinGeckoId(coinGeckoId) {
|
|
34
|
-
return (0, _utils.getDenomByCoinGeckoId)(this.
|
|
34
|
+
return (0, _utils.getDenomByCoinGeckoId)(this.allAsset, coinGeckoId);
|
|
35
35
|
}
|
|
36
36
|
}, {
|
|
37
37
|
key: "getSymbolByChainDenom",
|
|
38
38
|
value: function getSymbolByChainDenom(denom) {
|
|
39
|
-
return (0, _utils.getSymbolByChainDenom)(this.
|
|
39
|
+
return (0, _utils.getSymbolByChainDenom)(this.allAsset, denom);
|
|
40
40
|
}
|
|
41
41
|
}, {
|
|
42
42
|
key: "getChainDenomBySymbol",
|
|
43
43
|
value: function getChainDenomBySymbol(token) {
|
|
44
|
-
return (0, _utils.getChainDenomBySymbol)(this.
|
|
44
|
+
return (0, _utils.getChainDenomBySymbol)(this.allAsset, token);
|
|
45
45
|
}
|
|
46
46
|
}, {
|
|
47
47
|
key: "getExponentByDenom",
|
|
48
48
|
value: function getExponentByDenom(denom) {
|
|
49
|
-
return (0, _utils.getExponentByDenom)(this.
|
|
49
|
+
return (0, _utils.getExponentByDenom)(this.allAsset, denom);
|
|
50
50
|
}
|
|
51
51
|
}, {
|
|
52
52
|
key: "convertCoinGeckoPricesToDenomPriceMap",
|
|
53
53
|
value: function convertCoinGeckoPricesToDenomPriceMap(prices) {
|
|
54
|
-
return (0, _utils.convertCoinGeckoPricesToDenomPriceMap)(this.
|
|
54
|
+
return (0, _utils.convertCoinGeckoPricesToDenomPriceMap)(this.allAsset, prices);
|
|
55
55
|
}
|
|
56
56
|
}, {
|
|
57
57
|
key: "noDecimals",
|
|
@@ -61,17 +61,17 @@ var ChainRegistryChainUtil = /*#__PURE__*/function () {
|
|
|
61
61
|
}, {
|
|
62
62
|
key: "convertBaseUnitsToDollarValue",
|
|
63
63
|
value: function convertBaseUnitsToDollarValue(prices, symbol, amount) {
|
|
64
|
-
return (0, _utils.convertBaseUnitsToDollarValue)(this.
|
|
64
|
+
return (0, _utils.convertBaseUnitsToDollarValue)(this.allAsset, prices, symbol, amount);
|
|
65
65
|
}
|
|
66
66
|
}, {
|
|
67
67
|
key: "convertDollarValueToDenomUnits",
|
|
68
68
|
value: function convertDollarValueToDenomUnits(prices, symbol, value) {
|
|
69
|
-
return (0, _utils.convertDollarValueToDenomUnits)(this.
|
|
69
|
+
return (0, _utils.convertDollarValueToDenomUnits)(this.allAsset, prices, symbol, value);
|
|
70
70
|
}
|
|
71
71
|
}, {
|
|
72
72
|
key: "convertBaseUnitsToDisplayUnits",
|
|
73
73
|
value: function convertBaseUnitsToDisplayUnits(symbol, amount) {
|
|
74
|
-
return (0, _utils.convertBaseUnitsToDisplayUnits)(this.
|
|
74
|
+
return (0, _utils.convertBaseUnitsToDisplayUnits)(this.allAsset, symbol, amount);
|
|
75
75
|
}
|
|
76
76
|
}]);
|
|
77
77
|
return ChainRegistryChainUtil;
|
package/main/fetcher.js
CHANGED
|
@@ -28,19 +28,19 @@ var ChainRegistryFetcher = /*#__PURE__*/function () {
|
|
|
28
28
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
29
29
|
(0, _classCallCheck2["default"])(this, ChainRegistryFetcher);
|
|
30
30
|
(0, _defineProperty2["default"])(this, "urls", []);
|
|
31
|
-
(0, _defineProperty2["default"])(this, "
|
|
31
|
+
(0, _defineProperty2["default"])(this, "_assetLists", []);
|
|
32
32
|
(0, _defineProperty2["default"])(this, "_chains", []);
|
|
33
|
-
(0, _defineProperty2["default"])(this, "
|
|
33
|
+
(0, _defineProperty2["default"])(this, "_ibcData", []);
|
|
34
34
|
(0, _defineProperty2["default"])(this, "chainInfoList", []);
|
|
35
35
|
//
|
|
36
36
|
if (options.chains) {
|
|
37
37
|
this._chains = options.chains;
|
|
38
38
|
}
|
|
39
39
|
if (options.assetLists) {
|
|
40
|
-
this.
|
|
40
|
+
this._assetLists = options.assetLists;
|
|
41
41
|
}
|
|
42
42
|
if (options.ibcData) {
|
|
43
|
-
this.
|
|
43
|
+
this._ibcData = options.ibcData;
|
|
44
44
|
}
|
|
45
45
|
if (options.urls) {
|
|
46
46
|
this.urls = options.urls;
|
|
@@ -54,12 +54,12 @@ var ChainRegistryFetcher = /*#__PURE__*/function () {
|
|
|
54
54
|
}, {
|
|
55
55
|
key: "assetLists",
|
|
56
56
|
get: function get() {
|
|
57
|
-
return this.
|
|
57
|
+
return this._assetLists;
|
|
58
58
|
}
|
|
59
59
|
}, {
|
|
60
60
|
key: "ibcData",
|
|
61
61
|
get: function get() {
|
|
62
|
-
return this.
|
|
62
|
+
return this._ibcData;
|
|
63
63
|
}
|
|
64
64
|
}, {
|
|
65
65
|
key: "getChain",
|
|
@@ -71,19 +71,19 @@ var ChainRegistryFetcher = /*#__PURE__*/function () {
|
|
|
71
71
|
}, {
|
|
72
72
|
key: "getChainAssetList",
|
|
73
73
|
value: function getChainAssetList(chainName) {
|
|
74
|
-
return this.
|
|
74
|
+
return this._assetLists.find(function (list) {
|
|
75
75
|
return list.chain_name === chainName;
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
}, {
|
|
79
79
|
key: "getGeneratedAssetLists",
|
|
80
80
|
value: function getGeneratedAssetLists(chainName) {
|
|
81
|
-
return (0, _utils.getAssetLists)(chainName, this.
|
|
81
|
+
return (0, _utils.getAssetLists)(chainName, this._ibcData, this._assetLists);
|
|
82
82
|
}
|
|
83
83
|
}, {
|
|
84
84
|
key: "getChainIbcData",
|
|
85
85
|
value: function getChainIbcData(chainName) {
|
|
86
|
-
return this.
|
|
86
|
+
return this._ibcData.filter(function (info) {
|
|
87
87
|
return info.chain_1.chain_name === chainName || info.chain_2.chain_name === chainName;
|
|
88
88
|
});
|
|
89
89
|
}
|
|
@@ -91,11 +91,11 @@ var ChainRegistryFetcher = /*#__PURE__*/function () {
|
|
|
91
91
|
key: "getChainInfo",
|
|
92
92
|
value: function getChainInfo(chainName) {
|
|
93
93
|
var chainInfo = this.chainInfoList.find(function (it) {
|
|
94
|
-
return it.
|
|
94
|
+
return it.chainName === chainName;
|
|
95
95
|
});
|
|
96
96
|
if (!chainInfo) {
|
|
97
97
|
chainInfo = new _chainInfo.ChainInfo({
|
|
98
|
-
|
|
98
|
+
chainName: chainName,
|
|
99
99
|
fetcher: this
|
|
100
100
|
});
|
|
101
101
|
this.chainInfoList.push(chainInfo);
|
|
@@ -123,14 +123,14 @@ var ChainRegistryFetcher = /*#__PURE__*/function () {
|
|
|
123
123
|
}, {
|
|
124
124
|
key: "updateAssetList",
|
|
125
125
|
value: function updateAssetList(data) {
|
|
126
|
-
var found = this.
|
|
126
|
+
var found = this._assetLists.find(function (list) {
|
|
127
127
|
return list.chain_name === data.chain_name;
|
|
128
128
|
});
|
|
129
129
|
if (!found) {
|
|
130
|
-
this.
|
|
130
|
+
this._assetLists.push(data);
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
|
-
this.
|
|
133
|
+
this._assetLists = this._assetLists.map(function (list) {
|
|
134
134
|
if (list.chain_name === data.chain_name) {
|
|
135
135
|
return data;
|
|
136
136
|
} else {
|
|
@@ -141,14 +141,14 @@ var ChainRegistryFetcher = /*#__PURE__*/function () {
|
|
|
141
141
|
}, {
|
|
142
142
|
key: "upsertIbcData",
|
|
143
143
|
value: function upsertIbcData(data) {
|
|
144
|
-
var found = this.
|
|
144
|
+
var found = this._ibcData.find(function (info) {
|
|
145
145
|
return info.chain_1.chain_name === data.chain_1.chain_name && info.chain_2.chain_name === data.chain_2.chain_name;
|
|
146
146
|
});
|
|
147
147
|
if (!found) {
|
|
148
|
-
this.
|
|
148
|
+
this._ibcData.push(data);
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
|
-
this.
|
|
151
|
+
this._ibcData = this._ibcData.map(function (info) {
|
|
152
152
|
if (info.chain_1.chain_name === data.chain_1.chain_name && info.chain_2.chain_name === data.chain_2.chain_name) {
|
|
153
153
|
return data;
|
|
154
154
|
} else {
|
package/main/registry.js
CHANGED
|
@@ -73,15 +73,15 @@ var ChainRegistryClient = /*#__PURE__*/function (_ChainRegistryFetcher) {
|
|
|
73
73
|
var fileName = namePair[0].localeCompare(namePair[1]) <= 0 ? "".concat(namePair[0], "-").concat(namePair[1], ".json") : "".concat(namePair[1], "-").concat(namePair[0], ".json");
|
|
74
74
|
return "".concat(baseUrl, "/_IBC/").concat(fileName);
|
|
75
75
|
});
|
|
76
|
-
this.urls = [].concat((0, _toConsumableArray2["default"])(chainUrls), (0, _toConsumableArray2["default"])(assetlistUrls), (0, _toConsumableArray2["default"])(ibcUrls));
|
|
76
|
+
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 || []))));
|
|
77
77
|
}
|
|
78
78
|
}, {
|
|
79
79
|
key: "getChainUtil",
|
|
80
80
|
value: function getChainUtil(chainName) {
|
|
81
81
|
var chainInfo = this.getChainInfo(chainName);
|
|
82
82
|
return new _chainUtil.ChainRegistryChainUtil({
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
chainName: chainName,
|
|
84
|
+
chainInfo: chainInfo
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
}]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chain-registry/client",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.2",
|
|
4
4
|
"description": "Chain Registry Client",
|
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/cosmology-tech/chain-registry",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"@babel/preset-typescript": "^7.21.4",
|
|
54
54
|
"@types/jest": "^29.5.1",
|
|
55
55
|
"@types/sha.js": "^2.4.0",
|
|
56
|
+
"@types/supertest": "2.0.12",
|
|
56
57
|
"@typescript-eslint/eslint-plugin": "5.59.0",
|
|
57
58
|
"@typescript-eslint/parser": "5.59.0",
|
|
58
59
|
"babel-core": "7.0.0-bridge.0",
|
|
@@ -66,17 +67,19 @@
|
|
|
66
67
|
"eslint-plugin-unused-imports": "2.0.0",
|
|
67
68
|
"jest": "^29.5.0",
|
|
68
69
|
"long": "^5.2.0",
|
|
70
|
+
"nock": "13.3.2",
|
|
69
71
|
"prettier": "^2.8.7",
|
|
70
72
|
"regenerator-runtime": "^0.13.11",
|
|
73
|
+
"supertest": "6.3.3",
|
|
71
74
|
"ts-jest": "^29.1.0",
|
|
72
75
|
"typescript": "^5.0.4"
|
|
73
76
|
},
|
|
74
77
|
"dependencies": {
|
|
75
78
|
"@babel/runtime": "^7.21.0",
|
|
76
79
|
"@chain-registry/types": "^0.16.0",
|
|
77
|
-
"@chain-registry/utils": "^1.13.
|
|
80
|
+
"@chain-registry/utils": "^1.13.2",
|
|
78
81
|
"bfs-path": "^1.0.2",
|
|
79
82
|
"cross-fetch": "^3.1.5"
|
|
80
83
|
},
|
|
81
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "7643eb9d080056f05ac9284447cfca8d4aaf5470"
|
|
82
85
|
}
|
package/types/chain-info.d.ts
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import { AssetList, Chain, IBCInfo } from '@chain-registry/types';
|
|
2
|
-
|
|
3
2
|
import { ChainRegistryFetcher } from './fetcher';
|
|
4
|
-
|
|
5
3
|
export interface ChainInfoOptions {
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
chain_name: string;
|
|
5
|
+
fetcher: ChainRegistryFetcher;
|
|
8
6
|
}
|
|
9
|
-
|
|
10
7
|
export declare class ChainInfo {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
chain_name: string;
|
|
9
|
+
fetcher: ChainRegistryFetcher;
|
|
10
|
+
protected _chain: Chain;
|
|
11
|
+
protected _asset_list: AssetList;
|
|
12
|
+
protected _asset_lists: AssetList[];
|
|
13
|
+
protected _ibc_data: IBCInfo[];
|
|
14
|
+
constructor(options: ChainInfoOptions);
|
|
15
|
+
refresh(): void;
|
|
16
|
+
get chain(): Chain;
|
|
17
|
+
get nativeAssetLists(): AssetList;
|
|
18
|
+
get assetLists(): any[];
|
|
22
19
|
}
|
package/types/chain-util.d.ts
CHANGED
|
@@ -1,44 +1,23 @@
|
|
|
1
1
|
import { Asset } from '@chain-registry/types';
|
|
2
|
-
import type {
|
|
3
|
-
CoinDenom,
|
|
4
|
-
CoinGeckoUSD,
|
|
5
|
-
Exponent,
|
|
6
|
-
PriceHash
|
|
7
|
-
} from '@chain-registry/utils';
|
|
8
|
-
|
|
2
|
+
import type { CoinDenom, CoinGeckoUSD, Exponent, PriceHash } from '@chain-registry/utils';
|
|
9
3
|
import { ChainInfo } from './chain-info';
|
|
10
|
-
|
|
11
4
|
export interface ChainRegistryChainUtilOptions {
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
chain_name: string;
|
|
6
|
+
chain_info: ChainInfo;
|
|
14
7
|
}
|
|
15
|
-
|
|
16
8
|
export declare class ChainRegistryChainUtil {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
prices: PriceHash,
|
|
32
|
-
symbol: string,
|
|
33
|
-
amount: string | number
|
|
34
|
-
): string;
|
|
35
|
-
convertDollarValueToDenomUnits(
|
|
36
|
-
prices: PriceHash,
|
|
37
|
-
symbol: string,
|
|
38
|
-
value: string | number
|
|
39
|
-
): string;
|
|
40
|
-
convertBaseUnitsToDisplayUnits(
|
|
41
|
-
symbol: string,
|
|
42
|
-
amount: string | number
|
|
43
|
-
): string;
|
|
9
|
+
chain_name: string;
|
|
10
|
+
chain_info: ChainInfo;
|
|
11
|
+
_all_Asset: Asset[];
|
|
12
|
+
constructor(options: ChainRegistryChainUtilOptions);
|
|
13
|
+
getAssetByDenom(denom: CoinDenom): Asset;
|
|
14
|
+
getDenomByCoinGeckoId(coinGeckoId: string): CoinDenom;
|
|
15
|
+
getSymbolByChainDenom(denom: CoinDenom): string;
|
|
16
|
+
getChainDenomBySymbol(token: string): CoinDenom;
|
|
17
|
+
getExponentByDenom(denom: CoinDenom): Exponent;
|
|
18
|
+
convertCoinGeckoPricesToDenomPriceMap(prices: Record<string, CoinGeckoUSD>): PriceHash;
|
|
19
|
+
noDecimals(num: number | string): string;
|
|
20
|
+
convertBaseUnitsToDollarValue(prices: PriceHash, symbol: string, amount: string | number): string;
|
|
21
|
+
convertDollarValueToDenomUnits(prices: PriceHash, symbol: string, value: string | number): string;
|
|
22
|
+
convertBaseUnitsToDisplayUnits(symbol: string, amount: string | number): string;
|
|
44
23
|
}
|
package/types/fetcher.d.ts
CHANGED
|
@@ -1,38 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AssetList,
|
|
3
|
-
Chain,
|
|
4
|
-
ChainRegistry,
|
|
5
|
-
IBCInfo
|
|
6
|
-
} from '@chain-registry/types';
|
|
7
|
-
|
|
1
|
+
import { AssetList, Chain, ChainRegistry, IBCInfo } from '@chain-registry/types';
|
|
8
2
|
import { ChainInfo } from './chain-info';
|
|
9
|
-
|
|
10
3
|
export interface ChainRegistryFetcherOptions {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
assetLists?: AssetList[];
|
|
5
|
+
chains?: Chain[];
|
|
6
|
+
ibcData?: IBCInfo[];
|
|
7
|
+
urls?: string[];
|
|
15
8
|
}
|
|
16
|
-
|
|
17
9
|
export declare class ChainRegistryFetcher implements ChainRegistry {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
10
|
+
urls: string[];
|
|
11
|
+
protected _asset_lists: AssetList[];
|
|
12
|
+
protected _chains: Chain[];
|
|
13
|
+
protected _ibc_data: 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[]>;
|
|
38
30
|
}
|
package/types/registry.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { ChainRegistryChainUtil } from './chain-util';
|
|
2
2
|
import { ChainRegistryFetcher, ChainRegistryFetcherOptions } from './fetcher';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ibcNamePairs?: string[][];
|
|
9
|
-
baseUrl?: string;
|
|
3
|
+
export interface ChainRegistryClientOptions extends ChainRegistryFetcherOptions {
|
|
4
|
+
chainNames: string[];
|
|
5
|
+
assetListNames?: string[];
|
|
6
|
+
ibcNamePairs?: string[][];
|
|
7
|
+
baseUrl?: string;
|
|
10
8
|
}
|
|
11
9
|
export declare class ChainRegistryClient extends ChainRegistryFetcher {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
protected _options: ChainRegistryClientOptions;
|
|
11
|
+
constructor(options: ChainRegistryClientOptions);
|
|
12
|
+
generateUrls(): void;
|
|
13
|
+
getChainUtil(chainName: string): ChainRegistryChainUtil;
|
|
16
14
|
}
|