@icgio/icg-utils 1.7.34 → 1.7.36

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.
@@ -1 +1 @@
1
- module.exports = ['USDT', 'TUSD', 'PAX', 'BUSD', 'USDK', 'USDC', 'HUSD', 'DAI', 'IUSD', 'USDD', 'FEI', 'FRAX']
1
+ module.exports = ['USDT', 'TUSD', 'PAX', 'BUSD', 'USDK', 'USDC', 'HUSD', 'DAI', 'IUSD', 'USDD', 'FEI', 'FRAX', 'CUSD']
package/lib/mail.js CHANGED
@@ -25,33 +25,3 @@ module.exports.send = function (address, subject, data, config) {
25
25
  }
26
26
  })
27
27
  }
28
-
29
- module.exports.send_cn = function (address, subject, data, config, cd) {
30
- let transporter = nodemailer.createTransport({
31
- host: config.mail_smtp_server,
32
- port: 465,
33
- secure: true,
34
- auth: {
35
- user: config.mail_from_address_china,
36
- pass: cd.mail_user_password,
37
- },
38
- })
39
- let options = {
40
- from: config.mail_from_address_china,
41
- to: address,
42
- subject: subject,
43
- }
44
- if (/<[a-z][\s\S]*>/i.test(data)) {
45
- options.html = data
46
- options.text = ''
47
- } else {
48
- options.text = data
49
- options.html = ''
50
- }
51
- transporter.sendMail(options, (err, body) => {
52
- if (err) {
53
- return logger.error('Mail sent error: %j', err)
54
- }
55
- logger.info('Mail sent successfully: %j', body.response)
56
- })
57
- }
@@ -2,6 +2,7 @@ module.exports = class RateLimiter {
2
2
  constructor(settings) {
3
3
  this.max_concurrent = settings.max_concurrent ? settings.max_concurrent : null
4
4
  this.interval_concurrent = settings.interval_concurrent ? settings.interval_concurrent : null
5
+ this.abandon_tx = settings.abandon_tx ? settings.abandon_tx : false
5
6
  this.count = 0
6
7
  }
7
8
  process(func, ...args) {
@@ -17,7 +18,7 @@ module.exports = class RateLimiter {
17
18
  if (this.count < this.max_concurrent) {
18
19
  this.count++
19
20
  func(...args)
20
- } else {
21
+ } else if (!this.abandon_tx) {
21
22
  setTimeout(() => {
22
23
  this.process(func, ...args)
23
24
  }, this.interval_concurrent)
package/lib/utils.js CHANGED
@@ -1,5 +1,7 @@
1
1
  const _ = require('lodash')
2
2
 
3
+ const stablecoins = require('../constants/stablecoins')
4
+
3
5
  // Number.prototype.toFixed_old = Number.prototype.toFixed
4
6
 
5
7
  // Number.prototype.toFixed = function(s) {
@@ -699,12 +701,17 @@ module.exports.parse_pair = function (pair) {
699
701
  pair = pair.toUpperCase()
700
702
  let time
701
703
  ;[pair, time] = _.split(pair, '_')
702
- let result
703
- if (pair.endsWith('USDT') || pair.endsWith('USDC') || pair.endsWith('TUSD') || pair.endsWith('BUSD') || pair.endsWith('USDS') || pair.endsWith('DKKT') || pair.endsWith('CNYT'))
704
- result = [pair.substr(0, pair.length - 4), pair.substr(pair.length - 4, pair.length)]
705
- else if (pair.endsWith('QC') || pair.endsWith('ZB')) result = [pair.substr(0, pair.length - 2), pair.substr(pair.length - 2, pair.length)]
706
- else result = [pair.substr(0, pair.length - 3), pair.substr(pair.length - 3, pair.length)]
707
- if (time) result[1] += '_' + time
704
+ let result = ''
705
+ if (stablecoins.some((c) => pair.endsWith(c))) {
706
+ result = [pair.substr(0, pair.length - c.length), pair.substr(pair.length - 4, pair.length)]
707
+ } else if (pair.endsWith('QC')) {
708
+ result = [pair.substr(0, pair.length - 2), pair.substr(pair.length - 2, pair.length)]
709
+ } else {
710
+ result = [pair.substr(0, pair.length - 3), pair.substr(pair.length - 3, pair.length)]
711
+ }
712
+ if (time) {
713
+ result[1] += '_' + time
714
+ }
708
715
  return result
709
716
  }
710
717
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-utils",
3
- "version": "1.7.34",
3
+ "version": "1.7.36",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {