@chain-registry/utils 1.19.0 → 1.19.4

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 ADDED
@@ -0,0 +1,281 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [1.19.4](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.19.3...@chain-registry/utils@1.19.4) (2024-03-21)
7
+
8
+ **Note:** Version bump only for package @chain-registry/utils
9
+
10
+
11
+
12
+
13
+
14
+ ## 1.19.3 (2024-03-21)
15
+
16
+ **Note:** Version bump only for package @chain-registry/utils
17
+
18
+
19
+
20
+
21
+
22
+ ## [1.19.2](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.19.1...@chain-registry/utils@1.19.2) (2024-03-20)
23
+
24
+ **Note:** Version bump only for package @chain-registry/utils
25
+
26
+
27
+
28
+
29
+
30
+ ## 1.19.1 (2024-03-20)
31
+
32
+ **Note:** Version bump only for package @chain-registry/utils
33
+
34
+
35
+
36
+
37
+
38
+ # [1.19.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.18.2...@chain-registry/utils@1.19.0) (2024-03-19)
39
+
40
+ ### Bug Fixes
41
+
42
+ - add explicit return types ([095175a](https://github.com/cosmology-tech/chain-registry/commit/095175aaa08cbde99052b0bd87e2173c871632f0))
43
+ - rename files ([62aa8d0](https://github.com/cosmology-tech/chain-registry/commit/62aa8d06a99425ba059e3a2b6e1d96ea7a9a2e23))
44
+ - update types ([0537055](https://github.com/cosmology-tech/chain-registry/commit/05370552b73b1e84da952544a34239c7bdefc766))
45
+
46
+ ### Features
47
+
48
+ - add new utils ([b922c9d](https://github.com/cosmology-tech/chain-registry/commit/b922c9d5141655b92bdae8d22e1eabb92edfd8ec))
49
+ - add tests for new utils ([c4895a4](https://github.com/cosmology-tech/chain-registry/commit/c4895a469bed3cbe12305de2a99a1004f66efc25))
50
+
51
+ ## [1.18.2](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.18.1...@chain-registry/utils@1.18.2) (2024-02-27)
52
+
53
+ **Note:** Version bump only for package @chain-registry/utils
54
+
55
+ ## [1.18.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.18.0...@chain-registry/utils@1.18.1) (2024-02-26)
56
+
57
+ **Note:** Version bump only for package @chain-registry/utils
58
+
59
+ # [1.18.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.17.3...@chain-registry/utils@1.18.0) (2024-01-25)
60
+
61
+ **Note:** Version bump only for package @chain-registry/utils
62
+
63
+ ## [1.17.3](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.17.2...@chain-registry/utils@1.17.3) (2024-01-19)
64
+
65
+ **Note:** Version bump only for package @chain-registry/utils
66
+
67
+ ## [1.17.2](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.17.1...@chain-registry/utils@1.17.2) (2024-01-19)
68
+
69
+ **Note:** Version bump only for package @chain-registry/utils
70
+
71
+ ## [1.17.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.17.0...@chain-registry/utils@1.17.1) (2024-01-19)
72
+
73
+ **Note:** Version bump only for package @chain-registry/utils
74
+
75
+ # [1.17.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.16.1...@chain-registry/utils@1.17.0) (2023-12-20)
76
+
77
+ ### Features
78
+
79
+ - add chainName as optional param ([d415f33](https://github.com/cosmology-tech/chain-registry/commit/d415f33dc96651e5bb4ede689220d89ad11fe9d9))
80
+
81
+ ## [1.16.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.16.0...@chain-registry/utils@1.16.1) (2023-12-15)
82
+
83
+ **Note:** Version bump only for package @chain-registry/utils
84
+
85
+ # [1.16.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.15.0...@chain-registry/utils@1.16.0) (2023-12-15)
86
+
87
+ ### Features
88
+
89
+ - add getCoinGeckoIdByDenom method ([b05e67b](https://github.com/cosmology-tech/chain-registry/commit/b05e67b4b54258412d359745b1cd095987c67eb6))
90
+
91
+ # [1.15.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.14.0...@chain-registry/utils@1.15.0) (2023-12-15)
92
+
93
+ **Note:** Version bump only for package @chain-registry/utils
94
+
95
+ # [1.14.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.13.2...@chain-registry/utils@1.14.0) (2023-09-15)
96
+
97
+ **Note:** Version bump only for package @chain-registry/utils
98
+
99
+ ## [1.13.2](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.13.1...@chain-registry/utils@1.13.2) (2023-07-30)
100
+
101
+ **Note:** Version bump only for package @chain-registry/utils
102
+
103
+ ## [1.13.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.13.0...@chain-registry/utils@1.13.1) (2023-07-12)
104
+
105
+ **Note:** Version bump only for package @chain-registry/utils
106
+
107
+ # [1.13.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.12.0...@chain-registry/utils@1.13.0) (2023-07-11)
108
+
109
+ **Note:** Version bump only for package @chain-registry/utils
110
+
111
+ # [1.12.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.11.0...@chain-registry/utils@1.12.0) (2023-07-08)
112
+
113
+ **Note:** Version bump only for package @chain-registry/utils
114
+
115
+ # [1.11.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.10.0...@chain-registry/utils@1.11.0) (2023-06-27)
116
+
117
+ **Note:** Version bump only for package @chain-registry/utils
118
+
119
+ # [1.10.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.9.1...@chain-registry/utils@1.10.0) (2023-04-20)
120
+
121
+ **Note:** Version bump only for package @chain-registry/utils
122
+
123
+ ## [1.9.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.9.0...@chain-registry/utils@1.9.1) (2023-04-18)
124
+
125
+ **Note:** Version bump only for package @chain-registry/utils
126
+
127
+ # [1.9.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.8.0...@chain-registry/utils@1.9.0) (2023-04-18)
128
+
129
+ **Note:** Version bump only for package @chain-registry/utils
130
+
131
+ # [1.8.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.7.0...@chain-registry/utils@1.8.0) (2023-03-29)
132
+
133
+ **Note:** Version bump only for package @chain-registry/utils
134
+
135
+ # [1.7.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.6.0...@chain-registry/utils@1.7.0) (2023-03-02)
136
+
137
+ **Note:** Version bump only for package @chain-registry/utils
138
+
139
+ # [1.6.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.5.0...@chain-registry/utils@1.6.0) (2023-02-23)
140
+
141
+ **Note:** Version bump only for package @chain-registry/utils
142
+
143
+ # [1.5.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.4.0...@chain-registry/utils@1.5.0) (2023-02-08)
144
+
145
+ **Note:** Version bump only for package @chain-registry/utils
146
+
147
+ # [1.4.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.3.0...@chain-registry/utils@1.4.0) (2022-12-08)
148
+
149
+ **Note:** Version bump only for package @chain-registry/utils
150
+
151
+ # [1.3.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.2.1...@chain-registry/utils@1.3.0) (2022-11-10)
152
+
153
+ **Note:** Version bump only for package @chain-registry/utils
154
+
155
+ ## [1.2.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.2.0...@chain-registry/utils@1.2.1) (2022-10-27)
156
+
157
+ **Note:** Version bump only for package @chain-registry/utils
158
+
159
+ # [1.2.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.1.0...@chain-registry/utils@1.2.0) (2022-10-20)
160
+
161
+ **Note:** Version bump only for package @chain-registry/utils
162
+
163
+ # [1.1.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.0.1...@chain-registry/utils@1.1.0) (2022-10-20)
164
+
165
+ **Note:** Version bump only for package @chain-registry/utils
166
+
167
+ ## [1.0.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.0.0...@chain-registry/utils@1.0.1) (2022-10-20)
168
+
169
+ **Note:** Version bump only for package @chain-registry/utils
170
+
171
+ # [1.0.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.11.0...@chain-registry/utils@1.0.0) (2022-09-29)
172
+
173
+ **Note:** Version bump only for package @chain-registry/utils
174
+
175
+ # [0.11.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.10.2...@chain-registry/utils@0.11.0) (2022-09-20)
176
+
177
+ **Note:** Version bump only for package @chain-registry/utils
178
+
179
+ ## [0.10.2](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.10.1...@chain-registry/utils@0.10.2) (2022-09-19)
180
+
181
+ **Note:** Version bump only for package @chain-registry/utils
182
+
183
+ ## [0.10.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.10.0...@chain-registry/utils@0.10.1) (2022-09-19)
184
+
185
+ **Note:** Version bump only for package @chain-registry/utils
186
+
187
+ # [0.10.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.9.0...@chain-registry/utils@0.10.0) (2022-09-19)
188
+
189
+ **Note:** Version bump only for package @chain-registry/utils
190
+
191
+ # [0.9.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.8.0...@chain-registry/utils@0.9.0) (2022-09-16)
192
+
193
+ **Note:** Version bump only for package @chain-registry/utils
194
+
195
+ # [0.8.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.7.3...@chain-registry/utils@0.8.0) (2022-09-14)
196
+
197
+ **Note:** Version bump only for package @chain-registry/utils
198
+
199
+ ## [0.7.3](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.7.2...@chain-registry/utils@0.7.3) (2022-09-08)
200
+
201
+ **Note:** Version bump only for package @chain-registry/utils
202
+
203
+ ## [0.7.2](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.7.1...@chain-registry/utils@0.7.2) (2022-09-08)
204
+
205
+ **Note:** Version bump only for package @chain-registry/utils
206
+
207
+ ## [0.7.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.7.0...@chain-registry/utils@0.7.1) (2022-09-07)
208
+
209
+ **Note:** Version bump only for package @chain-registry/utils
210
+
211
+ # [0.7.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.6.3...@chain-registry/utils@0.7.0) (2022-09-06)
212
+
213
+ **Note:** Version bump only for package @chain-registry/utils
214
+
215
+ ## [0.6.3](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.6.2...@chain-registry/utils@0.6.3) (2022-08-31)
216
+
217
+ **Note:** Version bump only for package @chain-registry/utils
218
+
219
+ ## [0.6.2](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.6.1...@chain-registry/utils@0.6.2) (2022-08-31)
220
+
221
+ **Note:** Version bump only for package @chain-registry/utils
222
+
223
+ ## [0.6.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.6.0...@chain-registry/utils@0.6.1) (2022-08-31)
224
+
225
+ **Note:** Version bump only for package @chain-registry/utils
226
+
227
+ # [0.6.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.5.1...@chain-registry/utils@0.6.0) (2022-08-31)
228
+
229
+ **Note:** Version bump only for package @chain-registry/utils
230
+
231
+ ## [0.5.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.5.0...@chain-registry/utils@0.5.1) (2022-08-23)
232
+
233
+ **Note:** Version bump only for package @chain-registry/utils
234
+
235
+ # [0.5.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.4.0...@chain-registry/utils@0.5.0) (2022-08-23)
236
+
237
+ **Note:** Version bump only for package @chain-registry/utils
238
+
239
+ # [0.4.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.3.1...@chain-registry/utils@0.4.0) (2022-08-20)
240
+
241
+ **Note:** Version bump only for package @chain-registry/utils
242
+
243
+ ## [0.3.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.3.0...@chain-registry/utils@0.3.1) (2022-08-13)
244
+
245
+ **Note:** Version bump only for package @chain-registry/utils
246
+
247
+ # [0.3.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.2.1...@chain-registry/utils@0.3.0) (2022-08-13)
248
+
249
+ **Note:** Version bump only for package @chain-registry/utils
250
+
251
+ ## [0.2.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.2.0...@chain-registry/utils@0.2.1) (2022-08-13)
252
+
253
+ **Note:** Version bump only for package @chain-registry/utils
254
+
255
+ # 0.2.0 (2022-08-13)
256
+
257
+ **Note:** Version bump only for package @chain-registry/utils
258
+
259
+ # [0.1.0](https://github.com/cosmology-tech/chain-registry/compare/chain-registry-utils@0.0.6...chain-registry-utils@0.1.0) (2022-08-12)
260
+
261
+ **Note:** Version bump only for package chain-registry-utils
262
+
263
+ ## 0.0.6 (2022-07-25)
264
+
265
+ **Note:** Version bump only for package chain-registry-utils
266
+
267
+ ## [0.0.5](https://github.com/cosmology-tech/chain-registry/compare/chain-registry-utils@0.0.4...chain-registry-utils@0.0.5) (2022-07-14)
268
+
269
+ **Note:** Version bump only for package chain-registry-utils
270
+
271
+ ## [0.0.4](https://github.com/cosmology-tech/chain-registry/compare/chain-registry-utils@0.0.3...chain-registry-utils@0.0.4) (2022-07-14)
272
+
273
+ **Note:** Version bump only for package chain-registry-utils
274
+
275
+ ## 0.0.3 (2022-07-12)
276
+
277
+ **Note:** Version bump only for package chain-registry-utils
278
+
279
+ ## 0.0.2 (2022-07-12)
280
+
281
+ **Note:** Version bump only for package chain-registry-utils
package/main/assets.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getTokenNameByDenom = exports.getTokenLogoByDenom = exports.getSymbolByDenom = exports.getNativeTokenByChainName = exports.getExponentFromAsset = exports.getExponentBySymbol = exports.getExponentByDenom = exports.getDenomBySymbol = exports.getDenomByCoinGeckoId = exports.getCoinGeckoIdByDenom = exports.getChainNameByDenom = exports.getChainLogo = exports.getAssetBySymbol = exports.getAssetByDenom = exports.customFind = void 0;
7
- var customFind = function customFind(array, filterFn) {
7
+ var customFind = exports.customFind = function customFind(array, filterFn) {
8
8
  var filteredItems = array.filter(filterFn);
9
9
  var filterCount = filteredItems.length;
10
10
  if (filterCount > 1) {
@@ -12,7 +12,6 @@ var customFind = function customFind(array, filterFn) {
12
12
  }
13
13
  return filteredItems[0];
14
14
  };
15
- exports.customFind = customFind;
16
15
  var getAssetByKeyValue = function getAssetByKeyValue(assets, key, value, chainName) {
17
16
  var filteredAssets = assets.filter(function (_ref) {
18
17
  var chain_name = _ref.chain_name;
@@ -25,20 +24,17 @@ var getAssetByKeyValue = function getAssetByKeyValue(assets, key, value, chainNa
25
24
  return asset[key] === value;
26
25
  });
27
26
  };
28
- var getAssetByDenom = function getAssetByDenom(assets, denom, chainName) {
27
+ var getAssetByDenom = exports.getAssetByDenom = function getAssetByDenom(assets, denom, chainName) {
29
28
  return getAssetByKeyValue(assets, 'base', denom, chainName);
30
29
  };
31
- exports.getAssetByDenom = getAssetByDenom;
32
- var getAssetBySymbol = function getAssetBySymbol(assets, symbol, chainName) {
30
+ var getAssetBySymbol = exports.getAssetBySymbol = function getAssetBySymbol(assets, symbol, chainName) {
33
31
  return getAssetByKeyValue(assets, 'symbol', symbol, chainName);
34
32
  };
35
- exports.getAssetBySymbol = getAssetBySymbol;
36
- var getDenomByCoinGeckoId = function getDenomByCoinGeckoId(assets, coinGeckoId, chainName) {
33
+ var getDenomByCoinGeckoId = exports.getDenomByCoinGeckoId = function getDenomByCoinGeckoId(assets, coinGeckoId, chainName) {
37
34
  var _getAssetByKeyValue;
38
35
  return (_getAssetByKeyValue = getAssetByKeyValue(assets, 'coingecko_id', coinGeckoId, chainName)) === null || _getAssetByKeyValue === void 0 ? void 0 : _getAssetByKeyValue.base;
39
36
  };
40
- exports.getDenomByCoinGeckoId = getDenomByCoinGeckoId;
41
- var getCoinGeckoIdByDenom = function getCoinGeckoIdByDenom(assets, denom) {
37
+ var getCoinGeckoIdByDenom = exports.getCoinGeckoIdByDenom = function getCoinGeckoIdByDenom(assets, denom) {
42
38
  var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
43
39
  chainName = _ref3.chainName,
44
40
  _ref3$allowTestnet = _ref3.allowTestnet,
@@ -66,58 +62,48 @@ var getCoinGeckoIdByDenom = function getCoinGeckoIdByDenom(assets, denom) {
66
62
  });
67
63
  return asset === null || asset === void 0 ? void 0 : asset.coingecko_id;
68
64
  };
69
- exports.getCoinGeckoIdByDenom = getCoinGeckoIdByDenom;
70
- var getSymbolByDenom = function getSymbolByDenom(assets, denom, chainName) {
65
+ var getSymbolByDenom = exports.getSymbolByDenom = function getSymbolByDenom(assets, denom, chainName) {
71
66
  var _getAssetByDenom;
72
67
  return (_getAssetByDenom = getAssetByDenom(assets, denom, chainName)) === null || _getAssetByDenom === void 0 ? void 0 : _getAssetByDenom.symbol;
73
68
  };
74
- exports.getSymbolByDenom = getSymbolByDenom;
75
- var getDenomBySymbol = function getDenomBySymbol(assets, symbol, chainName) {
69
+ var getDenomBySymbol = exports.getDenomBySymbol = function getDenomBySymbol(assets, symbol, chainName) {
76
70
  var _getAssetByKeyValue2;
77
71
  return (_getAssetByKeyValue2 = getAssetByKeyValue(assets, 'symbol', symbol, chainName)) === null || _getAssetByKeyValue2 === void 0 ? void 0 : _getAssetByKeyValue2.base;
78
72
  };
79
- exports.getDenomBySymbol = getDenomBySymbol;
80
- var getExponentFromAsset = function getExponentFromAsset(asset) {
73
+ var getExponentFromAsset = exports.getExponentFromAsset = function getExponentFromAsset(asset) {
81
74
  var _asset$denom_units$fi;
82
75
  return (_asset$denom_units$fi = asset.denom_units.find(function (_ref8) {
83
76
  var denom = _ref8.denom;
84
77
  return denom === asset.display;
85
78
  })) === null || _asset$denom_units$fi === void 0 ? void 0 : _asset$denom_units$fi.exponent;
86
79
  };
87
- exports.getExponentFromAsset = getExponentFromAsset;
88
- var getExponentByDenom = function getExponentByDenom(assets, denom, chainName) {
80
+ var getExponentByDenom = exports.getExponentByDenom = function getExponentByDenom(assets, denom, chainName) {
89
81
  var asset = getAssetByDenom(assets, denom, chainName);
90
82
  return asset ? getExponentFromAsset(asset) : undefined;
91
83
  };
92
- exports.getExponentByDenom = getExponentByDenom;
93
- var getExponentBySymbol = function getExponentBySymbol(assets, symbol, chainName) {
84
+ var getExponentBySymbol = exports.getExponentBySymbol = function getExponentBySymbol(assets, symbol, chainName) {
94
85
  var asset = getAssetBySymbol(assets, symbol, chainName);
95
86
  return asset ? getExponentFromAsset(asset) : undefined;
96
87
  };
97
- exports.getExponentBySymbol = getExponentBySymbol;
98
- var getNativeTokenByChainName = function getNativeTokenByChainName(assets, chainName) {
88
+ var getNativeTokenByChainName = exports.getNativeTokenByChainName = function getNativeTokenByChainName(assets, chainName) {
99
89
  var assetList = customFind(assets, function (assetList) {
100
90
  return assetList.chain_name === chainName && !assetList.assets[0].base.startsWith('ibc/');
101
91
  });
102
92
  return assetList === null || assetList === void 0 ? void 0 : assetList.assets[0];
103
93
  };
104
- exports.getNativeTokenByChainName = getNativeTokenByChainName;
105
- var getTokenLogoByDenom = function getTokenLogoByDenom(assets, denom, chainName) {
94
+ var getTokenLogoByDenom = exports.getTokenLogoByDenom = function getTokenLogoByDenom(assets, denom, chainName) {
106
95
  var asset = getAssetByDenom(assets, denom, chainName);
107
96
  return Object.values((asset === null || asset === void 0 ? void 0 : asset.logo_URIs) || {})[0];
108
97
  };
109
- exports.getTokenLogoByDenom = getTokenLogoByDenom;
110
- var getChainLogo = function getChainLogo(assets, chainName) {
98
+ var getChainLogo = exports.getChainLogo = function getChainLogo(assets, chainName) {
111
99
  var nativeToken = getNativeTokenByChainName(assets, chainName);
112
100
  return Object.values((nativeToken === null || nativeToken === void 0 ? void 0 : nativeToken.logo_URIs) || {})[0];
113
101
  };
114
- exports.getChainLogo = getChainLogo;
115
- var getTokenNameByDenom = function getTokenNameByDenom(assets, denom, chainName) {
102
+ var getTokenNameByDenom = exports.getTokenNameByDenom = function getTokenNameByDenom(assets, denom, chainName) {
116
103
  var asset = getAssetByDenom(assets, denom, chainName);
117
104
  return asset === null || asset === void 0 ? void 0 : asset.name;
118
105
  };
119
- exports.getTokenNameByDenom = getTokenNameByDenom;
120
- var getChainNameByDenom = function getChainNameByDenom(assets, denom) {
106
+ var getChainNameByDenom = exports.getChainNameByDenom = function getChainNameByDenom(assets, denom) {
121
107
  var _customFind;
122
108
  var isIbcDenom = denom.startsWith('ibc/');
123
109
  if (isIbcDenom) {
@@ -132,5 +118,4 @@ var getChainNameByDenom = function getChainNameByDenom(assets, denom) {
132
118
  return asset.base === denom;
133
119
  });
134
120
  })) === null || _customFind === void 0 ? void 0 : _customFind.chain_name;
135
- };
136
- exports.getChainNameByDenom = getChainNameByDenom;
121
+ };
package/main/calc.js CHANGED
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.roundDown = exports.mapCoinGeckoPricesToDenoms = exports.convertDollarValueToBaseUnit = exports.convertDisplayUnitToBaseUnit = exports.convertBaseUnitToDollarValue = exports.convertBaseUnitToDisplayUnit = void 0;
8
8
  var _bignumber = _interopRequireDefault(require("bignumber.js"));
9
9
  var _assets = require("./assets");
10
- var mapCoinGeckoPricesToDenoms = function mapCoinGeckoPricesToDenoms(assets, prices) {
10
+ var mapCoinGeckoPricesToDenoms = exports.mapCoinGeckoPricesToDenoms = function mapCoinGeckoPricesToDenoms(assets, prices) {
11
11
  return Object.keys(prices).reduce(function (res, geckoId) {
12
12
  var denom = (0, _assets.getDenomByCoinGeckoId)(assets, geckoId);
13
13
  if (!denom) {
@@ -17,11 +17,9 @@ var mapCoinGeckoPricesToDenoms = function mapCoinGeckoPricesToDenoms(assets, pri
17
17
  return res;
18
18
  }, {});
19
19
  };
20
- exports.mapCoinGeckoPricesToDenoms = mapCoinGeckoPricesToDenoms;
21
- var roundDown = function roundDown(value) {
20
+ var roundDown = exports.roundDown = function roundDown(value) {
22
21
  return new _bignumber["default"](value).decimalPlaces(0, _bignumber["default"].ROUND_DOWN).toString();
23
22
  };
24
- exports.roundDown = roundDown;
25
23
  var getAssetInfo = function getAssetInfo(assets, symbol, chainName) {
26
24
  var asset = (0, _assets.getAssetBySymbol)(assets, symbol, chainName);
27
25
  var denom = asset === null || asset === void 0 ? void 0 : asset.base;
@@ -38,31 +36,27 @@ var shiftDecimalPlaces = function shiftDecimalPlaces(amount, exponent) {
38
36
  var direction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
39
37
  return new _bignumber["default"](amount).shiftedBy(exponent * direction).toString();
40
38
  };
41
- var convertBaseUnitToDollarValue = function convertBaseUnitToDollarValue(assets, prices, symbol, amount, chainName) {
39
+ var convertBaseUnitToDollarValue = exports.convertBaseUnitToDollarValue = function convertBaseUnitToDollarValue(assets, prices, symbol, amount, chainName) {
42
40
  var _getAssetInfo = getAssetInfo(assets, symbol, chainName),
43
41
  denom = _getAssetInfo.denom,
44
42
  exponent = _getAssetInfo.exponent;
45
43
  var baseAmount = shiftDecimalPlaces(amount, exponent, -1);
46
44
  return new _bignumber["default"](baseAmount).multipliedBy(prices[denom]).toString();
47
45
  };
48
- exports.convertBaseUnitToDollarValue = convertBaseUnitToDollarValue;
49
- var convertDollarValueToBaseUnit = function convertDollarValueToBaseUnit(assets, prices, symbol, value, chainName) {
46
+ var convertDollarValueToBaseUnit = exports.convertDollarValueToBaseUnit = function convertDollarValueToBaseUnit(assets, prices, symbol, value, chainName) {
50
47
  var _getAssetInfo2 = getAssetInfo(assets, symbol, chainName),
51
48
  denom = _getAssetInfo2.denom,
52
49
  exponent = _getAssetInfo2.exponent;
53
50
  var baseAmount = new _bignumber["default"](value).dividedBy(prices[denom]).toString();
54
51
  return roundDown(shiftDecimalPlaces(baseAmount, exponent));
55
52
  };
56
- exports.convertDollarValueToBaseUnit = convertDollarValueToBaseUnit;
57
- var convertBaseUnitToDisplayUnit = function convertBaseUnitToDisplayUnit(assets, symbol, amount, chainName) {
53
+ var convertBaseUnitToDisplayUnit = exports.convertBaseUnitToDisplayUnit = function convertBaseUnitToDisplayUnit(assets, symbol, amount, chainName) {
58
54
  var _getAssetInfo3 = getAssetInfo(assets, symbol, chainName),
59
55
  exponent = _getAssetInfo3.exponent;
60
56
  return shiftDecimalPlaces(amount, exponent, -1);
61
57
  };
62
- exports.convertBaseUnitToDisplayUnit = convertBaseUnitToDisplayUnit;
63
- var convertDisplayUnitToBaseUnit = function convertDisplayUnitToBaseUnit(assets, symbol, amount, chainName) {
58
+ var convertDisplayUnitToBaseUnit = exports.convertDisplayUnitToBaseUnit = function convertDisplayUnitToBaseUnit(assets, symbol, amount, chainName) {
64
59
  var _getAssetInfo4 = getAssetInfo(assets, symbol, chainName),
65
60
  exponent = _getAssetInfo4.exponent;
66
61
  return roundDown(shiftDecimalPlaces(amount, exponent));
67
- };
68
- exports.convertDisplayUnitToBaseUnit = convertDisplayUnitToBaseUnit;
62
+ };
package/main/chains.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getGasPriceRangesFromChain = exports.getChainPrettyName = exports.getChainNameByChainId = exports.getChainIdByChainName = exports.getChainGasPriceRanges = exports.getChainByChainName = exports.getChainByChainId = exports.getChainBech32Prefix = void 0;
7
7
  var _assets = require("./assets");
8
- var getGasPriceRangesFromChain = function getGasPriceRangesFromChain(chain) {
8
+ var getGasPriceRangesFromChain = exports.getGasPriceRangesFromChain = function getGasPriceRangesFromChain(chain) {
9
9
  var _chain$fees, _chain$fees$fee_token, _feeToken$low_gas_pri, _feeToken$average_gas, _feeToken$high_gas_pr;
10
10
  var feeToken = (_chain$fees = chain.fees) === null || _chain$fees === void 0 ? void 0 : (_chain$fees$fee_token = _chain$fees.fee_tokens) === null || _chain$fees$fee_token === void 0 ? void 0 : _chain$fees$fee_token[0];
11
11
  return {
@@ -14,41 +14,33 @@ var getGasPriceRangesFromChain = function getGasPriceRangesFromChain(chain) {
14
14
  high: (_feeToken$high_gas_pr = feeToken === null || feeToken === void 0 ? void 0 : feeToken.high_gas_price) !== null && _feeToken$high_gas_pr !== void 0 ? _feeToken$high_gas_pr : 0.04
15
15
  };
16
16
  };
17
- exports.getGasPriceRangesFromChain = getGasPriceRangesFromChain;
18
- var getChainByChainName = function getChainByChainName(chains, chainName) {
17
+ var getChainByChainName = exports.getChainByChainName = function getChainByChainName(chains, chainName) {
19
18
  return (0, _assets.customFind)(chains, function (chain) {
20
19
  return chain.chain_name === chainName;
21
20
  });
22
21
  };
23
- exports.getChainByChainName = getChainByChainName;
24
- var getChainByChainId = function getChainByChainId(chains, chainId) {
22
+ var getChainByChainId = exports.getChainByChainId = function getChainByChainId(chains, chainId) {
25
23
  return (0, _assets.customFind)(chains, function (chain) {
26
24
  return chain.chain_id === chainId;
27
25
  });
28
26
  };
29
- exports.getChainByChainId = getChainByChainId;
30
- var getChainNameByChainId = function getChainNameByChainId(chains, chainId) {
27
+ var getChainNameByChainId = exports.getChainNameByChainId = function getChainNameByChainId(chains, chainId) {
31
28
  var _getChainByChainId;
32
29
  return (_getChainByChainId = getChainByChainId(chains, chainId)) === null || _getChainByChainId === void 0 ? void 0 : _getChainByChainId.chain_name;
33
30
  };
34
- exports.getChainNameByChainId = getChainNameByChainId;
35
- var getChainIdByChainName = function getChainIdByChainName(chains, chainName) {
31
+ var getChainIdByChainName = exports.getChainIdByChainName = function getChainIdByChainName(chains, chainName) {
36
32
  var _getChainByChainName;
37
33
  return (_getChainByChainName = getChainByChainName(chains, chainName)) === null || _getChainByChainName === void 0 ? void 0 : _getChainByChainName.chain_id;
38
34
  };
39
- exports.getChainIdByChainName = getChainIdByChainName;
40
- var getChainGasPriceRanges = function getChainGasPriceRanges(chains, chainName) {
35
+ var getChainGasPriceRanges = exports.getChainGasPriceRanges = function getChainGasPriceRanges(chains, chainName) {
41
36
  var chain = getChainByChainName(chains, chainName);
42
37
  return chain ? getGasPriceRangesFromChain(chain) : undefined;
43
38
  };
44
- exports.getChainGasPriceRanges = getChainGasPriceRanges;
45
- var getChainPrettyName = function getChainPrettyName(chains, chainName) {
39
+ var getChainPrettyName = exports.getChainPrettyName = function getChainPrettyName(chains, chainName) {
46
40
  var _getChainByChainName2;
47
41
  return (_getChainByChainName2 = getChainByChainName(chains, chainName)) === null || _getChainByChainName2 === void 0 ? void 0 : _getChainByChainName2.pretty_name;
48
42
  };
49
- exports.getChainPrettyName = getChainPrettyName;
50
- var getChainBech32Prefix = function getChainBech32Prefix(chains, chainName) {
43
+ var getChainBech32Prefix = exports.getChainBech32Prefix = function getChainBech32Prefix(chains, chainName) {
51
44
  var _getChainByChainName3;
52
45
  return (_getChainByChainName3 = getChainByChainName(chains, chainName)) === null || _getChainByChainName3 === void 0 ? void 0 : _getChainByChainName3.bech32_prefix;
53
- };
54
- exports.getChainBech32Prefix = getChainBech32Prefix;
46
+ };
package/main/ibc.js CHANGED
@@ -9,12 +9,12 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
9
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
11
  var _sha = require("sha.js");
12
- 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; }
13
- 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; }
12
+ 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; }
13
+ 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; }
14
14
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
15
15
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
16
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
17
- var ibcDenom = function ibcDenom(paths, coinMinimalDenom) {
17
+ var ibcDenom = exports.ibcDenom = function ibcDenom(paths, coinMinimalDenom) {
18
18
  var prefixes = [];
19
19
  var _iterator = _createForOfIteratorHelper(paths),
20
20
  _step;
@@ -32,35 +32,30 @@ var ibcDenom = function ibcDenom(paths, coinMinimalDenom) {
32
32
  var denom = "".concat(prefix, "/").concat(coinMinimalDenom);
33
33
  return 'ibc/' + Buffer.from(new Uint8Array(new _sha.sha256().update(Buffer.from(denom)).digest())).toString('hex').toUpperCase();
34
34
  };
35
- exports.ibcDenom = ibcDenom;
36
35
  var findInfo = function findInfo(ibc, to, from) {
37
36
  return ibc.find(function (i) {
38
37
  return i.chain_1.chain_name === from && i.chain_2.chain_name === to;
39
38
  });
40
39
  };
41
- var getIbcInfo = function getIbcInfo(ibc, chain, counterparty) {
40
+ var getIbcInfo = exports.getIbcInfo = function getIbcInfo(ibc, chain, counterparty) {
42
41
  return findInfo(ibc, chain, counterparty) || findInfo(ibc, counterparty, chain);
43
42
  };
44
- exports.getIbcInfo = getIbcInfo;
45
- var getTransferChannel = function getTransferChannel(info) {
43
+ var getTransferChannel = exports.getTransferChannel = function getTransferChannel(info) {
46
44
  return info.channels.find(function (channel) {
47
45
  return channel.chain_1.port_id === 'transfer' && channel.chain_2.port_id === 'transfer';
48
46
  });
49
47
  };
50
- exports.getTransferChannel = getTransferChannel;
51
- var getNonTransferChannel = function getNonTransferChannel(info) {
48
+ var getNonTransferChannel = exports.getNonTransferChannel = function getNonTransferChannel(info) {
52
49
  return info.channels.find(function (channel) {
53
50
  return channel.chain_1.port_id !== 'transfer' && channel.chain_2.port_id === 'transfer' || channel.chain_1.port_id === 'transfer' && channel.chain_2.port_id !== 'transfer';
54
51
  });
55
52
  };
56
- exports.getNonTransferChannel = getNonTransferChannel;
57
- var getWasmChannel = function getWasmChannel(info) {
53
+ var getWasmChannel = exports.getWasmChannel = function getWasmChannel(info) {
58
54
  return info.channels.find(function (channel) {
59
55
  return channel.chain_1.port_id.startsWith('wasm.') && channel.chain_2.port_id === 'transfer' || channel.chain_1.port_id === 'transfer' && channel.chain_2.port_id.startsWith('wasm');
60
56
  });
61
57
  };
62
- exports.getWasmChannel = getWasmChannel;
63
- var getIbcAssetPath = function getIbcAssetPath(ibc, chain, counterparty, assets, base) {
58
+ var getIbcAssetPath = exports.getIbcAssetPath = function getIbcAssetPath(ibc, chain, counterparty, assets, base) {
64
59
  var _asset$traces$filter, _asset$traces, _asset$traces$filter2;
65
60
  var ibcInfo = getIbcInfo(ibc, chain, counterparty);
66
61
  if (!ibcInfo) {
@@ -107,8 +102,7 @@ var getIbcAssetPath = function getIbcAssetPath(ibc, chain, counterparty, assets,
107
102
  // base
108
103
  )));
109
104
  };
110
- exports.getIbcAssetPath = getIbcAssetPath;
111
- var getIbcDenomByBase = function getIbcDenomByBase(ibc, chain, counterparty, assets, base) {
105
+ var getIbcDenomByBase = exports.getIbcDenomByBase = function getIbcDenomByBase(ibc, chain, counterparty, assets, base) {
112
106
  var ibcInfo = getIbcInfo(ibc, chain, counterparty);
113
107
  if (ibcInfo) {
114
108
  var _asset$traces2, _asset$traces2$find, _ibcTrace$counterpart, _ibcTrace$counterpart2;
@@ -140,8 +134,7 @@ var getIbcDenomByBase = function getIbcDenomByBase(ibc, chain, counterparty, ass
140
134
  return ibcDenom(ibcPath, baseDenom);
141
135
  }
142
136
  };
143
- exports.getIbcDenomByBase = getIbcDenomByBase;
144
- var getIbcAssets = function getIbcAssets(chainName, ibc, assets) {
137
+ var getIbcAssets = exports.getIbcAssets = function getIbcAssets(chainName, ibc, assets) {
145
138
  var chainIbcInfo = ibc.filter(function (i) {
146
139
  return i.chain_1.chain_name === chainName || i.chain_2.chain_name === chainName;
147
140
  });
@@ -216,7 +209,6 @@ var getIbcAssets = function getIbcAssets(chainName, ibc, assets) {
216
209
  chain_name: v.counterparty.chain_name
217
210
  // port: v.counterparty.port_id
218
211
  },
219
-
220
212
  chain: {
221
213
  // dst_denom
222
214
  channel_id: v.chain.channel_id
@@ -245,8 +237,7 @@ var getIbcAssets = function getIbcAssets(chainName, ibc, assets) {
245
237
  };
246
238
  });
247
239
  };
248
- exports.getIbcAssets = getIbcAssets;
249
- var getCw20Assets = function getCw20Assets(chainName, ibc, assets) {
240
+ var getCw20Assets = exports.getCw20Assets = function getCw20Assets(chainName, ibc, assets) {
250
241
  var chainIbcInfo = ibc.filter(function (i) {
251
242
  return i.chain_1.chain_name === chainName || i.chain_2.chain_name === chainName;
252
243
  });
@@ -343,8 +334,7 @@ var getCw20Assets = function getCw20Assets(chainName, ibc, assets) {
343
334
  };
344
335
  });
345
336
  };
346
- exports.getCw20Assets = getCw20Assets;
347
- var getAssetLists = function getAssetLists(chainName, ibc, assets) {
337
+ var getAssetLists = exports.getAssetLists = function getAssetLists(chainName, ibc, assets) {
348
338
  var ibcAssetLists = getIbcAssets(chainName, ibc, assets);
349
339
  var cw20Assets = getCw20Assets(chainName, ibc, assets);
350
340
  return ibcAssetLists.reduce(function (m, v) {
@@ -361,5 +351,4 @@ var getAssetLists = function getAssetLists(chainName, ibc, assets) {
361
351
  assets: assets
362
352
  }].concat((0, _toConsumableArray2["default"])(m));
363
353
  }, []);
364
- };
365
- exports.getAssetLists = getAssetLists;
354
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chain-registry/utils",
3
- "version": "1.19.0",
3
+ "version": "1.19.4",
4
4
  "description": "Chain Registry Utils",
5
5
  "author": "Dan Lynch <pyramation@gmail.com>",
6
6
  "homepage": "https://github.com/cosmology-tech/chain-registry",
@@ -72,9 +72,9 @@
72
72
  },
73
73
  "dependencies": {
74
74
  "@babel/runtime": "^7.21.0",
75
- "@chain-registry/types": "^0.18.1",
75
+ "@chain-registry/types": "^0.18.5",
76
76
  "bignumber.js": "9.1.1",
77
77
  "sha.js": "^2.4.11"
78
78
  },
79
- "gitHead": "e57916824aad1598342fe9175e9e87b1ba0babcb"
79
+ "gitHead": "bce72467286cbc2f4eb3fd94188411d6e89aaaba"
80
80
  }