@chain-registry/client 1.13.0 → 1.14.1
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/main/chain-info.js +58 -0
- package/main/chain-util.js +79 -0
- package/main/fetcher.js +230 -0
- package/main/index.js +33 -0
- package/main/registry.js +70 -244
- package/package.json +3 -3
- package/types/chain-info.d.ts +19 -0
- package/types/chain-util.d.ts +23 -0
- package/types/fetcher.d.ts +30 -0
- package/types/index.d.ts +3 -0
- package/types/registry.d.ts +13 -44
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.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/client@1.14.0...@chain-registry/client@1.14.1) (2023-07-12)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @chain-registry/client
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [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)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @chain-registry/client
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [1.13.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/client@1.12.0...@chain-registry/client@1.13.0) (2023-07-08)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @chain-registry/client
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ChainInfo = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _utils = require("@chain-registry/utils");
|
|
12
|
+
var ChainInfo = /*#__PURE__*/function () {
|
|
13
|
+
function ChainInfo(options) {
|
|
14
|
+
(0, _classCallCheck2["default"])(this, ChainInfo);
|
|
15
|
+
(0, _defineProperty2["default"])(this, "chain_name", void 0);
|
|
16
|
+
(0, _defineProperty2["default"])(this, "fetcher", void 0);
|
|
17
|
+
(0, _defineProperty2["default"])(this, "_chain", void 0);
|
|
18
|
+
(0, _defineProperty2["default"])(this, "_asset_list", void 0);
|
|
19
|
+
(0, _defineProperty2["default"])(this, "_asset_lists", void 0);
|
|
20
|
+
(0, _defineProperty2["default"])(this, "_ibc_data", []);
|
|
21
|
+
this.chain_name = options.chain_name;
|
|
22
|
+
this.fetcher = options.fetcher;
|
|
23
|
+
this.refresh();
|
|
24
|
+
}
|
|
25
|
+
(0, _createClass2["default"])(ChainInfo, [{
|
|
26
|
+
key: "refresh",
|
|
27
|
+
value: function refresh() {
|
|
28
|
+
this._asset_list = this.fetcher.getChainAssetList(this.chain_name);
|
|
29
|
+
this._ibc_data = this.fetcher.getChainIbcData(this.chain_name);
|
|
30
|
+
this._chain = this.fetcher.getChain(this.chain_name);
|
|
31
|
+
var supportedChains = this._ibc_data.reduce(function (m, v) {
|
|
32
|
+
if (!m.includes(v.chain_1.chain_name)) m.push(v.chain_1.chain_name);
|
|
33
|
+
if (!m.includes(v.chain_2.chain_name)) m.push(v.chain_2.chain_name);
|
|
34
|
+
return m;
|
|
35
|
+
}, []);
|
|
36
|
+
this._asset_lists = this.fetcher.assetLists.filter(function (list) {
|
|
37
|
+
return supportedChains.includes(list.chain_name);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}, {
|
|
41
|
+
key: "chain",
|
|
42
|
+
get: function get() {
|
|
43
|
+
return this._chain;
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
key: "nativeAssetLists",
|
|
47
|
+
get: function get() {
|
|
48
|
+
return this._asset_list;
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
key: "assetLists",
|
|
52
|
+
get: function get() {
|
|
53
|
+
return (0, _utils.getAssetLists)(this.chain_name, this._ibc_data, this._asset_lists);
|
|
54
|
+
}
|
|
55
|
+
}]);
|
|
56
|
+
return ChainInfo;
|
|
57
|
+
}();
|
|
58
|
+
exports.ChainInfo = ChainInfo;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ChainRegistryChainUtil = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
+
var _utils = require("@chain-registry/utils");
|
|
13
|
+
var ChainRegistryChainUtil = /*#__PURE__*/function () {
|
|
14
|
+
function ChainRegistryChainUtil(options) {
|
|
15
|
+
(0, _classCallCheck2["default"])(this, ChainRegistryChainUtil);
|
|
16
|
+
(0, _defineProperty2["default"])(this, "chain_name", void 0);
|
|
17
|
+
(0, _defineProperty2["default"])(this, "chain_info", void 0);
|
|
18
|
+
(0, _defineProperty2["default"])(this, "_all_Asset", void 0);
|
|
19
|
+
this.chain_name = options.chain_name;
|
|
20
|
+
this.chain_info = options.chain_info;
|
|
21
|
+
this._all_Asset = this.chain_info.assetLists.reduce(function (m, it) {
|
|
22
|
+
[].push.apply(m, it.assets);
|
|
23
|
+
return m;
|
|
24
|
+
}, (0, _toConsumableArray2["default"])(this.chain_info.nativeAssetLists.assets));
|
|
25
|
+
}
|
|
26
|
+
(0, _createClass2["default"])(ChainRegistryChainUtil, [{
|
|
27
|
+
key: "getAssetByDenom",
|
|
28
|
+
value: function getAssetByDenom(denom) {
|
|
29
|
+
return (0, _utils.getAssetByDenom)(this._all_Asset, denom);
|
|
30
|
+
}
|
|
31
|
+
}, {
|
|
32
|
+
key: "getDenomByCoinGeckoId",
|
|
33
|
+
value: function getDenomByCoinGeckoId(coinGeckoId) {
|
|
34
|
+
return (0, _utils.getDenomByCoinGeckoId)(this._all_Asset, coinGeckoId);
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
key: "getSymbolByChainDenom",
|
|
38
|
+
value: function getSymbolByChainDenom(denom) {
|
|
39
|
+
return (0, _utils.getSymbolByChainDenom)(this._all_Asset, denom);
|
|
40
|
+
}
|
|
41
|
+
}, {
|
|
42
|
+
key: "getChainDenomBySymbol",
|
|
43
|
+
value: function getChainDenomBySymbol(token) {
|
|
44
|
+
return (0, _utils.getChainDenomBySymbol)(this._all_Asset, token);
|
|
45
|
+
}
|
|
46
|
+
}, {
|
|
47
|
+
key: "getExponentByDenom",
|
|
48
|
+
value: function getExponentByDenom(denom) {
|
|
49
|
+
return (0, _utils.getExponentByDenom)(this._all_Asset, denom);
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
key: "convertCoinGeckoPricesToDenomPriceMap",
|
|
53
|
+
value: function convertCoinGeckoPricesToDenomPriceMap(prices) {
|
|
54
|
+
return (0, _utils.convertCoinGeckoPricesToDenomPriceMap)(this._all_Asset, prices);
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
key: "noDecimals",
|
|
58
|
+
value: function noDecimals(num) {
|
|
59
|
+
return (0, _utils.noDecimals)(num);
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "convertBaseUnitsToDollarValue",
|
|
63
|
+
value: function convertBaseUnitsToDollarValue(prices, symbol, amount) {
|
|
64
|
+
return (0, _utils.convertBaseUnitsToDollarValue)(this._all_Asset, prices, symbol, amount);
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
key: "convertDollarValueToDenomUnits",
|
|
68
|
+
value: function convertDollarValueToDenomUnits(prices, symbol, value) {
|
|
69
|
+
return (0, _utils.convertDollarValueToDenomUnits)(this._all_Asset, prices, symbol, value);
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "convertBaseUnitsToDisplayUnits",
|
|
73
|
+
value: function convertBaseUnitsToDisplayUnits(symbol, amount) {
|
|
74
|
+
return (0, _utils.convertBaseUnitsToDisplayUnits)(this._all_Asset, symbol, amount);
|
|
75
|
+
}
|
|
76
|
+
}]);
|
|
77
|
+
return ChainRegistryChainUtil;
|
|
78
|
+
}();
|
|
79
|
+
exports.ChainRegistryChainUtil = ChainRegistryChainUtil;
|
package/main/fetcher.js
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ChainRegistryFetcher = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
var _utils = require("@chain-registry/utils");
|
|
14
|
+
var _bfsPath = require("bfs-path");
|
|
15
|
+
var _crossFetch = _interopRequireDefault(require("cross-fetch"));
|
|
16
|
+
var _chainInfo = require("./chain-info");
|
|
17
|
+
var fetchUrl = function fetchUrl(url) {
|
|
18
|
+
return (0, _crossFetch["default"])(url).then(function (res) {
|
|
19
|
+
if (res.status >= 400) {
|
|
20
|
+
throw new Error('Bad response');
|
|
21
|
+
}
|
|
22
|
+
return res.json();
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
// QUESTION: should ChainRegistryFetcher just be ChainRegistry?
|
|
26
|
+
var ChainRegistryFetcher = /*#__PURE__*/function () {
|
|
27
|
+
function ChainRegistryFetcher() {
|
|
28
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
29
|
+
(0, _classCallCheck2["default"])(this, ChainRegistryFetcher);
|
|
30
|
+
(0, _defineProperty2["default"])(this, "urls", []);
|
|
31
|
+
(0, _defineProperty2["default"])(this, "_asset_lists", []);
|
|
32
|
+
(0, _defineProperty2["default"])(this, "_chains", []);
|
|
33
|
+
(0, _defineProperty2["default"])(this, "_ibc_data", []);
|
|
34
|
+
(0, _defineProperty2["default"])(this, "chainInfoList", []);
|
|
35
|
+
//
|
|
36
|
+
if (options.chains) {
|
|
37
|
+
this._chains = options.chains;
|
|
38
|
+
}
|
|
39
|
+
if (options.assetLists) {
|
|
40
|
+
this._asset_lists = options.assetLists;
|
|
41
|
+
}
|
|
42
|
+
if (options.ibcData) {
|
|
43
|
+
this._ibc_data = options.ibcData;
|
|
44
|
+
}
|
|
45
|
+
if (options.urls) {
|
|
46
|
+
this.urls = options.urls;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
(0, _createClass2["default"])(ChainRegistryFetcher, [{
|
|
50
|
+
key: "chains",
|
|
51
|
+
get: function get() {
|
|
52
|
+
return this._chains;
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
key: "assetLists",
|
|
56
|
+
get: function get() {
|
|
57
|
+
return this._asset_lists;
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
key: "ibcData",
|
|
61
|
+
get: function get() {
|
|
62
|
+
return this._ibc_data;
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "getChain",
|
|
66
|
+
value: function getChain(chainName) {
|
|
67
|
+
return this._chains.find(function (chain) {
|
|
68
|
+
return chain.chain_name === chainName;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "getChainAssetList",
|
|
73
|
+
value: function getChainAssetList(chainName) {
|
|
74
|
+
return this._asset_lists.find(function (list) {
|
|
75
|
+
return list.chain_name === chainName;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}, {
|
|
79
|
+
key: "getGeneratedAssetLists",
|
|
80
|
+
value: function getGeneratedAssetLists(chainName) {
|
|
81
|
+
return (0, _utils.getAssetLists)(chainName, this._ibc_data, this._asset_lists);
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
key: "getChainIbcData",
|
|
85
|
+
value: function getChainIbcData(chainName) {
|
|
86
|
+
return this._ibc_data.filter(function (info) {
|
|
87
|
+
return info.chain_1.chain_name === chainName || info.chain_2.chain_name === chainName;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "getChainInfo",
|
|
92
|
+
value: function getChainInfo(chainName) {
|
|
93
|
+
var chainInfo = this.chainInfoList.find(function (it) {
|
|
94
|
+
return it.chain_name === chainName;
|
|
95
|
+
});
|
|
96
|
+
if (!chainInfo) {
|
|
97
|
+
chainInfo = new _chainInfo.ChainInfo({
|
|
98
|
+
chain_name: chainName,
|
|
99
|
+
fetcher: this
|
|
100
|
+
});
|
|
101
|
+
this.chainInfoList.push(chainInfo);
|
|
102
|
+
}
|
|
103
|
+
return chainInfo;
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
key: "upsertChain",
|
|
107
|
+
value: function upsertChain(data) {
|
|
108
|
+
var found = this._chains.find(function (chain) {
|
|
109
|
+
return chain.chain_name === data.chain_name && chain.network_type === data.network_type;
|
|
110
|
+
});
|
|
111
|
+
if (!found) {
|
|
112
|
+
this._chains.push(data);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
this._chains = this._chains.map(function (chain) {
|
|
116
|
+
if (chain.chain_name === data.chain_name && chain.network_type === data.network_type) {
|
|
117
|
+
return data;
|
|
118
|
+
} else {
|
|
119
|
+
return chain;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
key: "updateAssetList",
|
|
125
|
+
value: function updateAssetList(data) {
|
|
126
|
+
var found = this._asset_lists.find(function (list) {
|
|
127
|
+
return list.chain_name === data.chain_name;
|
|
128
|
+
});
|
|
129
|
+
if (!found) {
|
|
130
|
+
this._asset_lists.push(data);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
this._asset_lists = this._asset_lists.map(function (list) {
|
|
134
|
+
if (list.chain_name === data.chain_name) {
|
|
135
|
+
return data;
|
|
136
|
+
} else {
|
|
137
|
+
return list;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}, {
|
|
142
|
+
key: "upsertIbcData",
|
|
143
|
+
value: function upsertIbcData(data) {
|
|
144
|
+
var found = this._ibc_data.find(function (info) {
|
|
145
|
+
return info.chain_1.chain_name === data.chain_1.chain_name && info.chain_2.chain_name === data.chain_2.chain_name;
|
|
146
|
+
});
|
|
147
|
+
if (!found) {
|
|
148
|
+
this._ibc_data.push(data);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
this._ibc_data = this._ibc_data.map(function (info) {
|
|
152
|
+
if (info.chain_1.chain_name === data.chain_1.chain_name && info.chain_2.chain_name === data.chain_2.chain_name) {
|
|
153
|
+
return data;
|
|
154
|
+
} else {
|
|
155
|
+
return info;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}, {
|
|
160
|
+
key: "update",
|
|
161
|
+
value: function update(data) {
|
|
162
|
+
if (!data.$schema) throw new Error('not a registered JSON schema type');
|
|
163
|
+
var type = (0, _bfsPath.basename)(data.$schema, '.schema.json');
|
|
164
|
+
switch (type) {
|
|
165
|
+
case 'chain':
|
|
166
|
+
this.upsertChain(data);
|
|
167
|
+
break;
|
|
168
|
+
case 'assetlist':
|
|
169
|
+
this.updateAssetList(data);
|
|
170
|
+
break;
|
|
171
|
+
case 'ibc_data':
|
|
172
|
+
this.upsertIbcData(data);
|
|
173
|
+
break;
|
|
174
|
+
default:
|
|
175
|
+
throw new Error('unknown schema type');
|
|
176
|
+
}
|
|
177
|
+
this.chainInfoList.forEach(function (chainInfo) {
|
|
178
|
+
chainInfo.refresh();
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}, {
|
|
182
|
+
key: "fetch",
|
|
183
|
+
value: function () {
|
|
184
|
+
var _fetch = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(url) {
|
|
185
|
+
var data;
|
|
186
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
187
|
+
while (1) switch (_context.prev = _context.next) {
|
|
188
|
+
case 0:
|
|
189
|
+
_context.next = 2;
|
|
190
|
+
return fetchUrl(url);
|
|
191
|
+
case 2:
|
|
192
|
+
data = _context.sent;
|
|
193
|
+
this.update(data);
|
|
194
|
+
case 4:
|
|
195
|
+
case "end":
|
|
196
|
+
return _context.stop();
|
|
197
|
+
}
|
|
198
|
+
}, _callee, this);
|
|
199
|
+
}));
|
|
200
|
+
function fetch(_x) {
|
|
201
|
+
return _fetch.apply(this, arguments);
|
|
202
|
+
}
|
|
203
|
+
return fetch;
|
|
204
|
+
}()
|
|
205
|
+
}, {
|
|
206
|
+
key: "fetchUrls",
|
|
207
|
+
value: function () {
|
|
208
|
+
var _fetchUrls = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
209
|
+
var _this = this;
|
|
210
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
211
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
212
|
+
case 0:
|
|
213
|
+
return _context2.abrupt("return", Promise.all(this.urls.map(function (url) {
|
|
214
|
+
return _this.fetch(url);
|
|
215
|
+
})));
|
|
216
|
+
case 1:
|
|
217
|
+
case "end":
|
|
218
|
+
return _context2.stop();
|
|
219
|
+
}
|
|
220
|
+
}, _callee2, this);
|
|
221
|
+
}));
|
|
222
|
+
function fetchUrls() {
|
|
223
|
+
return _fetchUrls.apply(this, arguments);
|
|
224
|
+
}
|
|
225
|
+
return fetchUrls;
|
|
226
|
+
}()
|
|
227
|
+
}]);
|
|
228
|
+
return ChainRegistryFetcher;
|
|
229
|
+
}();
|
|
230
|
+
exports.ChainRegistryFetcher = ChainRegistryFetcher;
|
package/main/index.js
CHANGED
|
@@ -3,6 +3,39 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _chainInfo = require("./chain-info");
|
|
7
|
+
Object.keys(_chainInfo).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _chainInfo[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _chainInfo[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _chainUtil = require("./chain-util");
|
|
18
|
+
Object.keys(_chainUtil).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _chainUtil[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function get() {
|
|
24
|
+
return _chainUtil[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _fetcher = require("./fetcher");
|
|
29
|
+
Object.keys(_fetcher).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _fetcher[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function get() {
|
|
35
|
+
return _fetcher[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
6
39
|
var _registry = require("./registry");
|
|
7
40
|
Object.keys(_registry).forEach(function (key) {
|
|
8
41
|
if (key === "default" || key === "__esModule") return;
|
package/main/registry.js
CHANGED
|
@@ -4,261 +4,87 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
8
|
-
var
|
|
9
|
-
var
|
|
7
|
+
exports.ChainRegistryClient = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
13
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
12
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
(0, _defineProperty2["default"])(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (!m.includes(v.chain_1.chain_name)) m.push(v.chain_1.chain_name);
|
|
45
|
-
if (!m.includes(v.chain_2.chain_name)) m.push(v.chain_2.chain_name);
|
|
46
|
-
return m;
|
|
47
|
-
}, []);
|
|
48
|
-
this._asset_lists = this.fetcher.assetLists.filter(function (list) {
|
|
49
|
-
return supportedChains.includes(list.chain_name);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}, {
|
|
53
|
-
key: "nativeAssetLists",
|
|
54
|
-
get: function get() {
|
|
55
|
-
return this._asset_list;
|
|
56
|
-
}
|
|
57
|
-
}, {
|
|
58
|
-
key: "chain",
|
|
59
|
-
get: function get() {
|
|
60
|
-
return this._chain;
|
|
61
|
-
}
|
|
62
|
-
}, {
|
|
63
|
-
key: "assetLists",
|
|
64
|
-
get: function get() {
|
|
65
|
-
return (0, _utils.getAssetLists)(this.chain_name, this._ibc_data, this._asset_lists);
|
|
66
|
-
}
|
|
67
|
-
}]);
|
|
68
|
-
return ChainInfo;
|
|
69
|
-
}(); // QUESTION: should ChainRegistryFetcher just be ChainRegistry?
|
|
70
|
-
exports.ChainInfo = ChainInfo;
|
|
71
|
-
var ChainRegistryFetcher = /*#__PURE__*/function () {
|
|
72
|
-
function ChainRegistryFetcher() {
|
|
73
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
74
|
-
(0, _classCallCheck2["default"])(this, ChainRegistryFetcher);
|
|
75
|
-
(0, _defineProperty2["default"])(this, "_asset_lists", []);
|
|
76
|
-
(0, _defineProperty2["default"])(this, "_chains", []);
|
|
77
|
-
(0, _defineProperty2["default"])(this, "_ibc_data", []);
|
|
78
|
-
(0, _defineProperty2["default"])(this, "urls", []);
|
|
79
|
-
//
|
|
80
|
-
if (options.assetLists) {
|
|
81
|
-
this._asset_lists = options.assetLists;
|
|
82
|
-
}
|
|
83
|
-
if (options.chains) {
|
|
84
|
-
this._chains = options.chains;
|
|
85
|
-
}
|
|
86
|
-
if (options.ibcData) {
|
|
87
|
-
this._ibc_data = options.ibcData;
|
|
88
|
-
}
|
|
89
|
-
if (options.urls) {
|
|
90
|
-
this.urls = options.urls;
|
|
91
|
-
}
|
|
17
|
+
var _chainUtil = require("./chain-util");
|
|
18
|
+
var _fetcher = require("./fetcher");
|
|
19
|
+
var _excluded = ["chainNames", "assetListNames", "ibcNamePairs", "baseUrl"];
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
23
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
24
|
+
var ChainRegistryClient = /*#__PURE__*/function (_ChainRegistryFetcher) {
|
|
25
|
+
(0, _inherits2["default"])(ChainRegistryClient, _ChainRegistryFetcher);
|
|
26
|
+
var _super = _createSuper(ChainRegistryClient);
|
|
27
|
+
function ChainRegistryClient(options) {
|
|
28
|
+
var _this;
|
|
29
|
+
(0, _classCallCheck2["default"])(this, ChainRegistryClient);
|
|
30
|
+
var chainNames = options.chainNames,
|
|
31
|
+
assetListNames = options.assetListNames,
|
|
32
|
+
ibcNamePairs = options.ibcNamePairs,
|
|
33
|
+
baseUrl = options.baseUrl,
|
|
34
|
+
restOptions = (0, _objectWithoutProperties2["default"])(options, _excluded);
|
|
35
|
+
_this = _super.call(this, restOptions);
|
|
36
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "_options", {
|
|
37
|
+
chainNames: [],
|
|
38
|
+
baseUrl: 'https://raw.githubusercontent.com/cosmos/chain-registry/master'
|
|
39
|
+
});
|
|
40
|
+
_this._options = _objectSpread(_objectSpread({}, _this._options), {}, {
|
|
41
|
+
chainNames: chainNames || _this._options.chainNames,
|
|
42
|
+
assetListNames: assetListNames || _this._options.assetListNames,
|
|
43
|
+
ibcNamePairs: ibcNamePairs || _this._options.ibcNamePairs,
|
|
44
|
+
baseUrl: baseUrl || _this._options.baseUrl
|
|
45
|
+
});
|
|
46
|
+
_this.generateUrls();
|
|
47
|
+
return _this;
|
|
92
48
|
}
|
|
93
|
-
(0, _createClass2["default"])(
|
|
94
|
-
key: "
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}, {
|
|
106
|
-
key: "getGeneratedAssetLists",
|
|
107
|
-
value: function getGeneratedAssetLists(chainName) {
|
|
108
|
-
return (0, _utils.getAssetLists)(chainName, this._ibc_data, this._asset_lists);
|
|
109
|
-
}
|
|
110
|
-
}, {
|
|
111
|
-
key: "chains",
|
|
112
|
-
get: function get() {
|
|
113
|
-
return this._chains;
|
|
114
|
-
}
|
|
115
|
-
}, {
|
|
116
|
-
key: "getChain",
|
|
117
|
-
value: function getChain(chainName) {
|
|
118
|
-
return this._chains.find(function (chain) {
|
|
119
|
-
return chain.chain_name === chainName;
|
|
49
|
+
(0, _createClass2["default"])(ChainRegistryClient, [{
|
|
50
|
+
key: "generateUrls",
|
|
51
|
+
value: function generateUrls() {
|
|
52
|
+
var _this$_options = this._options,
|
|
53
|
+
chainNames = _this$_options.chainNames,
|
|
54
|
+
assetListNames = _this$_options.assetListNames,
|
|
55
|
+
ibcNamePairs = _this$_options.ibcNamePairs,
|
|
56
|
+
baseUrl = _this$_options.baseUrl;
|
|
57
|
+
var chainUrls = chainNames.map(function (chain) {
|
|
58
|
+
return "".concat(baseUrl, "/").concat(chain, "/chain.json");
|
|
120
59
|
});
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
key: "ibcData",
|
|
124
|
-
get: function get() {
|
|
125
|
-
return this._ibc_data;
|
|
126
|
-
}
|
|
127
|
-
}, {
|
|
128
|
-
key: "getChainIbcData",
|
|
129
|
-
value: function getChainIbcData(chainName) {
|
|
130
|
-
return this._ibc_data.filter(function (info) {
|
|
131
|
-
return info.chain_1.chain_name === chainName || info.chain_2.chain_name === chainName;
|
|
60
|
+
var assetlistUrls = (assetListNames || chainNames).map(function (chain) {
|
|
61
|
+
return "".concat(baseUrl, "/").concat(chain, "/assetlist.json");
|
|
132
62
|
});
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}, {
|
|
143
|
-
key: "upsertChain",
|
|
144
|
-
value: function upsertChain(data) {
|
|
145
|
-
var found = this._chains.find(function (chain) {
|
|
146
|
-
return chain.chain_name === data.chain_name && chain.network_type === data.network_type;
|
|
147
|
-
});
|
|
148
|
-
if (!found) {
|
|
149
|
-
this._chains.push(data);
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
this._chains = this._chains.map(function (chain) {
|
|
153
|
-
if (chain.chain_name === data.chain_name && chain.network_type === data.network_type) {
|
|
154
|
-
return data;
|
|
155
|
-
} else {
|
|
156
|
-
return chain;
|
|
63
|
+
var namePairs = ibcNamePairs;
|
|
64
|
+
if (!namePairs) {
|
|
65
|
+
namePairs = [];
|
|
66
|
+
for (var i = 0; i < chainNames.length; i++) {
|
|
67
|
+
for (var j = i + 1; j < chainNames.length; j++) {
|
|
68
|
+
namePairs.push([chainNames[i], chainNames[j]]);
|
|
69
|
+
}
|
|
157
70
|
}
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}, {
|
|
161
|
-
key: "updateAssetList",
|
|
162
|
-
value: function updateAssetList(data) {
|
|
163
|
-
var found = this._asset_lists.find(function (list) {
|
|
164
|
-
return list.chain_name === data.chain_name;
|
|
165
|
-
});
|
|
166
|
-
if (!found) {
|
|
167
|
-
this._asset_lists.push(data);
|
|
168
|
-
return;
|
|
169
71
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
} else {
|
|
174
|
-
return list;
|
|
175
|
-
}
|
|
72
|
+
var ibcUrls = namePairs.map(function (namePair) {
|
|
73
|
+
var fileName = namePair[0].localeCompare(namePair[1]) <= 0 ? "".concat(namePair[0], "-").concat(namePair[1], ".json") : "".concat(namePair[1], "-").concat(namePair[0], ".json");
|
|
74
|
+
return "".concat(baseUrl, "/_IBC/").concat(fileName);
|
|
176
75
|
});
|
|
76
|
+
this.urls = [].concat((0, _toConsumableArray2["default"])(chainUrls), (0, _toConsumableArray2["default"])(assetlistUrls), (0, _toConsumableArray2["default"])(ibcUrls));
|
|
177
77
|
}
|
|
178
78
|
}, {
|
|
179
|
-
key: "
|
|
180
|
-
value: function
|
|
181
|
-
var
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
this._ibc_data.push(data);
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
this._ibc_data = this._ibc_data.map(function (info) {
|
|
189
|
-
if (info.chain_1.chain_name === data.chain_1.chain_name && info.chain_2.chain_name === data.chain_2.chain_name) {
|
|
190
|
-
return data;
|
|
191
|
-
} else {
|
|
192
|
-
return info;
|
|
193
|
-
}
|
|
79
|
+
key: "getChainUtil",
|
|
80
|
+
value: function getChainUtil(chainName) {
|
|
81
|
+
var chainInfo = this.getChainInfo(chainName);
|
|
82
|
+
return new _chainUtil.ChainRegistryChainUtil({
|
|
83
|
+
chain_name: chainName,
|
|
84
|
+
chain_info: chainInfo
|
|
194
85
|
});
|
|
195
86
|
}
|
|
196
|
-
}, {
|
|
197
|
-
key: "update",
|
|
198
|
-
value: function update(data) {
|
|
199
|
-
if (!data.$schema) throw new Error('not a registered JSON schema type');
|
|
200
|
-
var type = (0, _bfsPath.basename)(data.$schema, '.schema.json');
|
|
201
|
-
switch (type) {
|
|
202
|
-
case 'chain':
|
|
203
|
-
this.upsertChain(data);
|
|
204
|
-
break;
|
|
205
|
-
case 'assetlist':
|
|
206
|
-
this.updateAssetList(data);
|
|
207
|
-
break;
|
|
208
|
-
case 'ibc_data':
|
|
209
|
-
this.upsertIbcData(data);
|
|
210
|
-
break;
|
|
211
|
-
default:
|
|
212
|
-
throw new Error('unknown schema type');
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}, {
|
|
216
|
-
key: "fetch",
|
|
217
|
-
value: function () {
|
|
218
|
-
var _fetch = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(url) {
|
|
219
|
-
var data;
|
|
220
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
221
|
-
while (1) switch (_context.prev = _context.next) {
|
|
222
|
-
case 0:
|
|
223
|
-
_context.next = 2;
|
|
224
|
-
return fetchUrl(url);
|
|
225
|
-
case 2:
|
|
226
|
-
data = _context.sent;
|
|
227
|
-
this.update(data);
|
|
228
|
-
case 4:
|
|
229
|
-
case "end":
|
|
230
|
-
return _context.stop();
|
|
231
|
-
}
|
|
232
|
-
}, _callee, this);
|
|
233
|
-
}));
|
|
234
|
-
function fetch(_x) {
|
|
235
|
-
return _fetch.apply(this, arguments);
|
|
236
|
-
}
|
|
237
|
-
return fetch;
|
|
238
|
-
}()
|
|
239
|
-
}, {
|
|
240
|
-
key: "fetchUrls",
|
|
241
|
-
value: function () {
|
|
242
|
-
var _fetchUrls = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
243
|
-
var _this = this;
|
|
244
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
245
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
246
|
-
case 0:
|
|
247
|
-
return _context2.abrupt("return", Promise.all(this.urls.map(function (url) {
|
|
248
|
-
return _this.fetch(url);
|
|
249
|
-
})));
|
|
250
|
-
case 1:
|
|
251
|
-
case "end":
|
|
252
|
-
return _context2.stop();
|
|
253
|
-
}
|
|
254
|
-
}, _callee2, this);
|
|
255
|
-
}));
|
|
256
|
-
function fetchUrls() {
|
|
257
|
-
return _fetchUrls.apply(this, arguments);
|
|
258
|
-
}
|
|
259
|
-
return fetchUrls;
|
|
260
|
-
}()
|
|
261
87
|
}]);
|
|
262
|
-
return
|
|
263
|
-
}();
|
|
264
|
-
exports.
|
|
88
|
+
return ChainRegistryClient;
|
|
89
|
+
}(_fetcher.ChainRegistryFetcher);
|
|
90
|
+
exports.ChainRegistryClient = ChainRegistryClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chain-registry/client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.1",
|
|
4
4
|
"description": "Chain Registry Client",
|
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/cosmology-tech/chain-registry",
|
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@babel/runtime": "^7.21.0",
|
|
76
76
|
"@chain-registry/types": "^0.16.0",
|
|
77
|
-
"@chain-registry/utils": "^1.
|
|
77
|
+
"@chain-registry/utils": "^1.13.1",
|
|
78
78
|
"bfs-path": "^1.0.2",
|
|
79
79
|
"cross-fetch": "^3.1.5"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "6660513da7c427a1b8166f1a68a1c3af6079ab11"
|
|
82
82
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AssetList, Chain, IBCInfo } from '@chain-registry/types';
|
|
2
|
+
import { ChainRegistryFetcher } from './fetcher';
|
|
3
|
+
export interface ChainInfoOptions {
|
|
4
|
+
chain_name: string;
|
|
5
|
+
fetcher: ChainRegistryFetcher;
|
|
6
|
+
}
|
|
7
|
+
export declare class ChainInfo {
|
|
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[];
|
|
19
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
chain_name: string;
|
|
6
|
+
chain_info: ChainInfo;
|
|
7
|
+
}
|
|
8
|
+
export declare class ChainRegistryChainUtil {
|
|
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;
|
|
23
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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 _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[]>;
|
|
30
|
+
}
|
package/types/index.d.ts
CHANGED
package/types/registry.d.ts
CHANGED
|
@@ -1,45 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
fetcher: ChainRegistryFetcher;
|
|
15
|
-
protected _asset_list: AssetList;
|
|
16
|
-
protected _asset_lists: AssetList[];
|
|
17
|
-
protected _chain: Chain;
|
|
18
|
-
protected _ibc_data: IBCInfo[];
|
|
19
|
-
constructor(options: ChainInfoOptions);
|
|
20
|
-
refresh(): void;
|
|
21
|
-
get nativeAssetLists(): AssetList;
|
|
22
|
-
get chain(): Chain;
|
|
23
|
-
get assetLists(): any[];
|
|
24
|
-
}
|
|
25
|
-
export declare class ChainRegistryFetcher implements ChainRegistry {
|
|
26
|
-
protected _asset_lists: AssetList[];
|
|
27
|
-
protected _chains: Chain[];
|
|
28
|
-
protected _ibc_data: IBCInfo[];
|
|
29
|
-
urls: string[];
|
|
30
|
-
constructor(options?: ChainRegistryFetcherOptions);
|
|
31
|
-
get assetLists(): AssetList[];
|
|
32
|
-
getChainAssetList(chainName: string): AssetList;
|
|
33
|
-
getGeneratedAssetLists(chainName: string): AssetList[];
|
|
34
|
-
get chains(): Chain[];
|
|
35
|
-
getChain(chainName: string): Chain;
|
|
36
|
-
get ibcData(): IBCInfo[];
|
|
37
|
-
getChainIbcData(chainName: string): IBCInfo[];
|
|
38
|
-
getChainInfo(chainName: string): ChainInfo;
|
|
39
|
-
upsertChain(data: Chain): void;
|
|
40
|
-
updateAssetList(data: AssetList): void;
|
|
41
|
-
upsertIbcData(data: IBCInfo): void;
|
|
42
|
-
update(data: Chain | AssetList | IBCInfo): void;
|
|
43
|
-
fetch(url: any): Promise<void>;
|
|
44
|
-
fetchUrls(): Promise<void[]>;
|
|
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;
|
|
45
14
|
}
|