@paraspell/sdk 3.0.6 → 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.cjs CHANGED
@@ -1,9 +1,310 @@
1
1
  'use strict';
2
2
 
3
- require('@polkadot/api');
3
+ var api = require('@polkadot/api');
4
4
  var ethers = require('ethers');
5
5
  var endpoints = require('@polkadot/apps-config/endpoints');
6
6
 
7
+ function _regeneratorRuntime() {
8
+ _regeneratorRuntime = function () {
9
+ return e;
10
+ };
11
+ var t,
12
+ e = {},
13
+ r = Object.prototype,
14
+ n = r.hasOwnProperty,
15
+ o = Object.defineProperty || function (t, e, r) {
16
+ t[e] = r.value;
17
+ },
18
+ i = "function" == typeof Symbol ? Symbol : {},
19
+ a = i.iterator || "@@iterator",
20
+ c = i.asyncIterator || "@@asyncIterator",
21
+ u = i.toStringTag || "@@toStringTag";
22
+ function define(t, e, r) {
23
+ return Object.defineProperty(t, e, {
24
+ value: r,
25
+ enumerable: !0,
26
+ configurable: !0,
27
+ writable: !0
28
+ }), t[e];
29
+ }
30
+ try {
31
+ define({}, "");
32
+ } catch (t) {
33
+ define = function (t, e, r) {
34
+ return t[e] = r;
35
+ };
36
+ }
37
+ function wrap(t, e, r, n) {
38
+ var i = e && e.prototype instanceof Generator ? e : Generator,
39
+ a = Object.create(i.prototype),
40
+ c = new Context(n || []);
41
+ return o(a, "_invoke", {
42
+ value: makeInvokeMethod(t, r, c)
43
+ }), a;
44
+ }
45
+ function tryCatch(t, e, r) {
46
+ try {
47
+ return {
48
+ type: "normal",
49
+ arg: t.call(e, r)
50
+ };
51
+ } catch (t) {
52
+ return {
53
+ type: "throw",
54
+ arg: t
55
+ };
56
+ }
57
+ }
58
+ e.wrap = wrap;
59
+ var h = "suspendedStart",
60
+ l = "suspendedYield",
61
+ f = "executing",
62
+ s = "completed",
63
+ y = {};
64
+ function Generator() {}
65
+ function GeneratorFunction() {}
66
+ function GeneratorFunctionPrototype() {}
67
+ var p = {};
68
+ define(p, a, function () {
69
+ return this;
70
+ });
71
+ var d = Object.getPrototypeOf,
72
+ v = d && d(d(values([])));
73
+ v && v !== r && n.call(v, a) && (p = v);
74
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
75
+ function defineIteratorMethods(t) {
76
+ ["next", "throw", "return"].forEach(function (e) {
77
+ define(t, e, function (t) {
78
+ return this._invoke(e, t);
79
+ });
80
+ });
81
+ }
82
+ function AsyncIterator(t, e) {
83
+ function invoke(r, o, i, a) {
84
+ var c = tryCatch(t[r], t, o);
85
+ if ("throw" !== c.type) {
86
+ var u = c.arg,
87
+ h = u.value;
88
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
89
+ invoke("next", t, i, a);
90
+ }, function (t) {
91
+ invoke("throw", t, i, a);
92
+ }) : e.resolve(h).then(function (t) {
93
+ u.value = t, i(u);
94
+ }, function (t) {
95
+ return invoke("throw", t, i, a);
96
+ });
97
+ }
98
+ a(c.arg);
99
+ }
100
+ var r;
101
+ o(this, "_invoke", {
102
+ value: function (t, n) {
103
+ function callInvokeWithMethodAndArg() {
104
+ return new e(function (e, r) {
105
+ invoke(t, n, e, r);
106
+ });
107
+ }
108
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
109
+ }
110
+ });
111
+ }
112
+ function makeInvokeMethod(e, r, n) {
113
+ var o = h;
114
+ return function (i, a) {
115
+ if (o === f) throw new Error("Generator is already running");
116
+ if (o === s) {
117
+ if ("throw" === i) throw a;
118
+ return {
119
+ value: t,
120
+ done: !0
121
+ };
122
+ }
123
+ for (n.method = i, n.arg = a;;) {
124
+ var c = n.delegate;
125
+ if (c) {
126
+ var u = maybeInvokeDelegate(c, n);
127
+ if (u) {
128
+ if (u === y) continue;
129
+ return u;
130
+ }
131
+ }
132
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
133
+ if (o === h) throw o = s, n.arg;
134
+ n.dispatchException(n.arg);
135
+ } else "return" === n.method && n.abrupt("return", n.arg);
136
+ o = f;
137
+ var p = tryCatch(e, r, n);
138
+ if ("normal" === p.type) {
139
+ if (o = n.done ? s : l, p.arg === y) continue;
140
+ return {
141
+ value: p.arg,
142
+ done: n.done
143
+ };
144
+ }
145
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
146
+ }
147
+ };
148
+ }
149
+ function maybeInvokeDelegate(e, r) {
150
+ var n = r.method,
151
+ o = e.iterator[n];
152
+ 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;
153
+ var i = tryCatch(o, e.iterator, r.arg);
154
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
155
+ var a = i.arg;
156
+ 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);
157
+ }
158
+ function pushTryEntry(t) {
159
+ var e = {
160
+ tryLoc: t[0]
161
+ };
162
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
163
+ }
164
+ function resetTryEntry(t) {
165
+ var e = t.completion || {};
166
+ e.type = "normal", delete e.arg, t.completion = e;
167
+ }
168
+ function Context(t) {
169
+ this.tryEntries = [{
170
+ tryLoc: "root"
171
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
172
+ }
173
+ function values(e) {
174
+ if (e || "" === e) {
175
+ var r = e[a];
176
+ if (r) return r.call(e);
177
+ if ("function" == typeof e.next) return e;
178
+ if (!isNaN(e.length)) {
179
+ var o = -1,
180
+ i = function next() {
181
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
182
+ return next.value = t, next.done = !0, next;
183
+ };
184
+ return i.next = i;
185
+ }
186
+ }
187
+ throw new TypeError(typeof e + " is not iterable");
188
+ }
189
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
190
+ value: GeneratorFunctionPrototype,
191
+ configurable: !0
192
+ }), o(GeneratorFunctionPrototype, "constructor", {
193
+ value: GeneratorFunction,
194
+ configurable: !0
195
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
196
+ var e = "function" == typeof t && t.constructor;
197
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
198
+ }, e.mark = function (t) {
199
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
200
+ }, e.awrap = function (t) {
201
+ return {
202
+ __await: t
203
+ };
204
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
205
+ return this;
206
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
207
+ void 0 === i && (i = Promise);
208
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
209
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
210
+ return t.done ? t.value : a.next();
211
+ });
212
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
213
+ return this;
214
+ }), define(g, "toString", function () {
215
+ return "[object Generator]";
216
+ }), e.keys = function (t) {
217
+ var e = Object(t),
218
+ r = [];
219
+ for (var n in e) r.push(n);
220
+ return r.reverse(), function next() {
221
+ for (; r.length;) {
222
+ var t = r.pop();
223
+ if (t in e) return next.value = t, next.done = !1, next;
224
+ }
225
+ return next.done = !0, next;
226
+ };
227
+ }, e.values = values, Context.prototype = {
228
+ constructor: Context,
229
+ reset: function (e) {
230
+ 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);
231
+ },
232
+ stop: function () {
233
+ this.done = !0;
234
+ var t = this.tryEntries[0].completion;
235
+ if ("throw" === t.type) throw t.arg;
236
+ return this.rval;
237
+ },
238
+ dispatchException: function (e) {
239
+ if (this.done) throw e;
240
+ var r = this;
241
+ function handle(n, o) {
242
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
243
+ }
244
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
245
+ var i = this.tryEntries[o],
246
+ a = i.completion;
247
+ if ("root" === i.tryLoc) return handle("end");
248
+ if (i.tryLoc <= this.prev) {
249
+ var c = n.call(i, "catchLoc"),
250
+ u = n.call(i, "finallyLoc");
251
+ if (c && u) {
252
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
253
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
254
+ } else if (c) {
255
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
256
+ } else {
257
+ if (!u) throw new Error("try statement without catch or finally");
258
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
259
+ }
260
+ }
261
+ }
262
+ },
263
+ abrupt: function (t, e) {
264
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
265
+ var o = this.tryEntries[r];
266
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
267
+ var i = o;
268
+ break;
269
+ }
270
+ }
271
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
272
+ var a = i ? i.completion : {};
273
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
274
+ },
275
+ complete: function (t, e) {
276
+ if ("throw" === t.type) throw t.arg;
277
+ 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;
278
+ },
279
+ finish: function (t) {
280
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
281
+ var r = this.tryEntries[e];
282
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
283
+ }
284
+ },
285
+ catch: function (t) {
286
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
287
+ var r = this.tryEntries[e];
288
+ if (r.tryLoc === t) {
289
+ var n = r.completion;
290
+ if ("throw" === n.type) {
291
+ var o = n.arg;
292
+ resetTryEntry(r);
293
+ }
294
+ return o;
295
+ }
296
+ }
297
+ throw new Error("illegal catch attempt");
298
+ },
299
+ delegateYield: function (e, r, n) {
300
+ return this.delegate = {
301
+ iterator: values(e),
302
+ resultName: r,
303
+ nextLoc: n
304
+ }, "next" === this.method && (this.arg = t), y;
305
+ }
306
+ }, e;
307
+ }
7
308
  function _toPrimitive(t, r) {
8
309
  if ("object" != typeof t || !t) return t;
9
310
  var e = t[Symbol.toPrimitive];
@@ -213,6 +514,16 @@ PERFORMANCE OF THIS SOFTWARE.
213
514
  /* global Reflect, Promise, SuppressedError, Symbol */
214
515
 
215
516
 
517
+ function __awaiter(thisArg, _arguments, P, generator) {
518
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
519
+ return new (P || (P = Promise))(function (resolve, reject) {
520
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
521
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
522
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
523
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
524
+ });
525
+ }
526
+
216
527
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
217
528
  var e = new Error(message);
218
529
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -4784,6 +5095,29 @@ var ParachainNode = /*#__PURE__*/function () {
4784
5095
  parameters: constructRelayToParaParameters(options, exports.Version.V3)
4785
5096
  };
4786
5097
  }
