@icgio/icg-utils 1.7.37 → 1.7.39
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/constants/coins-map.js +10219 -0
- package/lib/coingecko.js +27 -20
- package/package.json +3 -2
package/lib/coingecko.js
CHANGED
|
@@ -4,6 +4,8 @@ const needle = require('needle')
|
|
|
4
4
|
|
|
5
5
|
const parse_pair = require('./utils.js').parse_pair
|
|
6
6
|
const stablecoins = require('../constants/stablecoins')
|
|
7
|
+
let coins_map_raw = require('../constants/coins-map.js')
|
|
8
|
+
let coins_map = {}
|
|
7
9
|
|
|
8
10
|
const Limiter = require('./rate-limiter.js')
|
|
9
11
|
|
|
@@ -20,18 +22,22 @@ const options = {
|
|
|
20
22
|
},
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
let
|
|
25
|
+
let process_coins_map = (body) => {
|
|
26
|
+
let result = {}
|
|
27
|
+
for (let line of body) {
|
|
28
|
+
let cur = line.symbol.toUpperCase()
|
|
29
|
+
_.set(result, [cur], line.id)
|
|
30
|
+
}
|
|
31
|
+
result['ETH'] = 'ethereum'
|
|
32
|
+
result['MTR'] = 'meter-stable'
|
|
33
|
+
result['WAXL'] = 'axelar'
|
|
34
|
+
return result
|
|
35
|
+
}
|
|
36
|
+
|
|
24
37
|
let get_coins_map = (cb) => {
|
|
25
38
|
cmc_limiter.process(needle.get, 'https://api.coingecko.com/api/v3/coins/list', (err, res, body) => {
|
|
26
39
|
if (body && Array.isArray(body)) {
|
|
27
|
-
|
|
28
|
-
for (let line of body) {
|
|
29
|
-
let cur = line.symbol.toUpperCase()
|
|
30
|
-
_.set(result, [cur], line.id)
|
|
31
|
-
}
|
|
32
|
-
result['ETH'] = 'ethereum'
|
|
33
|
-
result['MTR'] = 'meter-stable'
|
|
34
|
-
cb({ success: true, body: result })
|
|
40
|
+
cb({ success: true, body: process_coins_map(body) })
|
|
35
41
|
} else {
|
|
36
42
|
cb({ success: false, body })
|
|
37
43
|
}
|
|
@@ -180,23 +186,24 @@ let get_coingecko_rates = (cb, pair_or_pairs_or_cur_curs, type) => {
|
|
|
180
186
|
get_coingecko_rate_page(page, cb)
|
|
181
187
|
}
|
|
182
188
|
}
|
|
183
|
-
if (_.isEmpty(coins_map)) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
} else {
|
|
191
|
-
|
|
192
|
-
|
|
189
|
+
// if (_.isEmpty(coins_map)) {
|
|
190
|
+
// get_coins_map((res) => {
|
|
191
|
+
// if (res.success) {
|
|
192
|
+
// coins_map = res.body
|
|
193
|
+
// }
|
|
194
|
+
// get_coingecko_rates_base(cb, pair_or_pairs_or_cur_curs, type)
|
|
195
|
+
// })
|
|
196
|
+
// } else {
|
|
197
|
+
coins_map = process_coins_map(coins_map_raw)
|
|
198
|
+
get_coingecko_rates_base(cb, pair_or_pairs_or_cur_curs, type)
|
|
199
|
+
// }
|
|
193
200
|
}
|
|
194
201
|
|
|
195
202
|
// get_coingecko_rates(
|
|
196
203
|
// (res) => {
|
|
197
204
|
// console.log(res)
|
|
198
205
|
// },
|
|
199
|
-
// ['
|
|
206
|
+
// ['BTC', 'ETH'],
|
|
200
207
|
// 'curs'
|
|
201
208
|
// )
|
|
202
209
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icgio/icg-utils",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.39",
|
|
4
4
|
"description": "Utils package.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"nodemailer": "^4.7.0",
|
|
32
32
|
"qrcode-terminal": "^0.12.0",
|
|
33
33
|
"websocket": "^1.0.33",
|
|
34
|
-
"winston": "^2.4.5"
|
|
34
|
+
"winston": "^2.4.5",
|
|
35
|
+
"ws": "^8.13.0"
|
|
35
36
|
}
|
|
36
37
|
}
|