@pioneer-platform/maya-network 8.12.2 → 8.12.4
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/CHANGELOG.md +22 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +61 -29
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @pioneer-platform/maya-network
|
|
2
2
|
|
|
3
|
+
## 8.12.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix invalid RPC endpoint in multi-peer fallback
|
|
8
|
+
|
|
9
|
+
- Replace non-existent rpc.mayachain.info with rpc-maya.liquify.com
|
|
10
|
+
- All 3 node endpoints now verified and working
|
|
11
|
+
- Error messages showing all attempted endpoints (already working)
|
|
12
|
+
|
|
13
|
+
## 8.12.3
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Add multi-peer fallback for broadcast and account info
|
|
18
|
+
|
|
19
|
+
- Try 3 different Maya node peers if Unchained API fails
|
|
20
|
+
- Increased timeout from 10s to 15s for direct node broadcasts
|
|
21
|
+
- Comprehensive error messages showing all attempted endpoints
|
|
22
|
+
- Nodes: mayanode, tendermint, rpc (in priority order)
|
|
23
|
+
- Eliminates single point of failure for critical operations
|
|
24
|
+
|
|
3
25
|
## 8.12.2
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/lib/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare const https: any;
|
|
|
6
6
|
declare const axiosInstance: any;
|
|
7
7
|
declare const axiosRetry: any;
|
|
8
8
|
declare const UNCHAINED_API = "https://api.mayachain.shapeshift.com";
|
|
9
|
-
declare const
|
|
9
|
+
declare const MAYA_NODES: string[];
|
|
10
10
|
declare const MIDGARD_API = "https://midgard.mayachain.info/v2";
|
|
11
11
|
declare const BASE_MAYA = 10000000000;
|
|
12
12
|
/**********************************
|
package/lib/index.js
CHANGED
|
@@ -79,8 +79,13 @@ axiosRetry(axiosInstance, {
|
|
|
79
79
|
});
|
|
80
80
|
// Unchained API endpoint (primary)
|
|
81
81
|
var UNCHAINED_API = 'https://api.mayachain.shapeshift.com';
|
|
82
|
-
//
|
|
83
|
-
|
|
82
|
+
// Multiple direct node peers for fallback (in priority order)
|
|
83
|
+
// Using verified public endpoints from Maya Protocol
|
|
84
|
+
var MAYA_NODES = [
|
|
85
|
+
'https://mayanode.mayachain.info',
|
|
86
|
+
'https://tendermint.mayachain.info',
|
|
87
|
+
'https://rpc-maya.liquify.com' // Community node (faster response)
|
|
88
|
+
];
|
|
84
89
|
// Fallback to Midgard for pool data (not available in Unchained)
|
|
85
90
|
var MIDGARD_API = 'https://midgard.mayachain.info/v2';
|
|
86
91
|
// Base unit conversion (10 decimal places for CACAO)
|
|
@@ -164,14 +169,14 @@ var get_info = function () {
|
|
|
164
169
|
};
|
|
165
170
|
var get_account_info = function (address) {
|
|
166
171
|
return __awaiter(this, void 0, void 0, function () {
|
|
167
|
-
var tag, result, unchainedData, unchainedError_1, nodeResult, nodeError_1;
|
|
172
|
+
var tag, result, unchainedData, unchainedError_1, _i, MAYA_NODES_1, nodeUrl, nodeResult, nodeError_1;
|
|
168
173
|
return __generator(this, function (_a) {
|
|
169
174
|
switch (_a.label) {
|
|
170
175
|
case 0:
|
|
171
176
|
tag = TAG + " | get_account_info | ";
|
|
172
177
|
_a.label = 1;
|
|
173
178
|
case 1:
|
|
174
|
-
_a.trys.push([1, 3, ,
|
|
179
|
+
_a.trys.push([1, 3, , 10]);
|
|
175
180
|
return [4 /*yield*/, axiosInstance({
|
|
176
181
|
method: 'GET',
|
|
177
182
|
url: "".concat(UNCHAINED_API, "/api/v1/account/").concat(address),
|
|
@@ -194,26 +199,38 @@ var get_account_info = function (address) {
|
|
|
194
199
|
case 3:
|
|
195
200
|
unchainedError_1 = _a.sent();
|
|
196
201
|
log.warn(tag, "Unchained API failed, trying node fallback:", unchainedError_1.message);
|
|
202
|
+
_i = 0, MAYA_NODES_1 = MAYA_NODES;
|
|
197
203
|
_a.label = 4;
|
|
198
204
|
case 4:
|
|
199
|
-
|
|
205
|
+
if (!(_i < MAYA_NODES_1.length)) return [3 /*break*/, 9];
|
|
206
|
+
nodeUrl = MAYA_NODES_1[_i];
|
|
207
|
+
_a.label = 5;
|
|
208
|
+
case 5:
|
|
209
|
+
_a.trys.push([5, 7, , 8]);
|
|
210
|
+
log.debug(tag, "Trying node: ".concat(nodeUrl));
|
|
200
211
|
return [4 /*yield*/, axiosInstance({
|
|
201
212
|
method: 'GET',
|
|
202
|
-
url: "".concat(
|
|
203
|
-
timeout:
|
|
213
|
+
url: "".concat(nodeUrl, "/auth/accounts/").concat(address),
|
|
214
|
+
timeout: 10000
|
|
204
215
|
})
|
|
205
216
|
// Node returns nested format already
|
|
206
217
|
];
|
|
207
|
-
case
|
|
218
|
+
case 6:
|
|
208
219
|
nodeResult = _a.sent();
|
|
209
220
|
// Node returns nested format already
|
|
221
|
+
log.info(tag, "Account info retrieved from ".concat(nodeUrl));
|
|
210
222
|
return [2 /*return*/, nodeResult.data];
|
|
211
|
-
case
|
|
223
|
+
case 7:
|
|
212
224
|
nodeError_1 = _a.sent();
|
|
213
|
-
log.
|
|
214
|
-
|
|
215
|
-
case
|
|
216
|
-
|
|
225
|
+
log.debug(tag, "Node ".concat(nodeUrl, " failed:"), nodeError_1.message);
|
|
226
|
+
return [3 /*break*/, 8];
|
|
227
|
+
case 8:
|
|
228
|
+
_i++;
|
|
229
|
+
return [3 /*break*/, 4];
|
|
230
|
+
case 9:
|
|
231
|
+
log.error(tag, "All endpoints failed");
|
|
232
|
+
throw new Error("All endpoints failed for account info");
|
|
233
|
+
case 10: return [2 /*return*/];
|
|
217
234
|
}
|
|
218
235
|
});
|
|
219
236
|
});
|
|
@@ -357,7 +374,7 @@ var get_transaction = function (txid) {
|
|
|
357
374
|
};
|
|
358
375
|
var broadcast_transaction = function (tx) {
|
|
359
376
|
return __awaiter(this, void 0, void 0, function () {
|
|
360
|
-
var tag, output, payload, result, unchainedError_2, nodeResult, nodeError, nodeError_2, nodeErrorMsg;
|
|
377
|
+
var tag, output, payload, result, unchainedError_2, nodeErrors, _i, MAYA_NODES_2, nodeUrl, nodeResult, nodeError, nodeError_2, nodeErrorMsg;
|
|
361
378
|
var _a, _b, _c, _d, _e;
|
|
362
379
|
return __generator(this, function (_f) {
|
|
363
380
|
switch (_f.label) {
|
|
@@ -402,41 +419,56 @@ var broadcast_transaction = function (tx) {
|
|
|
402
419
|
}
|
|
403
420
|
return [3 /*break*/, 4];
|
|
404
421
|
case 4:
|
|
405
|
-
|
|
406
|
-
|
|
422
|
+
nodeErrors = [];
|
|
423
|
+
_i = 0, MAYA_NODES_2 = MAYA_NODES;
|
|
424
|
+
_f.label = 5;
|
|
425
|
+
case 5:
|
|
426
|
+
if (!(_i < MAYA_NODES_2.length)) return [3 /*break*/, 10];
|
|
427
|
+
nodeUrl = MAYA_NODES_2[_i];
|
|
428
|
+
_f.label = 6;
|
|
429
|
+
case 6:
|
|
430
|
+
_f.trys.push([6, 8, , 9]);
|
|
431
|
+
log.info(tag, "Trying direct Maya node: ".concat(nodeUrl));
|
|
407
432
|
return [4 /*yield*/, axiosInstance({
|
|
408
|
-
url: "".concat(
|
|
433
|
+
url: "".concat(nodeUrl, "/txs"),
|
|
409
434
|
method: 'POST',
|
|
410
435
|
data: {
|
|
411
436
|
tx: tx,
|
|
412
437
|
mode: 'sync'
|
|
413
438
|
},
|
|
414
|
-
timeout:
|
|
439
|
+
timeout: 15000 // Increased timeout for direct nodes
|
|
415
440
|
})];
|
|
416
|
-
case
|
|
441
|
+
case 7:
|
|
417
442
|
nodeResult = _f.sent();
|
|
418
443
|
log.info(tag, 'Node response:', nodeResult.data);
|
|
419
444
|
// Node returns { txhash: "hash" } on success
|
|
420
445
|
if (nodeResult.data.txhash || nodeResult.data.hash) {
|
|
421
446
|
output.txid = nodeResult.data.txhash || nodeResult.data.hash;
|
|
422
447
|
output.success = true;
|
|
423
|
-
output.endpoint =
|
|
424
|
-
log.info(tag, "\u2705 Broadcast SUCCESS via
|
|
448
|
+
output.endpoint = nodeUrl;
|
|
449
|
+
log.info(tag, "\u2705 Broadcast SUCCESS via ".concat(nodeUrl, " - txid: ").concat(output.txid));
|
|
425
450
|
return [2 /*return*/, output];
|
|
426
451
|
}
|
|
427
452
|
else if (nodeResult.data.raw_log || nodeResult.data.message) {
|
|
428
453
|
nodeError = nodeResult.data.raw_log || nodeResult.data.message;
|
|
429
|
-
|
|
430
|
-
log.
|
|
454
|
+
nodeErrors.push("".concat(nodeUrl, ": ").concat(nodeError));
|
|
455
|
+
log.warn(tag, "Node ".concat(nodeUrl, " returned error:"), nodeError);
|
|
431
456
|
}
|
|
432
|
-
return [3 /*break*/,
|
|
433
|
-
case
|
|
457
|
+
return [3 /*break*/, 9];
|
|
458
|
+
case 8:
|
|
434
459
|
nodeError_2 = _f.sent();
|
|
435
|
-
log.error(tag, "Node broadcast also failed:", nodeError_2.message);
|
|
436
460
|
nodeErrorMsg = ((_c = (_b = nodeError_2.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.raw_log) || ((_e = (_d = nodeError_2.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.message) || nodeError_2.message;
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
461
|
+
nodeErrors.push("".concat(nodeUrl, ": ").concat(nodeErrorMsg));
|
|
462
|
+
log.warn(tag, "Node ".concat(nodeUrl, " failed:"), nodeErrorMsg);
|
|
463
|
+
return [3 /*break*/, 9];
|
|
464
|
+
case 9:
|
|
465
|
+
_i++;
|
|
466
|
+
return [3 /*break*/, 5];
|
|
467
|
+
case 10:
|
|
468
|
+
// All endpoints failed
|
|
469
|
+
output.error = "All endpoints failed. Unchained: ".concat(output.error, ". Nodes: ").concat(nodeErrors.join(' | '));
|
|
470
|
+
log.error(tag, "❌ All endpoints FAILED");
|
|
471
|
+
return [2 /*return*/, output];
|
|
440
472
|
}
|
|
441
473
|
});
|
|
442
474
|
});
|