5098
+ }, {
5099
+ key: "getProvider",
5100
+ value: function getProvider() {
5101
+ return getAllNodeProviders(this.node)[0];
5102
+ }
5103
+ }, {
5104
+ key: "createApiInstance",
5105
+ value: function createApiInstance$1() {
5106
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
5107
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
5108
+ while (1) switch (_context.prev = _context.next) {
5109
+ case 0:
5110
+ _context.next = 2;
5111
+ return createApiInstance(this.getProvider());
5112
+ case 2:
5113
+ return _context.abrupt("return", _context.sent);
5114
+ case 3:
5115
+ case "end":
5116
+ return _context.stop();
5117
+ }
5118
+ }, _callee, this);
5119
+ }));
5120
+ }
4787
5121
  }]);
4788
5122
  return ParachainNode;
4789
5123
  }();
@@ -4835,6 +5169,12 @@ var Acala$1 = /*#__PURE__*/function (_ParachainNode) {
4835
5169
  };
4836
5170
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
4837
5171
  }
5172
+ }, {
5173
+ key: "getProvider",
5174
+ value: function getProvider() {
5175
+ // Return the second WebSocket URL because the first one is sometimes unreliable.
5176
+ return getAllNodeProviders(this.node)[1];
5177
+ }
4838
5178
  }]);
