@chain-registry/client 1.1.0 → 1.2.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 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.2.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/client@1.2.0...@chain-registry/client@1.2.1) (2022-10-27)
7
+
8
+ **Note:** Version bump only for package @chain-registry/client
9
+
10
+
11
+
12
+
13
+
14
+ # [1.2.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/client@1.1.0...@chain-registry/client@1.2.0) (2022-10-20)
15
+
16
+ **Note:** Version bump only for package @chain-registry/client
17
+
18
+
19
+
20
+
21
+
6
22
  # [1.1.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/client@1.0.1...@chain-registry/client@1.1.0) (2022-10-20)
7
23
 
8
24
  **Note:** Version bump only for package @chain-registry/client
package/main/index.js CHANGED
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _registry = require("./registry");
8
-
9
7
  Object.keys(_registry).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _registry[key]) return;
package/main/registry.js CHANGED
@@ -1,38 +1,26 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.ChainRegistryFetcher = exports.ChainInfo = void 0;
9
-
10
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
19
-
20
13
  var _utils = require("@chain-registry/utils");
21
-
22
14
  var _bfsPath = require("bfs-path");
23
-
24
15
  var _crossFetch = _interopRequireDefault(require("cross-fetch"));
25
-
26
16
  var fetchUrl = function fetchUrl(url) {
27
17
  return (0, _crossFetch["default"])(url).then(function (res) {
28
18
  if (res.status >= 400) {
29
19
  throw new Error('Bad response');
30
20
  }
31
-
32
21
  return res.json();
33
22
  });
34
23
  };
