@icgio/icg-utils 1.7.37 → 1.7.38
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 +1 -0
- package/lib/coingecko.js +25 -19
- 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,21 @@ 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
|
+
return result
|
|
34
|
+
}
|
|
35
|
+
|
|
24
36
|
let get_coins_map = (cb) => {
|
|
25
37
|
cmc_limiter.process(needle.get, 'https://api.coingecko.com/api/v3/coins/list', (err, res, body) => {
|
|
26
38
|
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 })
|
|
39
|
+
cb({ success: true, body: process_coins_map(body) })
|
|
35
40
|
} else {
|
|
36
41
|
cb({ success: false, body })
|
|
37
42
|
}
|
|
@@ -180,23 +185,24 @@ let get_coingecko_rates = (cb, pair_or_pairs_or_cur_curs, type) => {
|
|
|
180
185
|
get_coingecko_rate_page(page, cb)
|
|
181
186
|
}
|
|
182
187
|
}
|
|
183
|
-
if (_.isEmpty(coins_map)) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
} else {
|
|
188
|
+
// if (_.isEmpty(coins_map)) {
|
|
189
|
+
// get_coins_map((res) => {
|
|
190
|
+
// if (res.success) {
|
|
191
|
+
// coins_map = res.body
|
|
192
|
+
// }
|
|
193
|
+
// get_coingecko_rates_base(cb, pair_or_pairs_or_cur_curs, type)
|
|
194
|
+
// })
|
|
195
|
+
// } else {
|
|
196
|
+
coins_map = process_coins_map(coins_map_raw)
|
|
191
197
|
get_coingecko_rates_base(cb, pair_or_pairs_or_cur_curs, type)
|
|
192
|
-
}
|
|
198
|
+
// }
|
|
193
199
|
}
|
|
194
200
|
|
|
195
201
|
// get_coingecko_rates(
|
|
196
202
|
// (res) => {
|
|
197
203
|
// console.log(res)
|
|
198
204
|
// },
|
|
199
|
-
// ['
|
|
205
|
+
// ['BTC', 'ETH'],
|
|
200
206
|
// 'curs'
|
|
201
207
|
// )
|
|
202
208
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icgio/icg-utils",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.38",
|
|
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
|
}
|