@chain-registry/client 1.14.1 → 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 CHANGED
@@ -3,6 +3,14 @@
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
+
6
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)
7
15
 
8
16
  **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
- * [@osmonauts/telescope](https://github.com/osmosis-labs/telescope) a "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs.
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.
@@ -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, "chain_name", void 0);
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, "_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;
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._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) {
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._asset_lists = this.fetcher.assetLists.filter(function (list) {
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._asset_list;
48
+ return this._assetList;
49
49
  }
50
50
  }, {
51
51
  key: "assetLists",
52
52
  get: function get() {
53
- return (0, _utils.getAssetLists)(this.chain_name, this._ibc_data, this._asset_lists);
53
+ return (0, _utils.getAssetLists)(this.chainName, this._ibcData, this._assetLists);
54
54
  }
55
55
  }]);
56
56
  return ChainInfo;
@@ -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, "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) {
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.chain_info.nativeAssetLists.assets));
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._all_Asset, denom);
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._all_Asset, coinGeckoId);
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._all_Asset, denom);
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._all_Asset, token);
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._all_Asset, denom);
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._all_Asset, prices);
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._all_Asset, prices, symbol, amount);
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._all_Asset, prices, symbol, value);
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._all_Asset, symbol, amount);
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, "_asset_lists", []);
31
+ (0, _defineProperty2["default"])(this, "_assetLists", []);
32
32
  (0, _defineProperty2["default"])(this, "_chains", []);
33
- (0, _defineProperty2["default"])(this, "_ibc_data", []);
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._asset_lists = options.assetLists;
40
+ this._assetLists = options.assetLists;
41
41
  }
42
42
  if (options.ibcData) {
43
- this._ibc_data = options.ibcData;
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._asset_lists;
57
+ return this._assetLists;
58
58
  }
59
59
  }, {
60
60
  key: "ibcData",
61
61
  get: function get() {
62
- return this._ibc_data;
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._asset_lists.find(function (list) {
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._ibc_data, this._asset_lists);
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._ibc_data.filter(function (info) {
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.chain_name === chainName;
94
+ return it.chainName === chainName;
95
95
  });
96
96
  if (!chainInfo) {
97
97
  chainInfo = new _chainInfo.ChainInfo({
98
- chain_name: chainName,
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._asset_lists.find(function (list) {
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._asset_lists.push(data);
130
+ this._assetLists.push(data);
131
131
  return;
132
132
  }
133
- this._asset_lists = this._asset_lists.map(function (list) {
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._ibc_data.find(function (info) {
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._ibc_data.push(data);
148
+ this._ibcData.push(data);
149
149
  return;
150
150
  }
151
- this._ibc_data = this._ibc_data.map(function (info) {
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
- chain_name: chainName,
84
- chain_info: chainInfo
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.1",
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.1",
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": "6660513da7c427a1b8166f1a68a1c3af6079ab11"
84
+ "gitHead": "7643eb9d080056f05ac9284447cfca8d4aaf5470"
82
85
  }