@paraspell/sdk-dedot 14.5.3 → 14.6.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.
Files changed (2) hide show
  1. package/dist/index.mjs +21 -26
  2. package/package.json +9 -9
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getEvmPrivateKeyHex, getNativeAssetSymbol, getOtherAssets, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, RoutingResolutionError, addXcmVersionHeader, createBridgedXcmPrefix, isCustomChain, isSenderSigner, PolkadotApi, UnsupportedOperationError, buildDryRunError, resolveModuleError, RuntimeApiUnavailableError, wrapTxBypass, localizeLocation, createAssetId, isAssetEqual, RELAY_LOCATION, SubmitTransactionError, replaceBigInt, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, findAssetInfo, getAllAssetsSymbols, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, isChainEvm, convertSs58 as convertSs58$1, Builder as Builder$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
1
+ import { getEvmPrivateKeyHex, getNativeAssetSymbol, getOtherAssets, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, RoutingResolutionError, addXcmVersionHeader, createBridgedXcmPrefix, isCustomChain, isSenderSigner, PolkadotApi, UnsupportedOperationError, buildDryRunError, resolveModuleError, RuntimeApiUnavailableError, wrapTxBypass, localizeLocation, createAssetId, isAssetEqual, RELAY_LOCATION, RuntimeApiError, SubmitTransactionError, replaceBigInt, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, findAssetInfo, getAllAssetsSymbols, getAssets, getAssetsObject, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, isChainEvm, convertSs58 as convertSs58$1, Builder as Builder$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
2
2
  export * from '@paraspell/sdk-core';
3
3
  import { stringPascalCase, isEvmAddress, decodeAddress, isHex, u8aToHex, hexToU8a, stringToU8a, blake2AsHex, xxhashAsHex } from 'dedot/utils';
4
4
  import { ParaSpellError, snakeToCamel, lowercaseFirstLetter } from '@paraspell/sdk-common';
@@ -296,7 +296,7 @@ function _toPrimitive(t, r) {
296
296
  if ("object" != typeof i) return i;
297
297
  throw new TypeError("@@toPrimitive must return a primitive value.");
298
298
  }
299
- return (String )(t);
299
+ return ("string" === r ? String : Number)(t);
300
300
  }
301
301
  function _toPropertyKey(t) {
302
302
  var i = _toPrimitive(t, "string");
@@ -411,15 +411,12 @@ var getLocationTokenId = function getLocationTokenId(location, chain) {
411
411
  };
412
412
 
413
413
  var computeOriginFee = function computeOriginFee(dryRun, chain, executionFee) {
414
- var isFeeAsset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
415
414
  // Extract delivery fees from emitted events
416
415
  var deliveryFees = [];
417
- var assetConversionFee = 0n;
418
416
  var _iterator = _createForOfIteratorHelper(dryRun.value.emittedEvents),
419
417
  _step;
420
418
  try {
421
419
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
422
- var _e$value, _e$value2;
423
420
  var e = _step.value;
424
421
  var isXcmEvent = ["XcmPallet", "PolkadotXcm", "CumulusXcm"].includes(e.pallet);
425
422
  var isFeesPaid = e.palletEvent.name === "FeesPaid";
@@ -444,26 +441,19 @@ var computeOriginFee = function computeOriginFee(dryRun, chain, executionFee) {
444
441
  _iterator2.f();
445
442
  }
446
443
  }
447
- if (isFeeAsset && e.type === "AssetConversion" && ((_e$value = e.value) === null || _e$value === void 0 ? void 0 : _e$value.type) === "SwapCreditExecuted" && (_e$value2 = e.value) !== null && _e$value2 !== void 0 && _e$value2.value && e.value.value.amount_in !== undefined && e.value.value.amount_in !== null) {
448
- assetConversionFee += e.value.value.amount_in;
449
- }
450
444
  }
451
445
  } catch (err) {
452
446
  _iterator.e(err);
453
447
  } finally {
454
448
  _iterator.f();
455
449
  }
456
- if (isFeeAsset && assetConversionFee > 0n) {
457
- return assetConversionFee;
458
- } else {
459
- var nativeAssetSymbol = getNativeAssetSymbol(chain);
460
- var totalDeliveryFees = deliveryFees.filter(function (df) {
461
- return df.tokenSymbol === nativeAssetSymbol;
462
- }).reduce(function (acc, df) {
463
- return acc + df.plancks;
464
- }, 0n);
465
- return totalDeliveryFees + executionFee;
466
- }
450
+ var nativeAssetSymbol = getNativeAssetSymbol(chain);
451
+ var totalDeliveryFees = deliveryFees.filter(function (df) {
452
+ return df.tokenSymbol === nativeAssetSymbol;
453
+ }).reduce(function (acc, df) {
454
+ return acc + df.plancks;
455
+ }, 0n);
456
+ return totalDeliveryFees + executionFee;
467
457
  };
