@paraspell/sdk 1.1.4 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -26,20 +26,6 @@ function _createClass(Constructor, protoProps, staticProps) {
26
26
  });
27
27
  return Constructor;
28
28
  }
29
- function _defineProperty(obj, key, value) {
30
- key = _toPropertyKey(key);
31
- if (key in obj) {
32
- Object.defineProperty(obj, key, {
33
- value: value,
34
- enumerable: true,
35
- configurable: true,
36
- writable: true
37
- });
38
- } else {
39
- obj[key] = value;
40
- }
41
- return obj;
42
- }
43
29
  function _inherits(subClass, superClass) {
44
30
  if (typeof superClass !== "function" && superClass !== null) {
45
31
  throw new TypeError("Super expression must either be null or a function");
@@ -177,6 +163,57 @@ function _arrayLikeToArray(arr, len) {
177
163
  function _nonIterableSpread() {
178
164
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
179
165
  }
166
+ function _createForOfIteratorHelper(o, allowArrayLike) {
167
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
168
+ if (!it) {
169
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
170
+ if (it) o = it;
171
+ var i = 0;
172
+ var F = function () {};
173
+ return {
174
+ s: F,
175
+ n: function () {
176
+ if (i >= o.length) return {
177
+ done: true
178
+ };
179
+ return {
180
+ done: false,
181
+ value: o[i++]
182
+ };
183
+ },
184
+ e: function (e) {
185
+ throw e;
186
+ },
187
+ f: F
188
+ };
189
+ }
190
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
191
+ }
192
+ var normalCompletion = true,
193
+ didErr = false,
194
+ err;
195
+ return {
196
+ s: function () {
197
+ it = it.call(o);
198
+ },
199
+ n: function () {
200
+ var step = it.next();
201
+ normalCompletion = step.done;
202
+ return step;
203
+ },
204
+ e: function (e) {
205
+ didErr = true;
206
+ err = e;
207
+ },
208
+ f: function () {
209
+ try {
210
+ if (!normalCompletion && it.return != null) it.return();
211
+ } finally {
212
+ if (didErr) throw err;
213
+ }
214
+ }
215
+ };
216
+ }
180
217
  function _toPrimitive(input, hint) {
181
218
  if (typeof input !== "object" || input === null) return input;
182
219
  var prim = input[Symbol.toPrimitive];
@@ -192,19 +229,6 @@ function _toPropertyKey(arg) {
192
229
  return typeof key === "symbol" ? key : String(key);
193
230
  }
194
231
 
195
- var NoXCMSupportImplementedError = /*#__PURE__*/function (_Error) {
196
- _inherits(NoXCMSupportImplementedError, _Error);
197
- var _super = _createSuper(NoXCMSupportImplementedError);
198
- function NoXCMSupportImplementedError(node) {
199
- var _this;
200
- _classCallCheck(this, NoXCMSupportImplementedError);
201
- _this = _super.call(this, "No XCM support implemented for ".concat(node, " node yet."));
202
- _this.name = 'NoXCMSupportImplemented';
203
- return _this;
204
- }
205
- return _createClass(NoXCMSupportImplementedError);
206
- }( /*#__PURE__*/_wrapNativeSuper(Error));
207
-
208
232
  var Acala$2 = {
209
233
  paraId: 2000,
210
234
  relayChainAssetSymbol: "DOT",
@@ -3538,67 +3562,19 @@ var assetsMapJson = /*#__PURE__*/Object.freeze({
3538
3562
  default: assets
3539
3563
  });
3540
3564
 
3541
- var assetsMap = assetsMapJson;
3542
- function getAssetsObject(node) {
3543
- return assetsMap[node];
3544
- }
3545
- function getAssetId(node, symbol) {
3546
- var info = getAssetsObject(node).otherAssets.find(function (o) {
3547
- return o.symbol === symbol;
3548
- });
3549
- return info ? info.assetId : null;
3550
- }
3551
- function getRelayChainSymbol(node) {
3552
- return getAssetsObject(node).relayChainAssetSymbol;
3553
- }
3554
- function getNativeAssets(node) {
3555
- var info = getAssetsObject(node).nativeAssets;
3556
- return info || [];
3557
- }
3558
- function getOtherAssets(node) {
3559
- return getAssetsObject(node).otherAssets;
3560
- }
3561
- function getAllAssetsSymbols(node) {
3562
- var _getAssetsObject = getAssetsObject(node),
3563
- relayChainAssetSymbol = _getAssetsObject.relayChainAssetSymbol,
3564
- nativeAssets = _getAssetsObject.nativeAssets,
3565
- otherAssets = _getAssetsObject.otherAssets;
3566
- return [relayChainAssetSymbol].concat(_toConsumableArray(nativeAssets.map(function (_ref) {
3567
- var symbol = _ref.symbol;
3568
- return symbol;
3569
- })), _toConsumableArray(otherAssets.map(function (_ref2) {
3570
- var symbol = _ref2.symbol;
3571
- return symbol;
3572
- })));
3573
- }
3574
- function hasSupportForAsset(node, symbol) {
3575
- return getAllAssetsSymbols(node).includes(symbol);
3576
- }
3577
- function getAssetDecimals(node, symbol) {
3578
- var _getAssetsObject2 = getAssetsObject(node),
3579
- otherAssets = _getAssetsObject2.otherAssets,
3580
- nativeAssets = _getAssetsObject2.nativeAssets;
3581
- var asset = [].concat(_toConsumableArray(otherAssets), _toConsumableArray(nativeAssets)).find(function (o) {
3582
- return o.symbol === symbol;
3583
- });
3584
- return asset ? asset.decimals : null;
3585
- }
3586
- function getParaId(node) {
3587
- return getAssetsObject(node).paraId;
3588
- }
3589
-
3590
- var index$4 = /*#__PURE__*/Object.freeze({
3591
- __proto__: null,
3592
- getAllAssetsSymbols: getAllAssetsSymbols,
3593
- getAssetDecimals: getAssetDecimals,
3594
- getAssetId: getAssetId,
3595
- getAssetsObject: getAssetsObject,
3596
- getNativeAssets: getNativeAssets,
3597
- getOtherAssets: getOtherAssets,
3598
- getParaId: getParaId,
3599
- getRelayChainSymbol: getRelayChainSymbol,
3600
- hasSupportForAsset: hasSupportForAsset
3601
- });
3565
+ // Used to inform user, that Parachain they wish to use has not yet implemented full XCM Support
3566
+ var NoXCMSupportImplementedError = /*#__PURE__*/function (_Error) {
3567
+ _inherits(NoXCMSupportImplementedError, _Error);
3568
+ var _super = _createSuper(NoXCMSupportImplementedError);
3569
+ function NoXCMSupportImplementedError(node) {
3570
+ var _this;
3571
+ _classCallCheck(this, NoXCMSupportImplementedError);
3572
+ _this = _super.call(this, "No XCM support implemented for ".concat(node, " node yet."));
3573
+ _this.name = 'NoXCMSupportImplemented';
3574
+ return _this;
3575
+ }
3576
+ return _createClass(NoXCMSupportImplementedError);
3577
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
3602
3578
 
3603
3579
  var supportsXTokens = function supportsXTokens(obj) {
3604
3580
  return 'transferXTokens' in obj;
@@ -3717,6 +3693,7 @@ var Unique$1 = /*#__PURE__*/function (_ParachainNode) {
3717
3693
  return Unique;
3718
3694
  }(ParachainNode);
3719
3695
 
3696
+ // Used to inform user, that currency they wish to use is not registered on either origin or destination Parachain
3720
3697
  var InvalidCurrencyError = /*#__PURE__*/function (_Error) {
3721
3698
  _inherits(InvalidCurrencyError, _Error);
3722
3699
  var _super = _createSuper(InvalidCurrencyError);
@@ -4402,6 +4379,7 @@ var Karura$1 = /*#__PURE__*/function (_ParachainNode) {
4402
4379
  return Karura;
4403
4380
  }(ParachainNode);
4404
4381
 
4382
+ // Contains basic structure of polkadotXCM call
4405
4383
  var PolkadotXCMTransferImpl = /*#__PURE__*/function () {
4406
4384
  function PolkadotXCMTransferImpl() {
4407
4385
  _classCallCheck(this, PolkadotXCMTransferImpl);
@@ -4458,6 +4436,7 @@ var Statemine$1 = /*#__PURE__*/function (_ParachainNode) {
4458
4436
  return Statemine;
4459
4437
  }(ParachainNode);
4460
4438
 
4439
+ // Used to inform user, that Parachain they wish to use does not support scenario they wish to use yet
4461
4440
  var ScenarioNotSupportedError = /*#__PURE__*/function (_Error) {
4462
4441
  _inherits(ScenarioNotSupportedError, _Error);
4463
4442
  var _super = _createSuper(ScenarioNotSupportedError);
@@ -4650,6 +4629,7 @@ var Shiden$1 = /*#__PURE__*/function (_ParachainNode) {
4650
4629
  return Shiden;
4651
4630
  }(ParachainNode);
4652
4631
 
4632
+ // Contains supported Parachains and exports supported XCM Pallets
4653
4633
  var NODE_NAMES = ['Statemint', 'Acala', 'Astar', 'BifrostPolkadot', 'Bitgreen', 'Centrifuge', 'Clover', 'ComposableFinance', 'Darwinia', 'HydraDX', 'Interlay', 'Kylin', 'Litentry', 'Moonbeam', 'Parallel', 'Statemine', 'Encointer', 'Altair', 'Amplitude', 'Bajun', 'Basilisk', 'BifrostKusama', 'Pioneer', 'Calamari', 'CrustShadow', 'Crab', 'Dorafactory', 'Imbue', 'Integritee', 'InvArchTinker', 'Karura', 'Kico', 'Kintsugi', 'Litmus', 'Mangata', 'Moonriver', 'ParallelHeiko', 'Picasso', 'Pichiu', 'Quartz', 'Robonomics', 'Shiden', 'Turing', 'Equilibrium', 'Unique', 'Crust', 'Efinity', 'Ipci'];
4654
4634
  var nodes = {
4655
4635
  Statemint: new Statemint$1(),
@@ -4703,6 +4683,83 @@ var nodes = {
4703
4683
  };
4704
4684
  var SUPPORTED_PALLETS = ['XTokens', 'OrmlXTokens', 'PolkadotXcm', 'RelayerXcm'];
4705
4685
 
4686
+ var assetsMap = assetsMapJson;
4687
+ function getAssetsObject(node) {
4688
+ return assetsMap[node];
4689
+ }
4690
+ function getAssetId(node, symbol) {
4691
+ var info = getAssetsObject(node).otherAssets.find(function (o) {
4692
+ return o.symbol === symbol;
4693
+ });
4694
+ return info ? info.assetId : null;
4695
+ }
4696
+ function getRelayChainSymbol(node) {
4697
+ return getAssetsObject(node).relayChainAssetSymbol;
4698
+ }
4699
+ function getNativeAssets(node) {
4700
+ var info = getAssetsObject(node).nativeAssets;
4701
+ return info || [];
4702
+ }
4703
+ function getOtherAssets(node) {
4704
+ return getAssetsObject(node).otherAssets;
4705
+ }
4706
+ function getAllAssetsSymbols(node) {
4707
+ var _getAssetsObject = getAssetsObject(node),
4708
+ relayChainAssetSymbol = _getAssetsObject.relayChainAssetSymbol,
4709
+ nativeAssets = _getAssetsObject.nativeAssets,
4710
+ otherAssets = _getAssetsObject.otherAssets;
4711
+ return [relayChainAssetSymbol].concat(_toConsumableArray(nativeAssets.map(function (_ref) {
4712
+ var symbol = _ref.symbol;
4713
+ return symbol;
4714
+ })), _toConsumableArray(otherAssets.map(function (_ref2) {
4715
+ var symbol = _ref2.symbol;
4716
+ return symbol;
4717
+ })));
4718
+ }
4719
+ function hasSupportForAsset(node, symbol) {
4720
+ return getAllAssetsSymbols(node).includes(symbol);
4721
+ }
4722
+ function getAssetDecimals(node, symbol) {
4723
+ var _getAssetsObject2 = getAssetsObject(node),
4724
+ otherAssets = _getAssetsObject2.otherAssets,
4725
+ nativeAssets = _getAssetsObject2.nativeAssets;
4726
+ var asset = [].concat(_toConsumableArray(otherAssets), _toConsumableArray(nativeAssets)).find(function (o) {
4727
+ return o.symbol === symbol;
4728
+ });
4729
+ return asset ? asset.decimals : null;
4730
+ }
4731
+ function getParaId(node) {
4732
+ return getAssetsObject(node).paraId;
4733
+ }
4734
+ function getTNode(nodeID) {
4735
+ var _iterator = _createForOfIteratorHelper(NODE_NAMES),
4736
+ _step;
4737
+ try {
4738
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
4739
+ var node = _step.value;
4740
+ if (getParaId(node) === nodeID) return node;
4741
+ }
4742
+ } catch (err) {
4743
+ _iterator.e(err);
4744
+ } finally {
4745
+ _iterator.f();
4746
+ }
4747
+ }
4748
+
4749
+ var index$4 = /*#__PURE__*/Object.freeze({
4750
+ __proto__: null,
4751
+ getAllAssetsSymbols: getAllAssetsSymbols,
4752
+ getAssetDecimals: getAssetDecimals,
4753
+ getAssetId: getAssetId,
4754
+ getAssetsObject: getAssetsObject,
4755
+ getNativeAssets: getNativeAssets,
4756
+ getOtherAssets: getOtherAssets,
4757
+ getParaId: getParaId,
4758
+ getRelayChainSymbol: getRelayChainSymbol,
4759
+ getTNode: getTNode,
4760
+ hasSupportForAsset: hasSupportForAsset
4761
+ });
4762
+
4706
4763
  function createAccID(api, account) {
4707
4764
  console.log('Generating AccountId32 address');
4708
4765
  return api.createType('AccountId32', account).toHex();
@@ -4803,17 +4860,34 @@ function handleAddress(scenario, pallet, api, to, nodeId, node) {
4803
4860
  }
4804
4861
  if (scenario === 'ParaToRelay' && pallet === 'polkadotXCM') {
4805
4862
  console.log('AccountId32 transfer');
4806
- return _defineProperty({}, node === 'Statemine' ? 'V3' : 'V1', {
4807
- parents: 0,
4808
- interior: {
4809
- X1: {
4810
- AccountId32: {
4811
- network: 'any',
4812
- id: createAccID(api, to)
4863
+ if (node === 'Statemine') {
4864
+ return {
4865
+ V3: {
4866
+ parents: 0,
4867
+ interior: {
4868
+ X1: {
4869
+ AccountId32: {
4870
+ id: createAccID(api, to)
4871
+ }
4872
+ }
4813
4873
  }
4814
4874
  }
4815
- }
4816
- });
4875
+ };
4876
+ } else {
4877
+ return {
4878
+ V1: {
4879
+ parents: 0,
4880
+ interior: {
4881
+ X1: {
4882
+ AccountId32: {
4883
+ network: 'any',
4884
+ id: createAccID(api, to)
4885
+ }
4886
+ }
4887
+ }
4888
+ }
4889
+ };
4890
+ }
4817
4891
  }
4818
4892
  if (scenario === 'ParaToPara' && pallet === 'polkadotXCM') {
4819
4893
  if (node === 'Quartz') {
@@ -4830,82 +4904,163 @@ function handleAddress(scenario, pallet, api, to, nodeId, node) {
4830
4904
  }
4831
4905
  if (ethers.ethers.utils.isAddress(to)) {
4832
4906
  console.log('AccountKey20 transfer');
4833
- return _defineProperty({}, node === 'Statemine' ? 'V3' : 'V1', {
4834
- parents: 0,
4835
- interior: {
4836
- X1: {
4837
- AccountKey20: {
4838
- network: 'Any',
4839
- key: to
4907
+ if (node === 'Statemine') {
4908
+ return {
4909
+ V3: {
4910
+ parents: 0,
4911
+ interior: {
4912
+ X1: {
4913
+ AccountKey20: {
4914
+ key: to
4915
+ }
4916
+ }
4840
4917
  }
4841
4918
  }
4842
- }
4843
- });
4919
+ };
4920
+ } else {
4921
+ return {
4922
+ V1: {
4923
+ parents: 0,
4924
+ interior: {
4925
+ X1: {
4926
+ AccountKey20: {
4927
+ network: 'Any',
4928
+ key: to
4929
+ }
4930
+ }
4931
+ }
4932
+ }
4933
+ };
4934
+ }
4844
4935
  } else {
4845
4936
  console.log('AccountId32 transfer');
4846
- return _defineProperty({}, node === 'Statemine' ? 'V3' : 'V1', {
4847
- parents: 0,
4848
- interior: {
4849
- X1: {
4850
- AccountId32: {
4851
- network: 'Any',
4852
- id: createAccID(api, to)
4937
+ if (node === 'Statemine') {
4938
+ return {
4939
+ V3: {
4940
+ parents: 0,
4941
+ interior: {
4942
+ X1: {
4943
+ AccountId32: {
4944
+ id: createAccID(api, to)
4945
+ }
4946
+ }
4853
4947
  }
4854
4948
  }
4855
- }
4856
- });
4949
+ };
4950
+ } else {
4951
+ return {
4952
+ V1: {
4953
+ parents: 0,
4954
+ interior: {
4955
+ X1: {
4956
+ AccountId32: {
4957
+ network: 'Any',
4958
+ id: createAccID(api, to)
4959
+ }
4960
+ }
4961
+ }
4962
+ }
4963
+ };
4964
+ }
4857
4965
  }
4858
4966
  }
4859
4967
  if (scenario === 'RelayToPara') {
4968
+ var asset = getRelayChainSymbol(node);
4860
4969
  if (ethers.ethers.utils.isAddress(to)) {
4861
4970
  console.log('AccountKey20 transfer');
4862
- return {
4863
- V1: {
4864
- parents: 0,
4865
- interior: {
4866
- X1: {
4867
- AccountKey20: {
4868
- network: 'Any',
4869
- key: to
4971
+ if (asset === 'KSM') {
4972
+ return {
4973
+ V3: {
4974
+ parents: 0,
4975
+ interior: {
4976
+ X1: {
4977
+ AccountKey20: {
4978
+ key: to
4979
+ }
4870
4980
  }
4871
4981
  }
4872
4982
  }
4873
- }
4874
- };
4983
+ };
4984
+ } else {
4985
+ return {
4986
+ V1: {
4987
+ parents: 0,
4988
+ interior: {
4989
+ X1: {
4990
+ AccountKey20: {
4991
+ network: 'Any',
4992
+ key: to
4993
+ }
4994
+ }
4995
+ }
4996
+ }
4997
+ };
4998
+ }
4875
4999
  } else {
4876
5000
  console.log('AccountId32 transfer');
4877
- return {
4878
- V1: {
4879
- parents: 0,
4880
- interior: {
4881
- X1: {
4882
- AccountId32: {
4883
- network: 'Any',
4884
- id: createAccID(api, to)
5001
+ if (asset === 'KSM') {
5002
+ return {
5003
+ V3: {
5004
+ parents: 0,
5005
+ interior: {
5006
+ X1: {
5007
+ AccountId32: {
5008
+ id: createAccID(api, to)
5009
+ }
4885
5010
  }
4886
5011
  }
4887
5012
  }
4888
- }
4889
- };
5013
+ };
5014
+ } else {
5015
+ return {
5016
+ V1: {
5017
+ parents: 0,
5018
+ interior: {
5019
+ X1: {
5020
+ AccountId32: {
5021
+ network: 'Any',
5022
+ id: createAccID(api, to)
5023
+ }
5024
+ }
5025
+ }
5026
+ }
5027
+ };
5028
+ }
4890
5029
  }
4891
5030
  }
4892
5031
  }
4893
5032
  function createCurrencySpecification(amount, scenario, node, cur) {
4894
5033
  if (scenario === 'ParaToRelay') {
4895
5034
  console.log('polkadotXCM transfer in native currency to Relay chain');
4896
- return {
4897
- V1: [{
4898
- id: {
4899
- Concrete: {
4900
- parents: 1,
4901
- interior: 'Here'
5035
+ if (node === 'Statemine') {
5036
+ return {
5037
+ V3: [{
5038
+ id: {
5039
+ Concrete: {
5040
+ parents: 1,
5041
+ interior: 'Here'
5042
+ }
5043
+ },
5044
+ fun: {
5045
+ Fungible: amount
4902
5046
  }
4903
- },
4904
- fun: {
4905
- Fungible: amount
4906
- }
4907
- }]
4908
- };
5047
+ }]
5048
+ };
5049
+ } else {
5050
+ return {
5051
+ V1: [{
5052
+ id: {
5053
+ Concrete: {
5054
+ parents: 1,
5055
+ interior: 'Here'
5056
+ }
5057
+ },
5058
+ fun: {
5059
+ Fungible: amount
5060
+ }
5061
+ }]
5062
+ };
5063
+ }
4909
5064
  }
4910
5065
  if (scenario === 'RelayToPara' || scenario === 'ParaToPara') {
4911
5066
  console.log('polkadotXCM Native currency to sender chain transfer');
@@ -4940,18 +5095,57 @@ function createCurrencySpecification(amount, scenario, node, cur) {
4940
5095
  };
4941
5096
  } else if ((node === 'Statemint' || node === 'Statemine') && scenario === 'ParaToPara') {
4942
5097
  // Another specific case for Statemint & Statemine to send for example USDt
5098
+ if (node === 'Statemine') {
5099
+ return {
5100
+ V3: [{
5101
+ id: {
5102
+ Concrete: {
5103
+ parents: 0,
5104
+ interior: {
5105
+ X2: [{
5106
+ PalletInstance: 50
5107
+ }, {
5108
+ GeneralIndex: cur
5109
+ }]
5110
+ }
5111
+ }
5112
+ },
5113
+ fun: {
5114
+ Fungible: amount
5115
+ }
5116
+ }]
5117
+ };
5118
+ } else {
5119
+ return {
5120
+ V1: [{
5121
+ id: {
5122
+ Concrete: {
5123
+ parents: 0,
5124
+ interior: {
5125
+ X2: [{
5126
+ PalletInstance: 50
5127
+ }, {
5128
+ GeneralIndex: cur
5129
+ }]
5130
+ }
5131
+ }
5132
+ },
5133
+ fun: {
5134
+ Fungible: amount
5135
+ }
5136
+ }]
5137
+ };
5138
+ }
5139
+ }
5140
+ // Otherwise
5141
+ var asset = getRelayChainSymbol(node);
5142
+ if (asset === 'KSM') {
4943
5143
  return {
4944
- V1: [{
5144
+ V3: [{
4945
5145
  id: {
4946
5146
  Concrete: {
4947
5147
  parents: 0,
4948
- interior: {
4949
- X2: [{
4950
- PalletInstance: 50
4951
- }, {
4952
- GeneralIndex: cur
4953
- }]
4954
- }
5148
+ interior: 'Here'
4955
5149
  }
4956
5150
  },
4957
5151
  fun: {
@@ -4960,7 +5154,6 @@ function createCurrencySpecification(amount, scenario, node, cur) {
4960
5154
  }]
4961
5155
  };
4962
5156
  }
4963
- // Otherwise
4964
5157
  return {
4965
5158
  V1: [{
4966
5159
  id: {
@@ -4979,12 +5172,21 @@ function createCurrencySpecification(amount, scenario, node, cur) {
4979
5172
  function createHeaderPolkadotXCM(scenario, nodeId, node) {
4980
5173
  console.log('Generating header for polkadotXCM transfer');
4981
5174
  if (scenario === 'ParaToRelay') {
4982
- return {
4983
- V1: {
4984
- parents: 1,
4985
- interior: 'Here'
4986
- }
4987
- };
5175
+ if (node === 'Statemine') {
5176
+ return {
5177
+ V3: {
5178
+ parents: 1,
5179
+ interior: 'Here'
5180
+ }
5181
+ };
5182
+ } else {
5183
+ return {
5184
+ V1: {
5185
+ parents: 1,
5186
+ interior: 'Here'
5187
+ }
5188
+ };
5189
+ }
4988
5190
  }
4989
5191
  if (scenario === 'ParaToPara') {
4990
5192
  if (node === 'Quartz') {
@@ -5008,16 +5210,31 @@ function createHeaderPolkadotXCM(scenario, nodeId, node) {
5008
5210
  };
5009
5211
  }
5010
5212
  if (scenario === 'RelayToPara') {
5011
- return {
5012
- V1: {
5013
- parents: 0,
5014
- interior: {
5015
- X1: {
5016
- Parachain: nodeId
5213
+ //We check nodeID currency (IF KSM then V3 IF DOT then V1)
5214
+ var asset = getRelayChainSymbol(node);
5215
+ if (asset === 'KSM') {
5216
+ return {
5217
+ V3: {
5218
+ parents: 0,
5219
+ interior: {
5220
+ X1: {
5221
+ Parachain: nodeId
5222
+ }
5017
5223
  }
5018
5224
  }
5019
- }
5020
- };
5225
+ };
5226
+ } else {
5227
+ return {
5228
+ V1: {
5229
+ parents: 0,
5230
+ interior: {
5231
+ X1: {
5232
+ Parachain: nodeId
5233
+ }
5234
+ }
5235
+ }
5236
+ };
5237
+ }
5021
5238
  }
5022
5239
  }
5023
5240
  function getNode(node) {
@@ -5051,6 +5268,7 @@ var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, symbolOrId) {
5051
5268
  return null;
5052
5269
  };
5053
5270
 
5271
+ // Used to inform user, that Parachain they wish to use is not supported yet
5054
5272
  var NodeNotSupportedError = /*#__PURE__*/function (_Error) {
5055
5273
  _inherits(NodeNotSupportedError, _Error);
5056
5274
  var _super = _createSuper(NodeNotSupportedError);
@@ -5064,6 +5282,7 @@ var NodeNotSupportedError = /*#__PURE__*/function (_Error) {
5064
5282
  return _createClass(NodeNotSupportedError);
5065
5283
  }( /*#__PURE__*/_wrapNativeSuper(Error));
5066
5284
 
5285
+ //Contains basic call formatting for different XCM Palletss
5067
5286
  function send(api, origin, currencySymbolOrId, amount, to, destination) {
5068
5287
  var asset = getAssetBySymbolOrId(origin, currencySymbolOrId.toString());
5069
5288
  if (!asset) {
@@ -5078,9 +5297,9 @@ function send(api, origin, currencySymbolOrId, amount, to, destination) {
5078
5297
  }
5079
5298
  function transferRelayToPara(api, destination, amount, to) {
5080
5299
  var paraId = getParaId(destination);
5081
- if (destination === 'Statemine' || destination === 'Encointer') {
5300
+ if (destination === 'Statemint' || destination === 'Statemine' || destination === 'Encointer') {
5082
5301
  // Same for Statemint, Statemine and Encoiter
5083
- return api.tx.xcmPallet.limitedTeleportAssets(createHeaderPolkadotXCM('RelayToPara', paraId), handleAddress('RelayToPara', '', api, to, paraId), createCurrencySpecification(amount, 'RelayToPara'), 0, 'Unlimited');
5302
+ return api.tx.xcmPallet.limitedTeleportAssets(createHeaderPolkadotXCM('RelayToPara', paraId, destination), handleAddress('RelayToPara', '', api, to, paraId, destination), createCurrencySpecification(amount, 'RelayToPara', destination), 0, 'Unlimited');
5084
5303
  } else if (destination === 'Darwinia' || destination === 'Crab' || destination === 'Quartz') {
5085
5304
  // Do not do anything because Darwinia and Crab does not have DOT and KSM registered Quartz does not work with UMP & DMP too
5086
5305
  throw new NodeNotSupportedError('These nodes do not support XCM transfers from Relay / to Relay chain.');
@@ -5094,6 +5313,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
5094
5313
  transferRelayToPara: transferRelayToPara
5095
5314
  });
5096
5315
 
5316
+ //Contains XYK Decentralized exchange functions implemented in collaboration with Basilisk team
5097
5317
  function addLiquidity(api, assetA, assetB, amountA, amountBMaxLimit) {
5098
5318
  return api.tx.xyk.addLiquidity(assetA, assetB, amountA, amountBMaxLimit);
5099
5319
  }
@@ -5119,6 +5339,7 @@ var index$2 = /*#__PURE__*/Object.freeze({
5119
5339
  sell: sell
5120
5340
  });
5121
5341
 
5342
+ //Contains call formatting for opening HRMP channels functionality
5122
5343
  function openChannel(api, origin, destination, maxSize, maxMessageSize) {
5123
5344
  return api.tx.sudo.sudo(api.tx.parasSudoWrapper.sudoEstablishHrmpChannel(getParaId(origin), getParaId(destination), maxSize, maxMessageSize));
5124
5345
  }
@@ -5128,6 +5349,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
5128
5349
  openChannel: openChannel
5129
5350
  });
5130
5351
 
5352
+ //Contains call formatting for closing HRMP channels functionality
5131
5353
  function closeChannel(api, origin, inbound, outbound) {
5132
5354
  return api.tx.sudo.sudo(api.tx.hrmp.forceCleanHrmp(getParaId(origin), inbound, outbound));
5133
5355
  }
@@ -6012,6 +6234,7 @@ var palletsMapJson = /*#__PURE__*/Object.freeze({
6012
6234
  default: pallets
6013
6235
  });
6014
6236
 
6237
+ // Script that pulls XCM Pallets for selected Parachain
6015
6238
  var palletsMap = palletsMapJson;
6016
6239
  var getDefaultPallet = function getDefaultPallet(node) {
6017
6240
  return palletsMap[node].defaultPallet;
@@ -6035,6 +6258,7 @@ exports.getOtherAssets = getOtherAssets;
6035
6258
  exports.getParaId = getParaId;
6036
6259
  exports.getRelayChainSymbol = getRelayChainSymbol;
6037
6260
  exports.getSupportedPallets = getSupportedPallets;
6261
+ exports.getTNode = getTNode;
6038
6262
  exports.hasSupportForAsset = hasSupportForAsset;
6039
6263
  exports.openChannels = index$1;
6040
6264
  exports.xcmPallet = index$3;