@paraspell/sdk-dedot 13.0.1 → 13.2.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/README.md CHANGED
@@ -13,9 +13,6 @@
13
13
  <a href="https://github.com/paraspell/xcm-sdk/actions">
14
14
  <img alt="build" src="https://github.com/paraspell/xcm-tools/actions/workflows/ci.yml/badge.svg" />
15
15
  </a>
16
- <a href="https://snyk.io/test/github/paraspell/sdk">
17
- <img alt="snyk" src="https://snyk.io/test/github/paraspell/sdk/badge.svg" />
18
- </a>
19
16
  </p>
20
17
  <p>Supporting every XCM Active Parachain <a href = "https://paraspell.github.io/docs/supported.html"\>[list]</p>
21
18
  <p>SDK documentation <a href = "https://paraspell.github.io/docs/" \>[here]</p>
@@ -597,6 +594,8 @@ console.log(CHAINS)
597
594
 
598
595
  - Run unit tests using `pnpm test`
599
596
 
597
+ - Run end-to-end tests (SDK+SWAP) using `pnpm test:e2e`
598
+
600
599
  - Run all core tests and checks using `pnpm runAll`
601
600
 
602
601
  > [!NOTE]
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getEvmPrivateKeyHex, getNativeAssetSymbol, getOtherAssets, NumberFormatError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProviders, isSenderSigner, PolkadotApi, resolveChainApi, DEFAULT_TTL_MS, isExternalChain, UnsupportedOperationError, findAssetInfoOrThrow, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, localizeLocation, isAssetXcEqual, addXcmVersionHeader, RELAY_LOCATION, getRelayChainOf, replaceBigInt, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, 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, findNativeAssetInfoOrThrow, getChainProviders, isSenderSigner, PolkadotApi, resolveChainApi, DEFAULT_TTL_MS, isExternalChain, UnsupportedOperationError, findAssetInfoOrThrow, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, localizeLocation, createAssetId, addXcmVersionHeader, isAssetXcEqual, RELAY_LOCATION, getRelayChainOf, replaceBigInt, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, 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 } from 'dedot/utils';
4
4
  import { Keyring } from '@polkadot/keyring';
@@ -797,8 +797,8 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
797
797
  this._ttlMs = clientTtlMs;
798
798
  this._chain = chain;
799
799
  _context3.n = 2;