4839
5179
  return Acala;
4840
5180
  }(ParachainNode);
@@ -5322,6 +5662,30 @@ var Mangata$1 = /*#__PURE__*/function (_ParachainNode) {
5322
5662
  value: function transferXTokens(input) {
5323
5663
  return XTokensTransferImpl.transferXTokens(input, input.currencyID);
5324
5664
  }
5665
+ }, {
5666
+ key: "createApiInstance",
5667
+ value: function createApiInstance() {
5668
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
5669
+ var MangataSDK, instance;
5670
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
5671
+ while (1) switch (_context.prev = _context.next) {
5672
+ case 0:
5673
+ _context.next = 2;
5674
+ return import('@mangata-finance/sdk');
5675
+ case 2:
5676
+ MangataSDK = _context.sent;
5677
+ instance = MangataSDK.Mangata.instance([this.getProvider()]);
5678
+ _context.next = 6;
5679
+ return instance.api();
5680
+ case 6:
5681
+ return _context.abrupt("return", _context.sent);
5682
+ case 7:
5683
+ case "end":
5684
+ return _context.stop();
5685
+ }
5686
+ }, _callee, this);
5687
+ }));
5688
+ }
5325
5689
  }]);
5326
5690
  return Mangata;
5327
5691
  }(ParachainNode);
