@chain-registry/utils 1.18.2 → 1.19.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 +20 -217
- package/main/assets.js +121 -0
- package/main/calc.js +62 -0
- package/main/chains.js +46 -0
- package/main/index.js +23 -12
- package/package.json +3 -3
- package/types/assets.d.ts +25 -0
- package/types/calc.d.ts +14 -0
- package/types/chains.d.ts +14 -0
- package/types/index.d.ts +4 -3
- package/main/asset-list-util.js +0 -109
- package/main/fees.js +0 -14
- package/types/asset-list-util.d.ts +0 -27
- package/types/fees.d.ts +0 -6
- package/types/registry.d.ts +0 -45
- /package/main/{utils.js → ibc.js} +0 -0
- /package/types/{utils.d.ts → ibc.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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.
|
|
6
|
+
## [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)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @chain-registry/utils
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## 1.19.1 (2024-03-20)
|
|
15
15
|
|
|
16
16
|
**Note:** Version bump only for package @chain-registry/utils
|
|
17
17
|
|
|
@@ -19,444 +19,247 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
# [1.
|
|
23
|
-
|
|
24
|
-
**Note:** Version bump only for package @chain-registry/utils
|
|
22
|
+
# [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)
|
|
25
23
|
|
|
24
|
+
### Bug Fixes
|
|
26
25
|
|
|
26
|
+
- add explicit return types ([095175a](https://github.com/cosmology-tech/chain-registry/commit/095175aaa08cbde99052b0bd87e2173c871632f0))
|
|
27
|
+
- rename files ([62aa8d0](https://github.com/cosmology-tech/chain-registry/commit/62aa8d06a99425ba059e3a2b6e1d96ea7a9a2e23))
|
|
28
|
+
- update types ([0537055](https://github.com/cosmology-tech/chain-registry/commit/05370552b73b1e84da952544a34239c7bdefc766))
|
|
27
29
|
|
|
30
|
+
### Features
|
|
28
31
|
|
|
32
|
+
- add new utils ([b922c9d](https://github.com/cosmology-tech/chain-registry/commit/b922c9d5141655b92bdae8d22e1eabb92edfd8ec))
|
|
33
|
+
- add tests for new utils ([c4895a4](https://github.com/cosmology-tech/chain-registry/commit/c4895a469bed3cbe12305de2a99a1004f66efc25))
|
|
29
34
|
|
|
30
|
-
## [1.
|
|
35
|
+
## [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)
|
|
31
36
|
|
|
32
37
|
**Note:** Version bump only for package @chain-registry/utils
|
|
33
38
|
|
|
39
|
+
## [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)
|
|
34
40
|
|
|
41
|
+
**Note:** Version bump only for package @chain-registry/utils
|
|
35
42
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
## [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)
|
|
43
|
+
# [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)
|
|
39
44
|
|
|
40
45
|
**Note:** Version bump only for package @chain-registry/utils
|
|
41
46
|
|
|
47
|
+
## [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)
|
|
42
48
|
|
|
49
|
+
**Note:** Version bump only for package @chain-registry/utils
|
|
43
50
|
|
|
51
|
+
## [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)
|
|
44
52
|
|
|
53
|
+
**Note:** Version bump only for package @chain-registry/utils
|
|
45
54
|
|
|
46
55
|
## [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)
|
|
47
56
|
|
|
48
57
|
**Note:** Version bump only for package @chain-registry/utils
|
|
49
58
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
59
|
# [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)
|
|
55
60
|
|
|
56
|
-
|
|
57
61
|
### Features
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
- add chainName as optional param ([d415f33](https://github.com/cosmology-tech/chain-registry/commit/d415f33dc96651e5bb4ede689220d89ad11fe9d9))
|
|
64
64
|
|
|
65
65
|
## [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)
|
|
66
66
|
|
|
67
67
|
**Note:** Version bump only for package @chain-registry/utils
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
69
|
# [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)
|
|
74
70
|
|
|
75
|
-
|
|
76
71
|
### Features
|
|
77
72
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
- add getCoinGeckoIdByDenom method ([b05e67b](https://github.com/cosmology-tech/chain-registry/commit/b05e67b4b54258412d359745b1cd095987c67eb6))
|
|
83
74
|
|
|
84
75
|
# [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)
|
|
85
76
|
|
|
86
77
|
**Note:** Version bump only for package @chain-registry/utils
|
|
87
78
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
79
|
# [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)
|
|
93
80
|
|
|
94
81
|
**Note:** Version bump only for package @chain-registry/utils
|
|
95
82
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
83
|
## [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)
|
|
101
84
|
|
|
102
85
|
**Note:** Version bump only for package @chain-registry/utils
|
|
103
86
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
87
|
## [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)
|
|
109
88
|
|
|
110
89
|
**Note:** Version bump only for package @chain-registry/utils
|
|
111
90
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
91
|
# [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)
|
|
117
92
|
|
|
118
93
|
**Note:** Version bump only for package @chain-registry/utils
|
|
119
94
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
95
|
# [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)
|
|
125
96
|
|
|
126
97
|
**Note:** Version bump only for package @chain-registry/utils
|
|
127
98
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
99
|
# [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)
|
|
133
100
|
|
|
134
101
|
**Note:** Version bump only for package @chain-registry/utils
|
|
135
102
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
103
|
# [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)
|
|
141
104
|
|
|
142
105
|
**Note:** Version bump only for package @chain-registry/utils
|
|
143
106
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
107
|
## [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)
|
|
149
108
|
|
|
150
109
|
**Note:** Version bump only for package @chain-registry/utils
|
|
151
110
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
111
|
# [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)
|
|
157
112
|
|
|
158
113
|
**Note:** Version bump only for package @chain-registry/utils
|
|
159
114
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
115
|
# [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)
|
|
165
116
|
|
|
166
117
|
**Note:** Version bump only for package @chain-registry/utils
|
|
167
118
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
119
|
# [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)
|
|
173
120
|
|
|
174
121
|
**Note:** Version bump only for package @chain-registry/utils
|
|
175
122
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
123
|
# [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)
|
|
181
124
|
|
|
182
125
|
**Note:** Version bump only for package @chain-registry/utils
|
|
183
126
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
127
|
# [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)
|
|
189
128
|
|
|
190
129
|
**Note:** Version bump only for package @chain-registry/utils
|
|
191
130
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
131
|
# [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)
|
|
197
132
|
|
|
198
133
|
**Note:** Version bump only for package @chain-registry/utils
|
|
199
134
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
135
|
# [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)
|
|
205
136
|
|
|
206
137
|
**Note:** Version bump only for package @chain-registry/utils
|
|
207
138
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
139
|
## [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)
|
|
213
140
|
|
|
214
141
|
**Note:** Version bump only for package @chain-registry/utils
|
|
215
142
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
143
|
# [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)
|
|
221
144
|
|
|
222
145
|
**Note:** Version bump only for package @chain-registry/utils
|
|
223
146
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
147
|
# [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)
|
|
229
148
|
|
|
230
149
|
**Note:** Version bump only for package @chain-registry/utils
|
|
231
150
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
151
|
## [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)
|
|
237
152
|
|
|
238
153
|
**Note:** Version bump only for package @chain-registry/utils
|
|
239
154
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
155
|
# [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)
|
|
245
156
|
|
|
246
157
|
**Note:** Version bump only for package @chain-registry/utils
|
|
247
158
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
159
|
# [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)
|
|
253
160
|
|
|
254
161
|
**Note:** Version bump only for package @chain-registry/utils
|
|
255
162
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
163
|
## [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)
|
|
261
164
|
|
|
262
165
|
**Note:** Version bump only for package @chain-registry/utils
|
|
263
166
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
167
|
## [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)
|
|
269
168
|
|
|
270
169
|
**Note:** Version bump only for package @chain-registry/utils
|
|
271
170
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
171
|
# [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)
|
|
277
172
|
|
|
278
173
|
**Note:** Version bump only for package @chain-registry/utils
|
|
279
174
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
175
|
# [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)
|
|
285
176
|
|
|
286
177
|
**Note:** Version bump only for package @chain-registry/utils
|
|
287
178
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
179
|
# [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)
|
|
293
180
|
|
|
294
181
|
**Note:** Version bump only for package @chain-registry/utils
|
|
295
182
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
183
|
## [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)
|
|
301
184
|
|
|
302
185
|
**Note:** Version bump only for package @chain-registry/utils
|
|
303
186
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
187
|
## [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)
|
|
309
188
|
|
|
310
189
|
**Note:** Version bump only for package @chain-registry/utils
|
|
311
190
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
191
|
## [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)
|
|
317
192
|
|
|
318
193
|
**Note:** Version bump only for package @chain-registry/utils
|
|
319
194
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
195
|
# [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)
|
|
325
196
|
|
|
326
197
|
**Note:** Version bump only for package @chain-registry/utils
|
|
327
198
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
199
|
## [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)
|
|
333
200
|
|
|
334
201
|
**Note:** Version bump only for package @chain-registry/utils
|
|
335
202
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
203
|
## [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)
|
|
341
204
|
|
|
342
205
|
**Note:** Version bump only for package @chain-registry/utils
|
|
343
206
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
207
|
## [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)
|
|
349
208
|
|
|
350
209
|
**Note:** Version bump only for package @chain-registry/utils
|
|
351
210
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
211
|
# [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)
|
|
357
212
|
|
|
358
213
|
**Note:** Version bump only for package @chain-registry/utils
|
|
359
214
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
215
|
## [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)
|
|
365
216
|
|
|
366
217
|
**Note:** Version bump only for package @chain-registry/utils
|
|
367
218
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
219
|
# [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)
|
|
373
220
|
|
|
374
221
|
**Note:** Version bump only for package @chain-registry/utils
|
|
375
222
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
223
|
# [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)
|
|
381
224
|
|
|
382
225
|
**Note:** Version bump only for package @chain-registry/utils
|
|
383
226
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
227
|
## [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)
|
|
389
228
|
|
|
390
229
|
**Note:** Version bump only for package @chain-registry/utils
|
|
391
230
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
231
|
# [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)
|
|
397
232
|
|
|
398
233
|
**Note:** Version bump only for package @chain-registry/utils
|
|
399
234
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
235
|
## [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)
|
|
405
236
|
|
|
406
237
|
**Note:** Version bump only for package @chain-registry/utils
|
|
407
238
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
239
|
# 0.2.0 (2022-08-13)
|
|
413
240
|
|
|
414
241
|
**Note:** Version bump only for package @chain-registry/utils
|
|
415
242
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
243
|
# [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)
|
|
421
244
|
|
|
422
245
|
**Note:** Version bump only for package chain-registry-utils
|
|
423
246
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
247
|
## 0.0.6 (2022-07-25)
|
|
429
248
|
|
|
430
249
|
**Note:** Version bump only for package chain-registry-utils
|
|
431
250
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
251
|
## [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)
|
|
437
252
|
|
|
438
253
|
**Note:** Version bump only for package chain-registry-utils
|
|
439
254
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
255
|
## [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)
|
|
445
256
|
|
|
446
257
|
**Note:** Version bump only for package chain-registry-utils
|
|
447
258
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
259
|
## 0.0.3 (2022-07-12)
|
|
453
260
|
|
|
454
261
|
**Note:** Version bump only for package chain-registry-utils
|
|
455
262
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
263
|
## 0.0.2 (2022-07-12)
|
|
461
264
|
|
|
462
265
|
**Note:** Version bump only for package chain-registry-utils
|
package/main/assets.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
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 = exports.customFind = function customFind(array, filterFn) {
|
|
8
|
+
var filteredItems = array.filter(filterFn);
|
|
9
|
+
var filterCount = filteredItems.length;
|
|
10
|
+
if (filterCount > 1) {
|
|
11
|
+
throw new Error("Ambiguity Error: ".concat(filterCount, " items found."));
|
|
12
|
+
}
|
|
13
|
+
return filteredItems[0];
|
|
14
|
+
};
|
|
15
|
+
var getAssetByKeyValue = function getAssetByKeyValue(assets, key, value, chainName) {
|
|
16
|
+
var filteredAssets = assets.filter(function (_ref) {
|
|
17
|
+
var chain_name = _ref.chain_name;
|
|
18
|
+
return !chainName || chain_name === chainName;
|
|
19
|
+
}).flatMap(function (_ref2) {
|
|
20
|
+
var assets = _ref2.assets;
|
|
21
|
+
return assets;
|
|
22
|
+
});
|
|
23
|
+
return customFind(filteredAssets, function (asset) {
|
|
24
|
+
return asset[key] === value;
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
var getAssetByDenom = exports.getAssetByDenom = function getAssetByDenom(assets, denom, chainName) {
|
|
28
|
+
return getAssetByKeyValue(assets, 'base', denom, chainName);
|
|
29
|
+
};
|
|
30
|
+
var getAssetBySymbol = exports.getAssetBySymbol = function getAssetBySymbol(assets, symbol, chainName) {
|
|
31
|
+
return getAssetByKeyValue(assets, 'symbol', symbol, chainName);
|
|
32
|
+
};
|
|
33
|
+
var getDenomByCoinGeckoId = exports.getDenomByCoinGeckoId = function getDenomByCoinGeckoId(assets, coinGeckoId, chainName) {
|
|
34
|
+
var _getAssetByKeyValue;
|
|
35
|
+
return (_getAssetByKeyValue = getAssetByKeyValue(assets, 'coingecko_id', coinGeckoId, chainName)) === null || _getAssetByKeyValue === void 0 ? void 0 : _getAssetByKeyValue.base;
|
|
36
|
+
};
|
|
37
|
+
var getCoinGeckoIdByDenom = exports.getCoinGeckoIdByDenom = function getCoinGeckoIdByDenom(assets, denom) {
|
|
38
|
+
var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
39
|
+
chainName = _ref3.chainName,
|
|
40
|
+
_ref3$allowTestnet = _ref3.allowTestnet,
|
|
41
|
+
allowTestnet = _ref3$allowTestnet === void 0 ? false : _ref3$allowTestnet,
|
|
42
|
+
_ref3$customAssetFilt = _ref3.customAssetFilter,
|
|
43
|
+
customAssetFilter = _ref3$customAssetFilt === void 0 ? function () {
|
|
44
|
+
return true;
|
|
45
|
+
} : _ref3$customAssetFilt,
|
|
46
|
+
_ref3$excludedChainNa = _ref3.excludedChainNames,
|
|
47
|
+
excludedChainNames = _ref3$excludedChainNa === void 0 ? [] : _ref3$excludedChainNa;
|
|
48
|
+
var filteredAssetLists = assets.filter(function (_ref4) {
|
|
49
|
+
var chain_name = _ref4.chain_name;
|
|
50
|
+
return (!chainName || chain_name === chainName) && (allowTestnet || !chain_name.includes('testnet')) && !excludedChainNames.includes(chain_name);
|
|
51
|
+
});
|
|
52
|
+
var filteredAssets = filteredAssetLists.flatMap(function (_ref5) {
|
|
53
|
+
var assets = _ref5.assets;
|
|
54
|
+
return assets;
|
|
55
|
+
}).filter(function (_ref6) {
|
|
56
|
+
var coingecko_id = _ref6.coingecko_id;
|
|
57
|
+
return coingecko_id;
|
|
58
|
+
}).filter(customAssetFilter);
|
|
59
|
+
var asset = filteredAssets.find(function (_ref7) {
|
|
60
|
+
var base = _ref7.base;
|
|
61
|
+
return base === denom;
|
|
62
|
+
});
|
|
63
|
+
return asset === null || asset === void 0 ? void 0 : asset.coingecko_id;
|
|
64
|
+
};
|
|
65
|
+
var getSymbolByDenom = exports.getSymbolByDenom = function getSymbolByDenom(assets, denom, chainName) {
|
|
66
|
+
var _getAssetByDenom;
|
|
67
|
+
return (_getAssetByDenom = getAssetByDenom(assets, denom, chainName)) === null || _getAssetByDenom === void 0 ? void 0 : _getAssetByDenom.symbol;
|
|
68
|
+
};
|
|
69
|
+
var getDenomBySymbol = exports.getDenomBySymbol = function getDenomBySymbol(assets, symbol, chainName) {
|
|
70
|
+
var _getAssetByKeyValue2;
|
|
71
|
+
return (_getAssetByKeyValue2 = getAssetByKeyValue(assets, 'symbol', symbol, chainName)) === null || _getAssetByKeyValue2 === void 0 ? void 0 : _getAssetByKeyValue2.base;
|
|
72
|
+
};
|
|
73
|
+
var getExponentFromAsset = exports.getExponentFromAsset = function getExponentFromAsset(asset) {
|
|
74
|
+
var _asset$denom_units$fi;
|
|
75
|
+
return (_asset$denom_units$fi = asset.denom_units.find(function (_ref8) {
|
|
76
|
+
var denom = _ref8.denom;
|
|
77
|
+
return denom === asset.display;
|
|
78
|
+
})) === null || _asset$denom_units$fi === void 0 ? void 0 : _asset$denom_units$fi.exponent;
|
|
79
|
+
};
|
|
80
|
+
var getExponentByDenom = exports.getExponentByDenom = function getExponentByDenom(assets, denom, chainName) {
|
|
81
|
+
var asset = getAssetByDenom(assets, denom, chainName);
|
|
82
|
+
return asset ? getExponentFromAsset(asset) : undefined;
|
|
83
|
+
};
|
|
84
|
+
var getExponentBySymbol = exports.getExponentBySymbol = function getExponentBySymbol(assets, symbol, chainName) {
|
|
85
|
+
var asset = getAssetBySymbol(assets, symbol, chainName);
|
|
86
|
+
return asset ? getExponentFromAsset(asset) : undefined;
|
|
87
|
+
};
|
|
88
|
+
var getNativeTokenByChainName = exports.getNativeTokenByChainName = function getNativeTokenByChainName(assets, chainName) {
|
|
89
|
+
var assetList = customFind(assets, function (assetList) {
|
|
90
|
+
return assetList.chain_name === chainName && !assetList.assets[0].base.startsWith('ibc/');
|
|
91
|
+
});
|
|
92
|
+
return assetList === null || assetList === void 0 ? void 0 : assetList.assets[0];
|
|
93
|
+
};
|
|
94
|
+
var getTokenLogoByDenom = exports.getTokenLogoByDenom = function getTokenLogoByDenom(assets, denom, chainName) {
|
|
95
|
+
var asset = getAssetByDenom(assets, denom, chainName);
|
|
96
|
+
return Object.values((asset === null || asset === void 0 ? void 0 : asset.logo_URIs) || {})[0];
|
|
97
|
+
};
|
|
98
|
+
var getChainLogo = exports.getChainLogo = function getChainLogo(assets, chainName) {
|
|
99
|
+
var nativeToken = getNativeTokenByChainName(assets, chainName);
|
|
100
|
+
return Object.values((nativeToken === null || nativeToken === void 0 ? void 0 : nativeToken.logo_URIs) || {})[0];
|
|
101
|
+
};
|
|
102
|
+
var getTokenNameByDenom = exports.getTokenNameByDenom = function getTokenNameByDenom(assets, denom, chainName) {
|
|
103
|
+
var asset = getAssetByDenom(assets, denom, chainName);
|
|
104
|
+
return asset === null || asset === void 0 ? void 0 : asset.name;
|
|
105
|
+
};
|
|
106
|
+
var getChainNameByDenom = exports.getChainNameByDenom = function getChainNameByDenom(assets, denom) {
|
|
107
|
+
var _customFind;
|
|
108
|
+
var isIbcDenom = denom.startsWith('ibc/');
|
|
109
|
+
if (isIbcDenom) {
|
|
110
|
+
var _asset$traces, _asset$traces$find, _asset$traces$find$co;
|
|
111
|
+
var _asset = getAssetByDenom(assets, denom);
|
|
112
|
+
return _asset === null || _asset === void 0 ? void 0 : (_asset$traces = _asset.traces) === null || _asset$traces === void 0 ? void 0 : (_asset$traces$find = _asset$traces.find(function (t) {
|
|
113
|
+
return t.type === 'ibc';
|
|
114
|
+
})) === null || _asset$traces$find === void 0 ? void 0 : (_asset$traces$find$co = _asset$traces$find.counterparty) === null || _asset$traces$find$co === void 0 ? void 0 : _asset$traces$find$co.chain_name;
|
|
115
|
+
}
|
|
116
|
+
return (_customFind = customFind(assets, function (assetList) {
|
|
117
|
+
return assetList.assets.some(function (asset) {
|
|
118
|
+
return asset.base === denom;
|
|
119
|
+
});
|
|
120
|
+
})) === null || _customFind === void 0 ? void 0 : _customFind.chain_name;
|
|
121
|
+
};
|
package/main/calc.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.roundDown = exports.mapCoinGeckoPricesToDenoms = exports.convertDollarValueToBaseUnit = exports.convertDisplayUnitToBaseUnit = exports.convertBaseUnitToDollarValue = exports.convertBaseUnitToDisplayUnit = void 0;
|
|
8
|
+
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
9
|
+
var _assets = require("./assets");
|
|
10
|
+
var mapCoinGeckoPricesToDenoms = exports.mapCoinGeckoPricesToDenoms = function mapCoinGeckoPricesToDenoms(assets, prices) {
|
|
11
|
+
return Object.keys(prices).reduce(function (res, geckoId) {
|
|
12
|
+
var denom = (0, _assets.getDenomByCoinGeckoId)(assets, geckoId);
|
|
13
|
+
if (!denom) {
|
|
14
|
+
throw new Error("No denom found for CoinGecko ID: ".concat(geckoId));
|
|
15
|
+
}
|
|
16
|
+
res[denom] = prices[geckoId].usd;
|
|
17
|
+
return res;
|
|
18
|
+
}, {});
|
|
19
|
+
};
|
|
20
|
+
var roundDown = exports.roundDown = function roundDown(value) {
|
|
21
|
+
return new _bignumber["default"](value).decimalPlaces(0, _bignumber["default"].ROUND_DOWN).toString();
|
|
22
|
+
};
|
|
23
|
+
var getAssetInfo = function getAssetInfo(assets, symbol, chainName) {
|
|
24
|
+
var asset = (0, _assets.getAssetBySymbol)(assets, symbol, chainName);
|
|
25
|
+
var denom = asset === null || asset === void 0 ? void 0 : asset.base;
|
|
26
|
+
var exponent = asset ? (0, _assets.getExponentFromAsset)(asset) : undefined;
|
|
27
|
+
if (!denom || !exponent) {
|
|
28
|
+
throw new Error("No denom or exponent found for symbol: ".concat(symbol));
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
denom: denom,
|
|
32
|
+
exponent: exponent
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
var shiftDecimalPlaces = function shiftDecimalPlaces(amount, exponent) {
|
|
36
|
+
var direction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
37
|
+
return new _bignumber["default"](amount).shiftedBy(exponent * direction).toString();
|
|
38
|
+
};
|
|
39
|
+
var convertBaseUnitToDollarValue = exports.convertBaseUnitToDollarValue = function convertBaseUnitToDollarValue(assets, prices, symbol, amount, chainName) {
|
|
40
|
+
var _getAssetInfo = getAssetInfo(assets, symbol, chainName),
|
|
41
|
+
denom = _getAssetInfo.denom,
|
|
42
|
+
exponent = _getAssetInfo.exponent;
|
|
43
|
+
var baseAmount = shiftDecimalPlaces(amount, exponent, -1);
|
|
44
|
+
return new _bignumber["default"](baseAmount).multipliedBy(prices[denom]).toString();
|
|
45
|
+
};
|
|
46
|
+
var convertDollarValueToBaseUnit = exports.convertDollarValueToBaseUnit = function convertDollarValueToBaseUnit(assets, prices, symbol, value, chainName) {
|
|
47
|
+
var _getAssetInfo2 = getAssetInfo(assets, symbol, chainName),
|
|
48
|
+
denom = _getAssetInfo2.denom,
|
|
49
|
+
exponent = _getAssetInfo2.exponent;
|
|
50
|
+
var baseAmount = new _bignumber["default"](value).dividedBy(prices[denom]).toString();
|
|
51
|
+
return roundDown(shiftDecimalPlaces(baseAmount, exponent));
|
|
52
|
+
};
|
|
53
|
+
var convertBaseUnitToDisplayUnit = exports.convertBaseUnitToDisplayUnit = function convertBaseUnitToDisplayUnit(assets, symbol, amount, chainName) {
|
|
54
|
+
var _getAssetInfo3 = getAssetInfo(assets, symbol, chainName),
|
|
55
|
+
exponent = _getAssetInfo3.exponent;
|
|
56
|
+
return shiftDecimalPlaces(amount, exponent, -1);
|
|
57
|
+
};
|
|
58
|
+
var convertDisplayUnitToBaseUnit = exports.convertDisplayUnitToBaseUnit = function convertDisplayUnitToBaseUnit(assets, symbol, amount, chainName) {
|
|
59
|
+
var _getAssetInfo4 = getAssetInfo(assets, symbol, chainName),
|
|
60
|
+
exponent = _getAssetInfo4.exponent;
|
|
61
|
+
return roundDown(shiftDecimalPlaces(amount, exponent));
|
|
62
|
+
};
|
package/main/chains.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getGasPriceRangesFromChain = exports.getChainPrettyName = exports.getChainNameByChainId = exports.getChainIdByChainName = exports.getChainGasPriceRanges = exports.getChainByChainName = exports.getChainByChainId = exports.getChainBech32Prefix = void 0;
|
|
7
|
+
var _assets = require("./assets");
|
|
8
|
+
var getGasPriceRangesFromChain = exports.getGasPriceRangesFromChain = function getGasPriceRangesFromChain(chain) {
|
|
9
|
+
var _chain$fees, _chain$fees$fee_token, _feeToken$low_gas_pri, _feeToken$average_gas, _feeToken$high_gas_pr;
|
|
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
|
+
return {
|
|
12
|
+
low: (_feeToken$low_gas_pri = feeToken === null || feeToken === void 0 ? void 0 : feeToken.low_gas_price) !== null && _feeToken$low_gas_pri !== void 0 ? _feeToken$low_gas_pri : 0.01,
|
|
13
|
+
average: (_feeToken$average_gas = feeToken === null || feeToken === void 0 ? void 0 : feeToken.average_gas_price) !== null && _feeToken$average_gas !== void 0 ? _feeToken$average_gas : 0.025,
|
|
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
|
+
};
|
|
16
|
+
};
|
|
17
|
+
var getChainByChainName = exports.getChainByChainName = function getChainByChainName(chains, chainName) {
|
|
18
|
+
return (0, _assets.customFind)(chains, function (chain) {
|
|
19
|
+
return chain.chain_name === chainName;
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var getChainByChainId = exports.getChainByChainId = function getChainByChainId(chains, chainId) {
|
|
23
|
+
return (0, _assets.customFind)(chains, function (chain) {
|
|
24
|
+
return chain.chain_id === chainId;
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
var getChainNameByChainId = exports.getChainNameByChainId = function getChainNameByChainId(chains, chainId) {
|
|
28
|
+
var _getChainByChainId;
|
|
29
|
+
return (_getChainByChainId = getChainByChainId(chains, chainId)) === null || _getChainByChainId === void 0 ? void 0 : _getChainByChainId.chain_name;
|
|
30
|
+
};
|
|
31
|
+
var getChainIdByChainName = exports.getChainIdByChainName = function getChainIdByChainName(chains, chainName) {
|
|
32
|
+
var _getChainByChainName;
|
|
33
|
+
return (_getChainByChainName = getChainByChainName(chains, chainName)) === null || _getChainByChainName === void 0 ? void 0 : _getChainByChainName.chain_id;
|
|
34
|
+
};
|
|
35
|
+
var getChainGasPriceRanges = exports.getChainGasPriceRanges = function getChainGasPriceRanges(chains, chainName) {
|
|
36
|
+
var chain = getChainByChainName(chains, chainName);
|
|
37
|
+
return chain ? getGasPriceRangesFromChain(chain) : undefined;
|
|
38
|
+
};
|
|
39
|
+
var getChainPrettyName = exports.getChainPrettyName = function getChainPrettyName(chains, chainName) {
|
|
40
|
+
var _getChainByChainName2;
|
|
41
|
+
return (_getChainByChainName2 = getChainByChainName(chains, chainName)) === null || _getChainByChainName2 === void 0 ? void 0 : _getChainByChainName2.pretty_name;
|
|
42
|
+
};
|
|
43
|
+
var getChainBech32Prefix = exports.getChainBech32Prefix = function getChainBech32Prefix(chains, chainName) {
|
|
44
|
+
var _getChainByChainName3;
|
|
45
|
+
return (_getChainByChainName3 = getChainByChainName(chains, chainName)) === null || _getChainByChainName3 === void 0 ? void 0 : _getChainByChainName3.bech32_prefix;
|
|
46
|
+
};
|
package/main/index.js
CHANGED
|
@@ -3,36 +3,47 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var
|
|
7
|
-
Object.keys(
|
|
6
|
+
var _ibc = require("./ibc");
|
|
7
|
+
Object.keys(_ibc).forEach(function (key) {
|
|
8
8
|
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] ===
|
|
9
|
+
if (key in exports && exports[key] === _ibc[key]) return;
|
|
10
10
|
Object.defineProperty(exports, key, {
|
|
11
11
|
enumerable: true,
|
|
12
12
|
get: function get() {
|
|
13
|
-
return
|
|
13
|
+
return _ibc[key];
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
|
-
var
|
|
18
|
-
Object.keys(
|
|
17
|
+
var _calc = require("./calc");
|
|
18
|
+
Object.keys(_calc).forEach(function (key) {
|
|
19
19
|
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] ===
|
|
20
|
+
if (key in exports && exports[key] === _calc[key]) return;
|
|
21
21
|
Object.defineProperty(exports, key, {
|
|
22
22
|
enumerable: true,
|
|
23
23
|
get: function get() {
|
|
24
|
-
return
|
|
24
|
+
return _calc[key];
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
|
-
var
|
|
29
|
-
Object.keys(
|
|
28
|
+
var _chains = require("./chains");
|
|
29
|
+
Object.keys(_chains).forEach(function (key) {
|
|
30
30
|
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] ===
|
|
31
|
+
if (key in exports && exports[key] === _chains[key]) return;
|
|
32
32
|
Object.defineProperty(exports, key, {
|
|
33
33
|
enumerable: true,
|
|
34
34
|
get: function get() {
|
|
35
|
-
return
|
|
35
|
+
return _chains[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _assets = require("./assets");
|
|
40
|
+
Object.keys(_assets).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _assets[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function get() {
|
|
46
|
+
return _assets[key];
|
|
36
47
|
}
|
|
37
48
|
});
|
|
38
49
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chain-registry/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.2",
|
|
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.
|
|
75
|
+
"@chain-registry/types": "^0.18.3",
|
|
76
76
|
"bignumber.js": "9.1.1",
|
|
77
77
|
"sha.js": "^2.4.11"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "3da58f4178fd61379a8358fca13f9d53f85d25cc"
|
|
80
80
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Asset, AssetDenomUnit, AssetList } from '@chain-registry/types';
|
|
2
|
+
export type Denom = AssetDenomUnit['denom'];
|
|
3
|
+
export type Exponent = AssetDenomUnit['exponent'];
|
|
4
|
+
export declare const customFind: <T>(array: T[], filterFn: (item: T) => boolean) => T;
|
|
5
|
+
export declare const getAssetByDenom: (assets: AssetList[], denom: Denom, chainName?: string) => Asset | undefined;
|
|
6
|
+
export declare const getAssetBySymbol: (assets: AssetList[], symbol: string, chainName?: string) => Asset | undefined;
|
|
7
|
+
export declare const getDenomByCoinGeckoId: (assets: AssetList[], coinGeckoId: string, chainName?: string) => Denom | undefined;
|
|
8
|
+
type GetCoinGeckoIdByDenomOptions = {
|
|
9
|
+
chainName?: string;
|
|
10
|
+
allowTestnet?: boolean;
|
|
11
|
+
customAssetFilter?: (asset: Asset) => boolean;
|
|
12
|
+
excludedChainNames?: string[];
|
|
13
|
+
};
|
|
14
|
+
export declare const getCoinGeckoIdByDenom: (assets: AssetList[], denom: Denom, { chainName, allowTestnet, customAssetFilter, excludedChainNames }?: GetCoinGeckoIdByDenomOptions) => string | undefined;
|
|
15
|
+
export declare const getSymbolByDenom: (assets: AssetList[], denom: Denom, chainName?: string) => string | undefined;
|
|
16
|
+
export declare const getDenomBySymbol: (assets: AssetList[], symbol: string, chainName?: string) => Denom | undefined;
|
|
17
|
+
export declare const getExponentFromAsset: (asset: Asset) => number | undefined;
|
|
18
|
+
export declare const getExponentByDenom: (assets: AssetList[], denom: Denom, chainName?: string) => Exponent | undefined;
|
|
19
|
+
export declare const getExponentBySymbol: (assets: AssetList[], symbol: string, chainName?: string) => Exponent | undefined;
|
|
20
|
+
export declare const getNativeTokenByChainName: (assets: AssetList[], chainName: string) => Asset | undefined;
|
|
21
|
+
export declare const getTokenLogoByDenom: (assets: AssetList[], denom: Denom, chainName?: string) => string | undefined;
|
|
22
|
+
export declare const getChainLogo: (assets: AssetList[], chainName: string) => string | undefined;
|
|
23
|
+
export declare const getTokenNameByDenom: (assets: AssetList[], denom: Denom, chainName?: string) => string | undefined;
|
|
24
|
+
export declare const getChainNameByDenom: (assets: AssetList[], denom: Denom) => string | undefined;
|
|
25
|
+
export {};
|
package/types/calc.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AssetList } from '@chain-registry/types';
|
|
2
|
+
import { Denom } from './assets';
|
|
3
|
+
export interface CoinGeckoUSDPrice {
|
|
4
|
+
usd: number;
|
|
5
|
+
}
|
|
6
|
+
export interface DenomPriceMap {
|
|
7
|
+
[key: Denom]: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const mapCoinGeckoPricesToDenoms: (assets: AssetList[], prices: Record<string, CoinGeckoUSDPrice>) => DenomPriceMap;
|
|
10
|
+
export declare const roundDown: (value: number | string) => string;
|
|
11
|
+
export declare const convertBaseUnitToDollarValue: (assets: AssetList[], prices: DenomPriceMap, symbol: string, amount: string | number, chainName?: string) => string;
|
|
12
|
+
export declare const convertDollarValueToBaseUnit: (assets: AssetList[], prices: DenomPriceMap, symbol: string, value: string | number, chainName?: string) => string;
|
|
13
|
+
export declare const convertBaseUnitToDisplayUnit: (assets: AssetList[], symbol: string, amount: string | number, chainName?: string) => string;
|
|
14
|
+
export declare const convertDisplayUnitToBaseUnit: (assets: AssetList[], symbol: string, amount: string | number, chainName?: string) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Chain } from '@chain-registry/types';
|
|
2
|
+
export interface GasPriceRanges {
|
|
3
|
+
low: number;
|
|
4
|
+
average: number;
|
|
5
|
+
high: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const getGasPriceRangesFromChain: (chain: Chain) => GasPriceRanges;
|
|
8
|
+
export declare const getChainByChainName: (chains: Chain[], chainName: string) => Chain | undefined;
|
|
9
|
+
export declare const getChainByChainId: (chains: Chain[], chainId: string) => Chain | undefined;
|
|
10
|
+
export declare const getChainNameByChainId: (chains: Chain[], chainId: string) => string | undefined;
|
|
11
|
+
export declare const getChainIdByChainName: (chains: Chain[], chainName: string) => string | undefined;
|
|
12
|
+
export declare const getChainGasPriceRanges: (chains: Chain[], chainName: string) => GasPriceRanges | undefined;
|
|
13
|
+
export declare const getChainPrettyName: (chains: Chain[], chainName: string) => string | undefined;
|
|
14
|
+
export declare const getChainBech32Prefix: (chains: Chain[], chainName: string) => string | undefined;
|
package/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './ibc';
|
|
2
|
+
export * from './calc';
|
|
3
|
+
export * from './chains';
|
|
4
|
+
export * from './assets';
|
package/main/asset-list-util.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.convertBaseUnitsToDisplayUnits = convertBaseUnitsToDisplayUnits;
|
|
8
|
-
exports.convertBaseUnitsToDollarValue = convertBaseUnitsToDollarValue;
|
|
9
|
-
exports.convertCoinGeckoPricesToDenomPriceMap = convertCoinGeckoPricesToDenomPriceMap;
|
|
10
|
-
exports.convertDollarValueToDenomUnits = convertDollarValueToDenomUnits;
|
|
11
|
-
exports.getAssetByDenom = getAssetByDenom;
|
|
12
|
-
exports.getChainDenomBySymbol = getChainDenomBySymbol;
|
|
13
|
-
exports.getCoinGeckoIdByDenom = getCoinGeckoIdByDenom;
|
|
14
|
-
exports.getDenomByCoinGeckoId = getDenomByCoinGeckoId;
|
|
15
|
-
exports.getExponentByDenom = getExponentByDenom;
|
|
16
|
-
exports.getSymbolByChainDenom = getSymbolByChainDenom;
|
|
17
|
-
exports.noDecimals = noDecimals;
|
|
18
|
-
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
19
|
-
function getAssetByKeyValue(assets, key, value, chainName) {
|
|
20
|
-
var filteredAssets = assets.filter(function (_ref) {
|
|
21
|
-
var chain_name = _ref.chain_name;
|
|
22
|
-
return !chainName || chain_name === chainName;
|
|
23
|
-
}).flatMap(function (_ref2) {
|
|
24
|
-
var assets = _ref2.assets;
|
|
25
|
-
return assets;
|
|
26
|
-
});
|
|
27
|
-
var matchingAssets = filteredAssets.filter(function (asset) {
|
|
28
|
-
return asset[key] === value;
|
|
29
|
-
});
|
|
30
|
-
if (matchingAssets.length === 0) {
|
|
31
|
-
throw new Error("No asset found for ".concat(key, " '").concat(value, "'"));
|
|
32
|
-
}
|
|
33
|
-
if (matchingAssets.length > 1) {
|
|
34
|
-
throw new Error("Ambiguity: ".concat(matchingAssets.length, " assets found for ").concat(key, " '").concat(value, "'"));
|
|
35
|
-
}
|
|
36
|
-
return matchingAssets[0];
|
|
37
|
-
}
|
|
38
|
-
function getAssetByDenom(assets, denom, chainName) {
|
|
39
|
-
return getAssetByKeyValue(assets, 'base', denom, chainName);
|
|
40
|
-
}
|
|
41
|
-
function getDenomByCoinGeckoId(assets, coinGeckoId, chainName) {
|
|
42
|
-
return getAssetByKeyValue(assets, 'coingecko_id', coinGeckoId, chainName).base;
|
|
43
|
-
}
|
|
44
|
-
function getCoinGeckoIdByDenom(assets, denom) {
|
|
45
|
-
var _asset$coingecko_id;
|
|
46
|
-
var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
47
|
-
chainName = _ref3.chainName,
|
|
48
|
-
_ref3$allowTestnet = _ref3.allowTestnet,
|
|
49
|
-
allowTestnet = _ref3$allowTestnet === void 0 ? false : _ref3$allowTestnet,
|
|
50
|
-
_ref3$customAssetFilt = _ref3.customAssetFilter,
|
|
51
|
-
customAssetFilter = _ref3$customAssetFilt === void 0 ? function () {
|
|
52
|
-
return true;
|
|
53
|
-
} : _ref3$customAssetFilt,
|
|
54
|
-
_ref3$excludedChainNa = _ref3.excludedChainNames,
|
|
55
|
-
excludedChainNames = _ref3$excludedChainNa === void 0 ? [] : _ref3$excludedChainNa;
|
|
56
|
-
var filteredAssetLists = assets.filter(function (_ref4) {
|
|
57
|
-
var chain_name = _ref4.chain_name;
|
|
58
|
-
return (!chainName || chain_name === chainName) && (allowTestnet || !chain_name.includes('testnet')) && !excludedChainNames.includes(chain_name);
|
|
59
|
-
});
|
|
60
|
-
var filteredAssets = filteredAssetLists.flatMap(function (_ref5) {
|
|
61
|
-
var assets = _ref5.assets;
|
|
62
|
-
return assets;
|
|
63
|
-
}).filter(function (_ref6) {
|
|
64
|
-
var coingecko_id = _ref6.coingecko_id;
|
|
65
|
-
return coingecko_id;
|
|
66
|
-
}).filter(customAssetFilter);
|
|
67
|
-
var asset = filteredAssets.find(function (_ref7) {
|
|
68
|
-
var base = _ref7.base;
|
|
69
|
-
return base === denom;
|
|
70
|
-
});
|
|
71
|
-
return (_asset$coingecko_id = asset === null || asset === void 0 ? void 0 : asset.coingecko_id) !== null && _asset$coingecko_id !== void 0 ? _asset$coingecko_id : null;
|
|
72
|
-
}
|
|
73
|
-
function getSymbolByChainDenom(assets, denom, chainName) {
|
|
74
|
-
return getAssetByDenom(assets, denom, chainName).symbol;
|
|
75
|
-
}
|
|
76
|
-
function getChainDenomBySymbol(assets, symbol, chainName) {
|
|
77
|
-
return getAssetByKeyValue(assets, 'symbol', symbol, chainName).base;
|
|
78
|
-
}
|
|
79
|
-
function getExponentByDenom(assets, denom, chainName) {
|
|
80
|
-
var _unit$exponent;
|
|
81
|
-
var asset = getAssetByDenom(assets, denom, chainName);
|
|
82
|
-
var unit = asset.denom_units.find(function (_ref8) {
|
|
83
|
-
var denom = _ref8.denom;
|
|
84
|
-
return denom === asset.display;
|
|
85
|
-
});
|
|
86
|
-
return (_unit$exponent = unit === null || unit === void 0 ? void 0 : unit.exponent) !== null && _unit$exponent !== void 0 ? _unit$exponent : 0;
|
|
87
|
-
}
|
|
88
|
-
function convertCoinGeckoPricesToDenomPriceMap(assets, prices) {
|
|
89
|
-
return Object.keys(prices).reduce(function (res, geckoId) {
|
|
90
|
-
var denom = getDenomByCoinGeckoId(assets, geckoId);
|
|
91
|
-
res[denom] = prices[geckoId].usd;
|
|
92
|
-
return res;
|
|
93
|
-
}, {});
|
|
94
|
-
}
|
|
95
|
-
function noDecimals(num) {
|
|
96
|
-
return new _bignumber["default"](num).decimalPlaces(0, _bignumber["default"].ROUND_DOWN).toString();
|
|
97
|
-
}
|
|
98
|
-
function convertBaseUnitsToDollarValue(assets, prices, symbol, amount, chainName) {
|
|
99
|
-
var denom = getChainDenomBySymbol(assets, symbol, chainName);
|
|
100
|
-
return new _bignumber["default"](amount).shiftedBy(-getExponentByDenom(assets, denom, chainName)).multipliedBy(prices[denom]).toString();
|
|
101
|
-
}
|
|
102
|
-
function convertDollarValueToDenomUnits(assets, prices, symbol, value, chainName) {
|
|
103
|
-
var denom = getChainDenomBySymbol(assets, symbol, chainName);
|
|
104
|
-
return new _bignumber["default"](value).dividedBy(prices[denom]).shiftedBy(getExponentByDenom(assets, denom, chainName)).toString();
|
|
105
|
-
}
|
|
106
|
-
function convertBaseUnitsToDisplayUnits(assets, symbol, amount, chainName) {
|
|
107
|
-
var denom = getChainDenomBySymbol(assets, symbol, chainName);
|
|
108
|
-
return new _bignumber["default"](amount).shiftedBy(-getExponentByDenom(assets, denom, chainName)).toString();
|
|
109
|
-
}
|
package/main/fees.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getGasPriceStep = void 0;
|
|
7
|
-
var getGasPriceStep = exports.getGasPriceStep = function getGasPriceStep(chain) {
|
|
8
|
-
var _chain$fees$fee_token, _chain$fees, _chain$fees$fee_token2, _chain$fees$fee_token3, _chain$fees$fee_token4, _chain$fees2, _chain$fees2$fee_toke, _chain$fees2$fee_toke2, _chain$fees$fee_token5, _chain$fees3, _chain$fees3$fee_toke, _chain$fees3$fee_toke2;
|
|
9
|
-
return {
|
|
10
|
-
low: (_chain$fees$fee_token = (_chain$fees = chain.fees) === null || _chain$fees === void 0 ? void 0 : (_chain$fees$fee_token2 = _chain$fees.fee_tokens) === null || _chain$fees$fee_token2 === void 0 ? void 0 : (_chain$fees$fee_token3 = _chain$fees$fee_token2[0]) === null || _chain$fees$fee_token3 === void 0 ? void 0 : _chain$fees$fee_token3.low_gas_price) !== null && _chain$fees$fee_token !== void 0 ? _chain$fees$fee_token : 0.01,
|
|
11
|
-
average: (_chain$fees$fee_token4 = (_chain$fees2 = chain.fees) === null || _chain$fees2 === void 0 ? void 0 : (_chain$fees2$fee_toke = _chain$fees2.fee_tokens) === null || _chain$fees2$fee_toke === void 0 ? void 0 : (_chain$fees2$fee_toke2 = _chain$fees2$fee_toke[0]) === null || _chain$fees2$fee_toke2 === void 0 ? void 0 : _chain$fees2$fee_toke2.average_gas_price) !== null && _chain$fees$fee_token4 !== void 0 ? _chain$fees$fee_token4 : 0.025,
|
|
12
|
-
high: (_chain$fees$fee_token5 = (_chain$fees3 = chain.fees) === null || _chain$fees3 === void 0 ? void 0 : (_chain$fees3$fee_toke = _chain$fees3.fee_tokens) === null || _chain$fees3$fee_toke === void 0 ? void 0 : (_chain$fees3$fee_toke2 = _chain$fees3$fee_toke[0]) === null || _chain$fees3$fee_toke2 === void 0 ? void 0 : _chain$fees3$fee_toke2.high_gas_price) !== null && _chain$fees$fee_token5 !== void 0 ? _chain$fees$fee_token5 : 0.04
|
|
13
|
-
};
|
|
14
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Asset, AssetDenomUnit, AssetList } from '@chain-registry/types';
|
|
2
|
-
export type CoinDenom = AssetDenomUnit['denom'];
|
|
3
|
-
export type Exponent = AssetDenomUnit['exponent'];
|
|
4
|
-
export interface CoinGeckoUSD {
|
|
5
|
-
usd: number;
|
|
6
|
-
}
|
|
7
|
-
export interface PriceHash {
|
|
8
|
-
[key: CoinDenom]: number;
|
|
9
|
-
}
|
|
10
|
-
export declare function getAssetByDenom(assets: AssetList[], denom: CoinDenom, chainName?: string): Asset;
|
|
11
|
-
export declare function getDenomByCoinGeckoId(assets: AssetList[], coinGeckoId: string, chainName?: string): CoinDenom;
|
|
12
|
-
type GetCoinGeckoIdByDenomOptions = {
|
|
13
|
-
chainName?: string;
|
|
14
|
-
allowTestnet?: boolean;
|
|
15
|
-
customAssetFilter?: (asset: Asset) => boolean;
|
|
16
|
-
excludedChainNames?: string[];
|
|
17
|
-
};
|
|
18
|
-
export declare function getCoinGeckoIdByDenom(assets: AssetList[], denom: CoinDenom, { chainName, allowTestnet, customAssetFilter, excludedChainNames }?: GetCoinGeckoIdByDenomOptions): string | null;
|
|
19
|
-
export declare function getSymbolByChainDenom(assets: AssetList[], denom: CoinDenom, chainName?: string): string;
|
|
20
|
-
export declare function getChainDenomBySymbol(assets: AssetList[], symbol: string, chainName?: string): CoinDenom;
|
|
21
|
-
export declare function getExponentByDenom(assets: AssetList[], denom: CoinDenom, chainName?: string): Exponent;
|
|
22
|
-
export declare function convertCoinGeckoPricesToDenomPriceMap(assets: AssetList[], prices: Record<string, CoinGeckoUSD>): PriceHash;
|
|
23
|
-
export declare function noDecimals(num: number | string): string;
|
|
24
|
-
export declare function convertBaseUnitsToDollarValue(assets: AssetList[], prices: PriceHash, symbol: string, amount: string | number, chainName?: string): string;
|
|
25
|
-
export declare function convertDollarValueToDenomUnits(assets: AssetList[], prices: PriceHash, symbol: string, value: string | number, chainName?: string): string;
|
|
26
|
-
export declare function convertBaseUnitsToDisplayUnits(assets: AssetList[], symbol: string, amount: string | number, chainName?: string): string;
|
|
27
|
-
export {};
|
package/types/fees.d.ts
DELETED
package/types/registry.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { AssetList, Chain, ChainRegistry, IBCInfo } from '@chain-registry/types';
|
|
2
|
-
export interface ChainRegistryFetcherOptions {
|
|
3
|
-
assetLists?: AssetList[];
|
|
4
|
-
chains?: Chain[];
|
|
5
|
-
ibcData?: IBCInfo[];
|
|
6
|
-
urls?: string[];
|
|
7
|
-
}
|
|
8
|
-
export interface ChainInfoOptions {
|
|
9
|
-
chain_name: string;
|
|
10
|
-
fetcher: ChainRegistryFetcher;
|
|
11
|
-
}
|
|
12
|
-
export declare class ChainInfo {
|
|
13
|
-
chain_name: string;
|
|
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[]>;
|
|
45
|
-
}
|
|
File without changes
|
|
File without changes
|