@paraspell/sdk 3.0.10 → 3.1.1

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.mjs CHANGED
@@ -469,6 +469,29 @@ function _createSuper(Derived) {
469
469
  return _possibleConstructorReturn(this, result);
470
470
  };
471
471
  }
472
+ function _superPropBase(object, property) {
473
+ while (!Object.prototype.hasOwnProperty.call(object, property)) {
474
+ object = _getPrototypeOf(object);
475
+ if (object === null) break;
476
+ }
477
+ return object;
478
+ }
479
+ function _get() {
480
+ if (typeof Reflect !== "undefined" && Reflect.get) {
481
+ _get = Reflect.get.bind();
482
+ } else {
483
+ _get = function _get(target, property, receiver) {
484
+ var base = _superPropBase(target, property);
485
+ if (!base) return;
486
+ var desc = Object.getOwnPropertyDescriptor(base, property);
487
+ if (desc.get) {
488
+ return desc.get.call(arguments.length < 3 ? target : receiver);
489
+ }
490
+ return desc.value;
491
+ };
492
+ }
493
+ return _get.apply(this, arguments);
494
+ }
472
495
  function _toConsumableArray(arr) {
473
496
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
474
497
  }
@@ -512,6 +535,18 @@ PERFORMANCE OF THIS SOFTWARE.
512
535
  /* global Reflect, Promise, SuppressedError, Symbol */
513
536
 
514
537
 
538
+ function __rest(s, e) {
539
+ var t = {};
540
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
541
+ t[p] = s[p];
542
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
543
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
544
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
545
+ t[p[i]] = s[p[i]];
546
+ }
547
+ return t;
548
+ }
549
+
515
550
  function __awaiter(thisArg, _arguments, P, generator) {
516
551
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
517
552
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -533,6 +568,11 @@ var Version;
533
568
  Version["V1"] = "V1";
534
569
  Version["V3"] = "V3";
535
570
  })(Version || (Version = {}));
571
+ var Parents;
572
+ (function (Parents) {
573
+ Parents[Parents["ONE"] = 1] = "ONE";
574
+ Parents[Parents["ZERO"] = 0] = "ZERO";
575
+ })(Parents || (Parents = {}));
536
576
 
537
577
  // Used to inform user, that Parachain they wish to use has not yet implemented full XCM Support
538
578
  var NoXCMSupportImplementedError = /*#__PURE__*/function (_Error) {
@@ -1458,23 +1498,6 @@ var Interlay$2 = {
1458
1498
  }
1459
1499
  ]
1460
1500
  };
1461
- var Kylin$2 = {
1462
- paraId: 2052,
1463
- relayChainAssetSymbol: "DOT",
1464
- nativeAssets: [
1465
- {
1466
- symbol: "KYL",
1467
- decimals: 18
1468
- }
1469
- ],
1470
- otherAssets: [
1471
- {
1472
- assetId: "1",
1473
- symbol: "DOT",
1474
- decimals: 0
1475
- }
1476
- ]
1477
- };
1478
1501
  var Litentry$2 = {
1479
1502
  paraId: 2013,
1480
1503
  relayChainAssetSymbol: "DOT",
@@ -4888,7 +4911,6 @@ var assets = {
4888
4911
  Darwinia: Darwinia$2,
4889
4912
  HydraDX: HydraDX$2,
4890
4913
  Interlay: Interlay$2,
4891
- Kylin: Kylin$2,
4892
4914
  Litentry: Litentry$2,
4893
4915
  Moonbeam: Moonbeam$2,
4894
4916
  Parallel: Parallel$2,
@@ -4961,7 +4983,6 @@ var assetsMapJson = /*#__PURE__*/Object.freeze({
4961
4983
  InvArchTinker: InvArchTinker$2,
4962
4984
  Karura: Karura$2,
4963
4985
  Kintsugi: Kintsugi$2,
4964
- Kylin: Kylin$2,
4965
4986
  Litentry: Litentry$2,
4966
4987
  Litmus: Litmus$2,
4967
4988
  Mangata: Mangata$2,
@@ -5036,10 +5057,10 @@ var getAssetDecimals = function getAssetDecimals(node, symbol) {
5036
5057
  var getParaId = function getParaId(node) {
5037
5058
  return getAssetsObject(node).paraId;
5038
5059
  };
5039
- var getTNode = function getTNode(nodeID) {
5060
+ var getTNode = function getTNode(paraId) {
5040
5061
  var _a;
5041
5062
  return (_a = NODE_NAMES.find(function (node) {
5042
- return getParaId(node) === nodeID;
5063
+ return getParaId(node) === paraId;
5043
5064
  })) !== null && _a !== void 0 ? _a : null;
5044
5065
  };
5045
5066
 
@@ -5061,15 +5082,42 @@ var constructRelayToParaParameters = function constructRelayToParaParameters(_re
5061
5082
  var api = _ref.api,
5062
5083
  destination = _ref.destination,
5063
5084
  address = _ref.address,
5064
- amount = _ref.amount;
5085
+ amount = _ref.amount,
5086
+ paraIdTo = _ref.paraIdTo;
5065
5087
  var includeFee = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
5066
- var paraId = getParaId(destination);
5067
- var parameters = [createHeaderPolkadotXCM('RelayToPara', version, paraId), generateAddressPayload(api, 'RelayToPara', null, address, version, paraId), createCurrencySpecification(amount, 'RelayToPara', version, destination), 0];
5088
+ var paraId = paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination);
5089
+ var parameters = [createPolkadotXcmHeader('RelayToPara', version, paraId), generateAddressPayload(api, 'RelayToPara', null, address, version, paraId), createCurrencySpec(amount, version, Parents.ZERO), 0];
5068
5090
  if (includeFee) {
5069
5091
  parameters.push('Unlimited');
5070
5092
  }
5071
5093
  return parameters;
5072
5094
  };
5095
+ var createCurrencySpec = function createCurrencySpec(amount, version, parents) {
5096
+ var interior = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'Here';
5097
+ return _defineProperty({}, version, [{
5098
+ id: {
5099
+ Concrete: {
5100
+ parents: parents,
5101
+ interior: interior
5102
+ }
5103
+ },
5104
+ fun: {
5105
+ Fungible: amount
5106
+ }
5107
+ }]);
5108
+ };
5109
+ var createPolkadotXcmHeader = function createPolkadotXcmHeader(scenario, version, nodeId) {
5110
+ var parents = scenario === 'RelayToPara' ? Parents.ZERO : Parents.ONE;
5111
+ var interior = scenario === 'ParaToRelay' ? 'Here' : {
5112
+ X1: {
5113
+ Parachain: nodeId
5114
+ }
5115
+ };
5116
+ return _defineProperty({}, scenario === 'RelayToPara' ? Version.V3 : version, {
5117
+ parents: parents,
5118
+ interior: interior
5119
+ });
5120
+ };
5073
5121
 
5074
5122
  var supportsXTokens = function supportsXTokens(obj) {
5075
5123
  return 'transferXTokens' in obj;
@@ -5113,10 +5161,10 @@ var ParachainNode = /*#__PURE__*/function () {
5113
5161
  }
5114
5162
  }, {
5115
5163
  key: "transfer",
5116
- value: function transfer(api, currencySymbol, currencyId, amount, to, destination) {
5117
- var serializedApiCallEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
5164
+ value: function transfer(api, currencySymbol, currencyId, amount, to, destination, paraIdTo) {
5165
+ var serializedApiCallEnabled = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
5118
5166
  var scenario = destination !== undefined ? 'ParaToPara' : 'ParaToRelay';
5119
- var paraId = destination !== undefined ? getParaId(destination) : undefined;
5167
+ var paraId = destination !== undefined ? paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination) : undefined;
5120
5168
  if (supportsXTokens(this)) {
5121
5169
  return this.transferXTokens({
5122
5170
  api: api,
@@ -5131,9 +5179,9 @@ var ParachainNode = /*#__PURE__*/function () {
5131
5179
  } else if (supportsPolkadotXCM(this)) {
5132
5180
  return this.transferPolkadotXCM({
5133
5181
  api: api,
5134
- header: createHeaderPolkadotXCM(scenario, this.version, paraId),
5182
+ header: this.createPolkadotXcmHeader(scenario, paraId),
5135
5183
  addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', to, this.version, paraId),
5136
- currencySelection: createCurrencySpecification(amount, scenario, this.version, this._node, currencyId),
5184
+ currencySelection: this.createCurrencySpec(amount, scenario, this.version, currencyId),
5137
5185
  scenario: scenario,
5138
5186
  currencySymbol: currencySymbol,
5139
5187
  serializedApiCallEnabled: serializedApiCallEnabled
@@ -5174,6 +5222,16 @@ var ParachainNode = /*#__PURE__*/function () {
5174
5222
  }, _callee, this);
5175
5223
  }));
5176
5224
  }
5225
+ }, {
5226
+ key: "createCurrencySpec",
5227
+ value: function createCurrencySpec$1(amount, scenario, version, currencyId) {
5228
+ return createCurrencySpec(amount, version, scenario === 'ParaToRelay' ? Parents.ONE : Parents.ZERO);
5229
+ }
5230
+ }, {
5231
+ key: "createPolkadotXcmHeader",
5232
+ value: function createPolkadotXcmHeader$1(scenario, paraId) {
5233
+ return createPolkadotXcmHeader(scenario, this.version, paraId);
5234
+ }
5177
5235
  }]);
5178
5236
  return ParachainNode;
5179
5237
  }();
@@ -5434,24 +5492,6 @@ var Interlay$1 = /*#__PURE__*/function (_ParachainNode) {
5434
5492
  return Interlay;
5435
5493
  }(ParachainNode);
5436
5494
 
5437
- var Kylin$1 = /*#__PURE__*/function (_ParachainNode) {
5438
- _inherits(Kylin, _ParachainNode);
5439
- var _super = _createSuper(Kylin);
5440
- function Kylin() {
5441
- _classCallCheck(this, Kylin);
5442
- return _super.call(this, 'Kylin', 'kylin', 'polkadot', Version.V1);
5443
- }
5444
- _createClass(Kylin, [{
5445
- key: "transferXTokens",
5446
- value: function transferXTokens(input) {
5447
- var currency = input.currency,
5448
- fees = input.fees;
5449
- return XTokensTransferImpl.transferXTokens(input, currency, fees, 'OrmlXTokens');
5450
- }
5451
- }]);
5452
- return Kylin;
5453
- }(ParachainNode);
5454
-
5455
5495
  var Litentry$1 = /*#__PURE__*/function (_ParachainNode) {
5456
5496
  _inherits(Litentry, _ParachainNode);
5457
5497
  var _super = _createSuper(Litentry);
@@ -5480,7 +5520,7 @@ var Moonbeam$1 = /*#__PURE__*/function (_ParachainNode) {
5480
5520
  value: function transferXTokens(input) {
5481
5521
  var currency = input.currency,
5482
5522
  currencyID = input.currencyID;
5483
- var currencySelection = currency === 'GLMR' ? 'SelfReserve ' : {
5523
+ var currencySelection = currency === 'GLMR' ? 'SelfReserve' : {
5484
5524
  ForeignAsset: currencyID
5485
5525
  };
5486
5526
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
@@ -5503,7 +5543,7 @@ var Parallel$1 = /*#__PURE__*/function (_ParachainNode) {
5503
5543
  var _super = _createSuper(Parallel);
5504
5544
  function Parallel() {
5505
5545
  _classCallCheck(this, Parallel);
5506
- return _super.call(this, 'Parallel', 'parallel', 'polkadot', Version.V1);
5546
+ return _super.call(this, 'Parallel', 'parallel', 'polkadot', Version.V3);
5507
5547
  }
5508
5548
  _createClass(Parallel, [{
5509
5549
  key: "transferXTokens",
@@ -5682,7 +5722,7 @@ var Moonriver$1 = /*#__PURE__*/function (_ParachainNode) {
5682
5722
  value: function transferXTokens(input) {
5683
5723
  var currency = input.currency,
5684
5724
  currencyID = input.currencyID;
5685
- var currencySelection = currency === 'MOVR' ? 'SelfReserve ' : {
5725
+ var currencySelection = currency === 'MOVR' ? 'SelfReserve' : {
5686
5726
  ForeignAsset: currencyID
5687
5727
  };
5688
5728
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
@@ -5716,20 +5756,39 @@ var Mangata$1 = /*#__PURE__*/function (_ParachainNode) {
5716
5756
  key: "createApiInstance",
5717
5757
  value: function createApiInstance() {
5718
5758
  return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
5719
- var MangataSDK, instance;
5759
+ var _yield$import, mTypes, mRpc, options, provider;
5720
5760
  return _regeneratorRuntime().wrap(function _callee$(_context) {
5721
5761
  while (1) switch (_context.prev = _context.next) {
5722
5762
  case 0:
5723
5763
  _context.next = 2;
5724
- return import('@mangata-finance/sdk');
5764
+ return import('@mangata-finance/type-definitions');
5725
5765
  case 2:
5726
- MangataSDK = _context.sent;
5727
- instance = MangataSDK.Mangata.instance([this.getProvider()]);
5728
- _context.next = 6;
5729
- return instance.api();
5730
- case 6:
5766
+ _yield$import = _context.sent;
5767
+ mTypes = _yield$import.mTypes;
5768
+ mRpc = _yield$import.mRpc;
5769
+ options = function options() {
5770
+ var _a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5771
+ var _a$types = _a.types,
5772
+ types = _a$types === void 0 ? {} : _a$types,
5773
+ _a$rpc = _a.rpc,
5774
+ rpc = _a$rpc === void 0 ? {} : _a$rpc,
5775
+ otherOptions = __rest(_a, ["types", "rpc"]);
5776
+ return Object.assign({
5777
+ types: Object.assign(Object.assign({}, mTypes), types),
5778
+ rpc: Object.assign(Object.assign({}, mRpc), rpc)
5779
+ }, otherOptions);
5780
+ };
5781
+ provider = new WsProvider(this.getProvider());
5782
+ _context.next = 9;
5783
+ return ApiPromise.create(options({
5784
+ provider: provider,
5785
+ throwOnConnect: true,
5786
+ throwOnUnknown: true,
5787
+ noInitWarn: true
5788
+ }));
5789
+ case 9:
5731
5790
  return _context.abrupt("return", _context.sent);
5732
- case 7:
5791
+ case 10:
5733
5792
  case "end":
5734
5793
  return _context.stop();
5735
5794
  }
@@ -5791,11 +5850,10 @@ var Calamari$1 = /*#__PURE__*/function (_ParachainNode) {
5791
5850
  key: "transferXTokens",
5792
5851
  value: function transferXTokens(input) {
5793
5852
  // Currently only option for XCM transfer
5794
- var currencyID = input.currencyID,
5795
- fees = input.fees;
5853
+ var currencyID = input.currencyID;
5796
5854
  return XTokensTransferImpl.transferXTokens(input, {
5797
5855
  MantaCurrency: currencyID
5798
- }, fees);
5856
+ });
5799
5857
  }
5800
5858
  }]);
5801
5859
  return Calamari;
@@ -5826,7 +5884,7 @@ var CrustShadow$1 = /*#__PURE__*/function (_ParachainNode) {
5826
5884
  }, {
5827
5885
  key: "transferXTokens",
5828
5886
  value: function transferXTokens(input) {
5829
- return XTokensTransferImpl.transferXTokens(input, this.getCurrencySelection(input));
5887
+ return XTokensTransferImpl.transferXTokens(input, this.getCurrencySelection(input), input.fees);
5830
5888
  }
5831
5889
  }]);
5832
5890
  return CrustShadow;
@@ -6009,6 +6067,22 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
6009
6067
  parameters: constructRelayToParaParameters(options, Version.V3, true)
6010
6068
  };
6011
6069
  }
6070
+ }, {
6071
+ key: "createCurrencySpec",
6072
+ value: function createCurrencySpec$1(amount, scenario, version, currencyId) {
6073
+ if (scenario === 'ParaToPara') {
6074
+ var interior = {
6075
+ X2: [{
6076
+ PalletInstance: 50
6077
+ }, {
6078
+ GeneralIndex: currencyId
6079
+ }]
6080
+ };
6081
+ return createCurrencySpec(amount, version, Parents.ZERO, interior);
6082
+ } else {
6083
+ return _get(_getPrototypeOf(AssetHubPolkadot.prototype), "createCurrencySpec", this).call(this, amount, scenario, version, currencyId);
6084
+ }
6085
+ }
6012
6086
  }]);
6013
6087
  return AssetHubPolkadot;
6014
6088
  }(ParachainNode);
@@ -6036,6 +6110,11 @@ var AssetHubKusama$1 = /*#__PURE__*/function (_ParachainNode) {
6036
6110
  parameters: constructRelayToParaParameters(options, Version.V3, true)
6037
6111
  };
6038
6112
  }
6113
+ }, {
6114
+ key: "createCurrencySpec",
6115
+ value: function createCurrencySpec(amount, scenario, version, currencyId) {
6116
+ return getNode('AssetHubPolkadot').createCurrencySpec(amount, scenario, version, currencyId);
6117
+ }
6039
6118
  }]);
6040
6119
  return AssetHubKusama;
6041
6120
  }(ParachainNode);
@@ -6106,6 +6185,42 @@ var Astar$1 = /*#__PURE__*/function (_ParachainNode) {
6106
6185
  var method = input.scenario === 'ParaToPara' ? 'reserveTransferAssets' : 'reserveWithdrawAssets';
6107
6186
  return PolkadotXCMTransferImpl.transferPolkadotXCM(input, method);
6108
6187
  }
6188
+ }, {
6189
+ key: "transferXTokens",
6190
+ value: function transferXTokens(input) {
6191
+ return XTokensTransferImpl.transferXTokens(input, input.currencyID);
6192
+ }
6193
+ }, {
6194
+ key: "transfer",
6195
+ value: function transfer(api, currencySymbol, currencyId, amount, to, destination, paraIdTo) {
6196
+ var serializedApiCallEnabled = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
6197
+ var scenario = destination !== undefined ? 'ParaToPara' : 'ParaToRelay';
6198
+ var paraId = destination !== undefined ? paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination) : undefined;
6199
+ var node = this.node;
6200
+ if (supportsXTokens(this) && currencySymbol !== 'ASTR') {
6201
+ return this.transferXTokens({
6202
+ api: api,
6203
+ currency: currencySymbol,
6204
+ currencyID: currencyId,
6205
+ amount: amount,
6206
+ addressSelection: generateAddressPayload(api, scenario, 'XTokens', to, this.version, paraId),
6207
+ fees: getFees(scenario),
6208
+ scenario: scenario,
6209
+ serializedApiCallEnabled: serializedApiCallEnabled
6210
+ });
6211
+ } else if (supportsPolkadotXCM(this)) {
6212
+ return this.transferPolkadotXCM({
6213
+ api: api,
6214
+ header: this.createPolkadotXcmHeader(scenario, paraId),
6215
+ addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', to, this.version, paraId),
6216
+ currencySelection: this.createCurrencySpec(amount, scenario, this.version, currencyId),
6217
+ scenario: scenario,
6218
+ currencySymbol: currencySymbol,
6219
+ serializedApiCallEnabled: serializedApiCallEnabled
6220
+ });
6221
+ }
6222
+ throw new NoXCMSupportImplementedError(node);
6223
+ }
6109
6224
  }]);
