@paraspell/sdk-core 8.9.4 → 8.9.5

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
@@ -2685,6 +2685,13 @@ var createBeneficiaryMultiLocation = function createBeneficiaryMultiLocation(_re
2685
2685
  }
2686
2686
  };
2687
2687
 
2688
+ /**
2689
+ * This function transforms a multiLocation by removing the `Parachain` junction
2690
+ * if it exists and setting the `parents` to `0`.
2691
+ *
2692
+ * @param multiLocation - The multiLocation to transform
2693
+ * @returns The transformed multiLocation
2694
+ */
2688
2695
  var transformMultiLocation = function transformMultiLocation(multiLocation) {
2689
2696
  var newInterior;
2690
2697
  if (multiLocation.interior === 'Here') {
@@ -3121,10 +3128,10 @@ var transferRelayToPara = /*#__PURE__*/function () {
3121
3128
  };
3122
3129
  }();
3123
3130
 
3124
- var determineAssetCheckEnabled = function determineAssetCheckEnabled(origin, currency, isBridge) {
3131
+ var determineAssetCheckEnabled = function determineAssetCheckEnabled(origin, currency) {
3125
3132
  if (isRelayChain(origin)) return true;
3126
3133
  var originNode = getNode(origin);
3127
- return 'multiasset' in currency || 'multilocation' in currency && assets.isOverrideMultiLocationSpecifier(currency.multilocation) || isBridge ? false : originNode.assetCheckEnabled;
3134
+ return 'multiasset' in currency || 'multilocation' in currency && assets.isOverrideMultiLocationSpecifier(currency.multilocation) ? false : originNode.assetCheckEnabled;
3128
3135
  };
3129
3136
 
3130
3137
  var isBridgeTransfer = function isBridgeTransfer(origin, destination) {
@@ -3402,7 +3409,7 @@ var send = /*#__PURE__*/function () {
3402
3409
  throw new Error('Relay chain to relay chain transfers are not supported.');
3403
3410
  case 7:
3404
3411
  isBridge = isBridgeTransfer(origin, destination);
3405
- assetCheckEnabled = determineAssetCheckEnabled(origin, currency, isBridge);
3412
+ assetCheckEnabled = determineAssetCheckEnabled(origin, currency);
3406
3413
  validateAssetSpecifiers(assetCheckEnabled, currency);
3407
3414
  asset = resolveAsset(currency, origin, destination, assetCheckEnabled);
3408
3415
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
@@ -4370,18 +4377,12 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
4370
4377
  key: "createCurrencySpec",
4371
4378
  value: function createCurrencySpec(amount, scenario, version, asset) {
4372
4379
  if (scenario === 'ParaToPara') {
4373
- var multiLocation = asset ? asset.multiLocation : undefined;
4374
- return createVersionedMultiAssets(version, amount, multiLocation !== null && multiLocation !== void 0 ? multiLocation : {
4375
- parents: sdkCommon.Parents.ZERO,
4376
- interior: {
4377
- X2: [{
4378
- PalletInstance: 50
4379
- }, {
4380
- // TODO: Handle missing assedId
4381
- GeneralIndex: asset && assets.isForeignAsset(asset) && asset.assetId ? asset.assetId : 0
4382
- }]
4383
- }
4384
- });
4380
+ var multiLocation = asset === null || asset === void 0 ? void 0 : asset.multiLocation;
4381
+ if (!multiLocation) {
4382
+ throw new assets.InvalidCurrencyError('Asset does not have a multiLocation defined');
4383
+ }
4384
+ var transformedMultiLocation = sdkCommon.hasJunction(multiLocation, 'Parachain', 1000) ? transformMultiLocation(multiLocation) : multiLocation;
4385
+ return createVersionedMultiAssets(version, amount, transformedMultiLocation);
4385
4386
  } else {
4386
4387
  return _superPropGet(AssetHubPolkadot, "createCurrencySpec", this, 3)([amount, scenario, version, asset]);
4387
4388
  }
@@ -5331,19 +5332,26 @@ var Manta = /*#__PURE__*/function (_ParachainNode) {
5331
5332
  }
5332
5333
  _inherits(Manta, _ParachainNode);
5333
5334
  return _createClass(Manta, [{
5334
- key: "transferXTokens",
5335
- value: function transferXTokens(input) {
5336
- var asset = input.asset;
5335
+ key: "getAssetId",
5336
+ value: function getAssetId(asset) {
5337
+ if (asset.symbol === this.getNativeAssetSymbol()) return Manta.NATIVE_ASSET_ID;
5337
5338
  if (!assets.isForeignAsset(asset) || !asset.assetId) {
5338
5339
  throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
5339
5340
  }
5341
+ return BigInt(asset.assetId);
5342
+ }
5343
+ }, {
5344
+ key: "transferXTokens",
5345
+ value: function transferXTokens(input) {
5346
+ var asset = input.asset;
5340
5347
  var currencySelection = {
5341
- MantaCurrency: BigInt(asset.assetId)
5348
+ MantaCurrency: this.getAssetId(asset)
5342
5349
  };
5343
5350
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
5344
5351
  }
5345
5352
  }]);
5346
5353
  }(ParachainNode);
5354
+ Manta.NATIVE_ASSET_ID = 1n;
5347
5355
 
5348
5356
  var Moonbeam = /*#__PURE__*/function (_ParachainNode) {
5349
5357
  function Moonbeam() {
package/dist/index.d.ts CHANGED
@@ -1137,7 +1137,9 @@ declare class Kintsugi<TApi, TRes> extends ParachainNode<TApi, TRes> implements
1137
1137
  }
1138
1138
 
1139
1139
  declare class Manta<TApi, TRes> extends ParachainNode<TApi, TRes> implements IXTokensTransfer {
1140
+ static readonly NATIVE_ASSET_ID = 1n;
1140
1141
  constructor();
1142
+ private getAssetId;
1141
1143
  transferXTokens<TApi, TRes>(input: TXTokensTransferOptions<TApi, TRes>): TRes;
1142
1144
  }
1143
1145
 
@@ -1450,6 +1452,13 @@ declare const getNode: <TApi, TRes, T extends keyof ReturnType<typeof nodes>>(no
1450
1452
 
1451
1453
  declare const createBeneficiaryMultiLocation: <TApi, TRes>({ api, scenario, pallet, recipientAddress, version, paraId }: TCreateBeneficiaryOptions<TApi, TRes>) => TMultiLocation;
1452
1454
 
1455
+ /**
1456
+ * This function transforms a multiLocation by removing the `Parachain` junction
1457
+ * if it exists and setting the `parents` to `0`.
1458
+ *
1459
+ * @param multiLocation - The multiLocation to transform
1460
+ * @returns The transformed multiLocation
1461
+ */
1453
1462
  declare const transformMultiLocation: (multiLocation: TMultiLocation) => TMultiLocation;
1454
1463
 
1455
1464
  declare const resolveParaId: (paraId: number | undefined, destination: TDestination) => number | undefined;
package/dist/index.mjs CHANGED
@@ -2686,6 +2686,13 @@ var createBeneficiaryMultiLocation = function createBeneficiaryMultiLocation(_re
2686
2686
  }
2687
2687
  };
2688
2688
 
2689
+ /**
2690
+ * This function transforms a multiLocation by removing the `Parachain` junction
2691
+ * if it exists and setting the `parents` to `0`.
2692
+ *
2693
+ * @param multiLocation - The multiLocation to transform
2694
+ * @returns The transformed multiLocation
2695
+ */
2689
2696
  var transformMultiLocation = function transformMultiLocation(multiLocation) {
2690
2697
  var newInterior;
2691
2698
  if (multiLocation.interior === 'Here') {
@@ -3122,10 +3129,10 @@ var transferRelayToPara = /*#__PURE__*/function () {
3122
3129
  };
3123
3130
  }();
3124
3131
 
3125
- var determineAssetCheckEnabled = function determineAssetCheckEnabled(origin, currency, isBridge) {
3132
+ var determineAssetCheckEnabled = function determineAssetCheckEnabled(origin, currency) {
3126
3133
  if (isRelayChain(origin)) return true;
3127
3134
  var originNode = getNode(origin);
3128
- return 'multiasset' in currency || 'multilocation' in currency && isOverrideMultiLocationSpecifier(currency.multilocation) || isBridge ? false : originNode.assetCheckEnabled;
3135
+ return 'multiasset' in currency || 'multilocation' in currency && isOverrideMultiLocationSpecifier(currency.multilocation) ? false : originNode.assetCheckEnabled;
3129
3136
  };
3130
3137
 
3131
3138
  var isBridgeTransfer = function isBridgeTransfer(origin, destination) {
@@ -3403,7 +3410,7 @@ var send = /*#__PURE__*/function () {
3403
3410
  throw new Error('Relay chain to relay chain transfers are not supported.');
3404
3411
  case 7:
3405
3412
  isBridge = isBridgeTransfer(origin, destination);
3406
- assetCheckEnabled = determineAssetCheckEnabled(origin, currency, isBridge);
3413
+ assetCheckEnabled = determineAssetCheckEnabled(origin, currency);
3407
3414
  validateAssetSpecifiers(assetCheckEnabled, currency);
3408
3415
  asset = resolveAsset(currency, origin, destination, assetCheckEnabled);
3409
3416
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
@@ -4371,18 +4378,12 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
4371
4378
  key: "createCurrencySpec",
4372
4379
  value: function createCurrencySpec(amount, scenario, version, asset) {
4373
4380
  if (scenario === 'ParaToPara') {
4374
- var multiLocation = asset ? asset.multiLocation : undefined;
4375
- return createVersionedMultiAssets(version, amount, multiLocation !== null && multiLocation !== void 0 ? multiLocation : {
4376
- parents: Parents.ZERO,
4377
- interior: {
4378
- X2: [{
4379
- PalletInstance: 50
4380
- }, {
4381
- // TODO: Handle missing assedId
4382
- GeneralIndex: asset && isForeignAsset(asset) && asset.assetId ? asset.assetId : 0
4383
- }]
4384
- }
4385
- });
4381
+ var multiLocation = asset === null || asset === void 0 ? void 0 : asset.multiLocation;
4382
+ if (!multiLocation) {
4383
+ throw new InvalidCurrencyError('Asset does not have a multiLocation defined');
4384
+ }
4385
+ var transformedMultiLocation = hasJunction(multiLocation, 'Parachain', 1000) ? transformMultiLocation(multiLocation) : multiLocation;
4386
+ return createVersionedMultiAssets(version, amount, transformedMultiLocation);
4386
4387
  } else {
4387
4388
  return _superPropGet(AssetHubPolkadot, "createCurrencySpec", this, 3)([amount, scenario, version, asset]);
4388
4389
  }
@@ -5332,19 +5333,26 @@ var Manta = /*#__PURE__*/function (_ParachainNode) {
5332
5333
  }
5333
5334
  _inherits(Manta, _ParachainNode);
5334
5335
  return _createClass(Manta, [{
5335
- key: "transferXTokens",
5336
- value: function transferXTokens(input) {
5337
- var asset = input.asset;
5336
+ key: "getAssetId",
5337
+ value: function getAssetId(asset) {
5338
+ if (asset.symbol === this.getNativeAssetSymbol()) return Manta.NATIVE_ASSET_ID;
5338
5339
  if (!isForeignAsset(asset) || !asset.assetId) {
5339
5340
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
5340
5341
  }
5342
+ return BigInt(asset.assetId);
5343
+ }
5344
+ }, {
5345
+ key: "transferXTokens",
5346
+ value: function transferXTokens(input) {
5347
+ var asset = input.asset;
5341
5348
  var currencySelection = {
5342
- MantaCurrency: BigInt(asset.assetId)
5349
+ MantaCurrency: this.getAssetId(asset)
5343
5350
  };
5344
5351
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
5345
5352
  }
5346
5353
  }]);
5347
5354
  }(ParachainNode);
5355
+ Manta.NATIVE_ASSET_ID = 1n;
5348
5356
 
5349
5357
  var Moonbeam = /*#__PURE__*/function (_ParachainNode) {
5350
5358
  function Moonbeam() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "8.9.4",
3
+ "version": "8.9.5",
4
4
  "description": "SDK core for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,9 +25,9 @@
25
25
  "dependencies": {
26
26
  "ethers": "^6.13.5",
27
27
  "viem": "^2.23.15",
28
- "@paraspell/sdk-common": "8.9.4",
29
- "@paraspell/pallets": "8.9.4",
30
- "@paraspell/assets": "8.9.4"
28
+ "@paraspell/pallets": "8.9.5",
29
+ "@paraspell/sdk-common": "8.9.5",
30
+ "@paraspell/assets": "8.9.5"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@babel/plugin-syntax-import-attributes": "^7.26.0",