@bithomp/xrpl-api 3.4.4 → 3.4.5

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.
@@ -16,6 +16,7 @@ exports.getConstructorName = getConstructorName;
16
16
  const lodash_1 = __importDefault(require("lodash"));
17
17
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
18
18
  const errors_1 = require("./errors");
19
+ const index_1 = require("./index");
19
20
  function signum(num) {
20
21
  return num === 0 ? 0 : num > 0 ? 1 : -1;
21
22
  }
@@ -87,7 +88,7 @@ function dropsToXrp(drops) {
87
88
  if (!drops.match(/^-?[0-9]+$/)) {
88
89
  throw new errors_1.ValidationError(`dropsToXrp: failed sanity check - value '${drops}', does not match (^-?[0-9]+$).`);
89
90
  }
90
- return new bignumber_js_1.default(drops).dividedBy(1000000.0).toString(10);
91
+ return new bignumber_js_1.default(drops).dividedBy(index_1.dropsInXRP).toString(10);
91
92
  }
92
93
  function xrpToDrops(xrp) {
93
94
  if (typeof xrp === "string") {
@@ -110,7 +111,7 @@ function xrpToDrops(xrp) {
110
111
  if (fraction.length > 6) {
111
112
  throw new errors_1.ValidationError(`xrpToDrops: value '${xrp}' has too many decimal places.`);
112
113
  }
113
- return new bignumber_js_1.default(xrp).times(1000000.0).integerValue(bignumber_js_1.default.ROUND_FLOOR).toString(10);
114
+ return new bignumber_js_1.default(xrp).times(index_1.dropsInXRP).integerValue(bignumber_js_1.default.ROUND_FLOOR).toString(10);
114
115
  }
115
116
  function removeUndefined(obj) {
116
117
  return lodash_1.default.omitBy(obj, (value) => value == null);
@@ -49,6 +49,7 @@ declare class Connection extends EventEmitter {
49
49
  connect(): Promise<void>;
50
50
  disconnect(): Promise<void>;
51
51
  request(request: Request, options?: any): Promise<Response | any>;
52
+ _request(request: Request, options?: any): Promise<Response | any>;
52
53
  submit(transaction: string): Promise<Response | any>;
53
54
  isConnected(): boolean;
54
55
  getOnlinePeriodMs(): number | null;
package/lib/connection.js CHANGED
@@ -112,6 +112,22 @@ class Connection extends events_1.EventEmitter {
112
112
  clearTimeout(this.connectionTimer);
113
113
  }
114
114
  async request(request, options) {
115
+ const result = await this._request(request, options);
116
+ if (result?.error === "timeout") {
117
+ const timeouts = this.latency.filter((info) => info.delta >= this.connectionTimeout).length;
118
+ if (timeouts >= 3) {
119
+ this.logger?.debug({
120
+ service: "Bithomp::XRPL::Connection",
121
+ function: "request",
122
+ url: this.url,
123
+ error: `Too many timeouts (${timeouts}) in last ${this.latency.length} requests, reconnecting...`,
124
+ });
125
+ this.reconnect();
126
+ }
127
+ }
128
+ return result;
129
+ }
130
+ async _request(request, options) {
115
131
  try {
116
132
  if (options?.skip_subscription_update !== true &&
117
133
  (request.command === "subscribe" || request.command === "unsubscribe")) {
@@ -48,7 +48,6 @@ function parseNFTokenBurn(tx) {
48
48
  signer: (0, regular_key_1.parseSignerRegularKey)(tx),
49
49
  delegate: (0, delegate_1.parseDelegate)(tx),
50
50
  source: (0, source_1.parseSource)(tx),
51
- account: tx.Account,
52
51
  nftokenID: tx.NFTokenID,
53
52
  emittedDetails: (0, emit_details_1.parseEmittedDetails)(tx),
54
53
  memos: (0, memos_1.parseMemos)(tx),
@@ -23,7 +23,6 @@ export interface NFTokenOfferFlagsKeysInterface {
23
23
  sellToken?: boolean;
24
24
  }
25
25
  export type FormattedNFTokenBurnSpecification = {
26
- account: string;
27
26
  nftokenID: string;
28
27
  } & FormattedBaseSpecification;
29
28
  export type FormattedNFTokenMintSpecification = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bithomp/xrpl-api",
3
- "version": "3.4.4",
3
+ "version": "3.4.5",
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",
@@ -43,7 +43,7 @@
43
43
  "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
44
44
  "lint": "eslint",
45
45
  "prepare": "npm run build",
46
- "prepublishOnly": "npm test && npm run lint",
46
+ "-prepublishOnly": "npm test && npm run lint",
47
47
  "preversion": "npm run lint",
48
48
  "version": "npm run format && git add -A src",
49
49
  "postversion": "git push && git push --tags"
@@ -72,9 +72,9 @@
72
72
  "@types/node": "^22.15.21",
73
73
  "@typescript-eslint/eslint-plugin": "^8.38.0",
74
74
  "@typescript-eslint/parser": "^8.38.0",
75
- "chai": "^4.5.0",
76
- "chai-as-promised": "^7.1.2",
77
- "eslint": "^9.32.0",
75
+ "chai": "^6.0.1",
76
+ "chai-as-promised": "^8.0.2",
77
+ "eslint": "^9.34.0",
78
78
  "eslint-config-prettier": "^10.1.8",
79
79
  "eslint-plugin-chai-friendly": "^1.1.0",
80
80
  "eslint-plugin-import": "^2.32.0",