@paraspell/sdk-core 8.9.3 → 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() {
@@ -5537,7 +5545,7 @@ var Peaq = /*#__PURE__*/function (_ParachainNode) {
5537
5545
  var Pendulum = /*#__PURE__*/function (_ParachainNode) {
5538
5546
  function Pendulum() {
5539
5547
  _classCallCheck(this, Pendulum);
5540
- return _callSuper(this, Pendulum, ['Pendulum', 'pendulum', 'polkadot', exports.Version.V3]);
5548
+ return _callSuper(this, Pendulum, ['Pendulum', 'pendulum', 'polkadot', exports.Version.V2]);
5541
5549
  }
5542
5550
  _inherits(Pendulum, _ParachainNode);
5543
5551
  return _createClass(Pendulum, [{
@@ -5545,25 +5553,21 @@ var Pendulum = /*#__PURE__*/function (_ParachainNode) {
5545
5553
  value: function transferXTokens(input) {
5546
5554
  var scenario = input.scenario,
5547
5555
  asset = input.asset;
5548
- if (scenario !== 'ParaToPara') {
5549
- throw new ScenarioNotSupportedError(this.node, input.scenario);
5550
- }
5551
- if (asset.symbol !== this.getNativeAssetSymbol()) {
5552
- throw new assets.InvalidCurrencyError("Asset ".concat(asset.symbol, " is not supported by node ").concat(this.node, "."));
5556
+ if (scenario === 'ParaToRelay') {
5557
+ throw new ScenarioNotSupportedError(this.node, scenario);
5553
5558
  }
5554
- if (!assets.isForeignAsset(asset)) {
5555
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
5559
+ if (scenario === 'ParaToPara' && asset.symbol === 'DOT') {
5560
+ throw new assets.InvalidCurrencyError('Pendulum does not support DOT transfers');
5556
5561
  }
5557
- var currencySelection = {
5558
- XCM: Number(asset.assetId)
5562
+ var currencySelection = asset.symbol === 'PEN' ? {
5563
+ Native: null
5564
+ } : {
5565
+ XCM: assets.isForeignAsset(asset) ? Number(asset.assetId) : function () {
5566
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
5567
+ }()
5559
5568
  };
5560
5569
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
5561
5570
  }
5562
- }, {
5563
- key: "transferRelayToPara",
5564
- value: function transferRelayToPara() {
5565
- throw new NodeNotSupportedError();
5566
- }
5567
5571
  }]);
5568
5572
  }(ParachainNode);
5569
5573
 
package/dist/index.d.ts CHANGED
@@ -32,6 +32,8 @@ type TForeignOrTokenAsset = TXcmForeignAsset | {
32
32
  type TForeignOrNativeAsset = TXcmForeignAsset | 'Native';
33
33
  type TXcmAsset = {
34
34
  XCM: number | undefined;
35
+ } | {
36
+ Native: null;
35
37
  };
36
38
  type TMantaAsset = {
37
39
  MantaCurrency: bigint | undefined;
@@ -1135,7 +1137,9 @@ declare class Kintsugi<TApi, TRes> extends ParachainNode<TApi, TRes> implements
1135
1137
  }
1136
1138
 
1137
1139
  declare class Manta<TApi, TRes> extends ParachainNode<TApi, TRes> implements IXTokensTransfer {
1140
+ static readonly NATIVE_ASSET_ID = 1n;
1138
1141
  constructor();
1142
+ private getAssetId;
1139
1143
  transferXTokens<TApi, TRes>(input: TXTokensTransferOptions<TApi, TRes>): TRes;
1140
1144
  }
1141
1145
 
@@ -1179,7 +1183,6 @@ declare class Peaq<TApi, TRes> extends ParachainNode<TApi, TRes> implements IXTo
1179
1183
  declare class Pendulum<TApi, TRes> extends ParachainNode<TApi, TRes> implements IXTokensTransfer {
1180
1184
  constructor();
1181
1185
  transferXTokens<TApi, TRes>(input: TXTokensTransferOptions<TApi, TRes>): TRes;
1182
- transferRelayToPara(): TSerializedApiCall;
1183
1186
  }
1184
1187
 
1185
1188
  declare class PeopleKusama<TApi, TRes> extends ParachainNode<TApi, TRes> implements IPolkadotXCMTransfer {
@@ -1449,6 +1452,13 @@ declare const getNode: <TApi, TRes, T extends keyof ReturnType<typeof nodes>>(no
1449
1452
 
1450
1453
  declare const createBeneficiaryMultiLocation: <TApi, TRes>({ api, scenario, pallet, recipientAddress, version, paraId }: TCreateBeneficiaryOptions<TApi, TRes>) => TMultiLocation;
1451
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
+ */
1452
1462
  declare const transformMultiLocation: (multiLocation: TMultiLocation) => TMultiLocation;
1453
1463
 
1454
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() {
@@ -5538,7 +5546,7 @@ var Peaq = /*#__PURE__*/function (_ParachainNode) {
5538
5546
  var Pendulum = /*#__PURE__*/function (_ParachainNode) {
5539
5547
  function Pendulum() {
5540
5548
  _classCallCheck(this, Pendulum);
5541
- return _callSuper(this, Pendulum, ['Pendulum', 'pendulum', 'polkadot', Version.V3]);
5549
+ return _callSuper(this, Pendulum, ['Pendulum', 'pendulum', 'polkadot', Version.V2]);
5542
5550
  }
5543
5551
  _inherits(Pendulum, _ParachainNode);
5544
5552
  return _createClass(Pendulum, [{
@@ -5546,25 +5554,21 @@ var Pendulum = /*#__PURE__*/function (_ParachainNode) {
5546
5554
  value: function transferXTokens(input) {
5547
5555
  var scenario = input.scenario,
5548
5556
  asset = input.asset;
5549
- if (scenario !== 'ParaToPara') {
5550
- throw new ScenarioNotSupportedError(this.node, input.scenario);
5551
- }
5552
- if (asset.symbol !== this.getNativeAssetSymbol()) {
5553
- throw new InvalidCurrencyError("Asset ".concat(asset.symbol, " is not supported by node ").concat(this.node, "."));
5557
+ if (scenario === 'ParaToRelay') {
5558
+ throw new ScenarioNotSupportedError(this.node, scenario);
5554
5559
  }
5555
- if (!isForeignAsset(asset)) {
5556
- throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
5560
+ if (scenario === 'ParaToPara' && asset.symbol === 'DOT') {
5561
+ throw new InvalidCurrencyError('Pendulum does not support DOT transfers');
5557
5562
  }
5558
- var currencySelection = {
5559
- XCM: Number(asset.assetId)
5563
+ var currencySelection = asset.symbol === 'PEN' ? {
5564
+ Native: null
5565
+ } : {
5566
+ XCM: isForeignAsset(asset) ? Number(asset.assetId) : function () {
5567
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
5568
+ }()
5560
5569
  };
5561
5570
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
5562
5571
  }
5563
- }, {
5564
- key: "transferRelayToPara",
5565
- value: function transferRelayToPara() {
5566
- throw new NodeNotSupportedError();
5567
- }
5568
5572
  }]);
5569
5573
  }(ParachainNode);
5570
5574
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "8.9.3",
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.3",
29
- "@paraspell/assets": "8.9.3",
30
- "@paraspell/pallets": "8.9.3"
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",