@paraspell/sdk-core 10.4.0 → 10.4.2

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
@@ -2873,61 +2873,55 @@ var getBalanceForeignPolkadotXcm = /*#__PURE__*/function () {
2873
2873
  while (1) switch (_context.n) {
2874
2874
  case 0:
2875
2875
  if (!(node === 'Moonbeam' || node === 'Moonriver')) {
2876
- _context.n = 3;
2876
+ _context.n = 2;
2877
2877
  break;
2878
2878
  }
2879
- if (!(!assets.isForeignAsset(asset) || !asset.assetId)) {
2879
+ if (!(!assets.isForeignAsset(asset) || !asset.assetId || !asset.multiLocation)) {
2880
2880
  _context.n = 1;
2881
2881
  break;
2882
2882
  }
2883
- throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
2883
+ throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multi-location or assetId"));
2884
2884
  case 1:
2885
- if (!(asset.multiLocation && sdkCommon.hasJunction(asset.multiLocation, 'GlobalConsensus'))) {
2886
- _context.n = 2;
2887
- break;
2888
- }
2889
2885
  return _context.a(2, getMoonbeamErc20Balance(node, asset.assetId, address));
2890
2886
  case 2:
2891
- return _context.a(2, api.getBalanceAssetsPallet(address, BigInt(asset.assetId)));
2892
- case 3:
2893
2887
  if (!(node === 'Mythos')) {
2894
- _context.n = 4;
2888
+ _context.n = 3;
2895
2889
  break;
2896
2890
  }
2897
2891
  return _context.a(2, api.getMythosForeignBalance(address));
2898
- case 4:
2892
+ case 3:
2899
2893
  if (assets.isForeignAsset(asset)) {
2900
- _context.n = 5;
2894
+ _context.n = 4;
2901
2895
  break;
2902
2896
  }
2903
2897
  throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
2904
- case 5:
2898
+ case 4:
2905
2899
  if (!(node === 'Polimec')) {
2906
- _context.n = 7;
2900
+ _context.n = 6;
2907
2901
  break;
2908
2902
  }
2909
2903
  if (!(asset.multiLocation === undefined)) {
2910
- _context.n = 6;
2904
+ _context.n = 5;
2911
2905
  break;
2912
2906
  }
2913
2907
  throw new assets.InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multi-location"));
2914
- case 6:
2908
+ case 5:
2915
2909
  return _context.a(2, api.getBalanceForeignAssetsPallet(address, asset.multiLocation));
2916
- case 7:
2910
+ case 6:
2917
2911
  if (!(node === 'AssetHubPolkadot')) {
2918
- _context.n = 9;
2912
+ _context.n = 8;
2919
2913
  break;
2920
2914
  }
2921
2915
  ASSETS_PALLET_ID = 50;
2922
2916
  hasRequiredJunctions = asset.multiLocation && sdkCommon.hasJunction(asset.multiLocation, 'PalletInstance', ASSETS_PALLET_ID) && sdkCommon.hasJunction(asset.multiLocation, 'GeneralIndex');
2923
2917
  if (!(!asset.multiLocation || hasRequiredJunctions)) {
2924
- _context.n = 8;
2918
+ _context.n = 7;
2925
2919
  break;
2926
2920
  }
2927
2921
  return _context.a(2, api.getBalanceAssetsPallet(address, Number(asset.assetId)));
2928
- case 8:
2922
+ case 7:
2929
2923
  return _context.a(2, api.getBalanceForeignAssetsPallet(address, asset.multiLocation));
2930
- case 9:
2924
+ case 8:
2931
2925
  return _context.a(2, api.getBalanceForeignPolkadotXcm(address, asset.assetId));
2932
2926
  }
2933
2927
  }, _callee);
@@ -6307,6 +6301,7 @@ var ParachainNode = /*#__PURE__*/function () {
6307
6301
  PARA_TO_PARA_FEE_DOT,
6308
6302
  fee,
6309
6303
  ethAsset,
6304
+ customXcmOnDest,
6310
6305
  messageId,
6311
6306
  call,
6312
6307
  _args3 = arguments;
@@ -6358,16 +6353,47 @@ var ParachainNode = /*#__PURE__*/function () {
6358
6353
  PARA_TO_PARA_FEE_DOT = 500000000; // 0.5 DOT
6359
6354
  fee = useOnlyDepositInstruction ? PARA_TO_PARA_FEE_DOT : (bridgeFee + executionFee).toString();
6360
6355
  ethAsset = assets.findAssetByMultiLocation(assets.getOtherAssets('Ethereum'), asset.multiLocation);
6361
- if (!(!ethAsset || !ethAsset.assetId)) {
6356
+ if (ethAsset) {
6362
6357
  _context3.n = 8;
6363
6358
  break;
6364
6359
  }
6365
6360
  throw new assets.InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset)));
