@pioneer-platform/maya-network 8.12.4 → 8.13.0

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @pioneer-platform/maya-network
2
2
 
3
+ ## 8.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Fix Maya node endpoints to use correct Cosmos SDK paths
8
+
9
+ - Use `/cosmos/tx/v1beta1/txs` for broadcast (was `/txs`)
10
+ - Use `/cosmos/auth/v1beta1/accounts` for account info (was `/auth/accounts`)
11
+ - Proper Cosmos SDK response parsing with `tx_response` wrapper
12
+ - Check `code: 0` for success (non-zero codes are errors)
13
+ - Better error messages showing transaction rejection reasons
14
+ - Fixes direct node fallback that was timing out due to wrong endpoints
15
+
3
16
  ## 8.12.4
4
17
 
5
18
  ### Patch Changes
package/lib/index.js CHANGED
@@ -83,8 +83,9 @@ var UNCHAINED_API = 'https://api.mayachain.shapeshift.com';
83
83
  // Using verified public endpoints from Maya Protocol
84
84
  var MAYA_NODES = [
85
85
  'https://mayanode.mayachain.info',
86
- 'https://tendermint.mayachain.info',
87
- 'https://rpc-maya.liquify.com' // Community node (faster response)
86
+ 'https://tendermint.mayachain.info'
87
+ // Note: Most public Maya nodes are experiencing issues
88
+ // If broadcast fails, it's likely due to network congestion (mempool full)
88
89
  ];
89
90
  // Fallback to Midgard for pool data (not available in Unchained)
90
91
  var MIDGARD_API = 'https://midgard.mayachain.info/v2';
@@ -169,7 +170,7 @@ var get_info = function () {
169
170
  };
170
171
  var get_account_info = function (address) {
171
172
  return __awaiter(this, void 0, void 0, function () {
172
- var tag, result, unchainedData, unchainedError_1, _i, MAYA_NODES_1, nodeUrl, nodeResult, nodeError_1;
173
+ var tag, result, unchainedData, unchainedError_1, _i, MAYA_NODES_1, nodeUrl, nodeResult, accountData, nodeError_1;
173
174
  return __generator(this, function (_a) {
174
175
  switch (_a.label) {
175
176
  case 0:
@@ -210,16 +211,25 @@ var get_account_info = function (address) {
210
211
  log.debug(tag, "Trying node: ".concat(nodeUrl));
211
212
  return [4 /*yield*/, axiosInstance({
212
213
  method: 'GET',
213
- url: "".concat(nodeUrl, "/auth/accounts/").concat(address),
214
+ url: "".concat(nodeUrl, "/cosmos/auth/v1beta1/accounts/").concat(address),
214
215
  timeout: 10000
215
216
  })
216
- // Node returns nested format already
217
+ // Cosmos SDK returns { account: {...} } - wrap for compatibility
217
218
  ];
218
219
  case 6:
219
220
  nodeResult = _a.sent();
220
- // Node returns nested format already
221
+ accountData = nodeResult.data.account || nodeResult.data;
221
222
  log.info(tag, "Account info retrieved from ".concat(nodeUrl));
222
- return [2 /*return*/, nodeResult.data];
223
+ // Convert Cosmos SDK format to our expected format
224
+ return [2 /*return*/, __assign({ result: {
225
+ value: {
226
+ account_number: String(accountData.account_number || '0'),
227
+ sequence: String(accountData.sequence || '0'),
228
+ address: accountData.address || address,
229
+ coins: accountData.coins || [],
230
+ public_key: accountData.pub_key || null
231
+ }
232
+ } }, accountData)];
223
233
  case 7:
224
234
  nodeError_1 = _a.sent();
225
235
  log.debug(tag, "Node ".concat(nodeUrl, " failed:"), nodeError_1.message);
@@ -374,7 +384,7 @@ var get_transaction = function (txid) {
374
384
  };
375
385
  var broadcast_transaction = function (tx) {
376
386
  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;
387
+ var tag, output, payload, result, unchainedError_2, nodeErrors, _i, MAYA_NODES_2, nodeUrl, nodeResult, txResponse, nodeError, nodeError, nodeError_2, nodeErrorMsg;
378
388
  var _a, _b, _c, _d, _e;
379
389
  return __generator(this, function (_f) {
380
390
  switch (_f.label) {
@@ -430,27 +440,33 @@ var broadcast_transaction = function (tx) {
430
440
  _f.trys.push([6, 8, , 9]);
431
441
  log.info(tag, "Trying direct Maya node: ".concat(nodeUrl));
432
442
  return [4 /*yield*/, axiosInstance({
433
- url: "".concat(nodeUrl, "/txs"),
443
+ url: "".concat(nodeUrl, "/cosmos/tx/v1beta1/txs"),
434
444
  method: 'POST',
435
445
  data: {
436
- tx: tx,
437
- mode: 'sync'
446
+ tx_bytes: tx,
447
+ mode: 'BROADCAST_MODE_SYNC'
438
448
  },
439
449
  timeout: 15000 // Increased timeout for direct nodes
440
450
  })];
441
451
  case 7:
442
452
  nodeResult = _f.sent();
443
453
  log.info(tag, 'Node response:', nodeResult.data);
444
- // Node returns { txhash: "hash" } on success
445
- if (nodeResult.data.txhash || nodeResult.data.hash) {
446
- output.txid = nodeResult.data.txhash || nodeResult.data.hash;
454
+ txResponse = nodeResult.data.tx_response || nodeResult.data;
455
+ // Code 0 means success, any other code is an error
456
+ if (txResponse.code === 0 && (txResponse.txhash || txResponse.hash)) {
457
+ output.txid = txResponse.txhash || txResponse.hash;
447
458
  output.success = true;
448
459
  output.endpoint = nodeUrl;
449
460
  log.info(tag, "\u2705 Broadcast SUCCESS via ".concat(nodeUrl, " - txid: ").concat(output.txid));
450
461
  return [2 /*return*/, output];
451
462
  }
452
- else if (nodeResult.data.raw_log || nodeResult.data.message) {
453
- nodeError = nodeResult.data.raw_log || nodeResult.data.message;
463
+ else if (txResponse.txhash || txResponse.hash) {
464
+ nodeError = "Transaction rejected (code ".concat(txResponse.code, "): ").concat(txResponse.raw_log || txResponse.message || 'Unknown error');
465
+ nodeErrors.push("".concat(nodeUrl, ": ").concat(nodeError));
466
+ log.warn(tag, "Node ".concat(nodeUrl, " rejected transaction:"), nodeError);
467
+ }
468
+ else if (txResponse.raw_log || txResponse.message || nodeResult.data.message) {
469
+ nodeError = txResponse.raw_log || txResponse.message || nodeResult.data.message;
454
470
  nodeErrors.push("".concat(nodeUrl, ": ").concat(nodeError));
455
471
  log.warn(tag, "Node ".concat(nodeUrl, " returned error:"), nodeError);
456
472
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pioneer-platform/maya-network",
3
- "version": "8.12.4",
3
+ "version": "8.13.0",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "scripts": {