@@ -5534,6 +5898,12 @@ var Karura$1 = /*#__PURE__*/function (_ParachainNode) {
5534
5898
  };
5535
5899
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
5536
5900
  }
5901
+ }, {
5902
+ key: "getProvider",
5903
+ value: function getProvider() {
5904
+ // Return the second WebSocket URL because the first one is sometimes unreliable.
5905
+ return getAllNodeProviders(this.node)[1];
5906
+ }
5537
5907
  }]);
5538
5908
  return Karura;
5539
5909
  }(ParachainNode);
@@ -5944,6 +6314,7 @@ var Zeitgeist$1 = /*#__PURE__*/function (_ParachainNode) {
5944
6314
 
5945
6315
  // Contains supported Parachains and exports supported XCM Pallets
5946
6316
  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'];
6317
+ var NODES_WITH_RELAY_CHAINS = [].concat(NODE_NAMES, ['Polkadot', 'Kusama']);
5947
6318
  var nodes = {
5948
6319
  AssetHubPolkadot: new AssetHubPolkadot$1(),
5949
6320
  Acala: new Acala$1(),
@@ -6213,11 +6584,61 @@ var getAllNodeProviders = function getAllNodeProviders(node) {
6213
6584
  var _a;
6214
6585
  var _ref10 = (_a = getNodeEndpointOption(node)) !== null && _a !== void 0 ? _a : {},
6215
6586
  providers = _ref10.providers;
6587
+ if (providers.length < 1) {
6588
+ throw new Error("Node ".concat(node, " does not have any providers."));
6589
+ }
6216
6590
  return Object.values(providers !== null && providers !== void 0 ? providers : []);
6217
6591
  };
6218
6592
  var getNodeProvider = function getNodeProvider(node) {
6219
- var providers = getAllNodeProviders(node);
6220
- return providers.length > 0 ? providers[0] : null;
6593
+ return getNode(node).getProvider();
6594
+ };
6595
+ var createApiInstance = function createApiInstance(wsUrl) {
6596
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
6597
+ var wsProvider;
6598
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
6599
+ while (1) switch (_context.prev = _context.next) {
6600
+ case 0:
6601
+ wsProvider = new api.WsProvider(wsUrl);
6602
+ _context.next = 3;
6603
+ return api.ApiPromise.create({
6604
+ provider: wsProvider
6605
+ });
6606
+ case 3:
6607
+ return _context.abrupt("return", _context.sent);
6608
+ case 4:
6609
+ case "end":
6610
+ return _context.stop();
6611
+ }
6612
+ }, _callee);
6613
+ }));
6614
+ };
6615
+ var createApiInstanceForNode = function createApiInstanceForNode(node) {
6616
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
6617
+ var endpointOption, wsUrl;
6618
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
6619
+ while (1) switch (_context2.prev = _context2.next) {
6620
+ case 0:
6621
+ if (!(node === 'Polkadot' || node === 'Kusama')) {
6622
+ _context2.next = 6;
6623
+ break;
6624
+ }
6625
+ endpointOption = node === 'Polkadot' ? endpoints.prodRelayPolkadot : endpoints.prodRelayKusama;
6626
+ wsUrl = Object.values(endpointOption.providers)[0];
6627
+ _context2.next = 5;
6628
+ return createApiInstance(wsUrl);
6629
+ case 5:
6630
+ return _context2.abrupt("return", _context2.sent);
6631
+ case 6:
6632
+ _context2.next = 8;
6633
+ return getNode(node).createApiInstance();
6634
+ case 8:
6635
+ return _context2.abrupt("return", _context2.sent);
6636
+ case 9:
6637
+ case "end":
6638
+ return _context2.stop();
6639
+ }
6640
+ }, _callee2);
6641
+ }));
6221
6642
  };
6222
6643
  var lowercaseFirstLetter = function lowercaseFirstLetter(str) {
6223
6644
  return str.charAt(0).toLowerCase() + str.slice(1);
@@ -7351,6 +7772,7 @@ var getSupportedPallets = function getSupportedPallets(node) {
7351
7772
  exports.Builder = Builder;
7352
7773
  exports.IncompatibleNodesError = IncompatibleNodesError;
7353
7774
  exports.InvalidCurrencyError = InvalidCurrencyError;
7775
+ exports.NODES_WITH_RELAY_CHAINS = NODES_WITH_RELAY_CHAINS;
7354
7776
  exports.NODE_NAMES = NODE_NAMES;
7355
7777
  exports.NoXCMSupportImplementedError = NoXCMSupportImplementedError;
7356
7778
  exports.NodeNotSupportedError = NodeNotSupportedError;
@@ -7358,6 +7780,7 @@ exports.SUPPORTED_PALLETS = SUPPORTED_PALLETS;
7358
7780
  exports.ScenarioNotSupportedError = ScenarioNotSupportedError;
7359
7781
  exports.assets = index$4;
7360
7782
  exports.closeChannels = index;
7783
+ exports.createApiInstanceForNode = createApiInstanceForNode;
7361
7784
  exports.getAllAssetsSymbols = getAllAssetsSymbols;
7362
7785
  exports.getAllNodeProviders = getAllNodeProviders;
7363
7786
  exports.getAssetDecimals = getAssetDecimals;
package/dist/index.d.ts CHANGED
@@ -15,9 +15,12 @@ declare abstract class ParachainNode {
15
15
  get assetCheckEnabled(): boolean;
16
16
  transfer(api: ApiPromise, currencySymbol: string | undefined, currencyId: string | undefined, amount: string, to: string, destination?: TNode, serializedApiCallEnabled?: boolean): Extrinsic | TSerializedApiCall;
17
17
  transferRelayToPara(options: TTransferRelayToParaOptions): TSerializedApiCall;
18
+ getProvider(): string;
19
+ createApiInstance(): Promise<ApiPromise>;
18
20
  }
19
21
 
20
22
  declare const NODE_NAMES: readonly ["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"];
23
+ declare const NODES_WITH_RELAY_CHAINS: readonly ["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", "Polkadot", "Kusama"];
21
24
  declare const SUPPORTED_PALLETS: readonly ["XTokens", "OrmlXTokens", "PolkadotXcm", "RelayerXcm"];
22
25
 
23
26
  type UpdateFunction = (name: string, index: number) => string;
@@ -26,6 +29,7 @@ type ExtrinsicFunction<T> = (arg: T) => Extrinsic;
26
29
  type TRelayChainType = 'polkadot' | 'kusama';
27
30
  type TRelayChainSymbol = 'DOT' | 'KSM';
28
31
  type TNode = (typeof NODE_NAMES)[number];
32
+ type TNodeWithRelayChains = (typeof NODES_WITH_RELAY_CHAINS)[number];
29
33
  interface TAssetDetails {
30
34
  assetId: string;
31
35
  symbol?: string;
@@ -307,7 +311,8 @@ declare const getSupportedPallets: (node: TNode) => TPallet[];
307
311
  declare const getNode: (node: TNode) => ParachainNode;
308
312
  declare const getNodeEndpointOption: (node: TNode) => any;
309
313
  declare const getAllNodeProviders: (node: TNode) => string[];
310
- declare const getNodeProvider: (node: TNode) => string | null;
314
+ declare const getNodeProvider: (node: TNode) => string;
315
+ declare const createApiInstanceForNode: (node: TNodeWithRelayChains) => Promise<ApiPromise>;
311
316
 
312
317
  declare class InvalidCurrencyError extends Error {
313
318
  constructor(message: string);
@@ -329,4 +334,4 @@ declare class IncompatibleNodesError extends Error {
329
334
  constructor();
330
335
  }
331
336
 
332
- export { type Bool, Builder, type Extrinsic, type ExtrinsicFunction, type IPolkadotXCMTransfer, type IXTokensTransfer, IncompatibleNodesError, InvalidCurrencyError, NODE_NAMES, NoXCMSupportImplementedError, NodeNotSupportedError, type PolkadotXCMTransferInput, SUPPORTED_PALLETS, ScenarioNotSupportedError, type TAssetDetails, type TAssetJsonMap, type TNativeAssetDetails, type TNode, type TNodeAssets, type TPallet, type TPalletJsonMap, type TPalletMap, type TRelayChainSymbol, type TRelayChainType, type TScenario, type TSerializedApiCall, type TTransferRelayToParaOptions, type UpdateFunction, Version, type XTokensTransferInput, index as assets, index$1 as closeChannels, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssetsObject, getDefaultPallet, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedPallets, getTNode, hasSupportForAsset, index$2 as openChannels, index$4 as xcmPallet, index$3 as xyk };
337
+ export { type Bool, Builder, type Extrinsic, type ExtrinsicFunction, type IPolkadotXCMTransfer, type IXTokensTransfer, IncompatibleNodesError, InvalidCurrencyError, NODES_WITH_RELAY_CHAINS, NODE_NAMES, NoXCMSupportImplementedError, NodeNotSupportedError, type PolkadotXCMTransferInput, SUPPORTED_PALLETS, ScenarioNotSupportedError, type TAssetDetails, type TAssetJsonMap, type TNativeAssetDetails, type TNode, type TNodeAssets, type TNodeWithRelayChains, type TPallet, type TPalletJsonMap, type TPalletMap, type TRelayChainSymbol, type TRelayChainType, type TScenario, type TSerializedApiCall, type TTransferRelayToParaOptions, type UpdateFunction, Version, type XTokensTransferInput, index as assets, index$1 as closeChannels, createApiInstanceForNode, getAllAssetsSymbols, getAllNodeProviders, getAssetDecimals, getAssetId, getAssetsObject, getDefaultPallet, getNativeAssets, getNode, getNodeEndpointOption, getNodeProvider, getOtherAssets, getParaId, getRelayChainSymbol, getSupportedPallets, getTNode, hasSupportForAsset, index$2 as openChannels, index$4 as xcmPallet, index$3 as xyk };
package/dist/index.mjs CHANGED
@@ -1,7 +1,308 @@
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
+ 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
+ }
5
306
  function _toPrimitive(t, r) {
6
307
  if ("object" != typeof t || !t) return t;
7
308
  var e = t[Symbol.toPrimitive];
@@ -211,6 +512,16 @@ PERFORMANCE OF THIS SOFTWARE.
211
512
  /* global Reflect, Promise, SuppressedError, Symbol */
212
513
 
213
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
+
214
525
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
215
526
  var e = new Error(message);
216
527
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -4782,6 +5093,29 @@ var ParachainNode = /*#__PURE__*/function () {
4782
5093
  parameters: constructRelayToParaParameters(options, Version.V3)
4783
5094
  };
4784
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
+ }
4785
5119
  }]);
4786
5120
  return ParachainNode;
4787
5121
  }();
@@ -4833,6 +5167,12 @@ var Acala$1 = /*#__PURE__*/function (_ParachainNode) {
4833
5167
  };
4834
5168
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
4835
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
+ }
4836
5176
  }]);
4837
5177
  return Acala;
4838
5178
  }(ParachainNode);
@@ -5320,6 +5660,30 @@ var Mangata$1 = /*#__PURE__*/function (_ParachainNode) {
5320
5660
  value: function transferXTokens(input) {
5321
5661
  return XTokensTransferImpl.transferXTokens(input, input.currencyID);
5322
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
+ }
5323
5687
  }]);
5324
5688
  return Mangata;
5325
5689
  }(ParachainNode);
@@ -5532,6 +5896,12 @@ var Karura$1 = /*#__PURE__*/function (_ParachainNode) {
5532
5896
  };
5533
5897
  return XTokensTransferImpl.transferXTokens(input, currencySelection);
5534
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
+ }
5535
5905
  }]);
5536
5906
  return Karura;
5537
5907
  }(ParachainNode);
@@ -5942,6 +6312,7 @@ var Zeitgeist$1 = /*#__PURE__*/function (_ParachainNode) {
5942
6312
 
5943
6313
  // Contains supported Parachains and exports supported XCM Pallets
5944
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']);
5945
6316
  var nodes = {
5946
6317
  AssetHubPolkadot: new AssetHubPolkadot$1(),
5947
6318
  Acala: new Acala$1(),
@@ -6211,11 +6582,61 @@ var getAllNodeProviders = function getAllNodeProviders(node) {
6211
6582
  var _a;
6212
6583
  var _ref10 = (_a = getNodeEndpointOption(node)) !== null && _a !== void 0 ? _a : {},
6213
6584
  providers = _ref10.providers;
6585
+ if (providers.length < 1) {
6586
+ throw new Error("Node ".concat(node, " does not have any providers."));
6587
+ }
6214
6588
  return Object.values(providers !== null && providers !== void 0 ? providers : []);
6215
6589
  };
6216
6590
  var getNodeProvider = function getNodeProvider(node) {
6217
- var providers = getAllNodeProviders(node);
6218
- 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
+ }));
6219
6640
  };
6220
6641
  var lowercaseFirstLetter = function lowercaseFirstLetter(str) {
6221
6642
  return str.charAt(0).toLowerCase() + str.slice(1);
@@ -7346,4 +7767,4 @@ var getSupportedPallets = function getSupportedPallets(node) {
7346
7767
  return palletsMap[node].supportedPallets;
7347
7768
  };
7348
7769
 
7349
- 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk",
3
- "version": "3.0.6",
3
+ "version": "3.0.7",
4
4
  "description": "SDK for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": "@paraspell/sdk",
6
6
  "license": "MIT",
@@ -20,6 +20,7 @@
20
20
  "dist"
21
21
  ],
22
22
  "dependencies": {
23
+ "@mangata-finance/sdk": "^2.1.1",
23
24
  "ethers": "^5.7.1"
24
25
  },
25
26
  "peerDependencies": {