6110
6225
  return Astar;
6111
6226
  }(ParachainNode);
@@ -6135,19 +6250,31 @@ var Darwinia$1 = /*#__PURE__*/function (_ParachainNode) {
6135
6250
  return _super.call(this, 'Darwinia', 'darwinia', 'polkadot', Version.V3);
6136
6251
  }
6137
6252
  _createClass(Darwinia, [{
6138
- key: "transferPolkadotXCM",
6139
- value: function transferPolkadotXCM(input) {
6140
- // TESTED https://polkadot.subscan.io/xcm_message/polkadot-55c5c36c8fe8794c8cfbea725c9f8bc5984c6b05
6141
- if (input.scenario === 'ParaToPara') {
6142
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserveTransferAssets');
6143
- }
6144
- throw new ScenarioNotSupportedError(this.node, input.scenario);
6253
+ key: "transferXTokens",
6254
+ value: function transferXTokens(input) {
6255
+ return XTokensTransferImpl.transferXTokens(input, input.currency === 'RING' ? 'SelfReserve' : {
6256
+ ForeignAsset: input.currencyID
6257
+ });
6145
6258
  }
6146
6259
  }, {
6147
6260
  key: "transferRelayToPara",
6148
6261
  value: function transferRelayToPara() {
6149
6262
  throw new NodeNotSupportedError();
6150
6263
  }
6264
+ }, {
6265
+ key: "createCurrencySpec",
6266
+ value: function createCurrencySpec$1(amount, scenario, version, currencyId) {
6267
+ if (scenario === 'ParaToPara') {
6268
+ var interior = {
6269
+ X1: {
6270
+ PalletInstance: 5
6271
+ }
6272
+ };
6273
+ return createCurrencySpec(amount, version, Parents.ZERO, interior);
6274
+ } else {
6275
+ return _get(_getPrototypeOf(Darwinia.prototype), "createCurrencySpec", this).call(this, amount, scenario, version, currencyId);
6276
+ }
6277
+ }
6151
6278
  }]);
6152
6279
  return Darwinia;
6153
6280
  }(ParachainNode);
