@paraspell/sdk 5.4.1 → 5.5.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
@@ -64,6 +64,7 @@ NOTES:
64
64
  - Fee asset is now a required builder parameter when you enter a multilocation array.
65
65
  - When using a multilocation array the amount parameter is overridden.
66
66
  - Multilocation arrays are now available. Customize your asset multilocations by .currency([{multilocation1},{multilocation2}..{multilocationN}]) For more information refer to the official documentation or following PR https://github.com/paraspell/xcm-tools/pull/224.
67
+ - POLKADOT <> KUSAMA Bridge is now available! Try sending DOT or KSM between AssetHubs.
67
68
  ```
68
69
 
69
70
  ### Builder pattern:
@@ -73,7 +74,7 @@ NOTES:
73
74
  await Builder(/*node api - optional*/)
74
75
  .from(NODE)
75
76
  .to(NODE /*,customParaId - optional*/ | Multilocation object /*Only works for PolkadotXCM pallet*/)
76
- .currency(CurrencyString| | CurrencyID | Multilocation object | MultilocationArray)
77
+ .currency(CurrencyString| CurrencyID | Multilocation object | MultilocationArray)
77
78
  /*.feeAsset(feeAsset) - Parameter required when using MultilocationArray*/
78
79
  .amount(amount) // Overriden when using MultilocationArray
79
80
  .address(address | Multilocation object /*If you are sending through xTokens, you need to pass the destination and address multilocation in one object (x2)*/)
@@ -292,6 +293,23 @@ import { getExistentialDeposit } from "@paraspell/sdk";
292
293
  const ed = getExistentialDeposit('Acala')
293
294
  ```
294
295
 
296
+ ### XCM Transfer info
297
+ ```ts
298
+ import { getTransferInfo, getBalanceForeign, getBalanceNative, getOriginFeeDetails } from "@paraspell/sdk";
299
+
300
+ //Get balance of foreign currency
301
+ await getBalanceForeign(address, Parachain name, currency)
302
+
303
+ //Get balance of native currency
304
+ await getBalanceNative(address, Parachain name)
305
+
306
+ //Get fee information regarding XCM call
307
+ await getOriginFeeDetails(from, to, currency, amount, originAddress)
308
+
309
+ //Get all the information about XCM transfer
310
+ await getTransferInfo(from, to, address, destinationAddress, currency, amount)
311
+ ```
312
+
295
313
  ## 💻 Tests
296
314
  - Run compilation using `pnpm compile`
297
315
 
package/dist/index.cjs CHANGED
@@ -642,11 +642,13 @@ exports.Version = void 0;
642
642
  Version["V1"] = "V1";
643
643
  Version["V2"] = "V2";
644
644
  Version["V3"] = "V3";
645
+ Version["V4"] = "V4";
645
646
  })(exports.Version || (exports.Version = {}));
646
647
  exports.Parents = void 0;
647
648
  (function (Parents) {
648
- Parents[Parents["ONE"] = 1] = "ONE";
649
649
  Parents[Parents["ZERO"] = 0] = "ZERO";
650
+ Parents[Parents["ONE"] = 1] = "ONE";
651
+ Parents[Parents["TWO"] = 2] = "TWO";
650
652
  })(exports.Parents || (exports.Parents = {}));
651
653
 
652
654
  // Used to inform user, that Parachain they wish to use has not yet implemented full XCM Support
@@ -996,6 +998,11 @@ var Astar$3 = {
996
998
  symbol: "TST",
997
999
  decimals: 18
998
1000
  },