6366
6361
  case 8:
6367
- _context3.n = 9;
6368
- return generateMessageId(api, senderAddress, getParaId(this.node), ethAsset.assetId, address, asset.amount);
6362
+ if (!useOnlyDepositInstruction) {
6363
+ _context3.n = 9;
6364
+ break;
6365
+ }
6366
+ customXcmOnDest = addXcmVersionHeader([{
6367
+ DepositAsset: {
6368
+ assets: {
6369
+ Wild: {
6370
+ AllCounted: 1
6371
+ }
6372
+ },
6373
+ beneficiary: createBeneficiaryMultiLocation({
6374
+ api: api,
6375
+ scenario: scenario,
6376
+ pallet: 'PolkadotXcm',
6377
+ recipientAddress: address,
6378
+ version: version
6379
+ })
6380
+ }
6381
+ }], version);
6382
+ _context3.n = 12;
6383
+ break;
6369
6384
  case 9:
6385
+ if (ethAsset.assetId) {
6386
+ _context3.n = 10;
6387
+ break;
6388
+ }
6389
+ throw new assets.InvalidCurrencyError("Ethereum asset ".concat(JSON.stringify(ethAsset), " has no assetId"));
6390
+ case 10:
6391
+ _context3.n = 11;
6392
+ return generateMessageId(api, senderAddress, getParaId(this.node), ethAsset.assetId, address, asset.amount);
6393
+ case 11:
6370
6394
  messageId = _context3.v;
6395
+ customXcmOnDest = createCustomXcmOnDest(input, this.node, version, messageId);
6396
+ case 12:
6371
6397
  call = {
6372
6398
  module: 'PolkadotXcm',
6373
6399
  method: 'transfer_assets_using_type_and_then',
@@ -6377,22 +6403,7 @@ var ParachainNode = /*#__PURE__*/function () {
6377
6403
  assets_transfer_type: 'DestinationReserve',
6378
6404
  remote_fees_id: addXcmVersionHeader((_feeAsset$multiLocati2 = feeAsset === null || feeAsset === void 0 ? void 0 : feeAsset.multiLocation) !== null && _feeAsset$multiLocati2 !== void 0 ? _feeAsset$multiLocati2 : DOT_MULTILOCATION, version),
6379
6405
  fees_transfer_type: 'DestinationReserve',
6380
- custom_xcm_on_dest: useOnlyDepositInstruction ? addXcmVersionHeader([{
6381
- DepositAsset: {
6382
- assets: {
6383
- Wild: {
6384
- AllCounted: 1
6385
- }
6386
- },
6387
- beneficiary: createBeneficiaryMultiLocation({
6388
- api: api,
6389
- scenario: scenario,
6390
- pallet: 'PolkadotXcm',
6391
- recipientAddress: address,
6392
- version: version
6393
- })
6394
- }
6395
- }], version) : createCustomXcmOnDest(input, this.node, version, messageId),
6406
+ custom_xcm_on_dest: customXcmOnDest,
6396
6407
  weight_limit: 'Unlimited'
6397
6408
  }
6398
6409
  };
@@ -6976,7 +6987,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
6976
6987
  var _this;
6977
6988
  _classCallCheck(this, AssetHubPolkadot);
6978
6989
  _this = _callSuper(this, AssetHubPolkadot, ['AssetHubPolkadot', 'PolkadotAssetHub', 'polkadot', exports.Version.V3]);
