@bithomp/xrpl-api 3.7.23 → 3.7.25

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/connection.js CHANGED
@@ -52,7 +52,7 @@ exports.DEFAULT_API_VERSION = xrpl_1.RIPPLED_API_V1;
52
52
  const SLOW_DOWN_ERROR_MESSAGES = [
53
53
  "slowDown",
54
54
  "Unexpected server response: 429",
55
- "You are placing too much load on the server."
55
+ "You are placing too much load on the server.",
56
56
  ];
57
57
  class Connection extends events_1.EventEmitter {
58
58
  constructor(url, type, options = {}) {
@@ -103,15 +103,20 @@ class Connection extends events_1.EventEmitter {
103
103
  this.connectionValidation("connect");
104
104
  }
105
105
  catch (err) {
106
+ const errorMessage = err?.message || err?.name || err;
106
107
  this.logger?.warn({
107
108
  service: "Bithomp::XRPL::Connection",
108
109
  function: "connect",
109
110
  url: this.url,
110
- error: err?.message || err?.name || err,
111
+ error: errorMessage,
111
112
  });
112
113
  this.removeWatchTimer();
113
114
  this.removeClient();
114
- this.connectionWatchTimer = setTimeout(this.bindConnectionWatchTimeout, LEDGER_CLOSED_TIMEOUT);
115
+ let reconnectDelay = LEDGER_CLOSED_TIMEOUT;
116
+ if (SLOW_DOWN_ERROR_MESSAGES.includes(errorMessage)) {
117
+ reconnectDelay = LEDGER_CLOSED_TIMEOUT * 5;
118
+ }
119
+ this.connectionWatchTimer = setTimeout(this.bindConnectionWatchTimeout, reconnectDelay);
115
120
  }
116
121
  }
117
122
  async disconnect() {
@@ -260,18 +260,19 @@ function adjustBalancesForPaymentChannel(balanceChanges, metadata, nativeCurrenc
260
260
  else {
261
261
  unlockedAmount = new bignumber_js_1.default(channelChanges.amount.value).minus(channelChanges?.balance?.value || "0");
262
262
  }
263
- if (unlockedAmount.isZero()) {
264
- return;
263
+ if (!unlockedAmount.isZero()) {
264
+ adjustBalancesChanges(balanceChanges, channelChanges.source.address, [
265
+ { currency: channelChanges.amount.currency, value: `-${unlockedAmount.toString()}` },
266
+ ]);
265
267
  }
266
- adjustBalancesChanges(balanceChanges, channelChanges.source.address, [
267
- { currency: channelChanges.amount.currency, value: `-${unlockedAmount.toString()}` },
268
- ]);
269
- if (channelChanges.source.address !== tx.Account && channelChanges?.balance && channelChanges?.amount) {
270
- const returnedAmount = new bignumber_js_1.default(channelChanges.amount.value).minus(new bignumber_js_1.default(channelChanges.balance.value));
271
- if (!returnedAmount.isZero()) {
272
- adjustBalancesChanges(balanceChanges, channelChanges.source.address, [
273
- { currency: channelChanges.amount.currency, value: `-${returnedAmount}` },
274
- ]);
268
+ if (channelChanges.balanceChange) {
269
+ if (channelChanges.source.address !== tx.Account && channelChanges?.balance && channelChanges?.amount) {
270
+ const returnedAmount = new bignumber_js_1.default(channelChanges.amount.value).minus(new bignumber_js_1.default(channelChanges.balance.value));
271
+ if (!returnedAmount.isZero()) {
272
+ adjustBalancesChanges(balanceChanges, channelChanges.source.address, [
273
+ { currency: channelChanges.amount.currency, value: `-${returnedAmount.toString()}` },
274
+ ]);
275
+ }
275
276
  }
276
277
  }
277
278
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bithomp/xrpl-api",
3
- "version": "3.7.23",
3
+ "version": "3.7.25",
4
4
  "description": "A Bithomp JavaScript/TypeScript library for interacting with the XRP Ledger",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",