@icgio/icg-utils 1.9.29 → 1.9.31

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/lib/forex-rate.js CHANGED
@@ -4,7 +4,7 @@ const utils = require('./utils.js')
4
4
  let get_forex_rate_usd = function (pair, cb) {
5
5
  let [cur, quote_cur] = utils.parse_pair(pair)
6
6
  needle.get(`https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/usd.json`, (err, res, body) => {
7
- if (body.usd) {
7
+ if (body && body.usd) {
8
8
  cb(body.usd[quote_cur.toLowerCase()])
9
9
  }
10
10
  })
package/lib/utils.js CHANGED
@@ -912,6 +912,25 @@ function sort_keys(dict) {
912
912
  return _.fromPairs(_.sortBy(_.toPairs(dict), (e) => e[0]))
913
913
  }
914
914
 
915
+ function convert_deposit_withdrawal_chain(chain) {
916
+ if (!chain) {
917
+ return null
918
+ }
919
+ chain = chain.toLowerCase()
920
+
921
+ if (['erc20', 'eth', 'ethereum'].includes(chain)) {
922
+ return 'ETH'
923
+ } else if (['bep20', 'bsc', 'bnb', 'bnb smart chain', 'bnb chain'].includes(chain)) {
924
+ return 'BNB'
925
+ } else if (['trc20', 'trx', 'tron'].includes(chain)) {
926
+ return 'TRON'
927
+ } else if (['sol', 'solana'].includes(chain)) {
928
+ return 'SOL'
929
+ } else {
930
+ return chain.toUpperCase()
931
+ }
932
+ }
933
+
915
934
  module.exports = {
916
935
  ordered_dict,
917
936
  random_id,
@@ -937,4 +956,5 @@ module.exports = {
937
956
  number_with_commas,
938
957
  exchange_cur_quote_cur_converter,
939
958
  sort_keys,
959
+ convert_deposit_withdrawal_chain
940
960
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-utils",
3
- "version": "1.9.29",
3
+ "version": "1.9.31",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {