@bithomp/xrpl-api 3.1.8 → 3.1.9

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.
@@ -107,28 +107,29 @@ async function getTransactions(account, options = { limit: DEFAULT_LIMIT }) {
107
107
  async function findTransactions(account, options = { limit: DEFAULT_LIMIT, timeout: 15000 }) {
108
108
  let transactions = [];
109
109
  let accountTransactionsError = null;
110
- const formatted = options.legacy === true || options.formatted === true;
111
110
  const timeStart = new Date();
112
- options.binary = false;
113
- applyLimitOptions(options);
114
- await applyStartTxOptions(options);
115
- while (transactions.length !== options.limit) {
111
+ const loadOptions = { ...options };
112
+ const formatted = loadOptions.legacy === true || loadOptions.formatted === true;
113
+ loadOptions.binary = false;
114
+ applyLimitOptions(loadOptions);
115
+ await applyStartTxOptions(loadOptions);
116
+ while (transactions.length !== loadOptions.limit) {
116
117
  const currentTime = new Date();
117
- if (options.timeout && currentTime.getTime() - timeStart.getTime() > options.timeout) {
118
+ if (loadOptions.timeout && currentTime.getTime() - timeStart.getTime() > loadOptions.timeout) {
118
119
  break;
119
120
  }
120
- let limit = options.limit;
121
- if (transactions.length === 0 && options.startTxHash) {
121
+ let limit = loadOptions.limit;
122
+ if (transactions.length === 0 && loadOptions.startTxHash) {
122
123
  limit += LIMIT_INCREASE_COUNT;
123
124
  }
124
- if (options.sourceTag || options.destinationTag) {
125
+ if (loadOptions.sourceTag || loadOptions.destinationTag) {
125
126
  limit += LIMIT_INCREASE_COUNT;
126
127
  }
127
128
  if (limit > MAX_LIMIT) {
128
129
  limit = MAX_LIMIT;
129
130
  }
130
131
  const accountTransactions = await getTransactions(account, {
131
- ...options,
132
+ ...loadOptions,
132
133
  ...{ balanceChanges: false, specification: false, limit },
133
134
  });
134
135
  if (!accountTransactions || accountTransactions.error) {
@@ -136,16 +137,16 @@ async function findTransactions(account, options = { limit: DEFAULT_LIMIT, timeo
136
137
  break;
137
138
  }
138
139
  let newTransactions = accountTransactions.transactions;
139
- options.marker = accountTransactions.marker;
140
+ loadOptions.marker = accountTransactions.marker;
140
141
  newTransactions = newTransactions
141
- .filter(lodash_1.default.partial(filterHelperTransactions, account, options))
142
- .filter(lodash_1.default.partial(filterHelperStartTx, options));
143
- if (formatted !== true && (options.balanceChanges === true || options.specification === true)) {
142
+ .filter(lodash_1.default.partial(filterHelperTransactions, account, loadOptions))
143
+ .filter(lodash_1.default.partial(filterHelperStartTx, loadOptions));
144
+ if (formatted !== true && (loadOptions.balanceChanges === true || loadOptions.specification === true)) {
144
145
  for (const newTransaction of newTransactions) {
145
- if (options.balanceChanges === true) {
146
+ if (loadOptions.balanceChanges === true) {
146
147
  newTransaction.balanceChanges = (0, xrpl_1.getBalanceChanges)(newTransaction.meta);
147
148
  }
148
- if (options.specification === true) {
149
+ if (loadOptions.specification === true) {
149
150
  const details = (0, transaction_1.getAccountTxDetails)(newTransaction, true);
150
151
  newTransaction.specification = details.specification;
151
152
  newTransaction.outcome = details.outcome;
@@ -154,23 +155,23 @@ async function findTransactions(account, options = { limit: DEFAULT_LIMIT, timeo
154
155
  }
155
156
  }
156
157
  transactions = transactions.concat(newTransactions);
157
- transactions = transactions.slice(0, options.limit);
158
- if (options.marker === undefined) {
158
+ transactions = transactions.slice(0, loadOptions.limit);
159
+ if (loadOptions.marker === undefined) {
159
160
  break;
160
161
  }
161
162
  }
162
163
  if (accountTransactionsError && transactions.length === 0) {
163
164
  return accountTransactionsError;
164
165
  }
165
- if (options.marker && transactions.length === 0) {
166
+ if (loadOptions.marker && transactions.length === 0) {
166
167
  return {
167
168
  status: "timeout",
168
169
  error: "searchTimeout",
169
- marker: options.marker,
170
+ marker: loadOptions.marker,
170
171
  };
171
172
  }
172
173
  if (formatted === true) {
173
- transactions = transactions.map((transaction) => (0, transaction_1.getAccountTxDetails)(transaction, options.includeRawTransactions === true));
174
+ transactions = transactions.map((transaction) => (0, transaction_1.getAccountTxDetails)(transaction, loadOptions.includeRawTransactions === true));
174
175
  }
175
176
  return transactions;
176
177
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bithomp/xrpl-api",
3
- "version": "3.1.8",
3
+ "version": "3.1.9",
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",