@paraspell/sdk 10.0.2 → 10.1.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/dist/index.cjs CHANGED
@@ -511,6 +511,13 @@ var _transform = function transform(obj) {
511
511
  type: key,
512
512
  value: checkAndConvertToNumberOrBigInt(value)
513
513
  };
514
+ } else if (key === 'GlobalConsensus' && _typeof(value) === 'object' && ('polkadot' in value || 'kusama' in value)) {
515
+ return {
516
+ type: key,
517
+ value: {
518
+ type: 'polkadot' in value ? 'Polkadot' : 'Kusama'
519
+ }
520
+ };
514
521
  } else if (key === 'PalletInstance' || key === 'GeneralIndex') {
515
522
  return {
516
523
  type: key,
@@ -1092,6 +1099,11 @@ var PapiApi = /*#__PURE__*/function () {
1092
1099
  dkLen: 32
1093
1100
  })));
1094
1101
  }
1102
+ }, {
1103
+ key: "getMethod",
1104
+ value: function getMethod(tx) {
1105
+ return tx.decodedCall.value.value;
1106
+ }
1095
1107
  }, {
1096
1108
  key: "calculateTransactionFee",
1097
1109
  value: function () {
@@ -1437,7 +1449,7 @@ var PapiApi = /*#__PURE__*/function () {
1437
1449
  value: function () {
1438
1450
  var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref6) {
1439
1451
  var _this$api$getUnsafeAp;
1440
- var tx, address, node, isFeeAsset, supportsDryRunApi, needsVersionParam, DEFAULT_XCM_VERSION, result, isSuccess, _result$value, _ref7, _ref8, _errorValue$value$typ, _errorValue$value, _result$value2, errorValue, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
1452
+ var tx, address, node, isFeeAsset, supportsDryRunApi, nodesRequiringVersionParam, needsVersionParam, DEFAULT_XCM_VERSION, result, isSuccess, _result$value, _ref7, _ref8, _errorValue$value$typ, _errorValue$value, _result$value2, errorValue, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
1441
1453
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1442
1454
  while (1) switch (_context17.prev = _context17.next) {
1443
1455
  case 0:
@@ -1449,9 +1461,10 @@ var PapiApi = /*#__PURE__*/function () {
1449
1461
  }
1450
1462
  throw new sdkCore.NodeNotSupportedError("DryRunApi is not available on node ".concat(node));
1451
1463
  case 4:
1452
- needsVersionParam = node === 'BifrostPolkadot' || node === 'BifrostKusama' || node === 'AssetHubKusama' || node === 'Kusama' || node === 'Polimec';
1464
+ nodesRequiringVersionParam = ['BifrostPolkadot', 'BifrostKusama', 'AssetHubKusama', 'AssetHubPolkadot', 'Kusama', 'Polkadot', 'Polimec'];
1465
+ needsVersionParam = nodesRequiringVersionParam.includes(node);
1453
1466
  DEFAULT_XCM_VERSION = 3;
1454
- _context17.next = 8;
1467
+ _context17.next = 9;
1455
1468
  return (_this$api$getUnsafeAp = this.api.getUnsafeApi().apis.DryRunApi).dry_run_call.apply(_this$api$getUnsafeAp, [{
1456
1469
  type: 'system',
1457
1470
  value: {
@@ -1459,11 +1472,11 @@ var PapiApi = /*#__PURE__*/function () {
1459
1472
  value: address
1460
1473
  }
1461
1474
  }, tx.decodedCall].concat(_toConsumableArray(needsVersionParam ? [DEFAULT_XCM_VERSION] : [])));
1462
- case 8:
1475
+ case 9:
1463
1476
  result = _context17.sent;
1464
1477
  isSuccess = result.success && result.value.execution_result.success;
1465
1478
  if (isSuccess) {
1466
- _context17.next = 14;
1479
+ _context17.next = 15;
1467
1480
  break;
1468
1481
  }
1469
1482
  errorValue = result === null || result === void 0 || (_result$value = result.value) === null || _result$value === void 0 || (_result$value = _result$value.execution_result) === null || _result$value === void 0 || (_result$value = _result$value.value) === null || _result$value === void 0 || (_result$value = _result$value.error) === null || _result$value === void 0 ? void 0 : _result$value.value;
@@ -1472,10 +1485,10 @@ var PapiApi = /*#__PURE__*/function () {
1472
1485
  success: false,
1473
1486
  failureReason: failureReason
1474
1487
  }));
1475
- case 14:
1476
- _context17.next = 16;
1488
+ case 15:
1489
+ _context17.next = 17;
1477
1490
  return this.calculateTransactionFee(tx, address);
1478
- case 16:
1491
+ case 17:
1479
1492
  executionFee = _context17.sent;
1480
1493
  fee = sdkCore.computeFeeFromDryRun(result, node, executionFee, isFeeAsset);
1481
1494
  actualWeight = result.value.execution_result.value.actual_weight;
@@ -1492,7 +1505,7 @@ var PapiApi = /*#__PURE__*/function () {
1492
1505
  forwardedXcms: forwardedXcms,
1493
1506
  destParaId: destParaId
1494
1507
  }));
1495
- case 23:
1508
+ case 24:
1496
1509
  case "end":
1497
1510
  return _context17.stop();
1498
1511
  }
@@ -1539,10 +1552,10 @@ var PapiApi = /*#__PURE__*/function () {
1539
1552
  emitted = result.value.emitted_events; // We want to look for the last event
1540
1553
  reversedEvents = _toConsumableArray(emitted).reverse();
1541
1554
  palletsWithIssued = ['Balances', 'ForeignAssets', 'Assets'];
1542
- isFeeAsset = origin === 'AssetHubPolkadot' && feeAsset && sdkCore.isAssetEqual(feeAsset, asset);
1555
+ isFeeAsset = origin === 'AssetHubPolkadot' && feeAsset && asset && sdkCore.isAssetEqual(feeAsset, asset);
1543
1556
  feeEvent = (_ref0 = (_ref1 = (_ref10 = (_ref11 = isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
1544
1557
  return event.type === 'ForeignAssets' && event.value.type === 'Issued';
1545
- }) : undefined) !== null && _ref11 !== void 0 ? _ref11 : origin === 'Mythos' ? reversedEvents.find(function (event) {
1558
+ }) : undefined) !== null && _ref11 !== void 0 ? _ref11 : origin === 'Mythos' || node === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? reversedEvents.find(function (event) {
1546
1559
  return event.type === 'AssetConversion' && event.value.type === 'SwapCreditExecuted';
1547
1560
  }) : undefined) !== null && _ref10 !== void 0 ? _ref10 :
1548
1561
  // Prefer an Issued event
package/dist/index.mjs CHANGED
@@ -510,6 +510,13 @@ var _transform = function transform(obj) {
510
510
  type: key,
511
511
  value: checkAndConvertToNumberOrBigInt(value)
512
512
  };
513
+ } else if (key === 'GlobalConsensus' && _typeof(value) === 'object' && ('polkadot' in value || 'kusama' in value)) {
514
+ return {
515
+ type: key,
516
+ value: {
517
+ type: 'polkadot' in value ? 'Polkadot' : 'Kusama'
518
+ }
519
+ };
513
520
  } else if (key === 'PalletInstance' || key === 'GeneralIndex') {
514
521
  return {
515
522
  type: key,
@@ -1091,6 +1098,11 @@ var PapiApi = /*#__PURE__*/function () {
1091
1098
  dkLen: 32
1092
1099
  })));