468
458
 
469
459
  var isValidSubstrateAddress = function isValidSubstrateAddress(address) {
@@ -1515,8 +1505,7 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
1515
1505
  key: "getXcmWeight",
1516
1506
  value: function () {
1517
1507
  var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(xcm) {
1518
- var _okValue$refTime, _okValue$proofSize;
1519
- var result, okValue;
1508
+ var result, _result$value5, refTime, proofSize;
1520
1509
  return _regenerator().w(function (_context10) {
1521
1510
  while (1) switch (_context10.n) {
1522
1511
  case 0:
@@ -1524,10 +1513,16 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
1524
1513
  return this.api.call.xcmPaymentApi.queryXcmWeight(!xcm.type ? _transform(xcm) : xcm);
1525
1514
  case 1:
1526
1515
  result = _context10.v;
1527
- okValue = result === null || result === void 0 ? void 0 : result.value;
1516
+ if (!result.isErr) {
1517
+ _context10.n = 2;
1518
+ break;
1519
+ }
1520
+ throw new RuntimeApiError("Failed to get XCM weight for payment fee calculation. Reason: ".concat(JSON.stringify(result.err)));
1521
+ case 2:
1522
+ _result$value5 = result.value, refTime = _result$value5.refTime, proofSize = _result$value5.proofSize;
1528
1523
  return _context10.a(2, {
1529
- refTime: BigInt((_okValue$refTime = okValue === null || okValue === void 0 ? void 0 : okValue.refTime) !== null && _okValue$refTime !== void 0 ? _okValue$refTime : 0),
1530
- proofSize: BigInt((_okValue$proofSize = okValue === null || okValue === void 0 ? void 0 : okValue.proofSize) !== null && _okValue$proofSize !== void 0 ? _okValue$proofSize : 0)
1524
+ refTime: refTime,
1525
+ proofSize: proofSize
1531
1526
  });
1532
1527
  }
1533
1528
  }, _callee10, this);
@@ -1549,7 +1544,7 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
1549
1544
  key: "getDryRunXcm",
1550
1545
  value: function () {
1551
1546
  var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(_ref1) {
1552
- var _result$value5;
1547
+ var _result$value6;
1553
1548
  var originLocation, xcm, asset, chain, version, supportsDryRunApi, transformedOriginLocation, result, executionResult, isSuccess, failure, actualWeight, weight, forwardedXcms, destParaId, fee;
1554
1549
  return _regenerator().w(function (_context11) {
1555
1550
  while (1) switch (_context11.n) {
@@ -1567,7 +1562,7 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
1567
1562
  return this.api.call.dryRunApi.dryRunXcm(transformedOriginLocation, xcm);
1568
1563
  case 2:
1569
1564
  result = _context11.v;
1570
- executionResult = result === null || result === void 0 || (_result$value5 = result.value) === null || _result$value5 === void 0 ? void 0 : _result$value5.executionResult;
1565
+ executionResult = result === null || result === void 0 || (_result$value6 = result.value) === null || _result$value6 === void 0 ? void 0 : _result$value6.executionResult;
1571
1566
  isSuccess = result.isOk && executionResult.type === "Complete";
1572
1567
  if (isSuccess) {
1573
1568
  _context11.n = 3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-dedot",
3
- "version": "14.5.3",
3
+ "version": "14.6.0",
4
4
  "description": "Dedot-based SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,23 +22,23 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@paraspell/sdk-common": "14.5.3",
26
- "@paraspell/sdk-core": "14.5.3"
25
+ "@paraspell/sdk-common": "14.6.0",
26
+ "@paraspell/sdk-core": "14.6.0"
27
27
  },
28
28
  "peerDependencies": {
29
- "dedot": ">= 1.4.0",
30
- "@polkadot/keyring": ">= 14"
29
+ "@polkadot/keyring": ">= 14",
30
+ "dedot": ">= 1.4.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@babel/plugin-syntax-import-attributes": "^7.29.7",
34
- "@babel/preset-env": "^7.29.7",
34
+ "@babel/preset-env": "^7.29.14",
35
35
  "@codecov/rollup-plugin": "^2.0.1",
36
36
  "@rollup/plugin-babel": "^7.1.0",
37
37
  "@rollup/plugin-json": "^6.1.0",
38
38
  "@rollup/plugin-typescript": "^12.3.1",
39
- "@vitest/coverage-v8": "^5.0.5",
40
- "dotenv": "^18.0.9",
41
- "rollup": "^4.66.0",
39
+ "@vitest/coverage-v8": "^5.1.2",
40
+ "dotenv": "^18.0.10",
41
+ "rollup": "^4.68.8",
42
42
  "rollup-plugin-dts": "^6.5.1"
43
43
  },
44
44
  "scripts": {