6979
- _this.handleBifrostEthTransfer = function (input) {
6990
+ _this.handleLocalReserveTransfer = function (input) {
6980
6991
  var useDOTAsFeeAsset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6981
6992
  var api = input.api,
6982
6993
  scenario = input.scenario,
@@ -7307,6 +7318,9 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7307
7318
  if (!assets.isAssetEqual(feeAsset, asset)) {
7308
7319
  throw new assets.InvalidCurrencyError("Fee asset does not match transfer asset.");
7309
7320
  }
7321
+ if (assets.normalizeSymbol(asset.symbol) === assets.normalizeSymbol('KSM')) {
7322
+ return Promise.resolve(this.handleLocalReserveTransfer(input));
7323
+ }
7310
7324
  var isNativeAsset = asset.symbol === this.getNativeAssetSymbol();
7311
7325
  if (!isNativeAsset) {
7312
7326
  return Promise.resolve(this.handleExecuteTransfer(input));
@@ -7323,10 +7337,10 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7323
7337
  }
7324
7338
  var isEthereumAsset = asset.multiLocation && assets.findAssetByMultiLocation(assets.getOtherAssets('Ethereum'), asset.multiLocation);
7325
7339
  if (destination === 'BifrostPolkadot' && isEthereumAsset) {
7326
- return Promise.resolve(this.handleBifrostEthTransfer(input));
7340
+ return Promise.resolve(this.handleLocalReserveTransfer(input));
7327
7341
  }
7328
7342
  if (isEthereumAsset) {
7329
- return Promise.resolve(this.handleBifrostEthTransfer(input, true));
7343
+ return Promise.resolve(this.handleLocalReserveTransfer(input, true));
7330
7344
  }
7331
7345
  var isSystemNode = !sdkCommon.isTMultiLocation(destination) && SYSTEM_NODES_POLKADOT.includes(destination);
7332
7346
  if (scenario === 'ParaToPara' && asset.symbol === 'DOT' && !assets.isForeignAsset(asset) && destination !== 'Hydration' && destination !== 'Polimec' && destination !== 'Moonbeam' && destination !== 'BifrostPolkadot' && destination !== 'PeoplePolkadot' && destination !== 'Ajuna' && !isSystemNode) {
package/dist/index.d.ts CHANGED
@@ -1298,7 +1298,7 @@ declare class AssetHubPolkadot<TApi, TRes> extends ParachainNode<TApi, TRes> imp
1298
1298
  handleEthBridgeNativeTransfer<TApi, TRes>(input: TPolkadotXCMTransferOptions<TApi, TRes>): Promise<TRes>;
1299
1299
  handleEthBridgeTransfer<TApi, TRes>(input: TPolkadotXCMTransferOptions<TApi, TRes>): Promise<TRes>;
1300
1300
  handleMythosTransfer<TApi, TRes>(input: TPolkadotXCMTransferOptions<TApi, TRes>): TRes;
1301
- handleBifrostEthTransfer: <TApi_1, TRes_1>(input: TPolkadotXCMTransferOptions<TApi_1, TRes_1>, useDOTAsFeeAsset?: boolean) => TRes_1;
1301
+ handleLocalReserveTransfer: <TApi_1, TRes_1>(input: TPolkadotXCMTransferOptions<TApi_1, TRes_1>, useDOTAsFeeAsset?: boolean) => TRes_1;
1302
1302
  patchInput<TApi, TRes>(input: TPolkadotXCMTransferOptions<TApi, TRes>): TPolkadotXCMTransferOptions<TApi, TRes>;
1303
1303
  private getMethod;
1304
1304
  private handleExecuteTransfer;
package/dist/index.mjs CHANGED
@@ -2874,61 +2874,55 @@ var getBalanceForeignPolkadotXcm = /*#__PURE__*/function () {
2874
2874
  while (1) switch (_context.n) {
2875
2875
  case 0:
2876
2876
  if (!(node === 'Moonbeam' || node === 'Moonriver')) {
2877
- _context.n = 3;
2877
+ _context.n = 2;
2878
2878
  break;
2879
2879
  }
2880
- if (!(!isForeignAsset(asset) || !asset.assetId)) {
2880
+ if (!(!isForeignAsset(asset) || !asset.assetId || !asset.multiLocation)) {
2881
2881
  _context.n = 1;
2882
2882
  break;
2883
2883
  }
2884
- throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
2884
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multi-location or assetId"));
2885
2885
  case 1:
2886
- if (!(asset.multiLocation && hasJunction(asset.multiLocation, 'GlobalConsensus'))) {
2887
- _context.n = 2;
2888
- break;
2889
- }
2890
2886
  return _context.a(2, getMoonbeamErc20Balance(node, asset.assetId, address));
2891
2887
  case 2:
2892
- return _context.a(2, api.getBalanceAssetsPallet(address, BigInt(asset.assetId)));
2893
- case 3:
2894
2888
  if (!(node === 'Mythos')) {
2895
- _context.n = 4;
2889
+ _context.n = 3;
2896
2890
  break;
2897
2891
  }
2898
2892
  return _context.a(2, api.getMythosForeignBalance(address));
2899
- case 4:
2893
+ case 3:
2900
2894
  if (isForeignAsset(asset)) {
2901
- _context.n = 5;
2895
+ _context.n = 4;
2902
2896
  break;
2903
2897
  }
2904
2898
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " is not a foreign asset"));
2905
- case 5:
2899
+ case 4:
2906
2900
  if (!(node === 'Polimec')) {
2907
- _context.n = 7;
2901
+ _context.n = 6;
2908
2902
  break;
2909
2903
  }
2910
2904
  if (!(asset.multiLocation === undefined)) {
2911
- _context.n = 6;
2905
+ _context.n = 5;
2912
2906
  break;
2913
2907
  }
2914
2908
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no multi-location"));
2915
- case 6:
2909
+ case 5:
2916
2910
  return _context.a(2, api.getBalanceForeignAssetsPallet(address, asset.multiLocation));
2917
- case 7:
2911
+ case 6:
2918
2912
  if (!(node === 'AssetHubPolkadot')) {
2919
- _context.n = 9;
2913
+ _context.n = 8;
2920
2914
  break;
2921
2915
  }
2922
2916
  ASSETS_PALLET_ID = 50;
2923
2917
  hasRequiredJunctions = asset.multiLocation && hasJunction(asset.multiLocation, 'PalletInstance', ASSETS_PALLET_ID) && hasJunction(asset.multiLocation, 'GeneralIndex');
2924
2918
  if (!(!asset.multiLocation || hasRequiredJunctions)) {
2925
- _context.n = 8;
2919
+ _context.n = 7;
2926
2920
  break;
2927
2921
  }
2928
2922
  return _context.a(2, api.getBalanceAssetsPallet(address, Number(asset.assetId)));
2929
- case 8:
2923
+ case 7:
2930
2924
  return _context.a(2, api.getBalanceForeignAssetsPallet(address, asset.multiLocation));
2931
- case 9:
2925
+ case 8:
2932
2926
  return _context.a(2, api.getBalanceForeignPolkadotXcm(address, asset.assetId));
2933
2927
  }
2934
2928
  }, _callee);
@@ -6308,6 +6302,7 @@ var ParachainNode = /*#__PURE__*/function () {
6308
6302
  PARA_TO_PARA_FEE_DOT,
6309
6303
  fee,
6310
6304
  ethAsset,
6305
+ customXcmOnDest,
6311
6306
  messageId,
6312
6307
  call,
6313
6308
  _args3 = arguments;
@@ -6359,16 +6354,47 @@ var ParachainNode = /*#__PURE__*/function () {
6359
6354
  PARA_TO_PARA_FEE_DOT = 500000000; // 0.5 DOT
6360
6355
  fee = useOnlyDepositInstruction ? PARA_TO_PARA_FEE_DOT : (bridgeFee + executionFee).toString();
6361
6356
  ethAsset = findAssetByMultiLocation(getOtherAssets('Ethereum'), asset.multiLocation);
6362
- if (!(!ethAsset || !ethAsset.assetId)) {
6357
+ if (ethAsset) {
6363
6358
  _context3.n = 8;
6364
6359
  break;
6365
6360
  }
6366
6361
  throw new InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(asset)));
6367
6362
  case 8:
6368
- _context3.n = 9;
6369
- return generateMessageId(api, senderAddress, getParaId(this.node), ethAsset.assetId, address, asset.amount);
6363
+ if (!useOnlyDepositInstruction) {
6364
+ _context3.n = 9;
6365
+ break;
6366
+ }
6367
+ customXcmOnDest = addXcmVersionHeader([{
6368
+ DepositAsset: {
6369
+ assets: {
6370
+ Wild: {
6371
+ AllCounted: 1
6372
+ }
6373
+ },
6374
+ beneficiary: createBeneficiaryMultiLocation({
6375
+ api: api,
6376
+ scenario: scenario,
6377
+ pallet: 'PolkadotXcm',
6378
+ recipientAddress: address,
6379
+ version: version
6380
+ })
6381
+ }
6382
+ }], version);
6383
+ _context3.n = 12;
6384
+ break;
6370
6385
  case 9:
6386
+ if (ethAsset.assetId) {
6387
+ _context3.n = 10;
6388
+ break;
6389
+ }
6390
+ throw new InvalidCurrencyError("Ethereum asset ".concat(JSON.stringify(ethAsset), " has no assetId"));
6391
+ case 10:
6392
+ _context3.n = 11;
6393
+ return generateMessageId(api, senderAddress, getParaId(this.node), ethAsset.assetId, address, asset.amount);
6394
+ case 11:
6371
6395
  messageId = _context3.v;
6396
+ customXcmOnDest = createCustomXcmOnDest(input, this.node, version, messageId);
6397
+ case 12:
6372
6398
  call = {
6373
6399
  module: 'PolkadotXcm',
6374
6400
  method: 'transfer_assets_using_type_and_then',
@@ -6378,22 +6404,7 @@ var ParachainNode = /*#__PURE__*/function () {
6378
6404
  assets_transfer_type: 'DestinationReserve',
6379
6405
  remote_fees_id: addXcmVersionHeader((_feeAsset$multiLocati2 = feeAsset === null || feeAsset === void 0 ? void 0 : feeAsset.multiLocation) !== null && _feeAsset$multiLocati2 !== void 0 ? _feeAsset$multiLocati2 : DOT_MULTILOCATION, version),
6380
6406
  fees_transfer_type: 'DestinationReserve',
6381
- custom_xcm_on_dest: useOnlyDepositInstruction ? addXcmVersionHeader([{
6382
- DepositAsset: {
6383
- assets: {
6384
- Wild: {
6385
- AllCounted: 1
6386
- }
6387
- },
6388
- beneficiary: createBeneficiaryMultiLocation({
6389
- api: api,
6390
- scenario: scenario,
6391
- pallet: 'PolkadotXcm',
6392
- recipientAddress: address,
6393
- version: version
6394
- })
6395
- }
6396
- }], version) : createCustomXcmOnDest(input, this.node, version, messageId),
6407
+ custom_xcm_on_dest: customXcmOnDest,
6397
6408
  weight_limit: 'Unlimited'
6398
6409
  }
6399
6410
  };
@@ -6977,7 +6988,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
6977
6988
  var _this;
6978
6989
  _classCallCheck(this, AssetHubPolkadot);
6979
6990
  _this = _callSuper(this, AssetHubPolkadot, ['AssetHubPolkadot', 'PolkadotAssetHub', 'polkadot', Version.V3]);
6980
- _this.handleBifrostEthTransfer = function (input) {
6991
+ _this.handleLocalReserveTransfer = function (input) {
6981
6992
  var useDOTAsFeeAsset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6982
6993
  var api = input.api,
6983
6994
  scenario = input.scenario,
@@ -7308,6 +7319,9 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7308
7319
  if (!isAssetEqual(feeAsset, asset)) {
7309
7320
  throw new InvalidCurrencyError("Fee asset does not match transfer asset.");
7310
7321
  }
7322
+ if (normalizeSymbol(asset.symbol) === normalizeSymbol('KSM')) {
7323
+ return Promise.resolve(this.handleLocalReserveTransfer(input));
7324
+ }
7311
7325
  var isNativeAsset = asset.symbol === this.getNativeAssetSymbol();
7312
7326
  if (!isNativeAsset) {
7313
7327
  return Promise.resolve(this.handleExecuteTransfer(input));
@@ -7324,10 +7338,10 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7324
7338
  }
7325
7339
  var isEthereumAsset = asset.multiLocation && findAssetByMultiLocation(getOtherAssets('Ethereum'), asset.multiLocation);
7326
7340
  if (destination === 'BifrostPolkadot' && isEthereumAsset) {
7327
- return Promise.resolve(this.handleBifrostEthTransfer(input));
7341
+ return Promise.resolve(this.handleLocalReserveTransfer(input));
7328
7342
  }
7329
7343
  if (isEthereumAsset) {
7330
- return Promise.resolve(this.handleBifrostEthTransfer(input, true));
7344
+ return Promise.resolve(this.handleLocalReserveTransfer(input, true));
7331
7345
  }
7332
7346
  var isSystemNode = !isTMultiLocation(destination) && SYSTEM_NODES_POLKADOT.includes(destination);
7333
7347
  if (scenario === 'ParaToPara' && asset.symbol === 'DOT' && !isForeignAsset(asset) && destination !== 'Hydration' && destination !== 'Polimec' && destination !== 'Moonbeam' && destination !== 'BifrostPolkadot' && destination !== 'PeoplePolkadot' && destination !== 'Ajuna' && !isSystemNode) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "10.4.0",
3
+ "version": "10.4.2",
4
4
  "description": "SDK core for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,9 +26,9 @@
26
26
  "@noble/hashes": "^1.8.0",
27
27
  "@scure/base": "^1.2.6",
28
28
  "viem": "^2.30.5",
29
- "@paraspell/assets": "10.4.0",
30
- "@paraspell/pallets": "10.4.0",
31
- "@paraspell/sdk-common": "10.4.0"
29
+ "@paraspell/assets": "10.4.2",
30
+ "@paraspell/sdk-common": "10.4.2",
31
+ "@paraspell/pallets": "10.4.2"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/plugin-syntax-import-attributes": "^7.27.1",