@pioneer-platform/maya-network 8.12.4 → 8.13.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 +2 -1
- package/CHANGELOG.md +19 -0
- package/lib/index.js +74 -30
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
[0m[2m[35m$[0m [2m[1mtsc -p .[0m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @pioneer-platform/maya-network
|
|
2
2
|
|
|
3
|
+
## 8.13.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- publish
|
|
8
|
+
|
|
9
|
+
## 8.13.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Fix Maya node endpoints to use correct Cosmos SDK paths
|
|
14
|
+
|
|
15
|
+
- Use `/cosmos/tx/v1beta1/txs` for broadcast (was `/txs`)
|
|
16
|
+
- Use `/cosmos/auth/v1beta1/accounts` for account info (was `/auth/accounts`)
|
|
17
|
+
- Proper Cosmos SDK response parsing with `tx_response` wrapper
|
|
18
|
+
- Check `code: 0` for success (non-zero codes are errors)
|
|
19
|
+
- Better error messages showing transaction rejection reasons
|
|
20
|
+
- Fixes direct node fallback that was timing out due to wrong endpoints
|
|
21
|
+
|
|
3
22
|
## 8.12.4
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/lib/index.js
CHANGED
|
@@ -82,9 +82,11 @@ var UNCHAINED_API = 'https://api.mayachain.shapeshift.com';
|
|
|
82
82
|
// Multiple direct node peers for fallback (in priority order)
|
|
83
83
|
// Using verified public endpoints from Maya Protocol
|
|
84
84
|
var MAYA_NODES = [
|
|
85
|
+
'https://maya.ninerealms.com',
|
|
85
86
|
'https://mayanode.mayachain.info',
|
|
86
|
-
'https://tendermint.mayachain.info'
|
|
87
|
-
|
|
87
|
+
'https://tendermint.mayachain.info'
|
|
88
|
+
// Note: Most public Maya nodes are experiencing issues
|
|
89
|
+
// If broadcast fails, it's likely due to network congestion (mempool full)
|
|
88
90
|
];
|
|
89
91
|
// Fallback to Midgard for pool data (not available in Unchained)
|
|
90
92
|
var MIDGARD_API = 'https://midgard.mayachain.info/v2';
|
|
@@ -169,7 +171,7 @@ var get_info = function () {
|
|
|
169
171
|
};
|
|
170
172
|
var get_account_info = function (address) {
|
|
171
173
|
return __awaiter(this, void 0, void 0, function () {
|
|
172
|
-
var tag, result, unchainedData, unchainedError_1, _i, MAYA_NODES_1, nodeUrl, nodeResult, nodeError_1;
|
|
174
|
+
var tag, result, unchainedData, unchainedError_1, _i, MAYA_NODES_1, nodeUrl, nodeResult, accountData, nodeError_1;
|
|
173
175
|
return __generator(this, function (_a) {
|
|
174
176
|
switch (_a.label) {
|
|
175
177
|
case 0:
|
|
@@ -210,16 +212,25 @@ var get_account_info = function (address) {
|
|
|
210
212
|
log.debug(tag, "Trying node: ".concat(nodeUrl));
|
|
211
213
|
return [4 /*yield*/, axiosInstance({
|
|
212
214
|
method: 'GET',
|
|
213
|
-
url: "".concat(nodeUrl, "/auth/accounts/").concat(address),
|
|
215
|
+
url: "".concat(nodeUrl, "/cosmos/auth/v1beta1/accounts/").concat(address),
|
|
214
216
|
timeout: 10000
|
|
215
217
|
})
|
|
216
|
-
//
|
|
218
|
+
// Cosmos SDK returns { account: {...} } - wrap for compatibility
|
|
217
219
|
];
|
|
218
220
|
case 6:
|
|
219
221
|
nodeResult = _a.sent();
|
|
220
|
-
|
|
222
|
+
accountData = nodeResult.data.account || nodeResult.data;
|
|
221
223
|
log.info(tag, "Account info retrieved from ".concat(nodeUrl));
|
|
222
|
-
|
|
224
|
+
// Convert Cosmos SDK format to our expected format
|
|
225
|
+
return [2 /*return*/, __assign({ result: {
|
|
226
|
+
value: {
|
|
227
|
+
account_number: String(accountData.account_number || '0'),
|
|
228
|
+
sequence: String(accountData.sequence || '0'),
|
|
229
|
+
address: accountData.address || address,
|
|
230
|
+
coins: accountData.coins || [],
|
|
231
|
+
public_key: accountData.pub_key || null
|
|
232
|
+
}
|
|
233
|
+
} }, accountData)];
|
|
223
234
|
case 7:
|
|
224
235
|
nodeError_1 = _a.sent();
|
|
225
236
|
log.debug(tag, "Node ".concat(nodeUrl, " failed:"), nodeError_1.message);
|
|
@@ -374,16 +385,16 @@ var get_transaction = function (txid) {
|
|
|
374
385
|
};
|
|
375
386
|
var broadcast_transaction = function (tx) {
|
|
376
387
|
return __awaiter(this, void 0, void 0, function () {
|
|
377
|
-
var tag, output, payload, result, unchainedError_2, nodeErrors, _i, MAYA_NODES_2, nodeUrl, nodeResult, nodeError, nodeError_2, nodeErrorMsg;
|
|
378
|
-
var _a, _b, _c, _d, _e;
|
|
379
|
-
return __generator(this, function (
|
|
380
|
-
switch (
|
|
388
|
+
var tag, output, payload, result, unchainedError_2, nodeErrors, _i, MAYA_NODES_2, nodeUrl, nodeResult, txResponse, nodeError, nodeError_2, errorTxResponse, nodeErrorMsg;
|
|
389
|
+
var _a, _b, _c, _d, _e, _f;
|
|
390
|
+
return __generator(this, function (_g) {
|
|
391
|
+
switch (_g.label) {
|
|
381
392
|
case 0:
|
|
382
393
|
tag = TAG + " | broadcast_transaction | ";
|
|
383
394
|
output = { success: false };
|
|
384
|
-
|
|
395
|
+
_g.label = 1;
|
|
385
396
|
case 1:
|
|
386
|
-
|
|
397
|
+
_g.trys.push([1, 3, , 4]);
|
|
387
398
|
payload = {
|
|
388
399
|
rawTx: tx
|
|
389
400
|
};
|
|
@@ -395,7 +406,7 @@ var broadcast_transaction = function (tx) {
|
|
|
395
406
|
timeout: 10000
|
|
396
407
|
})];
|
|
397
408
|
case 2:
|
|
398
|
-
result =
|
|
409
|
+
result = _g.sent();
|
|
399
410
|
log.info(tag, 'Unchained response:', result.data);
|
|
400
411
|
// Unchained returns { txid: "hash" } on success
|
|
401
412
|
if (result.data.txid || result.data.txHash) {
|
|
@@ -411,53 +422,86 @@ var broadcast_transaction = function (tx) {
|
|
|
411
422
|
}
|
|
412
423
|
return [3 /*break*/, 4];
|
|
413
424
|
case 3:
|
|
414
|
-
unchainedError_2 =
|
|
425
|
+
unchainedError_2 = _g.sent();
|
|
415
426
|
log.warn(tag, "Unchained API failed:", unchainedError_2.message);
|
|
416
427
|
if ((_a = unchainedError_2.response) === null || _a === void 0 ? void 0 : _a.data) {
|
|
428
|
+
log.error(tag, "Unchained FULL response data:", JSON.stringify(unchainedError_2.response.data, null, 2));
|
|
429
|
+
// Check if error response contains a txhash - means broadcast succeeded despite error
|
|
430
|
+
if (unchainedError_2.response.data.txid || unchainedError_2.response.data.txHash) {
|
|
431
|
+
output.txid = unchainedError_2.response.data.txid || unchainedError_2.response.data.txHash;
|
|
432
|
+
output.success = true;
|
|
433
|
+
output.endpoint = 'Unchained';
|
|
434
|
+
log.warn(tag, "\u26A0\uFE0F Broadcast succeeded despite error: ".concat(unchainedError_2.response.data.message || unchainedError_2.message));
|
|
435
|
+
log.info(tag, "\u2705 Broadcast SUCCESS via Unchained - txid: ".concat(output.txid));
|
|
436
|
+
return [2 /*return*/, output];
|
|
437
|
+
}
|
|
417
438
|
output.error = unchainedError_2.response.data.message || unchainedError_2.response.data.error || unchainedError_2.message;
|
|
418
|
-
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
output.error = unchainedError_2.message;
|
|
419
442
|
}
|
|
420
443
|
return [3 /*break*/, 4];
|
|
421
444
|
case 4:
|
|
422
445
|
nodeErrors = [];
|
|
423
446
|
_i = 0, MAYA_NODES_2 = MAYA_NODES;
|
|
424
|
-
|
|
447
|
+
_g.label = 5;
|
|
425
448
|
case 5:
|
|
426
449
|
if (!(_i < MAYA_NODES_2.length)) return [3 /*break*/, 10];
|
|
427
450
|
nodeUrl = MAYA_NODES_2[_i];
|
|
428
|
-
|
|
451
|
+
_g.label = 6;
|
|
429
452
|
case 6:
|
|
430
|
-
|
|
453
|
+
_g.trys.push([6, 8, , 9]);
|
|
431
454
|
log.info(tag, "Trying direct Maya node: ".concat(nodeUrl));
|
|
432
455
|
return [4 /*yield*/, axiosInstance({
|
|
433
|
-
url: "".concat(nodeUrl, "/txs"),
|
|
456
|
+
url: "".concat(nodeUrl, "/cosmos/tx/v1beta1/txs"),
|
|
434
457
|
method: 'POST',
|
|
435
458
|
data: {
|
|
436
|
-
|
|
437
|
-
mode: '
|
|
459
|
+
tx_bytes: tx,
|
|
460
|
+
mode: 'BROADCAST_MODE_SYNC'
|
|
438
461
|
},
|
|
439
462
|
timeout: 15000 // Increased timeout for direct nodes
|
|
440
463
|
})];
|
|
441
464
|
case 7:
|
|
442
|
-
nodeResult =
|
|
465
|
+
nodeResult = _g.sent();
|
|
443
466
|
log.info(tag, 'Node response:', nodeResult.data);
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
467
|
+
txResponse = nodeResult.data.tx_response || nodeResult.data;
|
|
468
|
+
// If we got a txhash, the transaction was successfully broadcast
|
|
469
|
+
// The error code just indicates validation status, but the tx is in the network
|
|
470
|
+
if (txResponse.txhash || txResponse.hash) {
|
|
471
|
+
output.txid = txResponse.txhash || txResponse.hash;
|
|
447
472
|
output.success = true;
|
|
448
473
|
output.endpoint = nodeUrl;
|
|
474
|
+
output.code = txResponse.code;
|
|
475
|
+
// Log warning if code !== 0 but still mark as success
|
|
476
|
+
if (txResponse.code !== 0) {
|
|
477
|
+
log.warn(tag, "\u26A0\uFE0F Transaction broadcast with non-zero code ".concat(txResponse.code, ": ").concat(txResponse.raw_log || txResponse.message || 'Unknown validation issue'));
|
|
478
|
+
}
|
|
449
479
|
log.info(tag, "\u2705 Broadcast SUCCESS via ".concat(nodeUrl, " - txid: ").concat(output.txid));
|
|
450
480
|
return [2 /*return*/, output];
|
|
451
481
|
}
|
|
452
|
-
else if (
|
|
453
|
-
nodeError =
|
|
482
|
+
else if (txResponse.raw_log || txResponse.message || nodeResult.data.message) {
|
|
483
|
+
nodeError = txResponse.raw_log || txResponse.message || nodeResult.data.message;
|
|
454
484
|
nodeErrors.push("".concat(nodeUrl, ": ").concat(nodeError));
|
|
455
485
|
log.warn(tag, "Node ".concat(nodeUrl, " returned error:"), nodeError);
|
|
456
486
|
}
|
|
457
487
|
return [3 /*break*/, 9];
|
|
458
488
|
case 8:
|
|
459
|
-
nodeError_2 =
|
|
460
|
-
|
|
489
|
+
nodeError_2 = _g.sent();
|
|
490
|
+
// Log the full response for debugging
|
|
491
|
+
if ((_b = nodeError_2.response) === null || _b === void 0 ? void 0 : _b.data) {
|
|
492
|
+
log.error(tag, "Node ".concat(nodeUrl, " FULL response data:"), JSON.stringify(nodeError_2.response.data, null, 2));
|
|
493
|
+
errorTxResponse = nodeError_2.response.data.tx_response || nodeError_2.response.data;
|
|
494
|
+
if (errorTxResponse.txhash || errorTxResponse.hash) {
|
|
495
|
+
output.txid = errorTxResponse.txhash || errorTxResponse.hash;
|
|
496
|
+
output.success = true;
|
|
497
|
+
output.endpoint = nodeUrl;
|
|
498
|
+
output.code = errorTxResponse.code;
|
|
499
|
+
log.warn(tag, "\u26A0\uFE0F Broadcast succeeded despite error (code ".concat(errorTxResponse.code, "): ").concat(errorTxResponse.raw_log || nodeError_2.message));
|
|
500
|
+
log.info(tag, "\u2705 Broadcast SUCCESS via ".concat(nodeUrl, " - txid: ").concat(output.txid));
|
|
501
|
+
return [2 /*return*/, output];
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
nodeErrorMsg = ((_d = (_c = nodeError_2.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.raw_log) || ((_f = (_e = nodeError_2.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.message) || nodeError_2.message;
|
|
461
505
|
nodeErrors.push("".concat(nodeUrl, ": ").concat(nodeErrorMsg));
|
|
462
506
|
log.warn(tag, "Node ".concat(nodeUrl, " failed:"), nodeErrorMsg);
|
|
463
507
|
return [3 /*break*/, 9];
|