35
-
36
24
  var ChainInfo = /*#__PURE__*/function () {
37
25
  function ChainInfo(options) {
38
26
  (0, _classCallCheck2["default"])(this, ChainInfo);
@@ -46,20 +34,17 @@ var ChainInfo = /*#__PURE__*/function () {
46
34
  this.fetcher = options.fetcher;
47
35
  this.refresh();
48
36
  }
49
-
50
37
  (0, _createClass2["default"])(ChainInfo, [{
51
38
  key: "refresh",
52
39
  value: function refresh() {
53
40
  this._asset_list = this.fetcher.getChainAssetList(this.chain_name);
54
41
  this._ibc_data = this.fetcher.getChainIbcData(this.chain_name);
55
42
  this._chain = this.fetcher.getChain(this.chain_name);
56
-
57
43
  var supportedChains = this._ibc_data.reduce(function (m, v) {
58
44
  if (!m.includes(v.chain_1.chain_name)) m.push(v.chain_1.chain_name);
59
45
  if (!m.includes(v.chain_2.chain_name)) m.push(v.chain_2.chain_name);
60
46
  return m;
61
47
  }, []);
62
-
63
48
  this._asset_lists = this.fetcher.assetLists.filter(function (list) {
64
49
  return supportedChains.includes(list.chain_name);
65
50
  });
@@ -82,10 +67,7 @@ var ChainInfo = /*#__PURE__*/function () {
82
67
  }]);
83
68
  return ChainInfo;
84
69
  }(); // QUESTION: should ChainRegistryFetcher just be ChainRegistry?
85
-
86
-
87
70
  exports.ChainInfo = ChainInfo;
88
-
89
71
  var ChainRegistryFetcher = /*#__PURE__*/function () {
90
72
  function ChainRegistryFetcher() {
91
73
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -94,25 +76,20 @@ var ChainRegistryFetcher = /*#__PURE__*/function () {
94
76
  (0, _defineProperty2["default"])(this, "_chains", []);
95
77
  (0, _defineProperty2["default"])(this, "_ibc_data", []);
96
78
  (0, _defineProperty2["default"])(this, "urls", []);
97
-
98
79
  //
99
80
  if (options.assetLists) {
100
81
  this._asset_lists = options.assetLists;
101
82
  }
102
-
103
83
  if (options.chains) {
104
84
  this._chains = options.chains;
105
85
  }
106
-
107
86
  if (options.ibcData) {
108
87
  this._ibc_data = options.ibcData;
109
88
  }
110
-
111
89
  if (options.urls) {
112
90
  this.urls = options.urls;
113
91
  }
114
92
  }
115
-
116
93
  (0, _createClass2["default"])(ChainRegistryFetcher, [{
117
94
  key: "assetLists",
118
95
  get: function get() {
@@ -168,13 +145,10 @@ var ChainRegistryFetcher = /*#__PURE__*/function () {
168
145
  var found = this._chains.find(function (chain) {
169
146
  return chain.chain_name === data.chain_name && chain.network_type === data.network_type;
170
147
  });
171
-
172
148
  if (!found) {
173
149
  this._chains.push(data);
174
-
175
150
  return;
176
151
  }
177
-
178
152
  this._chains = this._chains.map(function (chain) {
179
153
  if (chain.chain_name === data.chain_name && chain.network_type === data.network_type) {
180
154
  return data;
@@ -189,13 +163,10 @@ var ChainRegistryFetcher = /*#__PURE__*/function () {
189
163
  var found = this._asset_lists.find(function (list) {
190
164
  return list.chain_name === data.chain_name;
191
165
  });
192
-
193
166
  if (!found) {
194
167
  this._asset_lists.push(data);
195
-
196
168
  return;
197
169
  }
198
-
199
170
  this._asset_lists = this._asset_lists.map(function (list) {
200
171
  if (list.chain_name === data.chain_name) {
201
172
  return data;
@@ -210,13 +181,10 @@ var ChainRegistryFetcher = /*#__PURE__*/function () {
210
181
  var found = this._ibc_data.find(function (info) {
211
182
  return info.chain_1.chain_name === data.chain_1.chain_name && info.chain_2.chain_name === data.chain_2.chain_name;
212
183
  });
213
-
214
184
  if (!found) {
215
185
  this._ibc_data.push(data);
216
-
217
186
  return;
218
187
  }
219
-
220
188
  this._ibc_data = this._ibc_data.map(function (info) {
221
189
  if (info.chain_1.chain_name === data.chain_1.chain_name && info.chain_2.chain_name === data.chain_2.chain_name) {
222
190
  return data;
@@ -230,20 +198,16 @@ var ChainRegistryFetcher = /*#__PURE__*/function () {
230
198
  value: function update(data) {
231
199
  if (!data.$schema) throw new Error('not a registered JSON schema type');
232
200
  var type = (0, _bfsPath.basename)(data.$schema, '.schema.json');
233
-
234
201
  switch (type) {
235
202
  case 'chain':
236
203
  this.upsertChain(data);
237
204
  break;
238
-
239
205
  case 'assetlist':
240
206
  this.updateAssetList(data);
241
207
  break;
242
-
243
208
  case 'ibc_data':
244
209
  this.upsertIbcData(data);
245
210
  break;
246
-
247
211
  default:
248
212
  throw new Error('unknown schema type');
249
213
  }
@@ -259,11 +223,9 @@ var ChainRegistryFetcher = /*#__PURE__*/function () {
259
223
  case 0:
260
224
  _context.next = 2;
261
225
  return fetchUrl(url);
262
-
263
226
  case 2:
264
227
  data = _context.sent;
265
228
  this.update(data);
266
-
267
229
  case 4:
268
230
  case "end":
269
231
  return _context.stop();
@@ -271,11 +233,9 @@ var ChainRegistryFetcher = /*#__PURE__*/function () {
271
233
  }
272
234
  }, _callee, this);
273
235
  }));
274
-
275
236
  function fetch(_x) {
276
237
  return _fetch.apply(this, arguments);
277
238
  }
278
-
279
239
  return fetch;
280
240
  }()
281
241
  }, {
@@ -283,7 +243,6 @@ var ChainRegistryFetcher = /*#__PURE__*/function () {
283
243
  value: function () {
284
244
  var _fetchUrls = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
285
245
  var _this = this;
286
-
287
246
  return _regenerator["default"].wrap(function _callee2$(_context2) {
288
247
  while (1) {
289
248
  switch (_context2.prev = _context2.next) {
@@ -291,7 +250,6 @@ var ChainRegistryFetcher = /*#__PURE__*/function () {
291
250
  return _context2.abrupt("return", Promise.all(this.urls.map(function (url) {
292
251
  return _this.fetch(url);
293
252
  })));
294
-
295
253
  case 1:
296
254
  case "end":
297
255
  return _context2.stop();
@@ -299,15 +257,12 @@ var ChainRegistryFetcher = /*#__PURE__*/function () {
299
257
  }
300
258
  }, _callee2, this);
301
259
  }));
302
-
303
260
  function fetchUrls() {
304
261
  return _fetchUrls.apply(this, arguments);
305
262
  }
306
-
307
263
  return fetchUrls;
308
264
  }()
309
265
  }]);
310
266
  return ChainRegistryFetcher;
311
267
  }();
312
-
313
268
  exports.ChainRegistryFetcher = ChainRegistryFetcher;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chain-registry/client",
3
- "version": "1.1.0",
3
+ "version": "1.2.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",
@@ -41,42 +41,42 @@
41
41
  "url": "https://github.com/cosmology-tech/chain-registry/issues"
42
42
  },
43
43
  "devDependencies": {
44
- "@babel/cli": "7.18.10",
45
- "@babel/core": "7.19.1",
44
+ "@babel/cli": "7.19.3",
45
+ "@babel/core": "7.19.6",
46
46
  "@babel/eslint-parser": "^7.19.1",
47
47
  "@babel/node": "^7.19.1",
48
48
  "@babel/plugin-proposal-class-properties": "7.18.6",
49
49
  "@babel/plugin-proposal-export-default-from": "7.18.10",
50
- "@babel/plugin-proposal-object-rest-spread": "7.18.9",
51
- "@babel/plugin-transform-runtime": "7.19.1",
52
- "@babel/preset-env": "7.19.1",
50
+ "@babel/plugin-proposal-object-rest-spread": "7.19.4",
51
+ "@babel/plugin-transform-runtime": "7.19.6",
52
+ "@babel/preset-env": "7.19.4",
53
53
  "@babel/preset-typescript": "^7.17.12",
54
- "@types/jest": "^29.0.2",
54
+ "@types/jest": "^29.2.0",
55
55
  "@types/sha.js": "^2.4.0",
56
- "@typescript-eslint/eslint-plugin": "5.37.0",
57
- "@typescript-eslint/parser": "5.37.0",
56
+ "@typescript-eslint/eslint-plugin": "5.40.1",
57
+ "@typescript-eslint/parser": "5.40.1",
58
58
  "babel-core": "7.0.0-bridge.0",
59
- "babel-jest": "29.0.3",
59
+ "babel-jest": "29.2.1",
60
60
  "babel-watch": "^7.0.0",
61
61
  "cross-env": "^7.0.2",
62
- "eslint": "8.23.1",
62
+ "eslint": "8.25.0",
63
63
  "eslint-config-prettier": "^8.5.0",
64
64
  "eslint-plugin-prettier": "^4.0.0",
65
65
  "eslint-plugin-simple-import-sort": "8.0.0",
66
66
  "eslint-plugin-unused-imports": "2.0.0",
67
- "jest": "^29.0.3",
67
+ "jest": "^29.2.1",
68
68
  "long": "^5.2.0",
69
69
  "prettier": "^2.7.0",
70
- "regenerator-runtime": "^0.13.7",
71
- "ts-jest": "^29.0.1",
72
- "typescript": "^4.8.3"
70
+ "regenerator-runtime": "^0.13.10",
71
+ "ts-jest": "^29.0.3",
72
+ "typescript": "^4.8.4"
73
73
  },
74
74
  "dependencies": {
75
- "@babel/runtime": "^7.19.0",
76
- "@chain-registry/types": "^0.12.0",
77
- "@chain-registry/utils": "^1.1.0",
75
+ "@babel/runtime": "^7.19.4",
76
+ "@chain-registry/types": "^0.13.1",
77
+ "@chain-registry/utils": "^1.2.1",
78
78
  "bfs-path": "^1.0.2",
79
79
  "cross-fetch": "^3.1.5"
80
80
  },
81
- "gitHead": "1f570daf2ee8e4a86cd7addf97f453a322b2e9b3"
81
+ "gitHead": "7c1e7c57d12c072c06dfe2c2c8b969b50205925a"
82
82
  }