@@ -6173,6 +6300,11 @@ var Crab$1 = /*#__PURE__*/function (_ParachainNode) {
6173
6300
  value: function transferRelayToPara() {
6174
6301
  throw new NodeNotSupportedError();
6175
6302
  }
6303
+ }, {
6304
+ key: "createCurrencySpec",
6305
+ value: function createCurrencySpec(amount, scenario, version, currencyId) {
6306
+ return getNode('Darwinia').createCurrencySpec(amount, scenario, version, currencyId);
6307
+ }
6176
6308
  }]);
6177
6309
  return Crab;
6178
6310
  }(ParachainNode);
@@ -6214,6 +6346,42 @@ var Shiden$1 = /*#__PURE__*/function (_ParachainNode) {
6214
6346
  var method = input.scenario === 'ParaToPara' ? 'reserveTransferAssets' : 'reserveWithdrawAssets';
6215
6347
  return PolkadotXCMTransferImpl.transferPolkadotXCM(input, method);
6216
6348
  }
6349
+ }, {
6350
+ key: "transferXTokens",
6351
+ value: function transferXTokens(input) {
6352
+ return XTokensTransferImpl.transferXTokens(input, input.currencyID);
6353
+ }
6354
+ }, {
6355
+ key: "transfer",
6356
+ value: function transfer(api, currencySymbol, currencyId, amount, to, destination, paraIdTo) {
6357
+ var serializedApiCallEnabled = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
6358
+ var scenario = destination !== undefined ? 'ParaToPara' : 'ParaToRelay';
6359
+ var paraId = destination !== undefined ? paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination) : undefined;
6360
+ var node = this.node;
6361
+ if (supportsXTokens(this) && currencySymbol !== 'SDN') {
6362
+ return this.transferXTokens({
6363
+ api: api,
6364
+ currency: currencySymbol,
6365
+ currencyID: currencyId,
6366
+ amount: amount,
6367
+ addressSelection: generateAddressPayload(api, scenario, 'XTokens', to, this.version, paraId),
6368
+ fees: getFees(scenario),
6369
+ scenario: scenario,
6370
+ serializedApiCallEnabled: serializedApiCallEnabled
6371
+ });
6372
+ } else if (supportsPolkadotXCM(this)) {
6373
+ return this.transferPolkadotXCM({
6374
+ api: api,
6375
+ header: this.createPolkadotXcmHeader(scenario, paraId),
6376
+ addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', to, this.version, paraId),
6377
+ currencySelection: this.createCurrencySpec(amount, scenario, this.version, currencyId),
6378
+ scenario: scenario,
6379
+ currencySymbol: currencySymbol,
6380
+ serializedApiCallEnabled: serializedApiCallEnabled
6381
+ });
6382
+ }
6383
+ throw new NoXCMSupportImplementedError(node);
6384
+ }
6217
6385
  }]);