1093
1100
  }
1101
+ }, {
1102
+ key: "getMethod",
1103
+ value: function getMethod(tx) {
1104
+ return tx.decodedCall.value.value;
1105
+ }
1094
1106
  }, {
1095
1107
  key: "calculateTransactionFee",
1096
1108
  value: function () {
@@ -1436,7 +1448,7 @@ var PapiApi = /*#__PURE__*/function () {
1436
1448
  value: function () {
1437
1449
  var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17(_ref6) {
1438
1450
  var _this$api$getUnsafeAp;
1439
- var tx, address, node, isFeeAsset, supportsDryRunApi, needsVersionParam, DEFAULT_XCM_VERSION, result, isSuccess, _result$value, _ref7, _ref8, _errorValue$value$typ, _errorValue$value, _result$value2, errorValue, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
1451
+ var tx, address, node, isFeeAsset, supportsDryRunApi, nodesRequiringVersionParam, needsVersionParam, DEFAULT_XCM_VERSION, result, isSuccess, _result$value, _ref7, _ref8, _errorValue$value$typ, _errorValue$value, _result$value2, errorValue, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
1440
1452
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1441
1453
  while (1) switch (_context17.prev = _context17.next) {
1442
1454
  case 0:
@@ -1448,9 +1460,10 @@ var PapiApi = /*#__PURE__*/function () {
1448
1460
  }
1449
1461
  throw new NodeNotSupportedError("DryRunApi is not available on node ".concat(node));
1450
1462
  case 4:
1451
- needsVersionParam = node === 'BifrostPolkadot' || node === 'BifrostKusama' || node === 'AssetHubKusama' || node === 'Kusama' || node === 'Polimec';
1463
+ nodesRequiringVersionParam = ['BifrostPolkadot', 'BifrostKusama', 'AssetHubKusama', 'AssetHubPolkadot', 'Kusama', 'Polkadot', 'Polimec'];
1464
+ needsVersionParam = nodesRequiringVersionParam.includes(node);
1452
1465
  DEFAULT_XCM_VERSION = 3;
1453
- _context17.next = 8;
1466
+ _context17.next = 9;
1454
1467
  return (_this$api$getUnsafeAp = this.api.getUnsafeApi().apis.DryRunApi).dry_run_call.apply(_this$api$getUnsafeAp, [{
1455
1468
  type: 'system',
1456
1469
  value: {
@@ -1458,11 +1471,11 @@ var PapiApi = /*#__PURE__*/function () {
1458
1471
  value: address
1459
1472
  }
1460
1473
  }, tx.decodedCall].concat(_toConsumableArray(needsVersionParam ? [DEFAULT_XCM_VERSION] : [])));
1461
- case 8:
1474
+ case 9:
1462
1475
  result = _context17.sent;
1463
1476
  isSuccess = result.success && result.value.execution_result.success;
1464
1477
  if (isSuccess) {
1465
- _context17.next = 14;
1478
+ _context17.next = 15;
1466
1479
  break;
1467
1480
  }
1468
1481
  errorValue = result === null || result === void 0 || (_result$value = result.value) === null || _result$value === void 0 || (_result$value = _result$value.execution_result) === null || _result$value === void 0 || (_result$value = _result$value.value) === null || _result$value === void 0 || (_result$value = _result$value.error) === null || _result$value === void 0 ? void 0 : _result$value.value;
@@ -1471,10 +1484,10 @@ var PapiApi = /*#__PURE__*/function () {
1471
1484
  success: false,
1472
1485
  failureReason: failureReason
1473
1486
  }));
1474
- case 14:
1475
- _context17.next = 16;
1487
+ case 15:
1488
+ _context17.next = 17;
1476
1489
  return this.calculateTransactionFee(tx, address);
1477
- case 16:
1490
+ case 17:
1478
1491
  executionFee = _context17.sent;
1479
1492
  fee = computeFeeFromDryRun(result, node, executionFee, isFeeAsset);
1480
1493
  actualWeight = result.value.execution_result.value.actual_weight;
@@ -1491,7 +1504,7 @@ var PapiApi = /*#__PURE__*/function () {
1491
1504
  forwardedXcms: forwardedXcms,
1492
1505
  destParaId: destParaId
1493
1506
  }));
1494
- case 23:
1507
+ case 24:
1495
1508
  case "end":
1496
1509
  return _context17.stop();
1497
1510
  }
@@ -1538,10 +1551,10 @@ var PapiApi = /*#__PURE__*/function () {
1538
1551
  emitted = result.value.emitted_events; // We want to look for the last event
1539
1552
  reversedEvents = _toConsumableArray(emitted).reverse();
1540
1553
  palletsWithIssued = ['Balances', 'ForeignAssets', 'Assets'];
1541
- isFeeAsset = origin === 'AssetHubPolkadot' && feeAsset && isAssetEqual(feeAsset, asset);
1554
+ isFeeAsset = origin === 'AssetHubPolkadot' && feeAsset && asset && isAssetEqual(feeAsset, asset);
1542
1555
  feeEvent = (_ref0 = (_ref1 = (_ref10 = (_ref11 = isFeeAsset ? _toConsumableArray(emitted).find(function (event) {
1543
1556
  return event.type === 'ForeignAssets' && event.value.type === 'Issued';
1544
- }) : undefined) !== null && _ref11 !== void 0 ? _ref11 : origin === 'Mythos' ? reversedEvents.find(function (event) {
1557
+ }) : undefined) !== null && _ref11 !== void 0 ? _ref11 : origin === 'Mythos' || node === 'AssetHubPolkadot' && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== 'DOT' ? reversedEvents.find(function (event) {
1545
1558
  return event.type === 'AssetConversion' && event.value.type === 'SwapCreditExecuted';
1546
1559
  }) : undefined) !== null && _ref10 !== void 0 ? _ref10 :
1547
1560
  // Prefer an Issued event
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk",
3
- "version": "10.0.2",
3
+ "version": "10.1.0",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,7 +27,7 @@
27
27
  "ethers": "^6.13.7",
28
28
  "quick-lru": "^7.0.1",
29
29
  "viem": "^2.28.1",
30
- "@paraspell/sdk-core": "10.0.2"
30
+ "@paraspell/sdk-core": "10.1.0"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "polkadot-api": ">= 1.10.2 < 2"