@pioneer-platform/thor-network 8.1.30 → 8.1.33

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/index.d.ts CHANGED
@@ -3,6 +3,7 @@ declare const prettyjson: any;
3
3
  declare const Axios: any;
4
4
  declare const https: any;
5
5
  declare const axios: any;
6
+ declare const axiosRetry: any;
6
7
  declare const log: any;
7
8
  declare let URL_THORNODE: string;
8
9
  declare let BASE_THOR: number;
package/lib/index.js CHANGED
@@ -61,6 +61,19 @@ var axios = Axios.create({
61
61
  rejectUnauthorized: false
62
62
  })
63
63
  });
64
+ var axiosRetry = require('axios-retry');
65
+ axiosRetry(axios, {
66
+ retries: 3,
67
+ retryDelay: function (retryCount) {
68
+ console.log("retry attempt: " + retryCount);
69
+ return retryCount * 2000; // time interval between retries
70
+ },
71
+ retryCondition: function (error) {
72
+ console.error(error);
73
+ // if retry condition is not specified, by default idempotent requests are retried
74
+ return error.response.status === 503;
75
+ },
76
+ });
64
77
  var log = require('@pioneer-platform/loggerdog')();
65
78
  var URL_THORNODE = process.env['URL_THORNODE'] || 'https://thornode.ninerealms.com';
66
79
  //let URL_MIDGARD = process.env['URL_THORNODE'] || 'https://testnet.midgard.thorchain.info/v2'
@@ -163,12 +176,14 @@ var broadcast_transaction = function (tx) {
163
176
  case 3:
164
177
  result2 = _a.sent();
165
178
  log.debug(tag, '** Broadcast ** REMOTE: result: ', result2.data);
166
- if (result2.data.txhash)
179
+ if (result2 && result2.data && result2.data.txhash)
167
180
  output.txid = result2.data.txhash;
168
181
  //verify success
169
182
  if (result2.data.raw_log) {
170
183
  logSend = result2.data.raw_log;
171
- log.debug(tag, "logSend: ", logSend);
184
+ log.info(tag, "logSend: ", logSend);
185
+ output.success = false;
186
+ output.error = logSend;
172
187
  }
173
188
  output.height = result2.height;
174
189
  output.gas_wanted = result2.gas_wanted;
@@ -187,11 +202,7 @@ var broadcast_transaction = function (tx) {
187
202
  output.success = false;
188
203
  output.error = e_2.response.data.error;
189
204
  return [3 /*break*/, 5];
190
- case 5:
191
- if (output.txid) {
192
- output.success = true;
193
- }
194
- return [2 /*return*/, output];
205
+ case 5: return [2 /*return*/, output];
195
206
  case 6:
196
207
  e_3 = _a.sent();
197
208
  console.error(tag, "throw error: ", e_3);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pioneer-platform/thor-network",
3
- "version": "8.1.30",
3
+ "version": "8.1.33",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "scripts": {
@@ -12,6 +12,7 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@pioneer-platform/loggerdog": "^8.1.17",
15
+ "axios-retry": "^3.3.1",
15
16
  "bech32": "^1.1.4",
16
17
  "bip32": "^2.0.5",
17
18
  "bip39": "^3.0.2",