@icgio/icg-utils 1.7.16 → 1.7.17

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.
Files changed (2) hide show
  1. package/lib/coingecko.js +0 -11
  2. package/package.json +1 -1
package/lib/coingecko.js CHANGED
@@ -38,21 +38,14 @@ let get_coins_map = (cb) => {
38
38
  })
39
39
  }
40
40
 
41
- let lock = false
42
41
  let get_coingecko_rates = (cb, pair_or_pairs_or_cur_curs, type) => {
43
- if (lock) {
44
- console.error('avoid calling get_coingecko_rates multiple times in a short time')
45
- return
46
- }
47
42
  function get_coingecko_rates_base(cb, pair_or_pairs_or_cur_curs, type) {
48
- lock = true
49
43
  if (type === 'pair') {
50
44
  let pair = pair_or_pairs_or_cur_curs
51
45
  let [cur, base_cur] = parse_pair(pair)
52
46
  let cur_id = coins_map[cur],
53
47
  vs_cur = stablecoins.indexOf(base_cur) > -1 ? 'usd' : base_cur.toLowerCase()
54
48
  cmc_limiter.process(needle.get, `https://api.coingecko.com/api/v3/simple/price?ids=${cur_id}&vs_currencies=${vs_cur}`, (err, res, body) => {
55
- lock = false
56
49
  if (err) {
57
50
  console.error(pair, err)
58
51
  } else if (!body[cur_id]) {
@@ -70,7 +63,6 @@ let get_coingecko_rates = (cb, pair_or_pairs_or_cur_curs, type) => {
70
63
  )
71
64
  let url = `https://api.coingecko.com/api/v3/simple/price?ids=${String(_.keys(cur_id_map))}&vs_currencies=usd`
72
65
  cmc_limiter.process(needle.get, url, (err, res, body) => {
73
- lock = false
74
66
  if (err) {
75
67
  console.error(err)
76
68
  return
@@ -95,7 +87,6 @@ let get_coingecko_rates = (cb, pair_or_pairs_or_cur_curs, type) => {
95
87
  let cur = pair_or_pairs_or_cur_curs,
96
88
  cur_id = coins_map[cur]
97
89
  cmc_limiter.process(needle.get, `https://api.coingecko.com/api/v3/simple/price?ids=${cur_id}&vs_currencies=usd`, (err, res, body) => {
98
- lock = false
99
90
  if (err) {
100
91
  console.error(cur, err)
101
92
  } else if (!body[cur_id]) {
@@ -113,7 +104,6 @@ let get_coingecko_rates = (cb, pair_or_pairs_or_cur_curs, type) => {
113
104
  )
114
105
  let url = `https://api.coingecko.com/api/v3/simple/price?ids=${String(_.keys(cur_id_map))}&vs_currencies=usd`
115
106
  cmc_limiter.process(needle.get, url, (err, res, body) => {
116
- lock = false
117
107
  if (err) {
118
108
  console.error(err)
119
109
  return
@@ -171,7 +161,6 @@ let get_coingecko_rates = (cb, pair_or_pairs_or_cur_curs, type) => {
171
161
  result[cur].ETH = result[cur].USD / result.ETH.USD
172
162
  }
173
163
  if (body.length < per_page_nums) {
174
- lock = false
175
164
  cb(result)
176
165
  } else {
177
166
  page++
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-utils",
3
- "version": "1.7.16",
3
+ "version": "1.7.17",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {