@paraspell/sdk 3.0.5 → 3.0.7

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
@@ -1,14 +1,322 @@
1
- import '@polkadot/api';
1
+ import { WsProvider, ApiPromise } from '@polkadot/api';
2
2
  import { ethers } from 'ethers';
3
3
  import { prodRelayPolkadot, prodRelayKusama } from '@polkadot/apps-config/endpoints';
4
4
 
5
- // derrived from https://github.com/kodadot/packages/blob/main/minimark/src/common/types.ts
6
- var Version;
7
- (function (Version) {
8
- Version["V1"] = "V1";
9
- Version["V3"] = "V3";
10
- })(Version || (Version = {}));
11
-
5
+ function _regeneratorRuntime() {
6
+ _regeneratorRuntime = function () {
7
+ return e;
8
+ };
9
+ var t,
10
+ e = {},
11
+ r = Object.prototype,
12
+ n = r.hasOwnProperty,
13
+ o = Object.defineProperty || function (t, e, r) {
14
+ t[e] = r.value;
15
+ },
16
+ i = "function" == typeof Symbol ? Symbol : {},
17
+ a = i.iterator || "@@iterator",
18
+ c = i.asyncIterator || "@@asyncIterator",
19
+ u = i.toStringTag || "@@toStringTag";
20
+ function define(t, e, r) {
21
+ return Object.defineProperty(t, e, {
22
+ value: r,
23
+ enumerable: !0,
24
+ configurable: !0,
25
+ writable: !0
26
+ }), t[e];
27
+ }
28
+ try {
29
+ define({}, "");
30
+ } catch (t) {
31
+ define = function (t, e, r) {
32
+ return t[e] = r;
33
+ };
34
+ }
35
+ function wrap(t, e, r, n) {
36
+ var i = e && e.prototype instanceof Generator ? e : Generator,
37
+ a = Object.create(i.prototype),
38
+ c = new Context(n || []);
39
+ return o(a, "_invoke", {
40
+ value: makeInvokeMethod(t, r, c)
41
+ }), a;
42
+ }
43
+ function tryCatch(t, e, r) {
44
+ try {
45
+ return {
46
+ type: "normal",
47
+ arg: t.call(e, r)
48
+ };
49
+ } catch (t) {
50
+ return {
51
+ type: "throw",
52
+ arg: t
53
+ };
54
+ }
55
+ }
56
+ e.wrap = wrap;
57
+ var h = "suspendedStart",
58
+ l = "suspendedYield",
59
+ f = "executing",
60
+ s = "completed",
61
+ y = {};
62
+ function Generator() {}
63
+ function GeneratorFunction() {}
64
+ function GeneratorFunctionPrototype() {}
65
+ var p = {};
66
+ define(p, a, function () {
67
+ return this;
68
+ });
69
+ var d = Object.getPrototypeOf,
70
+ v = d && d(d(values([])));
71
+ v && v !== r && n.call(v, a) && (p = v);
72
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
73
+ function defineIteratorMethods(t) {
74
+ ["next", "throw", "return"].forEach(function (e) {
75
+ define(t, e, function (t) {
76
+ return this._invoke(e, t);
77
+ });
78
+ });
79
+ }
80
+ function AsyncIterator(t, e) {
81
+ function invoke(r, o, i, a) {
82
+ var c = tryCatch(t[r], t, o);
83
+ if ("throw" !== c.type) {
84
+ var u = c.arg,
85
+ h = u.value;
86
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
87
+ invoke("next", t, i, a);
88
+ }, function (t) {
89
+ invoke("throw", t, i, a);
90
+ }) : e.resolve(h).then(function (t) {
91
+ u.value = t, i(u);
92
+ }, function (t) {
93
+ return invoke("throw", t, i, a);
94
+ });
95
+ }
96
+ a(c.arg);
97
+ }
98
+ var r;
99
+ o(this, "_invoke", {
100
+ value: function (t, n) {
101
+ function callInvokeWithMethodAndArg() {
102
+ return new e(function (e, r) {
103
+ invoke(t, n, e, r);
104
+ });
105
+ }
106
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
107
+ }
108
+ });
109
+ }
110
+ function makeInvokeMethod(e, r, n) {
111
+ var o = h;
112
+ return function (i, a) {
113
+ if (o === f) throw new Error("Generator is already running");
114
+ if (o === s) {
115
+ if ("throw" === i) throw a;
116
+ return {
117
+ value: t,
118
+ done: !0
119
+ };
120
+ }
121
+ for (n.method = i, n.arg = a;;) {
122
+ var c = n.delegate;
123
+ if (c) {
124
+ var u = maybeInvokeDelegate(c, n);
125
+ if (u) {
126
+ if (u === y) continue;
127
+ return u;
128
+ }
129
+ }
130
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
131
+ if (o === h) throw o = s, n.arg;
132
+ n.dispatchException(n.arg);
133
+ } else "return" === n.method && n.abrupt("return", n.arg);
134
+ o = f;
135
+ var p = tryCatch(e, r, n);
136
+ if ("normal" === p.type) {
137
+ if (o = n.done ? s : l, p.arg === y) continue;
138
+ return {
139
+ value: p.arg,
140
+ done: n.done
141
+ };
142
+ }
143
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
144
+ }
145
+ };
146
+ }
147
+ function maybeInvokeDelegate(e, r) {
148
+ var n = r.method,
149
+ o = e.iterator[n];
150
+ if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
151
+ var i = tryCatch(o, e.iterator, r.arg);
152
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
153
+ var a = i.arg;
154
+ return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
155
+ }
156
+ function pushTryEntry(t) {
157
+ var e = {
158
+ tryLoc: t[0]
159
+ };
160
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
161
+ }
162
+ function resetTryEntry(t) {
163
+ var e = t.completion || {};
164
+ e.type = "normal", delete e.arg, t.completion = e;
165
+ }
166
+ function Context(t) {
167
+ this.tryEntries = [{
168
+ tryLoc: "root"
169
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
170
+ }
171
+ function values(e) {
172
+ if (e || "" === e) {
173
+ var r = e[a];
174
+ if (r) return r.call(e);
175
+ if ("function" == typeof e.next) return e;
176
+ if (!isNaN(e.length)) {
177
+ var o = -1,
178
+ i = function next() {
179
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
180
+ return next.value = t, next.done = !0, next;
181
+ };
182
+ return i.next = i;
183
+ }
184
+ }
185
+ throw new TypeError(typeof e + " is not iterable");
186
+ }
187
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
188
+ value: GeneratorFunctionPrototype,
189
+ configurable: !0
190
+ }), o(GeneratorFunctionPrototype, "constructor", {
191
+ value: GeneratorFunction,
192
+ configurable: !0
193
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
194
+ var e = "function" == typeof t && t.constructor;
195
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
196
+ }, e.mark = function (t) {
197
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
198
+ }, e.awrap = function (t) {
199
+ return {
200
+ __await: t
201
+ };
202
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
203
+ return this;
204
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
205
+ void 0 === i && (i = Promise);
206
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
207
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
208
+ return t.done ? t.value : a.next();
209
+ });
210
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
211
+ return this;
212
+ }), define(g, "toString", function () {
213
+ return "[object Generator]";
214
+ }), e.keys = function (t) {
215
+ var e = Object(t),
216
+ r = [];
217
+ for (var n in e) r.push(n);
218
+ return r.reverse(), function next() {
219
+ for (; r.length;) {
220
+ var t = r.pop();
221
+ if (t in e) return next.value = t, next.done = !1, next;
222
+ }
223
+ return next.done = !0, next;
224
+ };
225
+ }, e.values = values, Context.prototype = {
226
+ constructor: Context,
227
+ reset: function (e) {
228
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
229
+ },
230
+ stop: function () {
231
+ this.done = !0;
232
+ var t = this.tryEntries[0].completion;
233
+ if ("throw" === t.type) throw t.arg;
234
+ return this.rval;
235
+ },
236
+ dispatchException: function (e) {
237
+ if (this.done) throw e;
238
+ var r = this;
239
+ function handle(n, o) {
240
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
241
+ }
242
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
243
+ var i = this.tryEntries[o],
244
+ a = i.completion;
245
+ if ("root" === i.tryLoc) return handle("end");
246
+ if (i.tryLoc <= this.prev) {
247
+ var c = n.call(i, "catchLoc"),
248
+ u = n.call(i, "finallyLoc");
249
+ if (c && u) {
250
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
251
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
252
+ } else if (c) {
253
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
254
+ } else {
255
+ if (!u) throw new Error("try statement without catch or finally");
256
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
257
+ }
258
+ }
259
+ }
260
+ },
261
+ abrupt: function (t, e) {
262
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
263
+ var o = this.tryEntries[r];
264
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
265
+ var i = o;
266
+ break;
267
+ }
268
+ }
269
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
270
+ var a = i ? i.completion : {};
271
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
272
+ },
273
+ complete: function (t, e) {
274
+ if ("throw" === t.type) throw t.arg;
275
+ return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
276
+ },
277
+ finish: function (t) {
278
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
279
+ var r = this.tryEntries[e];
280
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
281
+ }
282
+ },
283
+ catch: function (t) {
284
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
285
+ var r = this.tryEntries[e];
286
+ if (r.tryLoc === t) {
287
+ var n = r.completion;
288
+ if ("throw" === n.type) {
289
+ var o = n.arg;
290
+ resetTryEntry(r);
291
+ }
292
+ return o;
293
+ }
294
+ }
295
+ throw new Error("illegal catch attempt");
296
+ },
297
+ delegateYield: function (e, r, n) {
298
+ return this.delegate = {
299
+ iterator: values(e),
300
+ resultName: r,
301
+ nextLoc: n
302
+ }, "next" === this.method && (this.arg = t), y;
303
+ }
304
+ }, e;
305
+ }
306
+ function _toPrimitive(t, r) {
307
+ if ("object" != typeof t || !t) return t;
308
+ var e = t[Symbol.toPrimitive];
309
+ if (void 0 !== e) {
310
+ var i = e.call(t, r || "default");
311
+ if ("object" != typeof i) return i;
312
+ throw new TypeError("@@toPrimitive must return a primitive value.");
313
+ }
314
+ return ("string" === r ? String : Number)(t);
315
+ }
316
+ function _toPropertyKey(t) {
317
+ var i = _toPrimitive(t, "string");
318
+ return "symbol" == typeof i ? i : String(i);
319
+ }
12
320
  function _classCallCheck(instance, Constructor) {
13
321
  if (!(instance instanceof Constructor)) {
14
322
  throw new TypeError("Cannot call a class as a function");
@@ -186,71 +494,6 @@ function _arrayLikeToArray(arr, len) {
186
494
  function _nonIterableSpread() {
187
495
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
188
496
  }
189
- function _createForOfIteratorHelper(o, allowArrayLike) {
190
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
191
- if (!it) {
192
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
193
- if (it) o = it;
194
- var i = 0;
195
- var F = function () {};
196
- return {
197
- s: F,
198
- n: function () {
199
- if (i >= o.length) return {
200
- done: true
201
- };
202
- return {
203
- done: false,
204
- value: o[i++]
205
- };
206
- },
207
- e: function (e) {
208
- throw e;
209
- },
210
- f: F
211
- };
212
- }
213
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
214
- }
215
- var normalCompletion = true,
216
- didErr = false,
217
- err;
218
- return {
219
- s: function () {
220
- it = it.call(o);
221
- },
222
- n: function () {
223
- var step = it.next();
224
- normalCompletion = step.done;
225
- return step;
226
- },
227
- e: function (e) {
228
- didErr = true;
229
- err = e;
230
- },
231
- f: function () {
232
- try {
233
- if (!normalCompletion && it.return != null) it.return();
234
- } finally {
235
- if (didErr) throw err;
236
- }
237
- }
238
- };
239
- }
240
- function _toPrimitive(input, hint) {
241
- if (typeof input !== "object" || input === null) return input;
242
- var prim = input[Symbol.toPrimitive];
243
- if (prim !== undefined) {
244
- var res = prim.call(input, hint || "default");
245
- if (typeof res !== "object") return res;
246
- throw new TypeError("@@toPrimitive must return a primitive value.");
247
- }
248
- return (hint === "string" ? String : Number)(input);
249
- }
250
- function _toPropertyKey(arg) {
251
- var key = _toPrimitive(arg, "string");
252
- return typeof key === "symbol" ? key : String(key);
253
- }
254
497
 
255
498
  /******************************************************************************
256
499
  Copyright (c) Microsoft Corporation.
@@ -269,11 +512,28 @@ PERFORMANCE OF THIS SOFTWARE.
269
512
  /* global Reflect, Promise, SuppressedError, Symbol */
270
513
 
271
514
 
515
+ function __awaiter(thisArg, _arguments, P, generator) {
516
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
517
+ return new (P || (P = Promise))(function (resolve, reject) {
518
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
519
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
520
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
521
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
522
+ });
523
+ }
524
+
272
525
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
273
526
  var e = new Error(message);
274
527
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
275
528
  };
276
529
 
530
+ // derrived from https://github.com/kodadot/packages/blob/main/minimark/src/common/types.ts
531
+ var Version;
532
+ (function (Version) {
533
+ Version["V1"] = "V1";
534
+ Version["V3"] = "V3";
535
+ })(Version || (Version = {}));
536
+
277
537
  // Used to inform user, that Parachain they wish to use has not yet implemented full XCM Support
278
538
  var NoXCMSupportImplementedError = /*#__PURE__*/function (_Error) {
279
539
  _inherits(NoXCMSupportImplementedError, _Error);
@@ -4668,69 +4928,62 @@ var assetsMapJson = /*#__PURE__*/Object.freeze({
4668
4928
  });
4669
4929
 
4670
4930
  var assetsMap = assetsMapJson;
4671
- function getAssetsObject(node) {
4931
+ var getAssetsObject = function getAssetsObject(node) {
4672
4932
  return assetsMap[node];
4673
- }
4674
- function getAssetId(node, symbol) {
4933
+ };
4934
+ var getAssetId = function getAssetId(node, symbol) {
4675
4935
  var info = getAssetsObject(node).otherAssets.find(function (o) {
4676
4936
  return o.symbol === symbol;
4677
4937
  });
4678
- return info ? info.assetId : null;
4679
- }
4680
- function getRelayChainSymbol(node) {
4938
+ return info != null ? info.assetId : null;
4939
+ };
4940
+ var getRelayChainSymbol = function getRelayChainSymbol(node) {
4681
4941
  return getAssetsObject(node).relayChainAssetSymbol;
4682
- }
4683
- function getNativeAssets(node) {
4684
- var info = getAssetsObject(node).nativeAssets;
4685
- return info || [];
4686
- }
4687
- function getOtherAssets(node) {
4942
+ };
4943
+ var getNativeAssets = function getNativeAssets(node) {
4944
+ return getAssetsObject(node).nativeAssets;
4945
+ };
4946
+ var getOtherAssets = function getOtherAssets(node) {
4688
4947
  return getAssetsObject(node).otherAssets;
4689
- }
4690
- function getAllAssetsSymbols(node) {
4948
+ };
4949
+ var getAllAssetsSymbols = function getAllAssetsSymbols(node) {
4691
4950
  var _getAssetsObject = getAssetsObject(node),
4692
4951
  relayChainAssetSymbol = _getAssetsObject.relayChainAssetSymbol,
4693
4952
  nativeAssets = _getAssetsObject.nativeAssets,
4694
4953
  otherAssets = _getAssetsObject.otherAssets;
4695
- return [relayChainAssetSymbol].concat(_toConsumableArray(nativeAssets.map(function (_ref) {
4954
+ var nativeAssetsSymbols = nativeAssets.map(function (_ref) {
4696
4955
  var symbol = _ref.symbol;
4697
4956
  return symbol;
4698
- })), _toConsumableArray(otherAssets.filter(function (asset) {
4699
- return !!asset.symbol;
4957
+ });
4958
+ var otherAssetsSymbols = otherAssets.filter(function (asset) {
4959
+ return asset.symbol !== undefined;
4700
4960
  }).map(function (_ref2) {
4701
4961
  var symbol = _ref2.symbol;
4702
4962
  return symbol;
4703
- })));
4704
- }
4705
- function hasSupportForAsset(node, symbol) {
4963
+ });
4964
+ return [relayChainAssetSymbol].concat(_toConsumableArray(nativeAssetsSymbols), _toConsumableArray(otherAssetsSymbols));
4965
+ };
4966
+ var hasSupportForAsset = function hasSupportForAsset(node, symbol) {
4706
4967
  return getAllAssetsSymbols(node).includes(symbol);
4707
- }
4708
- function getAssetDecimals(node, symbol) {
4968
+ };
4969
+ var getAssetDecimals = function getAssetDecimals(node, symbol) {
4709
4970
  var _getAssetsObject2 = getAssetsObject(node),
4710
4971
  otherAssets = _getAssetsObject2.otherAssets,
4711
4972
  nativeAssets = _getAssetsObject2.nativeAssets;
4712
4973
  var asset = [].concat(_toConsumableArray(otherAssets), _toConsumableArray(nativeAssets)).find(function (o) {
4713
4974
  return o.symbol === symbol;
4714
4975
  });
4715
- return asset ? asset.decimals : null;
4716
- }
4717
- function getParaId(node) {
4976
+ return (asset === null || asset === void 0 ? void 0 : asset.decimals) !== undefined ? asset.decimals : null;
4977
+ };
4978
+ var getParaId = function getParaId(node) {
4718
4979
  return getAssetsObject(node).paraId;
4719
- }
4720
- function getTNode(nodeID) {
4721
- var _iterator = _createForOfIteratorHelper(NODE_NAMES),
4722
- _step;
4723
- try {
4724
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
4725
- var node = _step.value;
4726
- if (getParaId(node) === nodeID) return node;
4727
- }
4728
- } catch (err) {
4729
- _iterator.e(err);
4730
- } finally {
4731
- _iterator.f();
4732
- }
4733
- }
4980
+ };
4981
+ var getTNode = function getTNode(nodeID) {
4982
+ var _a;
4983
+ return (_a = NODE_NAMES.find(function (node) {
4984
+ return getParaId(node) === nodeID;
4985
+ })) !== null && _a !== void 0 ? _a : null;
4986
+ };
4734
4987
 
4735
4988
  var index$4 = /*#__PURE__*/Object.freeze({
4736
4989
  __proto__: null,
@@ -4746,6 +4999,20 @@ var index$4 = /*#__PURE__*/Object.freeze({
4746
4999
  hasSupportForAsset: hasSupportForAsset
4747
5000
  });
4748
5001
 
5002
+ var constructRelayToParaParameters = function constructRelayToParaParameters(_ref, version) {
5003
+ var api = _ref.api,
5004
+ destination = _ref.destination,
5005
+ address = _ref.address,
5006
+ amount = _ref.amount;
5007
+ var includeFee = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
5008
+ var paraId = getParaId(destination);
5009
+ var parameters = [createHeaderPolkadotXCM('RelayToPara', version, paraId), generateAddressPayload(api, 'RelayToPara', null, address, version, paraId), createCurrencySpecification(amount, 'RelayToPara', version, destination), 0];
5010
+ if (includeFee) {
5011
+ parameters.push('Unlimited');
5012
+ }
5013
+ return parameters;
5014
+ };
5015
+
4749
5016
  var supportsXTokens = function supportsXTokens(obj) {
4750
5017
  return 'transferXTokens' in obj;
4751
5018
  };
@@ -4755,6 +5022,7 @@ var supportsPolkadotXCM = function supportsPolkadotXCM(obj) {
4755
5022
  var ParachainNode = /*#__PURE__*/function () {
4756
5023
  function ParachainNode(node, name, type, version) {
4757
5024
  _classCallCheck(this, ParachainNode);
5025
+ this._assetCheckEnabled = true;
4758
5026
  this._name = name;
4759
5027
  this._type = type;
4760
5028
  this._node = node;
@@ -4780,12 +5048,17 @@ var ParachainNode = /*#__PURE__*/function () {
4780
5048
  get: function get() {
4781
5049
  return this._version;
4782
5050
  }
5051
+ }, {
5052
+ key: "assetCheckEnabled",
5053
+ get: function get() {
5054
+ return this._assetCheckEnabled;
5055
+ }
4783
5056
  }, {
4784
5057
  key: "transfer",
4785
5058
  value: function transfer(api, currencySymbol, currencyId, amount, to, destination) {
4786
5059
  var serializedApiCallEnabled = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
4787
- var scenario = destination ? 'ParaToPara' : 'ParaToRelay';
4788
- var paraId = destination ? getParaId(destination) : undefined;
5060
+ var scenario = destination !== undefined ? 'ParaToPara' : 'ParaToRelay';
5061
+ var paraId = destination !== undefined ? getParaId(destination) : undefined;
4789
5062
  if (supportsXTokens(this)) {
4790
5063
  return this.transferXTokens({
4791
5064
  api: api,
@@ -4811,10 +5084,43 @@ var ParachainNode = /*#__PURE__*/function () {
4811
5084
  throw new NoXCMSupportImplementedError(this._node);
4812
5085
  }
4813
5086
  }
5087
+ }, {
5088
+ key: "transferRelayToPara",
5089
+ value: function transferRelayToPara(options) {
5090
+ return {
5091
+ module: 'xcmPallet',
5092
+ section: 'reserveTransferAssets',
5093
+ parameters: constructRelayToParaParameters(options, Version.V3)
5094
+ };
5095
+ }
5096
+ }, {
5097
+ key: "getProvider",
5098
+ value: function getProvider() {
5099
+ return getAllNodeProviders(this.node)[0];
5100
+ }
5101
+ }, {
5102
+ key: "createApiInstance",
5103
+ value: function createApiInstance$1() {
5104
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
5105
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
5106
+ while (1) switch (_context.prev = _context.next) {
5107
+ case 0:
5108
+ _context.next = 2;
5109
+ return createApiInstance(this.getProvider());
5110
+ case 2:
5111
+ return _context.abrupt("return", _context.sent);
5112
+ case 3:
5113
+ case "end":
5114
+ return _context.stop();
5115
+ }
5116
+ }, _callee, this);
5117
+ }));
5118
+ }
4814
5119
  }]);
4815
5120
  return ParachainNode;
4816
5121
  }();
4817
5122
 
5123
+ // eslint-disable-next-line @typescript-eslint/no-extraneous-class
4818
5124
  var XTokensTransferImpl = /*#__PURE__*/function () {
4819
5125
  function XTokensTransferImpl() {
4820
5126
  _classCallCheck(this, XTokensTransferImpl);
@@ -4829,7 +5135,7 @@ var XTokensTransferImpl = /*#__PURE__*/function () {
4829
5135
  var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Unlimited';
4830
5136
  var pallet = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'XTokens';
4831
5137
  var module = lowercaseFirstLetter(pallet.toString());
4832
- if (serializedApiCallEnabled) {
5138
+ if (serializedApiCallEnabled === true) {
4833
5139
  return {
4834
5140
  module: module,
4835
5141
  section: 'transfer',
@@ -4854,13 +5160,19 @@ var Acala$1 = /*#__PURE__*/function (_ParachainNode) {
4854
5160
  value: function transferXTokens(input) {
4855
5161
  var currency = input.currency,
4856
5162
  currencyID = input.currencyID;
4857
- var currencySelection = currencyID ? {
5163
+ var currencySelection = currencyID !== undefined ? {
4858
5164
  ForeignAsset: currencyID
4859
5165
  } : {
4860
5166
  Token: currency
4861
5167
  };
4862
5168
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
4863
5169
  }
5170
+ }, {
5171
+ key: "getProvider",
5172
+ value: function getProvider() {
5173
+ // Return the second WebSocket URL because the first one is sometimes unreliable.
5174
+ return getAllNodeProviders(this.node)[1];
5175
+ }
4864
5176
  }]);
4865
5177
  return Acala;
4866
5178
  }(ParachainNode);
@@ -4912,7 +5224,7 @@ var Crust$1 = /*#__PURE__*/function (_ParachainNode) {
4912
5224
  if (currency === 'CRU') {
4913
5225
  return 'SelfReserve';
4914
5226
  }
4915
- if (!currencyID) {
5227
+ if (currencyID === undefined) {
4916
5228
  throw new InvalidCurrencyError("Asset ".concat(currency, " is not supported by node ").concat(this.node, "."));
4917
5229
  }
4918
5230
  return {
@@ -4940,7 +5252,7 @@ var BifrostPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
4940
5252
  value: function transferXTokens(input) {
4941
5253
  // Multiple asset options need addressing
4942
5254
  var currencySelection = {
4943
- Token: input.currency
5255
+ Native: input.currency
4944
5256
  };
4945
5257
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
4946
5258
  }
@@ -4994,7 +5306,7 @@ var Clover$1 = /*#__PURE__*/function (_ParachainNode) {
4994
5306
  if (currency === 'CLV') {
4995
5307
  return 'SelfReserve';
4996
5308
  }
4997
- if (!currencyID) {
5309
+ if (currencyID === undefined) {
4998
5310
  throw new InvalidCurrencyError("Asset ".concat(currency, " is not supported by node ").concat(this.node, "."));
4999
5311
  }
5000
5312
  return {
@@ -5017,7 +5329,14 @@ var ComposableFinance$1 = /*#__PURE__*/function (_ParachainNode) {
5017
5329
  _classCallCheck(this, ComposableFinance);
5018
5330
  return _super.call(this, 'ComposableFinance', 'composable', 'polkadot', Version.V3);
5019
5331
  }
5020
- return _createClass(ComposableFinance);
5332
+ _createClass(ComposableFinance, [{
5333
+ key: "transferXTokens",
5334
+ value: function transferXTokens(input) {
5335
+ var currencyID = input.currencyID;
5336
+ return XTokensTransferImpl.transferXTokens(input, currencyID);
5337
+ }
5338
+ }]);
5339
+ return ComposableFinance;
5021
5340
  }(ParachainNode);
5022
5341
 
5023
5342
  var HydraDX$1 = /*#__PURE__*/function (_ParachainNode) {
@@ -5049,7 +5368,7 @@ var Interlay$1 = /*#__PURE__*/function (_ParachainNode) {
5049
5368
  value: function transferXTokens(input) {
5050
5369
  var currency = input.currency,
5051
5370
  currencyID = input.currencyID;
5052
- var currencySelection = currencyID ? {
5371
+ var currencySelection = currencyID !== undefined ? {
5053
5372
  ForeignAsset: currencyID
5054
5373
  } : {
5055
5374
  Token: currency
@@ -5111,6 +5430,15 @@ var Moonbeam$1 = /*#__PURE__*/function (_ParachainNode) {
5111
5430
  };
5112
5431
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
5113
5432
  }
5433
+ }, {
5434
+ key: "transferRelayToPara",
5435
+ value: function transferRelayToPara(options) {
5436
+ return {
5437
+ module: 'xcmPallet',
5438
+ section: 'limitedReserveTransferAssets',
5439
+ parameters: constructRelayToParaParameters(options, Version.V3, true)
5440
+ };
5441
+ }
5114
5442
  }]);
5115
5443
  return Moonbeam;
5116
5444
  }(ParachainNode);
@@ -5215,9 +5543,10 @@ var BifrostKusama$1 = /*#__PURE__*/function (_ParachainNode) {
5215
5543
  key: "transferXTokens",
5216
5544
  value: function transferXTokens(input) {
5217
5545
  // Multiple asset options need addressing
5218
- return XTokensTransferImpl.transferXTokens(input, {
5219
- Token: input.currency
5220
- });
5546
+ var currencySelection = {
5547
+ Native: input.currency
5548
+ };
5549
+ return XTokensTransferImpl.transferXTokens(input, currencySelection);
5221
5550
  }
5222
5551
  }]);
5223
5552
  return BifrostKusama;
@@ -5228,7 +5557,7 @@ var Pioneer$1 = /*#__PURE__*/function (_ParachainNode) {
5228
5557
  var _super = _createSuper(Pioneer);
5229
5558
  function Pioneer() {
5230
5559
  _classCallCheck(this, Pioneer);
5231
- return _super.call(this, 'Pioneer', 'bitcountryPioneer', 'kusama', Version.V1);
5560
+ return _super.call(this, 'Pioneer', 'pioneer', 'kusama', Version.V1);
5232
5561
  }
5233
5562
  _createClass(Pioneer, [{
5234
5563
  key: "transferXTokens",
@@ -5306,6 +5635,15 @@ var Moonriver$1 = /*#__PURE__*/function (_ParachainNode) {
5306
5635
  };
5307
5636
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
5308
5637
  }
5638
+ }, {
5639
+ key: "transferRelayToPara",
5640
+ value: function transferRelayToPara(options) {
5641
+ return {
5642
+ module: 'xcmPallet',
5643
+ section: 'limitedReserveTransferAssets',
5644
+ parameters: constructRelayToParaParameters(options, Version.V3, true)
5645
+ };
5646
+ }
5309
5647
  }]);
5310
5648
  return Moonriver;
5311
5649
  }(ParachainNode);
@@ -5322,6 +5660,30 @@ var Mangata$1 = /*#__PURE__*/function (_ParachainNode) {
5322
5660
  value: function transferXTokens(input) {
5323
5661
  return XTokensTransferImpl.transferXTokens(input, input.currencyID);
5324
5662
  }
5663
+ }, {
5664
+ key: "createApiInstance",
5665
+ value: function createApiInstance() {
5666
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
5667
+ var MangataSDK, instance;
5668
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
5669
+ while (1) switch (_context.prev = _context.next) {
5670
+ case 0:
5671
+ _context.next = 2;
5672
+ return import('@mangata-finance/sdk');
5673
+ case 2:
5674
+ MangataSDK = _context.sent;
5675
+ instance = MangataSDK.Mangata.instance([this.getProvider()]);
5676
+ _context.next = 6;
5677
+ return instance.api();
5678
+ case 6:
5679
+ return _context.abrupt("return", _context.sent);
5680
+ case 7:
5681
+ case "end":
5682
+ return _context.stop();
5683
+ }
5684
+ }, _callee, this);
5685
+ }));
5686
+ }
5325
5687
  }]);
