@pioneer-platform/ripple-network 8.3.4 → 8.3.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.
Files changed (2) hide show
  1. package/lib/index.js +19 -30
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -209,23 +209,22 @@ var broadcast_transaction = function (tx) {
209
209
  };
210
210
  var get_account_info = function (address) {
211
211
  return __awaiter(this, void 0, void 0, function () {
212
- var tag, NOWNODES_API_KEY, serverInfoResponse, currentLedgerIndex, response, output, e_3;
213
- var _a, _b;
214
- return __generator(this, function (_c) {
215
- switch (_c.label) {
212
+ var tag, NOWNODES_API_KEY, ledgerCurrentResponse, currentLedgerIndex, response, output, e_3;
213
+ return __generator(this, function (_a) {
214
+ switch (_a.label) {
216
215
  case 0:
217
216
  tag = TAG + " | get_account_info | ";
218
- _c.label = 1;
217
+ _a.label = 1;
219
218
  case 1:
220
- _c.trys.push([1, 4, , 5]);
219
+ _a.trys.push([1, 4, , 5]);
221
220
  log.debug(tag, "Getting account info for:", address);
222
221
  NOWNODES_API_KEY = process.env['NOW_NODES_API'];
223
222
  return [4 /*yield*/, axios({
224
223
  url: URL_NODE,
225
224
  method: 'POST',
226
225
  data: {
227
- "method": "server_info",
228
- "params": []
226
+ "method": "ledger_current",
227
+ "params": [{}]
229
228
  },
230
229
  headers: {
231
230
  'Content-Type': 'application/json',
@@ -233,13 +232,9 @@ var get_account_info = function (address) {
233
232
  }
234
233
  })];
235
234
  case 2:
236
- serverInfoResponse = _c.sent();
237
- currentLedgerIndex = undefined;
238
- if (serverInfoResponse.data && serverInfoResponse.data.result && serverInfoResponse.data.result.info) {
239
- currentLedgerIndex = ((_a = serverInfoResponse.data.result.info.validated_ledger) === null || _a === void 0 ? void 0 : _a.seq) ||
240
- ((_b = serverInfoResponse.data.result.info.complete_ledgers) === null || _b === void 0 ? void 0 : _b.split('-').pop());
241
- log.debug(tag, "Current ledger index from server_info:", currentLedgerIndex);
242
- }
235
+ ledgerCurrentResponse = _a.sent();
236
+ currentLedgerIndex = ledgerCurrentResponse.data.result.ledger_current_index;
237
+ log.debug(tag, "Current ledger index:", currentLedgerIndex);
243
238
  return [4 /*yield*/, axios({
244
239
  url: URL_NODE,
245
240
  method: 'POST',
@@ -256,22 +251,16 @@ var get_account_info = function (address) {
256
251
  }
257
252
  })];
258
253
  case 3:
259
- response = _c.sent();
260
- if (response.data && response.data.result && response.data.result.account_data) {
261
- output = response.data.result.account_data;
262
- // Set the current ledger index from server_info
263
- output.ledger_index_current = currentLedgerIndex ? parseInt(currentLedgerIndex) : undefined;
264
- log.debug(tag, "Account info retrieved successfully");
265
- log.debug(tag, "ledger_index_current set to:", output.ledger_index_current);
266
- return [2 /*return*/, output];
267
- }
268
- else {
269
- throw new Error("Invalid response from NowNodes API");
270
- }
271
- return [3 /*break*/, 5];
254
+ response = _a.sent();
255
+ log.debug(tag, "Account info response:", response.data);
256
+ output = response.data.result.account_data;
257
+ // Add the current ledger index to the account info
258
+ output.ledger_index_current = currentLedgerIndex;
259
+ log.debug(tag, "Final account info with ledger index:", output);
260
+ return [2 /*return*/, output];
272
261
  case 4:
273
- e_3 = _c.sent();
274
- log.error(tag, "Error getting account info: ", e_3.message);
262
+ e_3 = _a.sent();
263
+ log.error(tag, "Error getting account info:", e_3);
275
264
  throw e_3;
276
265
  case 5: return [2 /*return*/];
277
266
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pioneer-platform/ripple-network",
3
- "version": "8.3.4",
3
+ "version": "8.3.5",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "description": "Pioneer Platform Ripple Network module with NowNodes integration",