1001
+ {
1002
+ assetId: "18446744073709551637",
1003
+ symbol: "vGLMR",
1004
+ decimals: 18
1005
+ },
999
1006
  {
1000
1007
  assetId: "18446744073709551624",
1001
1008
  symbol: "vDOT",
@@ -1031,6 +1038,11 @@ var Astar$3 = {
1031
1038
  symbol: "TDOT",
1032
1039
  decimals: 18
1033
1040
  },
1041
+ {
1042
+ assetId: "18446744073709551640",
1043
+ symbol: "vFIL",
1044
+ decimals: 18
1045
+ },
1034
1046
  {
1035
1047
  assetId: "1329",
1036
1048
  symbol: "PPC",
@@ -1061,6 +1073,11 @@ var Astar$3 = {
1061
1073
  symbol: "EQ",
1062
1074
  decimals: 9
1063
1075
  },
1076
+ {
1077
+ assetId: "18446744073709551638",
1078
+ symbol: "vMANTA",
1079
+ decimals: 18
1080
+ },
1064
1081
  {
1065
1082
  assetId: "18446744073709551627",
1066
1083
  symbol: "RING",
@@ -1085,6 +1102,11 @@ var Astar$3 = {
1085
1102
  assetId: "1332",
1086
1103
  symbol: "sDOT",
1087
1104
  decimals: 10
1105
+ },
1106
+ {
1107
+ assetId: "18446744073709551639",
1108
+ symbol: "FIL",
1109
+ decimals: 18
1088
1110
  }
1089
1111
  ]
1090
1112
  };
@@ -1507,6 +1529,11 @@ var HydraDX$3 = {
1507
1529
  symbol: "WBTC",
1508
1530
  decimals: 8
1509
1531
  },
1532
+ {
1533
+ assetId: "31",
1534
+ symbol: "RING",
1535
+ decimals: 18
1536
+ },
1510
1537
  {
1511
1538
  assetId: "15",
1512
1539
  symbol: "vDOT",
@@ -1579,7 +1606,7 @@ var HydraDX$3 = {
1579
1606
  },
1580
1607
  {
1581
1608
  assetId: "1",
1582
- symbol: "LRNA",
1609
+ symbol: "H2O",
1583
1610
  decimals: 12
1584
1611
  },
1585
1612
  {
@@ -1801,6 +1828,11 @@ var Moonbeam$3 = {
1801
1828
  symbol: "EQ",
1802
1829
  decimals: 9
1803
1830
  },
1831
+ {
1832
+ assetId: "61295607754960722617854661686514597014",
1833
+ symbol: "WIFD",
1834
+ decimals: 10
1835
+ },
1804
1836
  {
1805
1837
  assetId: "141196559012917796508928734717797136690",
1806
1838
  symbol: "ibcIST",
@@ -1938,7 +1970,7 @@ var Moonbeam$3 = {
1938
1970
  },
1939
1971
  {
1940
1972
  assetId: "238111524681612888331172110363070489924",
1941
- symbol: "OTP",
1973
+ symbol: "NEURO",
1942
1974
  decimals: 12
1943
1975
  },
1944
1976
  {
@@ -2357,6 +2389,11 @@ var AssetHubPolkadot$3 = {
2357
2389
  symbol: "JAM",
2358
2390
  decimals: 10
2359
2391
  },
2392
+ {
2393
+ assetId: "1212",
2394
+ symbol: "DOTTY",
2395
+ decimals: 10
2396
+ },
2360
2397
  {
2361
2398
  assetId: "77",
2362
2399
  symbol: "TRQ",
@@ -2372,6 +2409,11 @@ var AssetHubPolkadot$3 = {
2372
2409
  symbol: "TAPE",
2373
2410
  decimals: 10
2374
2411
  },
2412
+ {
2413
+ assetId: "36",
2414
+ symbol: "CLAY",
2415
+ decimals: 10
2416
+ },
2375
2417
  {
2376
2418
  assetId: "420666",
2377
2419
  symbol: "GIO",
@@ -2387,6 +2429,11 @@ var AssetHubPolkadot$3 = {
2387
2429
  symbol: "COCOA",
2388
2430
  decimals: 10
2389
2431
  },
2432
+ {
2433
+ assetId: "2020",
2434
+ symbol: "HYDRA",
2435
+ decimals: 10
2436
+ },
2390
2437
  {
2391
2438
  assetId: "5318008",
2392
2439
  symbol: "PXPS",
@@ -2467,6 +2514,11 @@ var AssetHubPolkadot$3 = {
2467
2514
  symbol: "SHRIMP",
2468
2515
  decimals: 10
2469
2516
  },
2517
+ {
2518
+ assetId: "1970",
2519
+ symbol: "NIPS",
2520
+ decimals: 10
2521
+ },
2470
2522
  {
2471
2523
  assetId: "42",
2472
2524
  symbol: "PJS",
@@ -2507,11 +2559,21 @@ var AssetHubPolkadot$3 = {
2507
2559
  symbol: "BORK",
2508
2560
  decimals: 10
2509
2561
  },
2562
+ {
2563
+ assetId: "33441",
2564
+ symbol: "MPACT",
2565
+ decimals: 8
2566
+ },
2510
2567
  {
2511
2568
  assetId: "22",
2512
2569
  symbol: "KNRY",
2513
2570
  decimals: 10
2514
2571
  },
2572
+ {
2573
+ assetId: "72",
2574
+ symbol: "NEHT",
2575
+ decimals: 12
2576
+ },
2515
2577
  {
2516
2578
  assetId: "79",
2517
2579
  symbol: "PGOLD",
@@ -2562,6 +2624,11 @@ var AssetHubPolkadot$3 = {
2562
2624
  symbol: "JOE",
2563
2625
  decimals: 9
2564
2626
  },
2627
+ {
2628
+ assetId: "45",
2629
+ symbol: "HYDRA",
2630
+ decimals: 10
2631
+ },
2565
2632
  {
2566
2633
  assetId: "2820",
2567
2634
  symbol: "HOOT",
@@ -2697,6 +2764,11 @@ var AssetHubPolkadot$3 = {
2697
2764
  symbol: "EDU",
2698
2765
  decimals: 10
2699
2766
  },
2767
+ {
2768
+ assetId: "2025",
2769
+ symbol: "FLMG",
2770
+ decimals: 20
2771
+ },
2700
2772
  {
2701
2773
  assetId: "1980",
2702
2774
  symbol: "GAVIN",
@@ -4117,6 +4189,11 @@ var Picasso$3 = {
4117
4189
  symbol: "kUSD",
4118
4190
  decimals: 12
4119
4191
  },
4192
+ {
4193
+ assetId: "3",
4194
+ symbol: "wSOL",
4195
+ decimals: 9
4196
+ },
4120
4197
  {
4121
4198
  assetId: "1088357900348863545351",
4122
4199
  symbol: "USDT_OSMO_LPT",
@@ -4177,11 +4254,21 @@ var Picasso$3 = {
4177
4254
  symbol: "DOT_TIA_LPT",
4178
4255
  decimals: 12
4179
4256
  },
4257
+ {
4258
+ assetId: "2",
4259
+ symbol: "ETH",
4260
+ decimals: 18
4261
+ },
4180
4262
  {
4181
4263
  assetId: "2011",
4182
4264
  symbol: "EQ",
4183
4265
  decimals: 9
4184
4266
  },
4267
+ {
4268
+ assetId: "45",
4269
+ symbol: "XLM",
4270
+ decimals: 12
4271
+ },
4185
4272
  {
4186
4273
  assetId: "25",
4187
4274
  symbol: "IST",
@@ -4307,6 +4394,11 @@ var Picasso$3 = {
4307
4394
  symbol: "HUAHUA",
4308
4395
  decimals: 6
4309
4396
  },
4397
+ {
4398
+ assetId: "44",
4399
+ symbol: "AMPE",
4400
+ decimals: 12
4401
+ },
4310
4402
  {
4311
4403
  assetId: "1088357900348863545365",
4312
4404
  symbol: "DOT_vDOT_LPT",
@@ -4647,6 +4739,11 @@ var AssetHubKusama$3 = {
4647
4739
  symbol: "LAC",
4648
4740
  decimals: 7
4649
4741
  },
4742
+ {
4743
+ assetId: "1985",
4744
+ symbol: "web3",
4745
+ decimals: 16
4746
+ },
4650
4747
  {
4651
4748
  assetId: "20",
4652
4749
  symbol: "BFKK",
@@ -5337,6 +5434,11 @@ var AssetHubKusama$3 = {
5337
5434
  symbol: "bLd",
5338
5435
  decimals: 18
5339
5436
  },
5437
+ {
5438
+ assetId: "2025",
5439
+ symbol: "FLMG",
5440
+ decimals: 10
5441
+ },
5340
5442
  {
5341
5443
  assetId: "91",
5342
5444
  symbol: "TMJ",
@@ -5764,6 +5866,9 @@ var Polkadex$3 = {
5764
5866
  symbol: "PHA",
5765
5867
  decimals: 12
5766
5868
  },
5869
+ {
5870
+ assetId: "130314105136721928300689838359167097187"
5871
+ },
5767
5872
  {
5768
5873
  assetId: "14826654563114266286226336203450732505"
5769
5874
  },
@@ -6770,6 +6875,21 @@ var isTMulti = function isTMulti(value) {
6770
6875
  var isTMultiLocation = function isTMultiLocation(value) {
6771
6876
  return value && typeof value.parents !== 'undefined' && typeof value.interior !== 'undefined';
6772
6877
  };
6878
+ var createBridgeCurrencySpec = function createBridgeCurrencySpec(amount, ecosystem) {
6879
+ return _defineProperty({}, exports.Version.V4, [{
6880
+ id: {
6881
+ parents: exports.Parents.TWO,
6882
+ interior: {
6883
+ X1: [{
6884
+ GlobalConsensus: ecosystem
6885
+ }]
6886
+ }
6887
+ },
6888
+ fun: {
6889
+ Fungible: amount
6890
+ }
6891
+ }]);
6892
+ };
6773
6893
  var createCurrencySpec = function createCurrencySpec(amount, version, parents, overriddenCurrency) {
6774
6894
  var interior = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'Here';
6775
6895
  if (!overriddenCurrency) {
@@ -6808,6 +6928,20 @@ var createPolkadotXcmHeader = function createPolkadotXcmHeader(scenario, version
6808
6928
  interior: interior
6809
6929
  });
6810
6930
  };
6931
+ var createBridgePolkadotXcmDest = function createBridgePolkadotXcmDest(version, ecosystem, destination, nodeId) {
6932
+ var multiLocation = {
6933
+ parents: exports.Parents.TWO,
6934
+ interior: {
6935
+ X2: [{
6936
+ GlobalConsensus: ecosystem
6937
+ }, {
6938
+ Parachain: nodeId
6939
+ }]
6940
+ }
6941
+ };
6942
+ var isMultiLocationDestination = _typeof(destination) === 'object';
6943
+ return _defineProperty({}, version, isMultiLocationDestination ? destination : multiLocation);
6944
+ };
6811
6945
  var calculateTransactionFee$1 = function calculateTransactionFee(tx, address) {
6812
6946
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
6813
6947
  var _yield$tx$paymentInfo, partialFee;
@@ -8259,10 +8393,16 @@ var ParachainNode = /*#__PURE__*/function () {
8259
8393
  api: api,
8260
8394
  header: this.createPolkadotXcmHeader(scenario, destination, paraId),
8261
8395
  addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, this.version, paraId),
8396
+ address: address,
8397
+ amount: amount,
8262
8398
  currencySelection: this.createCurrencySpec(amount, scenario, this.version, currencyId, overridedCurrencyMultiLocation),
8399
+ currencyId: currencyId,
8263
8400
  scenario: scenario,
8264
8401
  currencySymbol: currencySymbol,
8265
8402
  feeAsset: feeAsset,
8403
+ destination: destination,
8404
+ paraIdTo: paraId,
8405
+ overridedCurrency: overridedCurrencyMultiLocation,
8266
8406
  serializedApiCallEnabled: serializedApiCallEnabled
8267
8407
  });
8268
8408
  } else {
@@ -9089,9 +9229,31 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
9089
9229
  }
9090
9230
  _inherits(AssetHubPolkadot, _ParachainNode);
9091
9231
  return _createClass(AssetHubPolkadot, [{
9232
+ key: "handleBridgeTransfer",
9233
+ value: function handleBridgeTransfer(input, targetChain) {
9234
+ if (targetChain === 'Kusama' && input.currencyId === 'KSM' || targetChain === 'Polkadot' && input.currencyId === 'DOT') {
9235
+ var modifiedInput = Object.assign(Object.assign({}, input), {
9236
+ header: createBridgePolkadotXcmDest(exports.Version.V4, targetChain, input.destination, input.paraIdTo),
9237
+ addressSelection: generateAddressMultiLocationV4(input.api, input.address),
9238
+ currencySelection: createBridgeCurrencySpec(input.amount, targetChain)
9239
+ });
9240
+ return PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, 'transferAssets', 'Unlimited');
9241
+ } else if (targetChain === 'Polkadot' && input.currencyId === 'KSM' || targetChain === 'Kusama' && input.currencyId === 'DOT') {
9242
+ var _modifiedInput = Object.assign(Object.assign({}, input), {
9243
+ header: createBridgePolkadotXcmDest(exports.Version.V3, targetChain, input.destination, input.paraIdTo),
9244
+ currencySelection: createCurrencySpec(input.amount, exports.Version.V3, exports.Parents.ONE, input.overridedCurrency)
9245
+ });
9246
+ return PolkadotXCMTransferImpl.transferPolkadotXCM(_modifiedInput, 'limitedReserveTransferAssets', 'Unlimited');
9247
+ }
9248
+ throw new InvalidCurrencyError('Polkadot <-> Kusama bridge does not support this currency');
9249
+ }
9250
+ }, {
9092
9251
  key: "transferPolkadotXCM",
9093
9252
  value: function transferPolkadotXCM(input) {
9094
9253
  var scenario = input.scenario;
9254
+ if (input.destination === 'AssetHubKusama') {
9255
+ return this.handleBridgeTransfer(input, 'Kusama');
9256
+ }
9095
9257
  var method = scenario === 'ParaToPara' ? 'limitedReserveTransferAssets' : 'limitedTeleportAssets';
9096
9258
  return PolkadotXCMTransferImpl.transferPolkadotXCM(input, method, 'Unlimited');
9097
9259
  }
@@ -9137,6 +9299,9 @@ var AssetHubKusama = /*#__PURE__*/function (_ParachainNode) {
9137
9299
  value: function transferPolkadotXCM(input) {
9138
9300
  // TESTED https://kusama.subscan.io/xcm_message/kusama-ddc2a48f0d8e0337832d7aae26f6c3053e1f4ffd
9139
9301
  // TESTED https://kusama.subscan.io/xcm_message/kusama-8e423130a4d8b61679af95dbea18a55124f99672
9302
+ if (input.destination === 'AssetHubPolkadot') {
9303
+ return getNode('AssetHubPolkadot').handleBridgeTransfer(input, 'Polkadot');
9304
+ }
9140
9305
  var scenario = input.scenario;
9141
9306
  var method = scenario === 'ParaToPara' ? 'limitedReserveTransferAssets' : 'limitedTeleportAssets';
9142
9307
  return PolkadotXCMTransferImpl.transferPolkadotXCM(input, method, 'Unlimited');
@@ -9152,8 +9317,8 @@ var AssetHubKusama = /*#__PURE__*/function (_ParachainNode) {
9152
9317
  }
9153
9318
  }, {
9154
9319
  key: "createCurrencySpec",
9155
- value: function createCurrencySpec(amount, scenario, version, currencyId) {
9156
- return getNode('AssetHubPolkadot').createCurrencySpec(amount, scenario, version, currencyId);
9320
+ value: function createCurrencySpec(amount, scenario, version, currencyId, overridedMultiLocation) {
9321
+ return getNode('AssetHubPolkadot').createCurrencySpec(amount, scenario, version, currencyId, overridedMultiLocation);
9157
9322
  }
9158
9323
  }]);
9159
9324
  }(ParachainNode);
@@ -9265,6 +9430,7 @@ var Astar = /*#__PURE__*/function (_ParachainNode) {
9265
9430
  address = options.address,
9266
9431
  destination = options.destination,
9267
9432
  paraIdTo = options.paraIdTo,
9433
+ feeAsset = options.feeAsset,
9268
9434
  overridedCurrencyMultiLocation = options.overridedCurrencyMultiLocation,
9269
9435
  _options$serializedAp = options.serializedApiCallEnabled,
9270
9436
  serializedApiCallEnabled = _options$serializedAp === void 0 ? false : _options$serializedAp;
@@ -9291,9 +9457,16 @@ var Astar = /*#__PURE__*/function (_ParachainNode) {
9291
9457
  api: api,
9292
9458
  header: this.createPolkadotXcmHeader(scenario, destination, paraId),
9293
9459
  addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, this.version, paraId),
9460
+ address: address,
9461
+ amount: amount,
9294
9462
  currencySelection: this.createCurrencySpec(amount, scenario, this.version, currencyId, overridedCurrencyMultiLocation),
9463
+ currencyId: currencyId,
9295
9464
  scenario: scenario,
9296
9465
  currencySymbol: currencySymbol,
9466
+ feeAsset: feeAsset,
9467
+ destination: destination,
9468
+ paraIdTo: paraIdTo,
9469
+ overridedCurrency: overridedCurrencyMultiLocation,
9297
9470
  serializedApiCallEnabled: serializedApiCallEnabled
9298
9471
  });
9299
9472
  }
@@ -9414,6 +9587,7 @@ var Shiden = /*#__PURE__*/function (_ParachainNode) {
9414
9587
  address = options.address,
9415
9588
  destination = options.destination,
9416
9589
  paraIdTo = options.paraIdTo,
9590
+ feeAsset = options.feeAsset,
9417
9591
  overridedCurrencyMultiLocation = options.overridedCurrencyMultiLocation,
9418
9592
  _options$serializedAp = options.serializedApiCallEnabled,
9419
9593
  serializedApiCallEnabled = _options$serializedAp === void 0 ? false : _options$serializedAp;
@@ -9440,9 +9614,16 @@ var Shiden = /*#__PURE__*/function (_ParachainNode) {
9440
9614
  api: api,
9441
9615
  header: this.createPolkadotXcmHeader(scenario, destination, paraId),
9442
9616
  addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, this.version, paraId),
9617
+ address: address,
9618
+ amount: amount,
9443
9619
  currencySelection: this.createCurrencySpec(amount, scenario, this.version, currencyId, overridedCurrencyMultiLocation),
9620
+ currencyId: currencyId,
9444
9621
  scenario: scenario,
9445
9622
  currencySymbol: currencySymbol,
9623
+ feeAsset: feeAsset,
9624
+ destination: destination,
9625
+ paraIdTo: paraIdTo,
9626
+ overridedCurrency: overridedCurrencyMultiLocation,
9446
9627
  serializedApiCallEnabled: serializedApiCallEnabled
9447
9628
  });
9448
9629
  }
@@ -9849,6 +10030,28 @@ var getFees = function getFees(scenario) {
9849
10030
  }
9850
10031
  throw new Error("Fees for scenario ".concat(scenario, " are not defined."));
9851
10032
  };
10033
+ var generateAddressMultiLocationV4 = function generateAddressMultiLocationV4(api, address) {
10034
+ var isMultiLocation = _typeof(address) === 'object';
10035
+ if (isMultiLocation) {
10036
+ return _defineProperty({}, exports.Version.V4, address);
10037
+ }
10038
+ var isEthAddress = ethers.ethers.utils.isAddress(address);
10039
+ return _defineProperty({}, exports.Version.V4, {
10040
+ parents: exports.Parents.ZERO,
10041
+ interior: {
10042
+ X1: [isEthAddress ? {
10043
+ AccountKey20: {
10044
+ key: address
10045
+ }
10046
+ } : {
10047
+ AccountId32: {
10048
+ id: createAccID(api, address),
10049
+ network: null
10050
+ }
10051
+ }]
10052
+ }
10053
+ });
10054
+ };
9852
10055
  var generateAddressPayload = function generateAddressPayload(api, scenario, pallet, recipientAddress, version, nodeId) {
9853
10056
  var isMultiLocation = _typeof(recipientAddress) === 'object';
9854
10057
  if (isMultiLocation) {
@@ -9933,8 +10136,8 @@ var getNodeEndpointOption = function getNodeEndpointOption(node) {
9933
10136
  var _getNode = getNode(node),
9934
10137
  type = _getNode.type,
9935
10138
  name = _getNode.name;
9936
- var _ref6 = type === 'polkadot' ? endpoints.prodRelayPolkadot : endpoints.prodRelayKusama,
9937
- linked = _ref6.linked;
10139
+ var _ref8 = type === 'polkadot' ? endpoints.prodRelayPolkadot : endpoints.prodRelayKusama,
10140
+ linked = _ref8.linked;
9938
10141
  if (linked === undefined) return undefined;
9939
10142
  var preferredOption = linked.find(function (o) {
9940
10143
  return o.info === name && Object.values(o.providers).length > 0;
@@ -9945,8 +10148,8 @@ var getNodeEndpointOption = function getNodeEndpointOption(node) {
9945
10148
  };
9946
10149
  var getAllNodeProviders = function getAllNodeProviders(node) {
9947
10150
  var _a;
9948
- var _ref7 = (_a = getNodeEndpointOption(node)) !== null && _a !== void 0 ? _a : {},
9949
- providers = _ref7.providers;
10151
+ var _ref9 = (_a = getNodeEndpointOption(node)) !== null && _a !== void 0 ? _a : {},
10152
+ providers = _ref9.providers;
9950
10153
  if (providers.length < 1) {
9951
10154
  throw new Error("Node ".concat(node, " does not have any providers."));
9952
10155
  }
@@ -10006,11 +10209,11 @@ var createApiInstanceForNode = function createApiInstanceForNode(node) {
10006
10209
  var lowercaseFirstLetter = function lowercaseFirstLetter(str) {
10007
10210
  return str.charAt(0).toLowerCase() + str.slice(1);
10008
10211
  };
10009
- var callPolkadotJsTxFunction = function callPolkadotJsTxFunction(api, _ref8) {
10212
+ var callPolkadotJsTxFunction = function callPolkadotJsTxFunction(api, _ref10) {
10010
10213
  var _api$tx$module;
10011
- var module = _ref8.module,
10012
- section = _ref8.section,
10013
- parameters = _ref8.parameters;
10214
+ var module = _ref10.module,
10215
+ section = _ref10.section,
10216
+ parameters = _ref10.parameters;
10014
10217
  return (_api$tx$module = api.tx[module])[section].apply(_api$tx$module, _toConsumableArray(parameters));
10015
10218
  };
10016
10219
  var determineRelayChain = function determineRelayChain(node) {
@@ -10189,7 +10392,7 @@ var checkKeepAlive = function checkKeepAlive(_ref) {
10189
10392
 
10190
10393
  var sendCommon = function sendCommon(options) {
10191
10394
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
10192
- var _a, api, origin, currency, amount, address, destination, paraIdTo, destApiForKeepAlive, feeAsset, _options$serializedAp, serializedApiCallEnabled, asset, isMultiLocationDestination, isMultiLocationCurrency, originRelayChainSymbol, destinationRelayChainSymbol, originNode, assetCheckEnabled, apiWithFallback, amountStr, currencyStr, currencyId;
10395
+ var _a, api, origin, currency, amount, address, destination, paraIdTo, destApiForKeepAlive, feeAsset, _options$serializedAp, serializedApiCallEnabled, asset, isMultiLocationDestination, isMultiLocationCurrency, originRelayChainSymbol, destinationRelayChainSymbol, supportsBridge, originNode, assetCheckEnabled, apiWithFallback, amountStr, currencyStr, currencyId;
10193
10396
  return _regeneratorRuntime().wrap(function _callee$(_context) {
10194
10397
  while (1) switch (_context.prev = _context.next) {
10195
10398
  case 0:
@@ -10247,71 +10450,72 @@ var sendCommon = function sendCommon(options) {
10247
10450
  isMultiLocationDestination = _typeof(destination) === 'object';
10248
10451
  isMultiLocationCurrency = _typeof(currency) === 'object';
10249
10452
  if (!(destination !== undefined && !isMultiLocationDestination)) {
10250
- _context.next = 25;
10453
+ _context.next = 26;
10251
10454
  break;
10252
10455
  }
10253
10456
  originRelayChainSymbol = getRelayChainSymbol(origin);
10254
10457
  destinationRelayChainSymbol = getRelayChainSymbol(destination);
10255
- if (!(originRelayChainSymbol !== destinationRelayChainSymbol)) {
10256
- _context.next = 25;
10458
+ supportsBridge = (origin === 'AssetHubPolkadot' || origin === 'AssetHubKusama') && (destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama');
10459
+ if (!(!supportsBridge && originRelayChainSymbol !== destinationRelayChainSymbol)) {
10460
+ _context.next = 26;
10257
10461
  break;
10258
10462
  }
10259
10463
  throw new IncompatibleNodesError();
10260
- case 25:
10464
+ case 26:
10261
10465
  originNode = getNode(origin);
10262
10466
  assetCheckEnabled = destination === 'AssetHubKusama' || destination === 'AssetHubPolkadot' || isMultiLocationCurrency ? false : originNode.assetCheckEnabled;
10263
10467
  if (!(asset === null && assetCheckEnabled)) {
10264
- _context.next = 29;
10468
+ _context.next = 30;
10265
10469
  break;
10266
10470
  }
10267
10471
  throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency or currencyId ").concat(JSON.stringify(currency), "."));
10268
- case 29:
10472
+ case 30:
10269
10473
  if (!(destination !== undefined && !isMultiLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !hasSupportForAsset(destination, asset.symbol))) {
10270
- _context.next = 31;
10474
+ _context.next = 32;
10271
10475
  break;
10272
10476
  }
10273
10477
  throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency or currencyId ").concat(JSON.stringify(currency), "."));
10274
- case 31:
10478
+ case 32:
10275
10479
  if (!(api !== null && api !== void 0)) {
10276
- _context.next = 35;
10480
+ _context.next = 36;
10277
10481
  break;
10278
10482
  }
10279
10483
  _context.t0 = api;
10280
- _context.next = 38;
10484
+ _context.next = 39;
10281
10485
  break;
10282
- case 35:
10283
- _context.next = 37;
10486
+ case 36:
10487
+ _context.next = 38;
10284
10488
  return createApiInstanceForNode(origin);
10285
- case 37:
10286
- _context.t0 = _context.sent;
10287
10489
  case 38:
10490
+ _context.t0 = _context.sent;
10491
+ case 39:
10288
10492
  apiWithFallback = _context.t0;
10289
10493
  amountStr = amount === null || amount === void 0 ? void 0 : amount.toString();
10290
10494
  if (!isTMulti(currency)) {
10291
- _context.next = 44;
10495
+ _context.next = 45;
10292
10496
  break;
10293
10497
  }
10294
10498
  console.warn('Keep alive check is not supported when using MultiLocation as currency.');
10295
- _context.next = 54;
10499
+ _context.next = 55;
10296
10500
  break;
10297
- case 44:
10501
+ case 45:
10298
10502
  if (!(_typeof(address) === 'object')) {
10299
- _context.next = 48;
10503
+ _context.next = 49;
10300
10504
  break;
10301
10505
  }
10302
10506
  console.warn('Keep alive check is not supported when using MultiLocation as address.');
10303
- _context.next = 54;
10507
+ _context.next = 55;
10304
10508
  break;
10305
- case 48:
10509
+ case 49:
10306
10510
  if (!(_typeof(destination) === 'object')) {
10307
- _context.next = 52;
10511
+ _context.next = 53;
10308
10512
  break;
10309
10513
  }
10310
10514
  console.warn('Keep alive check is not supported when using MultiLocation as destination.');
10311
- _context.next = 54;
10515
+ _context.next = 55;
10312
10516
  break;
10313
- case 52:
10314
- _context.next = 54;
10517
+ case 53:
10518
+ _context.next = 55;
10315
10519
  return checkKeepAlive({
10316
10520
  originApi: apiWithFallback,
10317
10521
  address: address,
@@ -10321,7 +10525,7 @@ var sendCommon = function sendCommon(options) {
10321
10525
  currencySymbol: (_a = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _a !== void 0 ? _a : currency.toString(),
10322
10526
  destNode: destination
10323
10527
  });
10324
- case 54:
10528
+ case 55:
10325
10529
  currencyStr = isTMulti(currency) ? undefined : currency.toString();
10326
10530
  currencyId = assetCheckEnabled ? asset === null || asset === void 0 ? void 0 : asset.assetId : currencyStr;
10327
10531
  return _context.abrupt("return", originNode.transfer({
@@ -10336,7 +10540,7 @@ var sendCommon = function sendCommon(options) {
10336
10540
  feeAsset: feeAsset,
10337
10541
  serializedApiCallEnabled: serializedApiCallEnabled
10338
10542
  }));
10339
- case 57:
10543
+ case 58:
10340
10544
  case "end":
10341
10545
  return _context.stop();
10342
10546
  }
package/dist/index.d.ts CHANGED
@@ -15,10 +15,16 @@ interface PolkadotXCMTransferInput {
15
15
  api: ApiPromise;
16
16
  header: any;
17
17
  addressSelection: any;
18
+ amount: string;
19
+ address: TAddress;
18
20
  currencySelection: any;
19
21
  scenario: TScenario;
20
22
  currencySymbol: string | undefined;
23
+ currencyId: string | undefined;
24
+ destination?: TDestination;
25
+ paraIdTo?: number;
21
26
  feeAsset?: TCurrency;
27
+ overridedCurrency?: TMultiLocation | TMultiAsset[];
22
28
  serializedApiCallEnabled?: boolean;
23
29
  }
24
30
  interface XTokensTransferInput {
@@ -61,12 +67,14 @@ type TScenario = 'ParaToRelay' | 'ParaToPara' | 'RelayToPara';
61
67
  declare enum Version {
62
68
  V1 = "V1",
63
69
  V2 = "V2",
64
- V3 = "V3"
70
+ V3 = "V3",
71
+ V4 = "V4"
65
72
  }
66
73
  type TVersionClaimAssets = Version.V3 | Version.V2;
67
74
  declare enum Parents {
75
+ ZERO = 0,
68
76
  ONE = 1,
69
- ZERO = 0
77
+ TWO = 2
70
78
  }
71
79
  type TAmount = string | number | bigint;
72
80
  type TCurrency = string | number | bigint;
package/dist/index.mjs CHANGED
@@ -640,11 +640,13 @@ var Version;
640
640
  Version["V1"] = "V1";
641
641
  Version["V2"] = "V2";
642
642
  Version["V3"] = "V3";
643
+ Version["V4"] = "V4";
643
644
  })(Version || (Version = {}));
644
645
  var Parents;
645
646
  (function (Parents) {
646
- Parents[Parents["ONE"] = 1] = "ONE";
647
647
  Parents[Parents["ZERO"] = 0] = "ZERO";
648
+ Parents[Parents["ONE"] = 1] = "ONE";
649
+ Parents[Parents["TWO"] = 2] = "TWO";
648
650
  })(Parents || (Parents = {}));
649
651
 
650
652
  // Used to inform user, that Parachain they wish to use has not yet implemented full XCM Support
@@ -994,6 +996,11 @@ var Astar$3 = {
994
996
  symbol: "TST",
995
997
  decimals: 18
996
998
  },
999
+ {
1000
+ assetId: "18446744073709551637",
1001
+ symbol: "vGLMR",
1002
+ decimals: 18
1003
+ },
997
1004
  {
998
1005
  assetId: "18446744073709551624",
999
1006
  symbol: "vDOT",
@@ -1029,6 +1036,11 @@ var Astar$3 = {
1029
1036
  symbol: "TDOT",
1030
1037
  decimals: 18
1031
1038
  },
1039
+ {
1040
+ assetId: "18446744073709551640",
1041
+ symbol: "vFIL",
1042
+ decimals: 18
1043
+ },
1032
1044
  {
1033
1045
  assetId: "1329",
1034
1046
  symbol: "PPC",
@@ -1059,6 +1071,11 @@ var Astar$3 = {
1059
1071
  symbol: "EQ",
1060
1072
  decimals: 9
1061
1073
  },
1074
+ {
1075
+ assetId: "18446744073709551638",
1076
+ symbol: "vMANTA",
1077
+ decimals: 18
1078
+ },
1062
1079
  {
1063
1080
  assetId: "18446744073709551627",
1064
1081
  symbol: "RING",
@@ -1083,6 +1100,11 @@ var Astar$3 = {
1083
1100
  assetId: "1332",
1084
1101
  symbol: "sDOT",
1085
1102
  decimals: 10
1103
+ },
1104
+ {
1105
+ assetId: "18446744073709551639",
1106
+ symbol: "FIL",
1107
+ decimals: 18
1086
1108
  }
1087
1109
  ]
1088
1110
  };
@@ -1505,6 +1527,11 @@ var HydraDX$3 = {
1505
1527
  symbol: "WBTC",
1506
1528
  decimals: 8
1507
1529
  },
1530
+ {
1531
+ assetId: "31",
1532
+ symbol: "RING",
1533
+ decimals: 18
1534
+ },
1508
1535
  {
1509
1536
  assetId: "15",
1510
1537
  symbol: "vDOT",
@@ -1577,7 +1604,7 @@ var HydraDX$3 = {
1577
1604
  },
1578
1605
  {
1579
1606
  assetId: "1",
1580
- symbol: "LRNA",
1607
+ symbol: "H2O",
1581
1608
  decimals: 12
1582
1609
  },
1583
1610
  {
@@ -1799,6 +1826,11 @@ var Moonbeam$3 = {
1799
1826
  symbol: "EQ",
1800
1827
  decimals: 9
1801
1828
  },
1829
+ {
1830
+ assetId: "61295607754960722617854661686514597014",
1831
+ symbol: "WIFD",
1832
+ decimals: 10
1833
+ },
1802
1834
  {
1803
1835
  assetId: "141196559012917796508928734717797136690",
1804
1836
  symbol: "ibcIST",
@@ -1936,7 +1968,7 @@ var Moonbeam$3 = {
1936
1968
  },
1937
1969
  {
1938
1970
  assetId: "238111524681612888331172110363070489924",
1939
- symbol: "OTP",
1971
+ symbol: "NEURO",
1940
1972
  decimals: 12
1941
1973
  },
1942
1974
  {
@@ -2355,6 +2387,11 @@ var AssetHubPolkadot$3 = {
2355
2387
  symbol: "JAM",
2356
2388
  decimals: 10
2357
2389
  },
2390
+ {
2391
+ assetId: "1212",
2392
+ symbol: "DOTTY",
2393
+ decimals: 10
2394
+ },
2358
2395
  {
2359
2396
  assetId: "77",
2360
2397
  symbol: "TRQ",
@@ -2370,6 +2407,11 @@ var AssetHubPolkadot$3 = {
2370
2407
  symbol: "TAPE",
2371
2408
  decimals: 10
2372
2409
  },
2410
+ {
2411
+ assetId: "36",
2412
+ symbol: "CLAY",
2413
+ decimals: 10
2414
+ },
2373
2415
  {
2374
2416
  assetId: "420666",
2375
2417
  symbol: "GIO",
@@ -2385,6 +2427,11 @@ var AssetHubPolkadot$3 = {
2385
2427
  symbol: "COCOA",
2386
2428
  decimals: 10
2387
2429
  },
2430
+ {
2431
+ assetId: "2020",
2432
+ symbol: "HYDRA",
2433
+ decimals: 10
2434
+ },
2388
2435
  {
2389
2436
  assetId: "5318008",
2390
2437
  symbol: "PXPS",
@@ -2465,6 +2512,11 @@ var AssetHubPolkadot$3 = {
2465
2512
  symbol: "SHRIMP",
2466
2513
  decimals: 10
2467
2514
  },
2515
+ {
2516
+ assetId: "1970",
2517
+ symbol: "NIPS",
2518
+ decimals: 10
2519
+ },
2468
2520
  {
2469
2521
  assetId: "42",
2470
2522
  symbol: "PJS",
@@ -2505,11 +2557,21 @@ var AssetHubPolkadot$3 = {
2505
2557
  symbol: "BORK",
2506
2558
  decimals: 10
2507
2559
  },
2560
+ {
2561
+ assetId: "33441",
2562
+ symbol: "MPACT",
2563
+ decimals: 8
2564
+ },
2508
2565
  {
2509
2566
  assetId: "22",
2510
2567
  symbol: "KNRY",
2511
2568
  decimals: 10
2512
2569
  },
2570
+ {
2571
+ assetId: "72",
2572
+ symbol: "NEHT",
2573
+ decimals: 12
2574
+ },
2513
2575
  {
2514
2576
  assetId: "79",
2515
2577
  symbol: "PGOLD",
@@ -2560,6 +2622,11 @@ var AssetHubPolkadot$3 = {
2560
2622
  symbol: "JOE",
2561
2623
  decimals: 9
2562
2624
  },
2625
+ {
2626
+ assetId: "45",
2627
+ symbol: "HYDRA",
2628
+ decimals: 10
2629
+ },
2563
2630
  {
2564
2631
  assetId: "2820",
2565
2632
  symbol: "HOOT",
@@ -2695,6 +2762,11 @@ var AssetHubPolkadot$3 = {
2695
2762
  symbol: "EDU",
2696
2763
  decimals: 10
2697
2764
  },
2765
+ {
2766
+ assetId: "2025",
2767
+ symbol: "FLMG",
2768
+ decimals: 20
2769
+ },
2698
2770
  {
2699
2771
  assetId: "1980",
2700
2772
  symbol: "GAVIN",
@@ -4115,6 +4187,11 @@ var Picasso$3 = {
4115
4187
  symbol: "kUSD",
4116
4188
  decimals: 12
4117
4189
  },
4190
+ {
4191
+ assetId: "3",
4192
+ symbol: "wSOL",
4193
+ decimals: 9
4194
+ },
4118
4195
  {
4119
4196
  assetId: "1088357900348863545351",
4120
4197
  symbol: "USDT_OSMO_LPT",
@@ -4175,11 +4252,21 @@ var Picasso$3 = {
4175
4252
  symbol: "DOT_TIA_LPT",
4176
4253
  decimals: 12
4177
4254
  },
4255
+ {
4256
+ assetId: "2",
4257
+ symbol: "ETH",
4258
+ decimals: 18
4259
+ },
4178
4260
  {
4179
4261
  assetId: "2011",
4180
4262
  symbol: "EQ",
4181
4263
  decimals: 9
4182
4264
  },
4265
+ {
4266
+ assetId: "45",
4267
+ symbol: "XLM",
4268
+ decimals: 12
4269
+ },
4183
4270
  {
4184
4271
  assetId: "25",
4185
4272
  symbol: "IST",
@@ -4305,6 +4392,11 @@ var Picasso$3 = {
4305
4392
  symbol: "HUAHUA",
4306
4393
  decimals: 6
4307
4394
  },
4395
+ {
4396
+ assetId: "44",
4397
+ symbol: "AMPE",
4398
+ decimals: 12
4399
+ },
4308
4400
  {
4309
4401
  assetId: "1088357900348863545365",
4310
4402
  symbol: "DOT_vDOT_LPT",
@@ -4645,6 +4737,11 @@ var AssetHubKusama$3 = {
4645
4737
  symbol: "LAC",
4646
4738
  decimals: 7
4647
4739
  },
4740
+ {
4741
+ assetId: "1985",
4742
+ symbol: "web3",
4743
+ decimals: 16
4744
+ },
4648
4745
  {
4649
4746
  assetId: "20",
4650
4747
  symbol: "BFKK",
@@ -5335,6 +5432,11 @@ var AssetHubKusama$3 = {
5335
5432
  symbol: "bLd",
5336
5433
  decimals: 18
5337
5434
  },
5435
+ {
5436
+ assetId: "2025",
5437
+ symbol: "FLMG",
5438
+ decimals: 10
5439
+ },
5338
5440
  {
5339
5441
  assetId: "91",
5340
5442
  symbol: "TMJ",
@@ -5762,6 +5864,9 @@ var Polkadex$3 = {
5762
5864
  symbol: "PHA",
5763
5865
  decimals: 12
5764
5866
  },
5867
+ {
5868
+ assetId: "130314105136721928300689838359167097187"
5869
+ },
5765
5870
  {
5766
5871
  assetId: "14826654563114266286226336203450732505"
5767
5872
  },
@@ -6768,6 +6873,21 @@ var isTMulti = function isTMulti(value) {
6768
6873
  var isTMultiLocation = function isTMultiLocation(value) {
6769
6874
  return value && typeof value.parents !== 'undefined' && typeof value.interior !== 'undefined';
6770
6875
  };
6876
+ var createBridgeCurrencySpec = function createBridgeCurrencySpec(amount, ecosystem) {
6877
+ return _defineProperty({}, Version.V4, [{
6878
+ id: {
6879
+ parents: Parents.TWO,
6880
+ interior: {
6881
+ X1: [{
6882
+ GlobalConsensus: ecosystem
6883
+ }]
6884
+ }
6885
+ },
6886
+ fun: {
6887
+ Fungible: amount
6888
+ }
6889
+ }]);
6890
+ };
6771
6891
  var createCurrencySpec = function createCurrencySpec(amount, version, parents, overriddenCurrency) {
6772
6892
  var interior = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'Here';
6773
6893
  if (!overriddenCurrency) {
@@ -6806,6 +6926,20 @@ var createPolkadotXcmHeader = function createPolkadotXcmHeader(scenario, version
6806
6926
  interior: interior
6807
6927
  });
6808
6928
  };
6929
+ var createBridgePolkadotXcmDest = function createBridgePolkadotXcmDest(version, ecosystem, destination, nodeId) {
6930
+ var multiLocation = {
6931
+ parents: Parents.TWO,
6932
+ interior: {
6933
+ X2: [{
6934
+ GlobalConsensus: ecosystem
6935
+ }, {
6936
+ Parachain: nodeId
6937
+ }]
6938
+ }
6939
+ };
6940
+ var isMultiLocationDestination = _typeof(destination) === 'object';
6941
+ return _defineProperty({}, version, isMultiLocationDestination ? destination : multiLocation);
6942
+ };
6809
6943
  var calculateTransactionFee$1 = function calculateTransactionFee(tx, address) {
6810
6944
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
6811
6945
  var _yield$tx$paymentInfo, partialFee;
@@ -8257,10 +8391,16 @@ var ParachainNode = /*#__PURE__*/function () {
8257
8391
  api: api,
8258
8392
  header: this.createPolkadotXcmHeader(scenario, destination, paraId),
8259
8393
  addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, this.version, paraId),
8394
+ address: address,
8395
+ amount: amount,
8260
8396
  currencySelection: this.createCurrencySpec(amount, scenario, this.version, currencyId, overridedCurrencyMultiLocation),
8397
+ currencyId: currencyId,
8261
8398
  scenario: scenario,
8262
8399
  currencySymbol: currencySymbol,
8263
8400
  feeAsset: feeAsset,
8401
+ destination: destination,
8402
+ paraIdTo: paraId,
8403
+ overridedCurrency: overridedCurrencyMultiLocation,
8264
8404
  serializedApiCallEnabled: serializedApiCallEnabled
8265
8405
  });
8266
8406
  } else {
@@ -9087,9 +9227,31 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
9087
9227
  }
9088
9228
  _inherits(AssetHubPolkadot, _ParachainNode);
9089
9229
  return _createClass(AssetHubPolkadot, [{
9230
+ key: "handleBridgeTransfer",
9231
+ value: function handleBridgeTransfer(input, targetChain) {
9232
+ if (targetChain === 'Kusama' && input.currencyId === 'KSM' || targetChain === 'Polkadot' && input.currencyId === 'DOT') {
9233
+ var modifiedInput = Object.assign(Object.assign({}, input), {
9234
+ header: createBridgePolkadotXcmDest(Version.V4, targetChain, input.destination, input.paraIdTo),
9235
+ addressSelection: generateAddressMultiLocationV4(input.api, input.address),
9236
+ currencySelection: createBridgeCurrencySpec(input.amount, targetChain)
9237
+ });
9238
+ return PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, 'transferAssets', 'Unlimited');
9239
+ } else if (targetChain === 'Polkadot' && input.currencyId === 'KSM' || targetChain === 'Kusama' && input.currencyId === 'DOT') {
9240
+ var _modifiedInput = Object.assign(Object.assign({}, input), {
9241
+ header: createBridgePolkadotXcmDest(Version.V3, targetChain, input.destination, input.paraIdTo),
9242
+ currencySelection: createCurrencySpec(input.amount, Version.V3, Parents.ONE, input.overridedCurrency)
9243
+ });
9244
+ return PolkadotXCMTransferImpl.transferPolkadotXCM(_modifiedInput, 'limitedReserveTransferAssets', 'Unlimited');
9245
+ }
9246
+ throw new InvalidCurrencyError('Polkadot <-> Kusama bridge does not support this currency');
9247
+ }
9248
+ }, {
9090
9249
  key: "transferPolkadotXCM",
9091
9250
  value: function transferPolkadotXCM(input) {
9092
9251
  var scenario = input.scenario;
9252
+ if (input.destination === 'AssetHubKusama') {
9253
+ return this.handleBridgeTransfer(input, 'Kusama');
9254
+ }
9093
9255
  var method = scenario === 'ParaToPara' ? 'limitedReserveTransferAssets' : 'limitedTeleportAssets';
9094
9256
  return PolkadotXCMTransferImpl.transferPolkadotXCM(input, method, 'Unlimited');
9095
9257
  }
@@ -9135,6 +9297,9 @@ var AssetHubKusama = /*#__PURE__*/function (_ParachainNode) {
9135
9297
  value: function transferPolkadotXCM(input) {
9136
9298
  // TESTED https://kusama.subscan.io/xcm_message/kusama-ddc2a48f0d8e0337832d7aae26f6c3053e1f4ffd
9137
9299
  // TESTED https://kusama.subscan.io/xcm_message/kusama-8e423130a4d8b61679af95dbea18a55124f99672
9300
+ if (input.destination === 'AssetHubPolkadot') {
9301
+ return getNode('AssetHubPolkadot').handleBridgeTransfer(input, 'Polkadot');
9302
+ }
9138
9303
  var scenario = input.scenario;
9139
9304
  var method = scenario === 'ParaToPara' ? 'limitedReserveTransferAssets' : 'limitedTeleportAssets';
9140
9305
  return PolkadotXCMTransferImpl.transferPolkadotXCM(input, method, 'Unlimited');
@@ -9150,8 +9315,8 @@ var AssetHubKusama = /*#__PURE__*/function (_ParachainNode) {
9150
9315
  }
9151
9316
  }, {
9152
9317
  key: "createCurrencySpec",
9153
- value: function createCurrencySpec(amount, scenario, version, currencyId) {
9154
- return getNode('AssetHubPolkadot').createCurrencySpec(amount, scenario, version, currencyId);
9318
+ value: function createCurrencySpec(amount, scenario, version, currencyId, overridedMultiLocation) {
9319
+ return getNode('AssetHubPolkadot').createCurrencySpec(amount, scenario, version, currencyId, overridedMultiLocation);
9155
9320
  }
9156
9321
  }]);
9157
9322
  }(ParachainNode);
@@ -9263,6 +9428,7 @@ var Astar = /*#__PURE__*/function (_ParachainNode) {
9263
9428
  address = options.address,
9264
9429
  destination = options.destination,
9265
9430
  paraIdTo = options.paraIdTo,
9431
+ feeAsset = options.feeAsset,
9266
9432
  overridedCurrencyMultiLocation = options.overridedCurrencyMultiLocation,
9267
9433
  _options$serializedAp = options.serializedApiCallEnabled,
9268
9434
  serializedApiCallEnabled = _options$serializedAp === void 0 ? false : _options$serializedAp;
@@ -9289,9 +9455,16 @@ var Astar = /*#__PURE__*/function (_ParachainNode) {
9289
9455
  api: api,
9290
9456
  header: this.createPolkadotXcmHeader(scenario, destination, paraId),
9291
9457
  addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, this.version, paraId),
9458
+ address: address,
9459
+ amount: amount,
9292
9460
  currencySelection: this.createCurrencySpec(amount, scenario, this.version, currencyId, overridedCurrencyMultiLocation),
9461
+ currencyId: currencyId,
9293
9462
  scenario: scenario,
9294
9463
  currencySymbol: currencySymbol,
9464
+ feeAsset: feeAsset,
9465
+ destination: destination,
9466
+ paraIdTo: paraIdTo,
9467
+ overridedCurrency: overridedCurrencyMultiLocation,
9295
9468
  serializedApiCallEnabled: serializedApiCallEnabled
9296
9469
  });
9297
9470
  }
@@ -9412,6 +9585,7 @@ var Shiden = /*#__PURE__*/function (_ParachainNode) {
9412
9585
  address = options.address,
9413
9586
  destination = options.destination,
9414
9587
  paraIdTo = options.paraIdTo,
9588
+ feeAsset = options.feeAsset,
9415
9589
  overridedCurrencyMultiLocation = options.overridedCurrencyMultiLocation,
9416
9590
  _options$serializedAp = options.serializedApiCallEnabled,
9417
9591
  serializedApiCallEnabled = _options$serializedAp === void 0 ? false : _options$serializedAp;
@@ -9438,9 +9612,16 @@ var Shiden = /*#__PURE__*/function (_ParachainNode) {
9438
9612
  api: api,
9439
9613
  header: this.createPolkadotXcmHeader(scenario, destination, paraId),
9440
9614
  addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, this.version, paraId),
9615
+ address: address,
9616
+ amount: amount,
9441
9617
  currencySelection: this.createCurrencySpec(amount, scenario, this.version, currencyId, overridedCurrencyMultiLocation),
9618
+ currencyId: currencyId,
9442
9619
  scenario: scenario,
9443
9620
  currencySymbol: currencySymbol,
9621
+ feeAsset: feeAsset,
9622
+ destination: destination,
9623
+ paraIdTo: paraIdTo,
9624
+ overridedCurrency: overridedCurrencyMultiLocation,
9444
9625
  serializedApiCallEnabled: serializedApiCallEnabled
9445
9626
  });
9446
9627
  }
@@ -9847,6 +10028,28 @@ var getFees = function getFees(scenario) {
9847
10028
  }
9848
10029
  throw new Error("Fees for scenario ".concat(scenario, " are not defined."));
9849
10030
  };
10031
+ var generateAddressMultiLocationV4 = function generateAddressMultiLocationV4(api, address) {
10032
+ var isMultiLocation = _typeof(address) === 'object';
10033
+ if (isMultiLocation) {
10034
+ return _defineProperty({}, Version.V4, address);
10035
+ }
10036
+ var isEthAddress = ethers.utils.isAddress(address);
10037
+ return _defineProperty({}, Version.V4, {
10038
+ parents: Parents.ZERO,
10039
+ interior: {
10040
+ X1: [isEthAddress ? {
10041
+ AccountKey20: {
10042
+ key: address
10043
+ }
10044
+ } : {
10045
+ AccountId32: {
10046
+ id: createAccID(api, address),
10047
+ network: null
10048
+ }
10049
+ }]
10050
+ }
10051
+ });
10052
+ };
9850
10053
  var generateAddressPayload = function generateAddressPayload(api, scenario, pallet, recipientAddress, version, nodeId) {
9851
10054
  var isMultiLocation = _typeof(recipientAddress) === 'object';
9852
10055
  if (isMultiLocation) {
@@ -9931,8 +10134,8 @@ var getNodeEndpointOption = function getNodeEndpointOption(node) {
9931
10134
  var _getNode = getNode(node),
9932
10135
  type = _getNode.type,
9933
10136
  name = _getNode.name;
9934
- var _ref6 = type === 'polkadot' ? prodRelayPolkadot : prodRelayKusama,
9935
- linked = _ref6.linked;
10137
+ var _ref8 = type === 'polkadot' ? prodRelayPolkadot : prodRelayKusama,
10138
+ linked = _ref8.linked;
9936
10139
  if (linked === undefined) return undefined;
9937
10140
  var preferredOption = linked.find(function (o) {
9938
10141
  return o.info === name && Object.values(o.providers).length > 0;
@@ -9943,8 +10146,8 @@ var getNodeEndpointOption = function getNodeEndpointOption(node) {
9943
10146
  };
9944
10147
  var getAllNodeProviders = function getAllNodeProviders(node) {
9945
10148
  var _a;
9946
- var _ref7 = (_a = getNodeEndpointOption(node)) !== null && _a !== void 0 ? _a : {},
9947
- providers = _ref7.providers;
10149
+ var _ref9 = (_a = getNodeEndpointOption(node)) !== null && _a !== void 0 ? _a : {},
10150
+ providers = _ref9.providers;
9948
10151
  if (providers.length < 1) {
9949
10152
  throw new Error("Node ".concat(node, " does not have any providers."));
9950
10153
  }
@@ -10004,11 +10207,11 @@ var createApiInstanceForNode = function createApiInstanceForNode(node) {
10004
10207
  var lowercaseFirstLetter = function lowercaseFirstLetter(str) {
10005
10208
  return str.charAt(0).toLowerCase() + str.slice(1);
10006
10209
  };
10007
- var callPolkadotJsTxFunction = function callPolkadotJsTxFunction(api, _ref8) {
10210
+ var callPolkadotJsTxFunction = function callPolkadotJsTxFunction(api, _ref10) {
10008
10211
  var _api$tx$module;
10009
- var module = _ref8.module,
10010
- section = _ref8.section,
10011
- parameters = _ref8.parameters;
10212
+ var module = _ref10.module,
10213
+ section = _ref10.section,
10214
+ parameters = _ref10.parameters;
10012
10215
  return (_api$tx$module = api.tx[module])[section].apply(_api$tx$module, _toConsumableArray(parameters));
10013
10216
  };
10014
10217
  var determineRelayChain = function determineRelayChain(node) {
@@ -10187,7 +10390,7 @@ var checkKeepAlive = function checkKeepAlive(_ref) {
10187
10390
 
10188
10391
  var sendCommon = function sendCommon(options) {
10189
10392
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
10190
- var _a, api, origin, currency, amount, address, destination, paraIdTo, destApiForKeepAlive, feeAsset, _options$serializedAp, serializedApiCallEnabled, asset, isMultiLocationDestination, isMultiLocationCurrency, originRelayChainSymbol, destinationRelayChainSymbol, originNode, assetCheckEnabled, apiWithFallback, amountStr, currencyStr, currencyId;
10393
+ var _a, api, origin, currency, amount, address, destination, paraIdTo, destApiForKeepAlive, feeAsset, _options$serializedAp, serializedApiCallEnabled, asset, isMultiLocationDestination, isMultiLocationCurrency, originRelayChainSymbol, destinationRelayChainSymbol, supportsBridge, originNode, assetCheckEnabled, apiWithFallback, amountStr, currencyStr, currencyId;
10191
10394
  return _regeneratorRuntime().wrap(function _callee$(_context) {
10192
10395
  while (1) switch (_context.prev = _context.next) {
10193
10396
  case 0:
@@ -10245,71 +10448,72 @@ var sendCommon = function sendCommon(options) {
10245
10448
  isMultiLocationDestination = _typeof(destination) === 'object';
10246
10449
  isMultiLocationCurrency = _typeof(currency) === 'object';
10247
10450
  if (!(destination !== undefined && !isMultiLocationDestination)) {
10248
- _context.next = 25;
10451
+ _context.next = 26;
10249
10452
  break;
10250
10453
  }
10251
10454
  originRelayChainSymbol = getRelayChainSymbol(origin);
10252
10455
  destinationRelayChainSymbol = getRelayChainSymbol(destination);
10253
- if (!(originRelayChainSymbol !== destinationRelayChainSymbol)) {
10254
- _context.next = 25;
10456
+ supportsBridge = (origin === 'AssetHubPolkadot' || origin === 'AssetHubKusama') && (destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama');
10457
+ if (!(!supportsBridge && originRelayChainSymbol !== destinationRelayChainSymbol)) {
10458
+ _context.next = 26;
10255
10459
  break;
10256
10460
  }
10257
10461
  throw new IncompatibleNodesError();
10258
- case 25:
10462
+ case 26:
10259
10463
  originNode = getNode(origin);
10260
10464
  assetCheckEnabled = destination === 'AssetHubKusama' || destination === 'AssetHubPolkadot' || isMultiLocationCurrency ? false : originNode.assetCheckEnabled;
10261
10465
  if (!(asset === null && assetCheckEnabled)) {
10262
- _context.next = 29;
10466
+ _context.next = 30;
10263
10467
  break;
10264
10468
  }
10265
10469
  throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency or currencyId ").concat(JSON.stringify(currency), "."));
10266
- case 29:
10470
+ case 30:
10267
10471
  if (!(destination !== undefined && !isMultiLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !hasSupportForAsset(destination, asset.symbol))) {
10268
- _context.next = 31;
10472
+ _context.next = 32;
10269
10473
  break;
10270
10474
  }
10271
10475
  throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency or currencyId ").concat(JSON.stringify(currency), "."));
10272
- case 31:
10476
+ case 32:
10273
10477
  if (!(api !== null && api !== void 0)) {
10274
- _context.next = 35;
10478
+ _context.next = 36;
10275
10479
  break;
10276
10480
  }
10277
10481
  _context.t0 = api;
10278
- _context.next = 38;
10482
+ _context.next = 39;
10279
10483
  break;
10280
- case 35:
10281
- _context.next = 37;
10484
+ case 36:
10485
+ _context.next = 38;
10282
10486
  return createApiInstanceForNode(origin);
10283
- case 37:
10284
- _context.t0 = _context.sent;
10285
10487
  case 38:
10488
+ _context.t0 = _context.sent;
10489
+ case 39:
10286
10490
  apiWithFallback = _context.t0;
10287
10491
  amountStr = amount === null || amount === void 0 ? void 0 : amount.toString();
10288
10492
  if (!isTMulti(currency)) {
10289
- _context.next = 44;
10493
+ _context.next = 45;
10290
10494
  break;
10291
10495
  }
10292
10496
  console.warn('Keep alive check is not supported when using MultiLocation as currency.');
10293
- _context.next = 54;
10497
+ _context.next = 55;
10294
10498
  break;
10295
- case 44:
10499
+ case 45:
10296
10500
  if (!(_typeof(address) === 'object')) {
10297
- _context.next = 48;
10501
+ _context.next = 49;
10298
10502
  break;
10299
10503
  }
10300
10504
  console.warn('Keep alive check is not supported when using MultiLocation as address.');
10301
- _context.next = 54;
10505
+ _context.next = 55;
10302
10506
  break;
10303
- case 48:
10507
+ case 49:
10304
10508
  if (!(_typeof(destination) === 'object')) {
10305
- _context.next = 52;
10509
+ _context.next = 53;
10306
10510
  break;
10307
10511
  }
10308
10512
  console.warn('Keep alive check is not supported when using MultiLocation as destination.');
10309
- _context.next = 54;
10513
+ _context.next = 55;
10310
10514
  break;
10311
- case 52:
10312
- _context.next = 54;
10515
+ case 53:
10516
+ _context.next = 55;
10313
10517
  return checkKeepAlive({
10314
10518
  originApi: apiWithFallback,
10315
10519
  address: address,
@@ -10319,7 +10523,7 @@ var sendCommon = function sendCommon(options) {
10319
10523
  currencySymbol: (_a = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _a !== void 0 ? _a : currency.toString(),
10320
10524
  destNode: destination
10321
10525
  });
10322
- case 54:
10526
+ case 55:
10323
10527
  currencyStr = isTMulti(currency) ? undefined : currency.toString();
10324
10528
  currencyId = assetCheckEnabled ? asset === null || asset === void 0 ? void 0 : asset.assetId : currencyStr;
10325
10529
  return _context.abrupt("return", originNode.transfer({
@@ -10334,7 +10538,7 @@ var sendCommon = function sendCommon(options) {
10334
10538
  feeAsset: feeAsset,
10335
10539
  serializedApiCallEnabled: serializedApiCallEnabled
10336
10540
  }));
10337
- case 57:
10541
+ case 58:
10338
10542
  case "end":
10339
10543
  return _context.stop();
10340
10544
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk",
3
- "version": "5.4.1",
3
+ "version": "5.5.0",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": "@paraspell/sdk",
6
6
  "license": "MIT",
@@ -23,10 +23,10 @@
23
23
  "ethers": "^5.7.2"
24
24
  },
25
25
  "peerDependencies": {
26
- "@polkadot/api": "^10.12.4",
27
- "@polkadot/api-base": "^10.12.4",
28
- "@polkadot/apps-config": "^0.136.1",
29
- "@polkadot/types": "^10.12.4",
26
+ "@polkadot/api": "^11.2.1",
27
+ "@polkadot/api-base": "^11.2.1",
28
+ "@polkadot/apps-config": "^0.138.1",
29
+ "@polkadot/types": "^11.2.1",
30
30
  "@polkadot/util": "^12.6.2"
31
31
  },
32
32
  "devDependencies": {