5326
5688
  return Mangata;
5327
5689
  }(ParachainNode);
@@ -5355,7 +5717,7 @@ var Kintsugi$1 = /*#__PURE__*/function (_ParachainNode) {
5355
5717
  value: function transferXTokens(input) {
5356
5718
  var currency = input.currency,
5357
5719
  currencyID = input.currencyID;
5358
- var currencySelection = currencyID ? {
5720
+ var currencySelection = currencyID !== undefined ? {
5359
5721
  ForeignAsset: currencyID
5360
5722
  } : {
5361
5723
  Token: currency
@@ -5402,7 +5764,7 @@ var CrustShadow$1 = /*#__PURE__*/function (_ParachainNode) {
5402
5764
  if (currency === 'CSM') {
5403
5765
  return 'SelfReserve';
5404
5766
  }
5405
- if (!currencyID) {
5767
+ if (currencyID === undefined) {
5406
5768
  throw new InvalidCurrencyError("Asset ".concat(currency, " is not supported by node ").concat(this.node, "."));
5407
5769
  }
5408
5770
  return {
@@ -5442,7 +5804,7 @@ var NodeNotSupportedError = /*#__PURE__*/function (_Error) {
5442
5804
  function NodeNotSupportedError(message) {
5443
5805
  var _this;
5444
5806
  _classCallCheck(this, NodeNotSupportedError);
5445
- _this = _super.call(this, message);
5807
+ _this = _super.call(this, message !== null && message !== void 0 ? message : 'These nodes do not support XCM transfers from Relay / to Relay chain.');
5446
5808
  _this.name = 'NodeNotSupported';
5447
5809
  return _this;
5448
5810
  }
@@ -5489,6 +5851,11 @@ var Integritee$1 = /*#__PURE__*/function (_ParachainNode) {
5489
5851
  if (input.currency === 'KSM') throw new InvalidCurrencyError("Node ".concat(this.node, " does not support currency KSM"));
5490
5852
  return XTokensTransferImpl.transferXTokens(input, input.currency);
5491
5853
  }
5854
+ }, {
5855
+ key: "transferRelayToPara",
5856
+ value: function transferRelayToPara() {
5857
+ throw new NodeNotSupportedError();
5858
+ }
5492
5859
  }]);
5493
5860
  return Integritee;
5494
5861
  }(ParachainNode);
@@ -5522,18 +5889,25 @@ var Karura$1 = /*#__PURE__*/function (_ParachainNode) {
5522
5889
  value: function transferXTokens(input) {
5523
5890
  var currency = input.currency,
5524
5891
  currencyID = input.currencyID;
5525
- var currencySelection = currencyID ? {
5892
+ var currencySelection = currencyID !== undefined ? {
5526
5893
  ForeignAsset: currencyID
5527
5894
  } : {
5528
5895
  Token: currency
5529
5896
  };
5530
5897
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
5531
5898
  }
5899
+ }, {
5900
+ key: "getProvider",
5901
+ value: function getProvider() {
5902
+ // Return the second WebSocket URL because the first one is sometimes unreliable.
5903
+ return getAllNodeProviders(this.node)[1];
5904
+ }
5532
5905
  }]);
5533
5906
  return Karura;
5534
5907
  }(ParachainNode);
5535
5908
 
5536
5909
  // Contains basic structure of polkadotXCM call
5910
+ // eslint-disable-next-line @typescript-eslint/no-extraneous-class
5537
5911
  var PolkadotXCMTransferImpl = /*#__PURE__*/function () {
5538
5912
  function PolkadotXCMTransferImpl() {
5539
5913
  _classCallCheck(this, PolkadotXCMTransferImpl);
@@ -5547,14 +5921,14 @@ var PolkadotXCMTransferImpl = /*#__PURE__*/function () {
5547
5921
  currencySelection = _ref.currencySelection,
5548
5922
  serializedApiCallEnabled = _ref.serializedApiCallEnabled;
5549
5923
  var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
5550
- if (serializedApiCallEnabled) {
5924
+ if (serializedApiCallEnabled === true) {
5551
5925
  return {
5552
5926
  module: 'polkadotXcm',
5553
5927
  section: method,
5554
- parameters: [header, addressSelection, currencySelection, 0].concat(_toConsumableArray(fees ? [fees] : []))
5928
+ parameters: [header, addressSelection, currencySelection, 0].concat(_toConsumableArray(fees !== undefined ? [fees] : []))
5555
5929
  };
5556
5930
  }
5557
- return fees ? api.tx.polkadotXcm[method](header, addressSelection, currencySelection, 0, fees) : api.tx.polkadotXcm[method](header, addressSelection, currencySelection, 0);
5931
+ return fees !== undefined ? api.tx.polkadotXcm[method](header, addressSelection, currencySelection, 0, fees) : api.tx.polkadotXcm[method](header, addressSelection, currencySelection, 0);
5558
5932
  }
5559
5933
  }]);
5560
5934
  return PolkadotXCMTransferImpl;
@@ -5574,6 +5948,15 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
5574
5948
  // TESTED https://polkadot.subscan.io/xcm_message/polkadot-c01158ff1a5c5a596138ed9d0f0f2bccc1d9c51d
5575
5949
  return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limitedTeleportAssets', 'Unlimited');
5576
5950
  }
5951
+ }, {
5952
+ key: "transferRelayToPara",
5953
+ value: function transferRelayToPara(options) {
5954
+ return {
5955
+ module: 'xcmPallet',
5956
+ section: 'limitedTeleportAssets',
5957
+ parameters: constructRelayToParaParameters(options, Version.V3, true)
5958
+ };
5959
+ }
5577
5960
  }]);
5578
5961
  return AssetHubPolkadot;
5579
5962
  }(ParachainNode);
@@ -5592,6 +5975,15 @@ var AssetHubKusama$1 = /*#__PURE__*/function (_ParachainNode) {
5592
5975
  // TESTED https://kusama.subscan.io/xcm_message/kusama-8e423130a4d8b61679af95dbea18a55124f99672
5593
5976
  return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limitedTeleportAssets', 'Unlimited');
5594
5977
  }
5978
+ }, {
5979
+ key: "transferRelayToPara",
5980
+ value: function transferRelayToPara(options) {
5981
+ return {
5982
+ module: 'xcmPallet',
5983
+ section: 'limitedTeleportAssets',
5984
+ parameters: constructRelayToParaParameters(options, Version.V3, true)
5985
+ };
5986
+ }
5595
5987
  }]);
5596
5988
  return AssetHubKusama;
5597
5989
  }(ParachainNode);
@@ -5613,6 +6005,15 @@ var Encointer$1 = /*#__PURE__*/function (_ParachainNode) {
5613
6005
  }
5614
6006
  throw new ScenarioNotSupportedError(this.node, input.scenario);
5615
6007
  }
6008
+ }, {
6009
+ key: "transferRelayToPara",
6010
+ value: function transferRelayToPara(options) {
6011
+ return {
6012
+ module: 'xcmPallet',
6013
+ section: 'limitedTeleportAssets',
6014
+ parameters: constructRelayToParaParameters(options, Version.V1, true)
6015
+ };
6016
+ }
5616
6017
  }]);
5617
6018
  return Encointer;
5618
6019
  }(ParachainNode);
@@ -5626,20 +6027,18 @@ var Robonomics$1 = /*#__PURE__*/function (_ParachainNode) {
5626
6027
  }
5627
6028
  _createClass(Robonomics, [{
5628
6029
  key: "transferPolkadotXCM",
5629
- value: function transferPolkadotXCM(_ref) {
5630
- var api = _ref.api,
5631
- header = _ref.header,
5632
- addressSelection = _ref.addressSelection,
5633
- currencySelection = _ref.currencySelection,
5634
- scenario = _ref.scenario;
5635
- // TESTED https://robonomics.subscan.io/xcm_message/kusama-e9641113dae59920e5cc0e012f1510ea0e2d0455
5636
- // TESTED https://robonomics.subscan.io/xcm_message/kusama-20b03208c99f2ef29d2d4b4cd4bc5659e54311ea
5637
- var method = scenario === 'ParaToPara' ? 'reserveTransferAssets' : 'reserveWithdrawAssets';
5638
- return api.tx.polkadotXcm[method](header, addressSelection, currencySelection, 0);
6030
+ value: function transferPolkadotXCM(input) {
6031
+ if (input.scenario === 'ParaToPara') {
6032
+ return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limitedReserveTransferAssets', {
6033
+ Limited: Robonomics.FEE
6034
+ });
6035
+ }
6036
+ return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserveWithdrawAssets');
5639
6037
  }
5640
6038
  }]);
5641
6039
  return Robonomics;
5642
6040
  }(ParachainNode);
6041
+ Robonomics$1.FEE = '400000000';
5643
6042
 
5644
6043
  var Astar$1 = /*#__PURE__*/function (_ParachainNode) {
5645
6044
  _inherits(Astar, _ParachainNode);
@@ -5692,6 +6091,11 @@ var Darwinia$1 = /*#__PURE__*/function (_ParachainNode) {
5692
6091
  }
5693
6092
  throw new ScenarioNotSupportedError(this.node, input.scenario);
5694
6093
  }
6094
+ }, {
6095
+ key: "transferRelayToPara",
6096
+ value: function transferRelayToPara() {
6097
+ throw new NodeNotSupportedError();
6098
+ }
5695
6099
  }]);
5696
6100
  return Darwinia;
5697
6101
  }(ParachainNode);
@@ -5712,6 +6116,11 @@ var Crab$1 = /*#__PURE__*/function (_ParachainNode) {
5712
6116
  }
5713
6117
  throw new ScenarioNotSupportedError(this.node, input.scenario);
5714
6118
  }
6119
+ }, {
6120
+ key: "transferRelayToPara",
6121
+ value: function transferRelayToPara() {
6122
+ throw new NodeNotSupportedError();
6123
+ }
5715
6124
  }]);
