@bithomp/xrpl-api 3.7.37 → 3.7.38

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.
@@ -47,7 +47,6 @@ declare class Connection extends EventEmitter {
47
47
  private streamsSubscribed;
48
48
  private bindConnectionWatchTimeout;
49
49
  constructor(url: string, type?: string, options?: ConnectionOptions);
50
- private scheduleReconnect;
51
50
  connect(): Promise<void>;
52
51
  disconnect(): Promise<void>;
53
52
  request(request: Request, options?: any): Promise<Response | any>;
@@ -45,8 +45,8 @@ const common_1 = require("./common");
45
45
  const utils_1 = require("./common/utils");
46
46
  const XRPLConnection = __importStar(require("xrpl/dist/npm/client/connection"));
47
47
  const RECONNECT_TIMEOUT = 1000 * 5;
48
- const LEDGER_CLOSED_TIMEOUT = 1000 * 20;
49
- const SCHEDULE_RECONNECT_TIMEOUT = 1000 * 60;
48
+ const LEDGER_CLOSED_TIMEOUT = 1000 * 15;
49
+ const SLOW_RECONNECT_TIMEOUT = LEDGER_CLOSED_TIMEOUT * 5;
50
50
  const SERVER_INFO_UPDATE_INTERVAL = 1000 * 60 * 5;
51
51
  const AVAILABLE_LEDGER_INDEX_WINDOW = 1000;
52
52
  exports.DEFAULT_API_VERSION = xrpl_1.RIPPLED_API_V1;
@@ -86,13 +86,6 @@ class Connection extends events_1.EventEmitter {
86
86
  this.accounts = {};
87
87
  this.streamsSubscribed = false;
88
88
  }
89
- scheduleReconnect(delay = RECONNECT_TIMEOUT) {
90
- if (this.shutdown) {
91
- return;
92
- }
93
- this.removeWatchTimer();
94
- this.connectionWatchTimer = setTimeout(this.bindConnectionWatchTimeout, delay);
95
- }
96
89
  async connect() {
97
90
  try {
98
91
  this.logger?.debug({
@@ -106,6 +99,7 @@ class Connection extends events_1.EventEmitter {
106
99
  this.client = new XRPLConnection.Connection(this.url, (0, common_1.removeUndefined)({ timeout: this.timeout, connectionTimeout: this.connectionTimeout }));
107
100
  this.setupEmitter();
108
101
  await this.client.connect();
102
+ this.latency = [];
109
103
  await this.updateServerInfo();
110
104
  await this.subscribe();
111
105
  this.connectionValidation("connect");
@@ -120,8 +114,11 @@ class Connection extends events_1.EventEmitter {
120
114
  });
121
115
  this.removeWatchTimer();
122
116
  this.removeClient();
123
- const isSlowDown = SLOW_DOWN_ERROR_MESSAGES.includes(errorMessage);
124
- this.scheduleReconnect(isSlowDown ? SCHEDULE_RECONNECT_TIMEOUT : RECONNECT_TIMEOUT);
117
+ let reconnectDelay = LEDGER_CLOSED_TIMEOUT;
118
+ if (SLOW_DOWN_ERROR_MESSAGES.includes(errorMessage)) {
119
+ reconnectDelay = SLOW_RECONNECT_TIMEOUT;
120
+ }
121
+ this.connectionWatchTimer = setTimeout(this.bindConnectionWatchTimeout, reconnectDelay);
125
122
  }
126
123
  }
127
124
  async disconnect() {
@@ -179,8 +176,6 @@ class Connection extends events_1.EventEmitter {
179
176
  }
180
177
  else {
181
178
  this.removeClient();
182
- const isSlowDown = SLOW_DOWN_ERROR_MESSAGES.includes(result?.error);
183
- this.scheduleReconnect(isSlowDown ? SCHEDULE_RECONNECT_TIMEOUT : RECONNECT_TIMEOUT);
184
179
  }
185
180
  return result;
186
181
  }
@@ -192,10 +187,10 @@ class Connection extends events_1.EventEmitter {
192
187
  }
193
188
  const waitTime = (0, utils_1.getTimestamp)() + RECONNECT_TIMEOUT;
194
189
  while (!this.client || !this.isConnected()) {
195
- await (0, utils_1.sleep)(100);
196
190
  if (this.shutdown) {
197
191
  return { error: "shutdownConnection", error_message: "Connection is shutdown.", status: "error" };
198
192
  }
193
+ await (0, utils_1.sleep)(100);
199
194
  if ((0, utils_1.getTimestamp)() > waitTime) {
200
195
  return { error: "notConnected", error_message: "Not connected.", status: "error" };
201
196
  }
@@ -387,9 +382,6 @@ class Connection extends events_1.EventEmitter {
387
382
  this.client = undefined;
388
383
  }
389
384
  this.emit("disconnected", code);
390
- if (!this.shutdown) {
391
- this.scheduleReconnect(RECONNECT_TIMEOUT);
392
- }
393
385
  });
394
386
  this.client.on("error", (source, message, error) => {
395
387
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bithomp/xrpl-api",
3
- "version": "3.7.37",
3
+ "version": "3.7.38",
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",
@@ -42,7 +42,7 @@
42
42
  "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
43
43
  "lint": "eslint",
44
44
  "prepare": "npm run build",
45
- "-prepublishOnly": "npm test && npm run lint",
45
+ "prepublishOnly": "npm test && npm run lint",
46
46
  "preversion": "npm run lint",
47
47
  "version": "npm run format && git add -A src",
48
48
  "postversion": "git push && git push --tags"
@@ -51,12 +51,12 @@
51
51
  "lib/**/*"
52
52
  ],
53
53
  "dependencies": {
54
- "@noble/ed25519": "^3.0.1",
55
- "@noble/hashes": "^2.0.1",
56
- "@noble/secp256k1": "^3.0.0",
57
- "axios": "^1.15.0",
54
+ "@noble/ed25519": "^3.1.0",
55
+ "@noble/hashes": "^2.2.0",
56
+ "@noble/secp256k1": "^3.1.0",
57
+ "axios": "^1.16.1",
58
58
  "base-x": "^5.0.1",
59
- "bignumber.js": "^9.3.1",
59
+ "bignumber.js": "^11.1.2",
60
60
  "lodash": "^4.18.1",
61
61
  "ripple-address-codec": "5.0.0",
62
62
  "ripple-binary-codec": "2.7.0",
@@ -70,20 +70,20 @@
70
70
  "@types/lodash": "^4.17.24",
71
71
  "@types/mocha": "^10.0.10",
72
72
  "@types/nconf": "^0.10.7",
73
- "@types/node": "^25.6.0",
74
- "@typescript-eslint/eslint-plugin": "^8.58.1",
75
- "@typescript-eslint/parser": "^8.58.1",
73
+ "@types/node": "^25.9.1",
74
+ "@typescript-eslint/eslint-plugin": "^8.60.0",
75
+ "@typescript-eslint/parser": "^8.60.0",
76
76
  "chai": "^6.2.2",
77
77
  "chai-as-promised": "^8.0.2",
78
- "eslint": "^9.39.2",
78
+ "eslint": "^9.39.4",
79
79
  "eslint-config-prettier": "^10.1.8",
80
80
  "eslint-plugin-chai-friendly": "^1.2.0",
81
81
  "eslint-plugin-import": "^2.32.0",
82
- "eslint-plugin-n": "^17.24.0",
83
- "eslint-plugin-promise": "^7.2.1",
84
- "mocha": "^11.7.5",
82
+ "eslint-plugin-n": "^18.0.1",
83
+ "eslint-plugin-promise": "^7.3.0",
84
+ "mocha": "^11.7.6",
85
85
  "nconf": "^0.13.0",
86
- "ts-jest": "^29.4.9",
86
+ "ts-jest": "^29.4.11",
87
87
  "ts-node": "^10.9.2",
88
88
  "typescript": "^5.9.3"
89
89
  }