@bithomp/xrpl-api 3.4.0 → 3.4.2

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.
@@ -26,4 +26,12 @@ export interface FindTransactionsOptions extends GetTransactionsOptions {
26
26
  legacy?: boolean;
27
27
  formatted?: boolean;
28
28
  }
29
+ interface FindTransactionsResponse {
30
+ account: string;
31
+ transactions: any[];
32
+ marker?: any;
33
+ validated?: boolean;
34
+ }
35
+ export declare function findTransactionsExt(account: string, options?: FindTransactionsOptions): Promise<FindTransactionsResponse | ErrorResponse>;
29
36
  export declare function findTransactions(account: string, options?: FindTransactionsOptions): Promise<object[] | ErrorResponse>;
37
+ export {};
@@ -37,6 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getTransactions = getTransactions;
40
+ exports.findTransactionsExt = findTransactionsExt;
40
41
  exports.findTransactions = findTransactions;
41
42
  const lodash_1 = __importDefault(require("lodash"));
42
43
  const xrpl_1 = require("xrpl");
@@ -76,7 +77,7 @@ async function getTransactions(account, options = { limit: DEFAULT_LIMIT }) {
76
77
  };
77
78
  }
78
79
  if (response.error) {
79
- const { error, error_code, error_message, error_exception, status, validated } = response;
80
+ const { error, error_code, error_message, error_exception, status, validated, warnings } = response;
80
81
  return (0, utils_1.removeUndefined)({
81
82
  account,
82
83
  error,
@@ -85,15 +86,17 @@ async function getTransactions(account, options = { limit: DEFAULT_LIMIT }) {
85
86
  error_exception,
86
87
  status,
87
88
  validated,
89
+ warnings,
88
90
  });
89
91
  }
90
92
  const result = response?.result;
91
93
  if (!result) {
92
- return {
94
+ return (0, utils_1.removeUndefined)({
93
95
  account,
94
96
  status: "error",
95
97
  error: "invalidResponse",
96
- };
98
+ warnings: response.warnings,
99
+ });
97
100
  }
98
101
  if (Array.isArray(result.transactions)) {
99
102
  if (options.balanceChanges === true || options.specification === true) {
@@ -127,9 +130,12 @@ async function getTransactions(account, options = { limit: DEFAULT_LIMIT }) {
127
130
  if (newMarker) {
128
131
  result.marker = newMarker;
129
132
  }
133
+ if (response.warnings && response.warnings.length > 0) {
134
+ result.warnings = response.warnings;
135
+ }
130
136
  return result;
131
137
  }
132
- async function findTransactions(account, options = { limit: DEFAULT_LIMIT, timeout: 15000 }) {
138
+ async function findTransactionsExt(account, options = { limit: DEFAULT_LIMIT, timeout: 15000 }) {
133
139
  let transactions = [];
134
140
  let accountTransactionsError = null;
135
141
  const timeStart = new Date();
@@ -145,6 +151,9 @@ async function findTransactions(account, options = { limit: DEFAULT_LIMIT, timeo
145
151
  if (loadOptions.sourceTag || loadOptions.destinationTag) {
146
152
  getTransactionsLimit += LIMIT_INCREASE_COUNT;
147
153
  }
154
+ if (loadOptions.types) {
155
+ getTransactionsLimit += LIMIT_INCREASE_COUNT;
156
+ }
148
157
  if (getTransactionsLimit > MAX_LIMIT) {
149
158
  getTransactionsLimit = MAX_LIMIT;
150
159
  }
@@ -193,8 +202,26 @@ async function findTransactions(account, options = { limit: DEFAULT_LIMIT, timeo
193
202
  }
194
203
  }
195
204
  if (newTransactions.length > 0) {
205
+ const transactionsToTake = loadOptions.limit - transactions.length;
206
+ if (transactionsToTake !== newTransactions.length) {
207
+ const isClio = accountTransactions.warnings?.some((w) => w.id === 2001);
208
+ let markerTransaction = null;
209
+ if (isClio) {
210
+ markerTransaction = newTransactions[transactionsToTake - 1];
211
+ }
212
+ else {
213
+ markerTransaction = newTransactions[transactionsToTake];
214
+ }
215
+ if (markerTransaction) {
216
+ loadOptions.marker = {
217
+ ledger: markerTransaction.tx.ledger_index,
218
+ seq: markerTransaction.meta.TransactionIndex,
219
+ bithompHash: loadOptions.marker.bithompHash,
220
+ };
221
+ }
222
+ }
223
+ newTransactions = newTransactions.slice(0, transactionsToTake);
196
224
  transactions = transactions.concat(newTransactions);
197
- transactions = transactions.slice(0, loadOptions.limit);
198
225
  }
199
226
  if (loadOptions.marker === undefined) {
200
227
  break;
@@ -213,7 +240,19 @@ async function findTransactions(account, options = { limit: DEFAULT_LIMIT, timeo
213
240
  if (formatted === true) {
214
241
  transactions = transactions.map((transaction) => (0, transaction_1.getAccountTxDetails)(transaction, loadOptions.includeRawTransactions === true));
215
242
  }
216
- return transactions;
243
+ return {
244
+ account,
245
+ transactions,
246
+ marker: loadOptions.marker,
247
+ validated: true,
248
+ };
249
+ }
250
+ async function findTransactions(account, options = { limit: DEFAULT_LIMIT, timeout: 15000 }) {
251
+ const result = await findTransactionsExt(account, options);
252
+ if (result.error) {
253
+ return result;
254
+ }
255
+ return result.transactions || [];
217
256
  }
218
257
  function applyLimitOptions(options) {
219
258
  if (options.sourceTag > 0 || options.destinationTag > 0) {
@@ -102,6 +102,15 @@ async function getTransaction(transaction, options = {}) {
102
102
  }
103
103
  }
104
104
  }
105
+ if (!result.hasOwnProperty("ctid")) {
106
+ const ctid = (0, transaction_1.encodeCTIDforTransaction)(result, connection.getNetworkID());
107
+ if (ctid) {
108
+ result.ctid = ctid;
109
+ }
110
+ }
111
+ if (result.hasOwnProperty("tx_json") && result.tx_json.hasOwnProperty("ctid")) {
112
+ delete result.tx_json.ctid;
113
+ }
105
114
  return result;
106
115
  }
107
116
  async function getTransactionByCTID(ctid, options = {}) {
@@ -68,8 +68,17 @@ function isCTID(ctid) {
68
68
  return true;
69
69
  }
70
70
  function encodeCTIDforTransaction(transaction, networkID) {
71
- const tx = (transaction.tx || transaction);
72
- if (!tx.ledger_index) {
71
+ let ledgerIndex;
72
+ if (transaction.ledger_index) {
73
+ ledgerIndex = transaction.ledger_index;
74
+ }
75
+ else if (transaction.tx && transaction.tx.ledger_index) {
76
+ ledgerIndex = transaction.tx.ledger_index;
77
+ }
78
+ else if (transaction.tx_json && transaction.tx_json.ledger_index) {
79
+ ledgerIndex = transaction.tx_json.ledger_index;
80
+ }
81
+ if (typeof ledgerIndex !== "number") {
73
82
  return undefined;
74
83
  }
75
84
  const meta = (transaction.meta || transaction.metaData);
@@ -79,7 +88,7 @@ function encodeCTIDforTransaction(transaction, networkID) {
79
88
  if (typeof networkID !== "number") {
80
89
  return undefined;
81
90
  }
82
- return encodeCTID(tx.ledger_index, meta.TransactionIndex, networkID);
91
+ return encodeCTID(ledgerIndex, meta.TransactionIndex, networkID);
83
92
  }
84
93
  function encodeCTID(ledgerIndex, txIndex, networkID) {
85
94
  if (typeof ledgerIndex !== "number") {
@@ -66,6 +66,7 @@ function parseTrustSet(tx) {
66
66
  qualityOut: (0, utils_1.parseQuality)(tx.QualityOut),
67
67
  ripplingDisabled: parseFlag(tx.Flags, xrpl_1.TrustSetFlags.tfSetNoRipple, xrpl_1.TrustSetFlags.tfClearNoRipple),
68
68
  frozen: parseFlag(tx.Flags, xrpl_1.TrustSetFlags.tfSetFreeze, xrpl_1.TrustSetFlags.tfClearFreeze),
69
+ deepFrozen: parseFlag(tx.Flags, xrpl_1.TrustSetFlags.tfSetDeepFreeze, xrpl_1.TrustSetFlags.tfClearDeepFreeze),
69
70
  authorized: parseFlag(tx.Flags, xrpl_1.TrustSetFlags.tfSetfAuth, 0),
70
71
  emittedDetails: (0, emit_details_1.parseEmittedDetails)(tx),
71
72
  memos: (0, memos_1.parseMemos)(tx),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bithomp/xrpl-api",
3
- "version": "3.4.0",
3
+ "version": "3.4.2",
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"
@@ -52,9 +52,9 @@
52
52
  "lib/**/*"
53
53
  ],
54
54
  "dependencies": {
55
- "axios": "^1.10.0",
55
+ "axios": "^1.11.0",
56
56
  "base-x": "^5.0.1",
57
- "bignumber.js": "^9.3.0",
57
+ "bignumber.js": "^9.3.1",
58
58
  "elliptic": "^6.6.1",
59
59
  "lodash": "^4.17.21",
60
60
  "ripple-address-codec": "5.0.0",
@@ -66,16 +66,16 @@
66
66
  "@eslint/eslintrc": "^3.3.1",
67
67
  "@types/chai": "^5.2.2",
68
68
  "@types/chai-as-promised": "^8.0.2",
69
- "@types/lodash": "^4.17.17",
69
+ "@types/lodash": "^4.17.20",
70
70
  "@types/mocha": "^10.0.10",
71
71
  "@types/nconf": "^0.10.7",
72
72
  "@types/node": "^22.15.21",
73
- "@typescript-eslint/eslint-plugin": "^8.34.0",
74
- "@typescript-eslint/parser": "^8.34.0",
73
+ "@typescript-eslint/eslint-plugin": "^8.38.0",
74
+ "@typescript-eslint/parser": "^8.38.0",
75
75
  "chai": "^4.5.0",
76
76
  "chai-as-promised": "^7.1.2",
77
- "eslint": "^9.31.0",
78
- "eslint-config-prettier": "^10.1.5",
77
+ "eslint": "^9.32.0",
78
+ "eslint-config-prettier": "^10.1.8",
79
79
  "eslint-plugin-chai-friendly": "^1.1.0",
80
80
  "eslint-plugin-import": "^2.32.0",
81
81
  "eslint-plugin-n": "^17.21.0",