5716
6125
  return Crab;
5717
6126
  }(ParachainNode);
@@ -5720,17 +6129,19 @@ var Quartz$1 = /*#__PURE__*/function (_ParachainNode) {
5720
6129
  _inherits(Quartz, _ParachainNode);
5721
6130
  var _super = _createSuper(Quartz);
5722
6131
  function Quartz() {
6132
+ var _this;
5723
6133
  _classCallCheck(this, Quartz);
5724
- return _super.call(this, 'Quartz', 'quartz', 'kusama', Version.V3);
6134
+ _this = _super.call(this, 'Quartz', 'quartz', 'kusama', Version.V3);
6135
+ _this._assetCheckEnabled = false;
6136
+ return _this;
5725
6137
  }
5726
6138
  _createClass(Quartz, [{
5727
- key: "transferPolkadotXCM",
5728
- value: function transferPolkadotXCM(input) {
5729
- // TESTED https://quartz.subscan.io/xcm_message/kusama-f5b6580f8d7f97a8d33209d2b5b34d97454587e9
5730
- if (input.scenario === 'ParaToPara') {
5731
- return PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserveTransferAssets');
5732
- }
5733
- throw new ScenarioNotSupportedError(this.node, input.scenario);
6139
+ key: "transferXTokens",
6140
+ value: function transferXTokens(input) {
6141
+ var currencyID = input.currencyID;
6142
+ return XTokensTransferImpl.transferXTokens(input, {
6143
+ ForeignAssetId: currencyID
6144
+ });
5734
6145
  }
5735
6146
  }]);
5736
6147
  return Quartz;
@@ -5760,13 +6171,13 @@ var Manta$1 = /*#__PURE__*/function (_ParachainNode) {
5760
6171
  var _super = _createSuper(Manta);
5761
6172
  function Manta() {
5762
6173
  _classCallCheck(this, Manta);
5763
- return _super.call(this, 'Manta', 'manta', 'polkadot', Version.V3);
6174
+ return _super.call(this, 'Manta', 'manta', 'polkadot', Version.V1);
5764
6175
  }
5765
6176
  _createClass(Manta, [{
5766
6177
  key: "transferXTokens",
5767
6178
  value: function transferXTokens(input) {
5768
6179
  return XTokensTransferImpl.transferXTokens(input, {
5769
- ForeignAssetId: input.currencyID
6180
+ MantaCurrency: input.currencyID
5770
6181
  });
5771
6182
  }
5772
6183
  }]);
@@ -5810,6 +6221,11 @@ var Nodle$1 = /*#__PURE__*/function (_ParachainNode) {
5810
6221
  }
5811
6222
  return XTokensTransferImpl.transferXTokens(input, 'NodleNative');
5812
6223
  }
6224
+ }, {
6225
+ key: "transferRelayToPara",
6226
+ value: function transferRelayToPara() {
6227
+ throw new NodeNotSupportedError();
6228
+ }
5813
6229
  }]);
5814
6230
  return Nodle;
5815
6231
  }(ParachainNode);
@@ -5850,6 +6266,11 @@ var Pendulum$1 = /*#__PURE__*/function (_ParachainNode) {
5850
6266
  XCM: input.currencyID
5851
6267
  });
5852
6268
  }
6269
+ }, {
6270
+ key: "transferRelayToPara",
6271
+ value: function transferRelayToPara() {
6272
+ throw new NodeNotSupportedError();
6273
+ }
5853
6274
  }]);
5854
6275
  return Pendulum;
5855
6276
  }(ParachainNode);