6218
6386
  return Shiden;
6219
6387
  }(ParachainNode);
@@ -6303,7 +6471,7 @@ var Pendulum$1 = /*#__PURE__*/function (_ParachainNode) {
6303
6471
  var _super = _createSuper(Pendulum);
6304
6472
  function Pendulum() {
6305
6473
  _classCallCheck(this, Pendulum);
6306
- return _super.call(this, 'Pendulum', 'pendulum', 'polkadot', Version.V1);
6474
+ return _super.call(this, 'Pendulum', 'pendulum', 'polkadot', Version.V3);
6307
6475
  }
6308
6476
  _createClass(Pendulum, [{
6309
6477
  key: "transferXTokens",
@@ -6363,7 +6531,7 @@ var Zeitgeist$1 = /*#__PURE__*/function (_ParachainNode) {
6363
6531
  }(ParachainNode);
6364
6532
 
6365
6533
  // Contains supported Parachains and exports supported XCM Pallets
6366
- var NODE_NAMES = ['AssetHubPolkadot', 'Acala', 'Astar', 'BifrostPolkadot', 'Bitgreen', 'Centrifuge', 'Clover', 'ComposableFinance', 'Darwinia', 'HydraDX', 'Interlay', 'Kylin', 'Litentry', 'Moonbeam', 'Parallel', 'AssetHubKusama', 'Encointer', 'Altair', 'Amplitude', 'Bajun', 'Basilisk', 'BifrostKusama', 'Pioneer', 'Calamari', 'CrustShadow', 'Crab', 'Imbue', 'Integritee', 'InvArchTinker', 'Karura', 'Kintsugi', 'Litmus', 'Mangata', 'Moonriver', 'ParallelHeiko', 'Picasso', 'Quartz', 'Robonomics', 'Shiden', 'Turing', 'Equilibrium', 'Unique', 'Crust', 'Manta', 'Genshiro', 'Nodle', 'OriginTrail', 'Pendulum', 'Polkadex', 'Zeitgeist'];
6534
+ var NODE_NAMES = ['AssetHubPolkadot', 'Acala', 'Astar', 'BifrostPolkadot', 'Bitgreen', 'Centrifuge', 'Clover', 'ComposableFinance', 'Darwinia', 'HydraDX', 'Interlay', 'Litentry', 'Moonbeam', 'Parallel', 'AssetHubKusama', 'Encointer', 'Altair', 'Amplitude', 'Bajun', 'Basilisk', 'BifrostKusama', 'Pioneer', 'Calamari', 'CrustShadow', 'Crab', 'Imbue', 'Integritee', 'InvArchTinker', 'Karura', 'Kintsugi', 'Litmus', 'Mangata', 'Moonriver', 'ParallelHeiko', 'Picasso', 'Quartz', 'Robonomics', 'Shiden', 'Turing', 'Equilibrium', 'Unique', 'Crust', 'Manta', 'Genshiro', 'Nodle', 'OriginTrail', 'Pendulum', 'Polkadex', 'Zeitgeist'];
6367
6535
  var NODES_WITH_RELAY_CHAINS = [].concat(NODE_NAMES, ['Polkadot', 'Kusama']);
6368
6536
  var nodes = {
6369
6537
  AssetHubPolkadot: new AssetHubPolkadot$1(),
@@ -6380,7 +6548,6 @@ var nodes = {
6380
6548
  Darwinia: new Darwinia$1(),
6381
6549
  HydraDX: new HydraDX$1(),
6382
6550
  Interlay: new Interlay$1(),
6383
- Kylin: new Kylin$1(),
6384
6551
  Litentry: new Litentry$1(),
6385
6552
  Moonbeam: new Moonbeam$1(),
6386
6553
  Parallel: new Parallel$1(),
@@ -6492,121 +6659,6 @@ var generateAddressPayload = function generateAddressPayload(api, scenario, pall
6492
6659
  }
6493
6660
  };
6494
6661
  };
6495
- // TODO: Refactor this function
6496
- var createCurrencySpecification = function createCurrencySpecification(amount, scenario, version, node, cur) {
6497
- if (scenario === 'ParaToRelay') {
6498
- return _defineProperty({}, version, [{
6499
- id: {
6500
- Concrete: {
6501
- parents: 1,
6502
- interior: 'Here'
6503
- }
6504
- },
6505
- fun: {
6506
- Fungible: amount
6507
- }
6508
- }]);
6509
- }
6510
- if (scenario === 'RelayToPara' || scenario === 'ParaToPara') {
6511
- console.log('polkadotXCM Native currency to sender chain transfer');
6512
- if ((node === 'Darwinia' || node === 'Crab') && scenario === 'ParaToPara') {
6513
- // Special case for Darwinia&Crab node
6514
- return {
6515
- V3: [{
6516
- id: {
6517
- Concrete: {
6518
- parents: 0,
6519
- interior: {
6520
- X1: {
6521
- PalletInstance: 5
6522
- }
6523
- }
6524
- }
6525
- },
6526
- fun: {
6527
- Fungible: amount
6528
- }
6529
- }]
6530
- };
6531
- } else if ((node === 'AssetHubPolkadot' || node === 'AssetHubKusama') && scenario === 'ParaToPara') {
6532
- // Another specific case for AssetHubPolkadot & AssetHubKusama to send for example USDt
6533
- return {
6534
- V3: [{
6535
- id: {
6536
- Concrete: {
6537
- parents: 0,
6538
- interior: {
6539
- X2: [{
6540
- PalletInstance: 50
6541
- }, {
6542
- GeneralIndex: cur
6543
- }]
6544
- }
6545
- }
6546
- },
6547
- fun: {
6548
- Fungible: amount
6549
- }
6550
- }]
6551
- };
6552
- }
6553
- if (scenario === 'ParaToPara' && node === 'Robonomics') {
6554
- return _defineProperty({}, version, [{
6555
- id: {
6556
- Concrete: {
6557
- parents: 0,
6558
- interior: 'Here'
6559
- }
6560
- },
6561
- fun: {
6562
- Fungible: amount
6563
- }
6564
- }]);
6565
- }
6566
- // Otherwise
6567
- return {
6568
- V3: [{
6569
- id: {
6570
- Concrete: {
6571
- parents: 0,
6572
- interior: 'Here'
6573
- }
6574
- },
6575
- fun: {
6576
- Fungible: amount
6577
- }
6578
- }]
6579
- };
6580
- }
6581
- };
6582
- var createHeaderPolkadotXCM = function createHeaderPolkadotXCM(scenario, version, nodeId) {
6583
- if (scenario === 'ParaToRelay') {
6584
- return _defineProperty({}, version, {
6585
- parents: 1,
6586
- interior: 'Here'
6587
- });
6588
- }
6589
- if (scenario === 'ParaToPara') {
6590
- return _defineProperty({}, version, {
6591
- parents: 1,
6592
- interior: {
6593
- X1: {
6594
- Parachain: nodeId
6595
- }
6596
- }
6597
- });
6598
- }
6599
- return {
6600
- V3: {
6601
- parents: 0,
6602
- interior: {
6603
- X1: {
6604
- Parachain: nodeId
6605
- }
6606
- }
6607
- }
6608
- };
6609
- };
6610
6662
  var getNode = function getNode(node) {
6611
6663
  return nodes[node];
6612
6664
  };
@@ -6614,26 +6666,16 @@ var getNodeEndpointOption = function getNodeEndpointOption(node) {
6614
6666
  var _getNode = getNode(node),
6615
6667
  type = _getNode.type,
6616
6668
  name = _getNode.name;
6617
- var _ref9 = type === 'polkadot' ? prodRelayPolkadot : prodRelayKusama,
6618
- linked = _ref9.linked;
6619
- // TMP Fix because some nodes don't have providers in endpoint options
6620
- if (node === 'Kylin') {
6621
- return {
6622
- info: 'kylin',
6623
- paraId: 2052,
6624
- providers: {
6625
- 'Kylin Network': 'wss://polkadot.kylin-node.co.uk'
6626
- }
6627
- };
6628
- }
6669
+ var _ref5 = type === 'polkadot' ? prodRelayPolkadot : prodRelayKusama,
6670
+ linked = _ref5.linked;
6629
6671
  return linked !== undefined ? linked.find(function (o) {
6630
6672
  return o.info === name;
6631
6673
  }) : undefined;
6632
6674
  };
6633
6675
  var getAllNodeProviders = function getAllNodeProviders(node) {
6634
6676
  var _a;
6635
- var _ref10 = (_a = getNodeEndpointOption(node)) !== null && _a !== void 0 ? _a : {},
6636
- providers = _ref10.providers;
6677
+ var _ref6 = (_a = getNodeEndpointOption(node)) !== null && _a !== void 0 ? _a : {},
6678
+ providers = _ref6.providers;
6637
6679
  if (providers.length < 1) {
6638
6680
  throw new Error("Node ".concat(node, " does not have any providers."));
6639
6681
  }
@@ -6693,11 +6735,11 @@ var createApiInstanceForNode = function createApiInstanceForNode(node) {
6693
6735
  var lowercaseFirstLetter = function lowercaseFirstLetter(str) {
6694
6736
  return str.charAt(0).toLowerCase() + str.slice(1);
6695
6737
  };
6696
- var callPolkadotJsTxFunction = function callPolkadotJsTxFunction(api, _ref11) {
6738
+ var callPolkadotJsTxFunction = function callPolkadotJsTxFunction(api, _ref7) {
6697
6739
  var _api$tx$module;
6698
- var module = _ref11.module,
6699
- section = _ref11.section,
6700
- parameters = _ref11.parameters;
6740
+ var module = _ref7.module,
6741
+ section = _ref7.section,
6742
+ parameters = _ref7.parameters;
6701
6743
  return (_api$tx$module = api.tx[module])[section].apply(_api$tx$module, _toConsumableArray(parameters));
6702
6744
  };
6703
6745
 
@@ -6726,8 +6768,8 @@ var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, symbolOrId) {
6726
6768
  };
6727
6769
 
6728
6770
  // Contains basic call formatting for different XCM Palletss
6729
- var sendCommon = function sendCommon(api, origin, currencySymbolOrId, amount, to, destination) {
6730
- var serializedApiCallEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
6771
+ var sendCommon = function sendCommon(api, origin, currencySymbolOrId, amount, to, destination, paraIdTo) {
6772
+ var serializedApiCallEnabled = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
6731
6773
  if (typeof currencySymbolOrId === 'number' && currencySymbolOrId > Number.MAX_SAFE_INTEGER) {
6732
6774
  throw new InvalidCurrencyError('The provided asset ID is larger than the maximum safe integer value. Please provide it as a string.');
6733
6775
  }
@@ -6747,32 +6789,33 @@ var sendCommon = function sendCommon(api, origin, currencySymbolOrId, amount, to
6747
6789
  throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency or currencyId ").concat(currencySymbolOrId, "."));
6748
6790
  }
6749
6791
  var currencyId = originNode.assetCheckEnabled ? asset === null || asset === void 0 ? void 0 : asset.assetId : currencySymbolOrId.toString();
6750
- return originNode.transfer(api, asset === null || asset === void 0 ? void 0 : asset.symbol, currencyId, amount, to, destination, serializedApiCallEnabled);
6792
+ return originNode.transfer(api, asset === null || asset === void 0 ? void 0 : asset.symbol, currencyId, amount, to, destination, paraIdTo, serializedApiCallEnabled);
6751
6793
  };
6752
- var sendSerializedApiCall = function sendSerializedApiCall(api, origin, currencySymbolOrId, amount, to, destination) {
6753
- return sendCommon(api, origin, currencySymbolOrId, amount.toString(), to, destination, true);
6794
+ var sendSerializedApiCall = function sendSerializedApiCall(api, origin, currencySymbolOrId, amount, to, destination, paraIdTo) {
6795
+ return sendCommon(api, origin, currencySymbolOrId, amount.toString(), to, destination, paraIdTo, true);
6754
6796
  };
6755
- function send(api, origin, currencySymbolOrId, amount, to, destination) {
6756
- return sendCommon(api, origin, currencySymbolOrId, amount.toString(), to, destination);
6797
+ function send(api, origin, currencySymbolOrId, amount, to, destination, paraIdTo) {
6798
+ return sendCommon(api, origin, currencySymbolOrId, amount.toString(), to, destination, paraIdTo);
6757
6799
  }
6758
- var transferRelayToParaCommon = function transferRelayToParaCommon(api, destination, amount, address) {
6759
- var serializedApiCallEnabled = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
6800
+ var transferRelayToParaCommon = function transferRelayToParaCommon(api, destination, amount, address, paraIdTo) {
6801
+ var serializedApiCallEnabled = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
6760
6802
  var serializedApiCall = getNode(destination).transferRelayToPara({
6761
6803
  api: api,
6762
6804
  destination: destination,
6763
6805
  address: address,
6764
- amount: amount
6806
+ amount: amount,
6807
+ paraIdTo: paraIdTo
6765
6808
  });
6766
6809
  if (serializedApiCallEnabled) {
6767
6810
  return serializedApiCall;
6768
6811
  }
6769
6812
  return callPolkadotJsTxFunction(api, serializedApiCall);
6770
6813
  };
6771
- function transferRelayToPara(api, destination, amount, to) {
6772
- return transferRelayToParaCommon(api, destination, amount.toString(), to);
6814
+ function transferRelayToPara(api, destination, amount, to, paraIdTo) {
6815
+ return transferRelayToParaCommon(api, destination, amount.toString(), to, paraIdTo);
6773
6816
  }
6774
- var transferRelayToParaSerializedApiCall = function transferRelayToParaSerializedApiCall(api, destination, amount, to) {
6775
- return transferRelayToParaCommon(api, destination, amount.toString(), to, true);
6817
+ var transferRelayToParaSerializedApiCall = function transferRelayToParaSerializedApiCall(api, destination, amount, to, paraIdTo) {
6818
+ return transferRelayToParaCommon(api, destination, amount.toString(), to, paraIdTo, true);
6776
6819
  };
6777
6820
 
6778
6821
  var index$3 = /*#__PURE__*/Object.freeze({
@@ -7079,10 +7122,11 @@ var OpenChannelBuilder = /*#__PURE__*/function () {
7079
7122
  }();
7080
7123
 
7081
7124
  var RelayToParaBuilder = /*#__PURE__*/function () {
7082
- function RelayToParaBuilder(api, to) {
7125
+ function RelayToParaBuilder(api, to, paraIdTo) {
7083
7126
  _classCallCheck(this, RelayToParaBuilder);
7084
7127
  this.api = api;
7085
7128
  this.to = to;
7129
+ this.paraIdTo = paraIdTo;
7086
7130
  }
7087
7131
  _createClass(RelayToParaBuilder, [{
7088
7132
  key: "amount",
@@ -7099,17 +7143,17 @@ var RelayToParaBuilder = /*#__PURE__*/function () {
7099
7143
  }, {
7100
7144
  key: "build",
7101
7145
  value: function build() {
7102
- return transferRelayToPara(this.api, this.to, this._amount, this._address);
7146
+ return transferRelayToPara(this.api, this.to, this._amount, this._address, this.paraIdTo);
7103
7147
  }
7104
7148
  }, {
7105
7149
  key: "buildSerializedApiCall",
7106
7150
  value: function buildSerializedApiCall() {
7107
- return transferRelayToParaSerializedApiCall(this.api, this.to, this._amount, this._address);
7151
+ return transferRelayToParaSerializedApiCall(this.api, this.to, this._amount, this._address, this.paraIdTo);
7108
7152
  }
7109
7153
  }], [{
7110
7154
  key: "create",
7111
- value: function create(api, to) {
7112
- return new RelayToParaBuilder(api, to);
7155
+ value: function create(api, to, paraIdTo) {
7156
+ return new RelayToParaBuilder(api, to, paraIdTo);
7113
7157
  }
7114
7158
  }]);
7115
7159
  return RelayToParaBuilder;
@@ -7202,12 +7246,13 @@ var SellBuilder = /*#__PURE__*/function () {
7202
7246
  }();
7203
7247
 
7204
7248
  var ParaToParaBuilder = /*#__PURE__*/function () {
7205
- function ParaToParaBuilder(api, from, to, currency) {
7249
+ function ParaToParaBuilder(api, from, to, currency, paraIdTo) {
7206
7250
  _classCallCheck(this, ParaToParaBuilder);
7207
7251
  this.api = api;
7208
7252
  this.from = from;
7209
7253
  this.to = to;
7210
7254
  this.currency = currency;
7255
+ this.paraIdTo = paraIdTo;
7211
7256
  }
7212
7257
  _createClass(ParaToParaBuilder, [{
7213
7258
  key: "amount",
@@ -7224,17 +7269,17 @@ var ParaToParaBuilder = /*#__PURE__*/function () {
7224
7269
  }, {
7225
7270
  key: "build",
7226
7271
  value: function build() {
7227
- return send(this.api, this.from, this.currency, this._amount, this._address, this.to);
7272
+ return send(this.api, this.from, this.currency, this._amount, this._address, this.to, this.paraIdTo);
7228
7273
  }
7229
7274
  }, {
7230
7275
  key: "buildSerializedApiCall",
7231
7276
  value: function buildSerializedApiCall() {
7232
- return sendSerializedApiCall(this.api, this.from, this.currency, this._amount, this._address, this.to);
7277
+ return sendSerializedApiCall(this.api, this.from, this.currency, this._amount, this._address, this.to, this.paraIdTo);
7233
7278
  }
7234
7279
  }], [{
7235
7280
  key: "createParaToPara",
7236
- value: function createParaToPara(api, from, to, currency) {
7237
- return new ParaToParaBuilder(api, from, to, currency);
7281
+ value: function createParaToPara(api, from, to, currency, paraIdTo) {
7282
+ return new ParaToParaBuilder(api, from, to, currency, paraIdTo);
7238
7283
  }
7239
7284
  }]);
7240
7285
  return ParaToParaBuilder;
@@ -7275,16 +7320,17 @@ var ParaToRelayBuilder = /*#__PURE__*/function () {
7275
7320
  }();
7276
7321
 
7277
7322
  var ToGeneralBuilder = /*#__PURE__*/function () {
7278
- function ToGeneralBuilder(api, from, to) {
7323
+ function ToGeneralBuilder(api, from, to, paraIdTo) {
7279
7324
  _classCallCheck(this, ToGeneralBuilder);
7280
7325
  this.api = api;
7281
7326
  this.from = from;
7282
7327
  this.to = to;
7328
+ this.paraIdTo = paraIdTo;
7283
7329
  }
7284
7330
  _createClass(ToGeneralBuilder, [{
7285
7331
  key: "currency",
7286
7332
  value: function currency(_currency) {
7287
- return ParaToParaBuilder.createParaToPara(this.api, this.from, this.to, _currency);
7333
+ return ParaToParaBuilder.createParaToPara(this.api, this.from, this.to, _currency, this.paraIdTo);
7288
7334
  }
7289
7335
  }, {
7290
7336
  key: "openChannel",
@@ -7302,8 +7348,8 @@ var FromGeneralBuilder = /*#__PURE__*/function () {
7302
7348
  }
7303
7349
  _createClass(FromGeneralBuilder, [{
7304
7350
  key: "to",
7305
- value: function to(node) {
7306
- return new ToGeneralBuilder(this.api, this.from, node);
7351
+ value: function to(node, paraIdTo) {
7352
+ return new ToGeneralBuilder(this.api, this.from, node, paraIdTo);
7307
7353
  }
7308
7354
  }, {
7309
7355
  key: "amount",
@@ -7330,8 +7376,8 @@ var GeneralBuilder = /*#__PURE__*/function () {
7330
7376
  }
7331
7377
  }, {
7332
7378
  key: "to",
7333
- value: function to(node) {
7334
- return RelayToParaBuilder.create(this.api, node);
7379
+ value: function to(node, paraIdTo) {
7380
+ return RelayToParaBuilder.create(this.api, node, paraIdTo);
7335
7381
  }
7336
7382
  }, {
7337
7383
  key: "addLiquidity",
@@ -7439,13 +7485,6 @@ var Interlay = {
7439
7485
  "XTokens"
7440
7486
  ]
7441
7487
  };
7442
- var Kylin = {
7443
- defaultPallet: "OrmlXTokens",
7444
- supportedPallets: [
7445
- "PolkadotXcm",
7446
- "OrmlXTokens"
7447
- ]
7448
- };
7449
7488
  var Litentry = {
7450
7489
  defaultPallet: "XTokens",
7451
7490
  supportedPallets: [
@@ -7716,7 +7755,6 @@ var pallets = {
7716
7755
  Darwinia: Darwinia,
7717
7756
  HydraDX: HydraDX,
7718
7757
  Interlay: Interlay,
7719
- Kylin: Kylin,
7720
7758
  Litentry: Litentry,
7721
7759
  Moonbeam: Moonbeam,
7722
7760
  Parallel: Parallel,
@@ -7788,7 +7826,6 @@ var palletsMapJson = /*#__PURE__*/Object.freeze({
7788
7826
  InvArchTinker: InvArchTinker,
7789
7827
  Karura: Karura,
7790
7828
  Kintsugi: Kintsugi,
7791
- Kylin: Kylin,
7792
7829
  Litentry: Litentry,
7793
7830
  Litmus: Litmus,
7794
7831
  Mangata: Mangata,
@@ -7821,4 +7858,4 @@ var getSupportedPallets = function getSupportedPallets(node) {
7821
7858
  return palletsMap[node].supportedPallets;
7822
7859
  };
7823
7860
 
7824
- export { Builder, IncompatibleNodesError, InvalidCurrencyError, NODES_WITH_RELAY_CHAINS, NODE_NAMES, NoXCMSupportImplementedError, NodeNotSupportedError, SUPPORTED_PALLETS, ScenarioNotSupportedError, Version, index$4 as assets, index as closeChannels, createApiInstanceForNode, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssetsObject, getDefaultPallet, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedPallets, getTNode, hasSupportForAsset, index$1 as openChannels, index$3 as xcmPallet, index$2 as xyk };
7861
+ export { Builder, IncompatibleNodesError, InvalidCurrencyError, NODES_WITH_RELAY_CHAINS, NODE_NAMES, NoXCMSupportImplementedError, NodeNotSupportedError, Parents, SUPPORTED_PALLETS, ScenarioNotSupportedError, Version, index$4 as assets, index as closeChannels, createApiInstanceForNode, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssetsObject, getDefaultPallet, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedPallets, getTNode, hasSupportForAsset, index$1 as openChannels, index$3 as xcmPallet, index$2 as xyk };