800
- return resolveChainApi(this._config, chain, function (wsUrl, c) {
801
- return _this2.createApiInstance(wsUrl, c);
800
+ return resolveChainApi(this._config, chain, function (wsUrl) {
801
+ return leaseClient(wsUrl, _this2._ttlMs);
802
802
  });
803
803
  case 2:
804
804
  this._api = _context3.v;
@@ -814,8 +814,8 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
814
814
  }()
815
815
  }, {
816
816
  key: "createApiInstance",
817
- value: function createApiInstance(wsUrl, _chain) {
818
- return leaseClient(wsUrl, this._ttlMs, false);
817
+ value: function createApiInstance(wsUrl) {
818
+ return leaseClient(wsUrl, this._ttlMs);
819
819
  }
820
820
  }, {
821
821
  key: "accountToHex",
@@ -1293,7 +1293,7 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
1293
1293
  forwardedXcms = result.value.forwardedXcms.length > 0 ? result.value.forwardedXcms[0] : [];
1294
1294
  actualWeight = (_execRes$actualWeight = execRes === null || execRes === void 0 ? void 0 : execRes.actualWeight) !== null && _execRes$actualWeight !== void 0 ? _execRes$actualWeight : execRes === null || execRes === void 0 ? void 0 : execRes.actual_weight;
1295
1295
  weight = actualWeight ? actualWeight : undefined;
1296
- destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === "Here" ? 0 : forwardedXcms[0].value.interior.value[0].value;
1296
+ destParaId = this.extractDestParaId(forwardedXcms);
1297
1297
  localXcm = resValue === null || resValue === void 0 ? void 0 : resValue.localXcm;
1298
1298
  USE_XCM_PAYMENT_API_CHAINS = ["Astar"];
1299
1299
  if (!(hasXcmPaymentApiSupport(chain) && localXcm && (feeAsset || USE_XCM_PAYMENT_API_CHAINS.includes(chain) || chain.startsWith("AssetHub") && destination === "Ethereum") || resolvedFeeAsset.isCustomAsset)) {
@@ -1370,7 +1370,8 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
1370
1370
  queryWeight,
1371
1371
  weight,
1372
1372
  assetLocalizedLoc,
1373
- transformedAssetLoc,
1373
+ assetId,
1374
+ transformedAssetId,
1374
1375
  execFeeRes,
1375
1376
  execFee,
1376
1377
  bridgeHubExecFee,
@@ -1416,12 +1417,10 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
1416
1417
  case 3:
1417
1418
  weight = _t5;
1418
1419
  assetLocalizedLoc = localizeLocation(chain, asset.location);
1419
- transformedAssetLoc = _transform(assetLocalizedLoc);
1420
+ assetId = createAssetId(version, assetLocalizedLoc);
1421
+ transformedAssetId = _transform(addXcmVersionHeader(assetId, version));
1420
1422
  _context1.n = 4;
1421
- return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weight, {
1422
- type: version,
1423
- value: transformedAssetLoc
1424
- });
1423
+ return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weight, transformedAssetId);
1425
1424
  case 4:
1426
1425
  execFeeRes = _context1.v;
1427
1426
  execFee = typeof (execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.value) === "bigint" ? execFeeRes.value : 0n;
@@ -1455,7 +1454,7 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
1455
1454
  value: function () {
1456
1455
  var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(chain, forwardedXcm, asset, assetLocalizedLoc, version) {
1457
1456
  var _deliveryFeeRes, _assets$0$fun$value, _assets$;
1458
- var usedThirdParam, deliveryFeeRes, baseArgs, _this$api$call$xcmPay, message, _this$api$call$xcmPay2, versionedAssetLoc, assets, deliveryFeeResolved, nativeAsset, res, _t6;
1457
+ var usedThirdParam, deliveryFeeRes, baseArgs, _this$api$call$xcmPay, message, _this$api$call$xcmPay2, assetId, versionedAssetLoc, assets, deliveryFeeResolved, nativeAsset, res, _t6;
1459
1458
  return _regenerator().w(function (_context10) {
1460
1459
  while (1) switch (_context10.p = _context10.n) {
1461
1460
  case 0:
@@ -1481,7 +1480,8 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
1481
1480
  break;
1482
1481
  }
1483
1482
  usedThirdParam = true;
1484
- versionedAssetLoc = addXcmVersionHeader(assetLocalizedLoc, version);
1483
+ assetId = createAssetId(version, assetLocalizedLoc);
1484
+ versionedAssetLoc = _transform(addXcmVersionHeader(assetId, version));
1485
1485
  _context10.n = 4;
1486
1486
  return (_this$api$call$xcmPay2 = this.api.call.xcmPaymentApi).queryDeliveryFees.apply(_this$api$call$xcmPay2, baseArgs.concat([versionedAssetLoc]));
1487
1487
  case 4:
@@ -1589,6 +1589,14 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
1589
1589
  }
1590
1590
  return getXcmWeight;
1591
1591
  }()
1592
+ }, {
1593
+ key: "extractDestParaId",
1594
+ value: function extractDestParaId(forwardedXcms) {
1595
+ var _first$value, _interior$value$0$val, _interior$value, _interior$value2;
1596
+ var first = forwardedXcms[0];
1597
+ var interior = first === null || first === void 0 || (_first$value = first.value) === null || _first$value === void 0 ? void 0 : _first$value.interior;
1598
+ return forwardedXcms.length === 0 ? undefined : (interior === null || interior === void 0 ? void 0 : interior.type) === "Here" ? 0 : (_interior$value$0$val = interior === null || interior === void 0 || (_interior$value = interior.value) === null || _interior$value === void 0 || (_interior$value = _interior$value[0]) === null || _interior$value === void 0 ? void 0 : _interior$value.value) !== null && _interior$value$0$val !== void 0 ? _interior$value$0$val : interior === null || interior === void 0 || (_interior$value2 = interior.value) === null || _interior$value2 === void 0 ? void 0 : _interior$value2.value;
1599
+ }
1592
1600
  }, {
1593
1601
  key: "getDryRunXcm",
1594
1602
  value: function () {
@@ -1626,7 +1634,7 @@ var DedotApi = /*#__PURE__*/function (_PolkadotApi) {
1626
1634
  actualWeight = executionResult.value.used;
1627
1635
  weight = actualWeight ? actualWeight : undefined;
1628
1636
  forwardedXcms = result.value.forwardedXcms.length > 0 ? result.value.forwardedXcms[0] : [];
1629
- destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === "Here" ? 0 : forwardedXcms[0].value.interior.value[0].value;
1637
+ destParaId = this.extractDestParaId(forwardedXcms);
1630
1638
  if (!hasXcmPaymentApiSupport(chain)) {
1631
1639
  _context13.n = 6;
1632
1640
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-dedot",
3
- "version": "13.0.1",
3
+ "version": "13.2.0",
4
4
  "description": "Dedot-based SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,7 +23,7 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@paraspell/sdk-core": "13.0.1"
26
+ "@paraspell/sdk-core": "13.2.0"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "dedot": ">= 1.2.0",
@@ -52,6 +52,7 @@
52
52
  "test": "vitest run",
53
53
  "test:cov": "vitest run --coverage",
54
54
  "test:watch": "vitest",
55
- "runAll": "pnpm compile && pnpm format:write && pnpm lint && pnpm test"
55
+ "runAll": "pnpm compile && pnpm format:write && pnpm lint && pnpm test",
56
+ "test:e2e": "vitest run --config ./vitest.config.e2e.ts --sequence.concurrent"
56
57
  }
57
58
  }