@@ -5880,9 +6301,10 @@ var Zeitgeist$1 = /*#__PURE__*/function (_ParachainNode) {
5880
6301
  _createClass(Zeitgeist, [{
5881
6302
  key: "transferXTokens",
5882
6303
  value: function transferXTokens(input) {
5883
- return XTokensTransferImpl.transferXTokens(input, {
6304
+ var currencySelection = input.currency === 'ZTG' ? 'Ztg' : {
5884
6305
  ForeignAsset: input.currencyID
5885
- });
6306
+ };
6307
+ return XTokensTransferImpl.transferXTokens(input, currencySelection);
5886
6308
  }
5887
6309
  }]);
5888
6310
  return Zeitgeist;
@@ -5890,6 +6312,7 @@ var Zeitgeist$1 = /*#__PURE__*/function (_ParachainNode) {
5890
6312
 
5891
6313
  // Contains supported Parachains and exports supported XCM Pallets
5892
6314
  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'];
6315
+ var NODES_WITH_RELAY_CHAINS = [].concat(NODE_NAMES, ['Polkadot', 'Kusama']);
5893
6316
  var nodes = {
5894
6317
  AssetHubPolkadot: new AssetHubPolkadot$1(),
5895
6318
  Acala: new Acala$1(),
@@ -6017,6 +6440,7 @@ var generateAddressPayload = function generateAddressPayload(api, scenario, pall
6017
6440
  }
6018
6441
  };
6019
6442
  };
6443
+ // TODO: Refactor this function
6020
6444
  var createCurrencySpecification = function createCurrencySpecification(amount, scenario, version, node, cur) {
6021
6445
  if (scenario === 'ParaToRelay') {
6022
6446
  return _defineProperty({}, version, [{
@@ -6074,6 +6498,19 @@ var createCurrencySpecification = function createCurrencySpecification(amount, s
6074
6498
  }]
6075
6499
  };
6076
6500
  }
6501
+ if (scenario === 'ParaToPara' && node === 'Robonomics') {
6502
+ return _defineProperty({}, version, [{
6503
+ id: {
6504
+ Concrete: {
6505
+ parents: 0,
6506
+ interior: 'Here'
6507
+ }
6508
+ },
6509
+ fun: {
6510
+ Fungible: amount
6511
+ }
6512
+ }]);
6513
+ }
6077
6514
  // Otherwise
6078
6515
  return {
6079
6516
  V3: [{
@@ -6125,51 +6562,90 @@ var getNodeEndpointOption = function getNodeEndpointOption(node) {
6125
6562
  var _getNode = getNode(node),
6126
6563
  type = _getNode.type,
6127
6564
  name = _getNode.name;
6128
- var _ref8 = type === 'polkadot' ? prodRelayPolkadot : prodRelayKusama,
6129
- linked = _ref8.linked;
6565
+ var _ref9 = type === 'polkadot' ? prodRelayPolkadot : prodRelayKusama,
6566
+ linked = _ref9.linked;
6130
6567
  // TMP Fix because some nodes don't have providers in endpoint options
6131
- if (node === 'Imbue') {
6132
- return {
6133
- info: 'imbue',
6134
- paraId: 2121,
6135
- providers: {
6136
- 'Imbue Network 0': 'wss://kusama.imbuenetwork.com'
6137
- }
6138
- };
6139
- }
6140
- if (node === 'Polkadex') {
6568
+ if (node === 'Kylin') {
6141
6569
  return {
6142
- info: 'polkadex',
6143
- paraId: 2040,
6570
+ info: 'kylin',
6571
+ paraId: 2052,
6144
6572
  providers: {
6145
- Dwellir: 'wss://polkadex-rpc.dwellir.com',
6146
- OnFinality: 'wss://polkadex-parachain.api.onfinality.io/public-ws',
6147
- RadiumBlock: 'wss://polkadex-parachain.public.curie.radiumblock.co/ws'
6573
+ 'Kylin Network': 'wss://polkadot.kylin-node.co.uk'
6148
6574
  }
6149
6575
  };
6150
6576
  }
6151
- return linked ? linked.find(function (o) {
6577
+ return linked !== undefined ? linked.find(function (o) {
6152
6578
  return o.info === name;
6153
6579
  }) : undefined;
6154
6580
  };
6155
6581
  var getAllNodeProviders = function getAllNodeProviders(node) {
6156
6582
  var _a;
6157
- var _ref9 = (_a = getNodeEndpointOption(node)) !== null && _a !== void 0 ? _a : {},
6158
- providers = _ref9.providers;
6583
+ var _ref10 = (_a = getNodeEndpointOption(node)) !== null && _a !== void 0 ? _a : {},
6584
+ providers = _ref10.providers;
6585
+ if (providers.length < 1) {
6586
+ throw new Error("Node ".concat(node, " does not have any providers."));
6587
+ }
6159
6588
  return Object.values(providers !== null && providers !== void 0 ? providers : []);
6160
6589
  };
6161
6590
  var getNodeProvider = function getNodeProvider(node) {
6162
- var providers = getAllNodeProviders(node);
6163
- return providers.length > 0 ? providers[0] : null;
6591
+ return getNode(node).getProvider();
6592
+ };
6593
+ var createApiInstance = function createApiInstance(wsUrl) {
6594
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
6595
+ var wsProvider;
6596
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
6597
+ while (1) switch (_context.prev = _context.next) {
6598
+ case 0:
6599
+ wsProvider = new WsProvider(wsUrl);
6600
+ _context.next = 3;
6601
+ return ApiPromise.create({
6602
+ provider: wsProvider
6603
+ });
6604
+ case 3:
6605
+ return _context.abrupt("return", _context.sent);
6606
+ case 4:
6607
+ case "end":
6608
+ return _context.stop();
6609
+ }
6610
+ }, _callee);
6611
+ }));
6612
+ };
6613
+ var createApiInstanceForNode = function createApiInstanceForNode(node) {
6614
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
6615
+ var endpointOption, wsUrl;
6616
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
6617
+ while (1) switch (_context2.prev = _context2.next) {
6618
+ case 0:
6619
+ if (!(node === 'Polkadot' || node === 'Kusama')) {
6620
+ _context2.next = 6;
6621
+ break;
6622
+ }
6623
+ endpointOption = node === 'Polkadot' ? prodRelayPolkadot : prodRelayKusama;
6624
+ wsUrl = Object.values(endpointOption.providers)[0];
6625
+ _context2.next = 5;
6626
+ return createApiInstance(wsUrl);
6627
+ case 5:
6628
+ return _context2.abrupt("return", _context2.sent);
6629
+ case 6:
6630
+ _context2.next = 8;
6631
+ return getNode(node).createApiInstance();
6632
+ case 8:
6633
+ return _context2.abrupt("return", _context2.sent);
6634
+ case 9:
6635
+ case "end":
6636
+ return _context2.stop();
6637
+ }
6638
+ }, _callee2);
6639
+ }));
6164
6640
  };
6165
6641
  var lowercaseFirstLetter = function lowercaseFirstLetter(str) {
6166
6642
  return str.charAt(0).toLowerCase() + str.slice(1);
6167
6643
  };
6168
- var callPolkadotJsTxFunction = function callPolkadotJsTxFunction(api, _ref10) {
6644
+ var callPolkadotJsTxFunction = function callPolkadotJsTxFunction(api, _ref11) {
6169
6645
  var _api$tx$module;
6170
- var module = _ref10.module,
6171
- section = _ref10.section,
6172
- parameters = _ref10.parameters;
6646
+ var module = _ref11.module,
6647
+ section = _ref11.section,
6648
+ parameters = _ref11.parameters;
6173
6649
  return (_api$tx$module = api.tx[module])[section].apply(_api$tx$module, _toConsumableArray(parameters));
6174
6650
  };
6175
6651
 
@@ -6183,7 +6659,7 @@ var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, symbolOrId) {
6183
6659
  assetId = _ref.assetId;
6184
6660
  return symbol === symbolOrId || assetId === symbolOrId;
6185
6661
  });
