@pioneer-platform/ripple-network 8.11.0 → 8.11.1
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.
- package/.turbo/turbo-build.log +1 -2
- package/CHANGELOG.md +6 -0
- package/lib/index.js +44 -8
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
[0m[2m[35m$[0m [2m[1mtsc -p .[0m
|
|
1
|
+
$ tsc -p .
|
package/CHANGELOG.md
CHANGED
package/lib/index.js
CHANGED
|
@@ -97,16 +97,27 @@ module.exports = {
|
|
|
97
97
|
'Content-Type': 'application/json',
|
|
98
98
|
'api-key': NOWNODES_API_KEY
|
|
99
99
|
}
|
|
100
|
-
})
|
|
100
|
+
})
|
|
101
|
+
// Detailed logging for debugging API response format
|
|
102
|
+
];
|
|
101
103
|
case 2:
|
|
102
104
|
testResult = _b.sent();
|
|
105
|
+
// Detailed logging for debugging API response format
|
|
106
|
+
log.debug(tag, "NowNodes response structure:", JSON.stringify(testResult.data, null, 2));
|
|
103
107
|
if (testResult.data && testResult.data.result) {
|
|
104
108
|
log.info(tag, "Successfully connected to NowNodes XRP HTTP API");
|
|
105
109
|
log.info(tag, "Server info:", ((_a = testResult.data.result.info) === null || _a === void 0 ? void 0 : _a.server_version) || "Unknown version");
|
|
106
110
|
return [2 /*return*/, true];
|
|
107
111
|
}
|
|
112
|
+
else if (testResult.data && testResult.data.error) {
|
|
113
|
+
// Handle error responses from NowNodes
|
|
114
|
+
log.error(tag, "NowNodes API error:", testResult.data.error);
|
|
115
|
+
throw new Error("NowNodes API error: ".concat(JSON.stringify(testResult.data.error)));
|
|
116
|
+
}
|
|
108
117
|
else {
|
|
109
|
-
|
|
118
|
+
// Log the actual response structure for debugging
|
|
119
|
+
log.error(tag, "Unexpected response structure from NowNodes:", testResult.data);
|
|
120
|
+
throw new Error("Invalid response from NowNodes API: ".concat(JSON.stringify(testResult.data)));
|
|
110
121
|
}
|
|
111
122
|
return [3 /*break*/, 4];
|
|
112
123
|
case 3:
|
|
@@ -270,7 +281,7 @@ var get_account_info = function (address) {
|
|
|
270
281
|
};
|
|
271
282
|
var get_balance = function (address) {
|
|
272
283
|
return __awaiter(this, void 0, void 0, function () {
|
|
273
|
-
var tag, NOWNODES_API_KEY, response, balanceInDrops, balanceInXRP, e_4;
|
|
284
|
+
var tag, NOWNODES_API_KEY, response, balanceInDrops, balanceInXRP, error, errorCode, errorMsg, e_4;
|
|
274
285
|
return __generator(this, function (_a) {
|
|
275
286
|
switch (_a.label) {
|
|
276
287
|
case 0:
|
|
@@ -294,23 +305,48 @@ var get_balance = function (address) {
|
|
|
294
305
|
'Content-Type': 'application/json',
|
|
295
306
|
'api-key': NOWNODES_API_KEY
|
|
296
307
|
}
|
|
297
|
-
})
|
|
308
|
+
})
|
|
309
|
+
// Check for successful response with account data
|
|
310
|
+
];
|
|
298
311
|
case 2:
|
|
299
312
|
response = _a.sent();
|
|
313
|
+
// Check for successful response with account data
|
|
300
314
|
if (response.data && response.data.result && response.data.result.account_data) {
|
|
301
315
|
balanceInDrops = parseFloat(response.data.result.account_data.Balance);
|
|
302
316
|
balanceInXRP = balanceInDrops / 1000000;
|
|
303
317
|
log.debug(tag, "Balance retrieved:", balanceInXRP, "XRP");
|
|
304
318
|
return [2 /*return*/, balanceInXRP];
|
|
305
319
|
}
|
|
306
|
-
|
|
307
|
-
|
|
320
|
+
// Check for error responses (account not found, malformed, etc.)
|
|
321
|
+
if (response.data && response.data.result && response.data.result.error) {
|
|
322
|
+
error = response.data.result.error;
|
|
323
|
+
errorCode = response.data.result.error_code;
|
|
324
|
+
errorMsg = response.data.result.error_message || error;
|
|
325
|
+
// Handle common errors gracefully
|
|
326
|
+
if (error === 'actNotFound' || errorCode === 19) {
|
|
327
|
+
// Account not found = not yet activated on Ripple (needs 10 XRP reserve)
|
|
328
|
+
log.info(tag, "Account not found (not activated): ".concat(address));
|
|
329
|
+
return [2 /*return*/, 0];
|
|
330
|
+
}
|
|
331
|
+
else if (error === 'actMalformed' || errorCode === 35) {
|
|
332
|
+
// Malformed address - likely wrong format or checksum
|
|
333
|
+
log.error(tag, "Malformed Ripple address: ".concat(address, " - ").concat(errorMsg));
|
|
334
|
+
return [2 /*return*/, 0]; // Return 0 instead of throwing to allow test to continue
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
// Other errors
|
|
338
|
+
log.warn(tag, "Ripple API error for ".concat(address, ": ").concat(error, " (").concat(errorCode, ") - ").concat(errorMsg));
|
|
339
|
+
return [2 /*return*/, 0];
|
|
340
|
+
}
|
|
308
341
|
}
|
|
309
|
-
|
|
342
|
+
// Unknown response format
|
|
343
|
+
log.error(tag, "Unexpected response format from NowNodes API:", response.data);
|
|
344
|
+
return [2 /*return*/, 0];
|
|
310
345
|
case 3:
|
|
311
346
|
e_4 = _a.sent();
|
|
312
347
|
log.error(tag, "Error getting balance: ", e_4.message);
|
|
313
|
-
|
|
348
|
+
// Return 0 instead of throwing to prevent balance fetch from failing entirely
|
|
349
|
+
return [2 /*return*/, 0];
|
|
314
350
|
case 4: return [2 /*return*/];
|
|
315
351
|
}
|
|
316
352
|
});
|