6186
- if (asset) {
6662
+ if (asset !== undefined) {
6187
6663
  var symbol = asset.symbol,
6188
6664
  assetId = asset.assetId;
6189
6665
  return {
@@ -6204,73 +6680,47 @@ var sendCommon = function sendCommon(api, origin, currencySymbolOrId, amount, to
6204
6680
  throw new InvalidCurrencyError('The provided asset ID is larger than the maximum safe integer value. Please provide it as a string.');
6205
6681
  }
6206
6682
  var asset = getAssetBySymbolOrId(origin, currencySymbolOrId.toString());
6207
- if (destination) {
6683
+ if (destination !== undefined) {
6208
6684
  var originRelayChainSymbol = getRelayChainSymbol(origin);
6209
6685
  var destinationRelayChainSymbol = getRelayChainSymbol(destination);
6210
6686
  if (originRelayChainSymbol !== destinationRelayChainSymbol) {
6211
6687
  throw new IncompatibleNodesError();
6212
6688
  }
6213
6689
  }
6214
- if (!asset) {
6690
+ var originNode = getNode(origin);
6691
+ if (asset === null && originNode.assetCheckEnabled) {
6215
6692
  throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency or currencyId ").concat(currencySymbolOrId, "."));
6216
6693
  }
6217
- if (destination && asset.symbol && !hasSupportForAsset(destination, asset.symbol)) {
6694
+ if (destination !== undefined && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && getNode(destination).assetCheckEnabled && !hasSupportForAsset(destination, asset.symbol)) {
6218
6695
  throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency or currencyId ").concat(currencySymbolOrId, "."));
6219
6696
  }
6220
- var currencySymbol = asset.symbol,
6221
- currencyId = asset.assetId;
6222
- return getNode(origin).transfer(api, currencySymbol, currencyId, amount, to, destination, serializedApiCallEnabled);
6697
+ var currencyId = originNode.assetCheckEnabled ? asset === null || asset === void 0 ? void 0 : asset.assetId : currencySymbolOrId.toString();
6698
+ return originNode.transfer(api, asset === null || asset === void 0 ? void 0 : asset.symbol, currencyId, amount, to, destination, serializedApiCallEnabled);
6223
6699
  };
6224
6700
  var sendSerializedApiCall = function sendSerializedApiCall(api, origin, currencySymbolOrId, amount, to, destination) {
6225
- return sendCommon(api, origin, currencySymbolOrId, amount, to, destination, true);
6701
+ return sendCommon(api, origin, currencySymbolOrId, amount.toString(), to, destination, true);
6226
6702
  };
6227
6703
  function send(api, origin, currencySymbolOrId, amount, to, destination) {
6228
- return sendCommon(api, origin, currencySymbolOrId, amount, to, destination);
6704
+ return sendCommon(api, origin, currencySymbolOrId, amount.toString(), to, destination);
6229
6705
  }
6230
- // TODO: Refactor this function
6231
- var transferRelayToParaCommon = function transferRelayToParaCommon(api, destination, amount, to) {
6706
+ var transferRelayToParaCommon = function transferRelayToParaCommon(api, destination, amount, address) {
6232
6707
  var serializedApiCallEnabled = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
6233
- var paraId = getParaId(destination);
6234
- if (destination === 'AssetHubPolkadot' || destination === 'AssetHubKusama' || destination === 'Moonbeam' || destination === 'Moonriver') {
6235
- // Same for AssetHubPolkadot, AssetHubKusama, Encoiter and Moonbeam
6236
- var _serializedApiCall = {
6237
- module: 'xcmPallet',
6238
- section: destination === 'Moonbeam' || destination === 'Moonriver' ? 'limitedReserveTransferAssets' : 'limitedTeleportAssets',
6239
- parameters: [createHeaderPolkadotXCM('RelayToPara', Version.V3, paraId), generateAddressPayload(api, 'RelayToPara', null, to, Version.V3, paraId), createCurrencySpecification(amount, 'RelayToPara', Version.V3, destination), 0, 'Unlimited']
6240
- };
6241
- if (serializedApiCallEnabled) {
6242
- return _serializedApiCall;
6243
- }
6244
- return callPolkadotJsTxFunction(api, _serializedApiCall);
6245
- } else if (destination === 'Encointer') {
6246
- var _serializedApiCall2 = {
6247
- module: 'xcmPallet',
6248
- section: 'limitedTeleportAssets',
6249
- parameters: [createHeaderPolkadotXCM('RelayToPara', Version.V1, paraId), generateAddressPayload(api, 'RelayToPara', null, to, Version.V1, paraId), createCurrencySpecification(amount, 'RelayToPara', Version.V1, destination), 0, 'Unlimited']
6250
- };
6251
- if (serializedApiCallEnabled) {
6252
- return _serializedApiCall2;
6253
- }
6254
- return callPolkadotJsTxFunction(api, _serializedApiCall2);
6255
- } else if (destination === 'Darwinia' || destination === 'Crab' || destination === 'Integritee' || destination === 'Nodle' || destination === 'Pendulum') {
6256
- // Do not do anything because Darwinia and Crab does not have DOT and KSM registered
6257
- throw new NodeNotSupportedError('These nodes do not support XCM transfers from Relay / to Relay chain.');
6258
- }
6259
- var serializedApiCall = {
6260
- module: 'xcmPallet',
6261
- section: 'reserveTransferAssets',
6262
- parameters: [createHeaderPolkadotXCM('RelayToPara', Version.V3, paraId), generateAddressPayload(api, 'RelayToPara', null, to, Version.V3, paraId), createCurrencySpecification(amount, 'RelayToPara', Version.V3, destination), 0]
6263
- };
6708
+ var serializedApiCall = getNode(destination).transferRelayToPara({
6709
+ api: api,
6710
+ destination: destination,
6711
+ address: address,
6712
+ amount: amount
6713
+ });
6264
6714
  if (serializedApiCallEnabled) {
6265
6715
  return serializedApiCall;
6266
6716
  }
6267
6717
  return callPolkadotJsTxFunction(api, serializedApiCall);
6268
6718
  };
6269
6719
  function transferRelayToPara(api, destination, amount, to) {
6270
- return transferRelayToParaCommon(api, destination, amount, to);
6720
+ return transferRelayToParaCommon(api, destination, amount.toString(), to);
6271
6721
  }
6272
6722
  var transferRelayToParaSerializedApiCall = function transferRelayToParaSerializedApiCall(api, destination, amount, to) {
6273
- return transferRelayToParaCommon(api, destination, amount, to, true);
6723
+ return transferRelayToParaCommon(api, destination, amount.toString(), to, true);
6274
6724
  };
6275
6725
 
6276
6726
  var index$3 = /*#__PURE__*/Object.freeze({
@@ -6282,7 +6732,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
6282
6732
  transferRelayToParaSerializedApiCall: transferRelayToParaSerializedApiCall
6283
6733
  });
6284
6734
 
6285
- //Contains XYK Decentralized exchange functions implemented in collaboration with Basilisk team
6735
+ // Contains XYK Decentralized exchange functions implemented in collaboration with Basilisk team
6286
6736
  function addLiquidity(api, assetA, assetB, amountA, amountBMaxLimit) {
6287
6737
  return api.tx.xyk.addLiquidity(assetA, assetB, amountA, amountBMaxLimit);
6288
6738
  }
@@ -6859,9 +7309,9 @@ var GeneralBuilder = /*#__PURE__*/function () {
6859
7309
  }]);
6860
7310
  return GeneralBuilder;
6861
7311
  }();
6862
- function Builder(api) {
7312
+ var Builder = function Builder(api) {
6863
7313
  return new GeneralBuilder(api);
6864
- }
7314
+ };
6865
7315
 
6866
7316
  var AssetHubPolkadot = {
6867
7317
  defaultPallet: "PolkadotXcm",
@@ -7317,4 +7767,4 @@ var getSupportedPallets = function getSupportedPallets(node) {
7317
7767
  return palletsMap[node].supportedPallets;
7318
7768
  };
7319
7769
 
7320
- export { Builder, IncompatibleNodesError, InvalidCurrencyError, NODE_NAMES, NoXCMSupportImplementedError, NodeNotSupportedError, SUPPORTED_PALLETS, ScenarioNotSupportedError, Version, index$4 as assets, index as closeChannels, 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 };
7770
+ 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 };