@paraspell/sdk-pjs 10.2.0 → 10.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +457 -665
- package/dist/index.d.ts +37 -8
- package/dist/index.mjs +457 -665
- package/package.json +13 -13
package/dist/index.cjs
CHANGED
|
@@ -120,274 +120,115 @@ function _objectSpread2(e) {
|
|
|
120
120
|
}
|
|
121
121
|
return e;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
function h(r, e, n, o) {
|
|
151
|
-
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
152
|
-
a = Object.create(i.prototype);
|
|
153
|
-
return c(a, "_invoke", function (r, e, n) {
|
|
154
|
-
var o = 1;
|
|
155
|
-
return function (i, a) {
|
|
156
|
-
if (3 === o) throw Error("Generator is already running");
|
|
157
|
-
if (4 === o) {
|
|
158
|
-
if ("throw" === i) throw a;
|
|
159
|
-
return {
|
|
160
|
-
value: t,
|
|
161
|
-
done: true
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
for (n.method = i, n.arg = a;;) {
|
|
165
|
-
var u = n.delegate;
|
|
166
|
-
if (u) {
|
|
167
|
-
var c = d(u, n);
|
|
168
|
-
if (c) {
|
|
169
|
-
if (c === f) continue;
|
|
170
|
-
return c;
|
|
171
|
-
}
|
|
123
|
+
function _regenerator() {
|
|
124
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
125
|
+
var e,
|
|
126
|
+
t,
|
|
127
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
128
|
+
n = r.iterator || "@@iterator",
|
|
129
|
+
o = r.toStringTag || "@@toStringTag";
|
|
130
|
+
function i(r, n, o, i) {
|
|
131
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
132
|
+
u = Object.create(c.prototype);
|
|
133
|
+
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
134
|
+
var i,
|
|
135
|
+
c,
|
|
136
|
+
u,
|
|
137
|
+
f = 0,
|
|
138
|
+
p = o || [],
|
|
139
|
+
y = false,
|
|
140
|
+
G = {
|
|
141
|
+
p: 0,
|
|
142
|
+
n: 0,
|
|
143
|
+
v: e,
|
|
144
|
+
a: d,
|
|
145
|
+
f: d.bind(e, 4),
|
|
146
|
+
d: function (t, r) {
|
|
147
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
172
148
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
149
|
+
};
|
|
150
|
+
function d(r, n) {
|
|
151
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
152
|
+
var o,
|
|
153
|
+
i = p[t],
|
|
154
|
+
d = G.p,
|
|
155
|
+
l = i[2];
|
|
156
|
+
r > 3 ? (o = l === n) && (c = i[4] || 3, u = i[5] === e ? i[3] : i[5], i[4] = 3, i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
157
|
+
}
|
|
158
|
+
if (o || r > 1) return a;
|
|
159
|
+
throw y = true, n;
|
|
160
|
+
}
|
|
161
|
+
return function (o, p, l) {
|
|
162
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
163
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
164
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
165
|
+
try {
|
|
166
|
+
if (f = 2, i) {
|
|
167
|
+
if (c || (o = "next"), t = i[o]) {
|
|
168
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
169
|
+
if (!t.done) return t;
|
|
170
|
+
u = t.value, c < 2 && (c = 0);
|
|
171
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
172
|
+
i = e;
|
|
173
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
174
|
+
} catch (t) {
|
|
175
|
+
i = e, c = 1, u = t;
|
|
176
|
+
} finally {
|
|
177
|
+
f = 1;
|
|
185
178
|
}
|
|
186
|
-
"throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg);
|
|
187
179
|
}
|
|
180
|
+
return {
|
|
181
|
+
value: t,
|
|
182
|
+
done: y
|
|
183
|
+
};
|
|
188
184
|
};
|
|
189
|
-
}(r,
|
|
190
|
-
}
|
|
191
|
-
function s(t, r, e) {
|
|
192
|
-
try {
|
|
193
|
-
return {
|
|
194
|
-
type: "normal",
|
|
195
|
-
arg: t.call(r, e)
|
|
196
|
-
};
|
|
197
|
-
} catch (t) {
|
|
198
|
-
return {
|
|
199
|
-
type: "throw",
|
|
200
|
-
arg: t
|
|
201
|
-
};
|
|
202
|
-
}
|
|
185
|
+
}(r, o, i), true), u;
|
|
203
186
|
}
|
|
204
|
-
|
|
205
|
-
var f = {};
|
|
187
|
+
var a = {};
|
|
206
188
|
function Generator() {}
|
|
207
189
|
function GeneratorFunction() {}
|
|
208
190
|
function GeneratorFunctionPrototype() {}
|
|
209
|
-
|
|
210
|
-
c(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l);
|
|
217
|
-
function g(t) {
|
|
218
|
-
["next", "throw", "return"].forEach(function (r) {
|
|
219
|
-
c(t, r, function (t) {
|
|
220
|
-
return this._invoke(r, t);
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
function AsyncIterator(t, r) {
|
|
225
|
-
function e(o, i, a, u) {
|
|
226
|
-
var c = s(t[o], t, i);
|
|
227
|
-
if ("throw" !== c.type) {
|
|
228
|
-
var h = c.arg,
|
|
229
|
-
f = h.value;
|
|
230
|
-
return f && "object" == typeof f && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) {
|
|
231
|
-
e("next", t, a, u);
|
|
232
|
-
}, function (t) {
|
|
233
|
-
e("throw", t, a, u);
|
|
234
|
-
}) : r.resolve(f).then(function (t) {
|
|
235
|
-
h.value = t, a(h);
|
|
236
|
-
}, function (t) {
|
|
237
|
-
return e("throw", t, a, u);
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
u(c.arg);
|
|
241
|
-
}
|
|
242
|
-
var o;
|
|
243
|
-
c(this, "_invoke", function (t, n) {
|
|
244
|
-
function i() {
|
|
245
|
-
return new r(function (r, o) {
|
|
246
|
-
e(t, n, r, o);
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
return o = o ? o.then(i, i) : i();
|
|
250
|
-
}, true);
|
|
251
|
-
}
|
|
252
|
-
function d(r, e) {
|
|
253
|
-
var n = e.method,
|
|
254
|
-
o = r.i[n];
|
|
255
|
-
if (o === t) return e.delegate = null, "throw" === n && r.i.return && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f;
|
|
256
|
-
var i = s(o, r.i, e.arg);
|
|
257
|
-
if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f;
|
|
258
|
-
var a = i.arg;
|
|
259
|
-
return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f);
|
|
260
|
-
}
|
|
261
|
-
function w(t) {
|
|
262
|
-
this.tryEntries.push(t);
|
|
263
|
-
}
|
|
264
|
-
function m(r) {
|
|
265
|
-
var e = r[4] || {};
|
|
266
|
-
e.type = "normal", e.arg = t, r[4] = e;
|
|
267
|
-
}
|
|
268
|
-
function Context(t) {
|
|
269
|
-
this.tryEntries = [[-1]], t.forEach(w, this), this.reset(true);
|
|
270
|
-
}
|
|
271
|
-
function x(r) {
|
|
272
|
-
if (null != r) {
|
|
273
|
-
var e = r[i];
|
|
274
|
-
if (e) return e.call(r);
|
|
275
|
-
if ("function" == typeof r.next) return r;
|
|
276
|
-
if (!isNaN(r.length)) {
|
|
277
|
-
var o = -1,
|
|
278
|
-
a = function e() {
|
|
279
|
-
for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = false, e;
|
|
280
|
-
return e.value = t, e.done = true, e;
|
|
281
|
-
};
|
|
282
|
-
return a.next = a;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
throw new TypeError(typeof r + " is not iterable");
|
|
191
|
+
t = Object.getPrototypeOf;
|
|
192
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
193
|
+
return this;
|
|
194
|
+
}), t),
|
|
195
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
196
|
+
function f(e) {
|
|
197
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
286
198
|
}
|
|
287
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype,
|
|
288
|
-
var r = "function" == typeof t && t.constructor;
|
|
289
|
-
return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name));
|
|
290
|
-
}, r.mark = function (t) {
|
|
291
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t;
|
|
292
|
-
}, r.awrap = function (t) {
|
|
293
|
-
return {
|
|
294
|
-
__await: t
|
|
295
|
-
};
|
|
296
|
-
}, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () {
|
|
199
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|
297
200
|
return this;
|
|
298
|
-
}),
|
|
299
|
-
void 0 === i && (i = Promise);
|
|
300
|
-
var a = new AsyncIterator(h(t, e, n, o), i);
|
|
301
|
-
return r.isGeneratorFunction(e) ? a : a.next().then(function (t) {
|
|
302
|
-
return t.done ? t.value : a.next();
|
|
303
|
-
});
|
|
304
|
-
}, g(v), c(v, u, "Generator"), c(v, i, function () {
|
|
305
|
-
return this;
|
|
306
|
-
}), c(v, "toString", function () {
|
|
201
|
+
}), _regeneratorDefine(u, "toString", function () {
|
|
307
202
|
return "[object Generator]";
|
|
308
|
-
}),
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
return function t() {
|
|
313
|
-
for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = false, t;
|
|
314
|
-
return t.done = true, t;
|
|
203
|
+
}), (_regenerator = function () {
|
|
204
|
+
return {
|
|
205
|
+
w: i,
|
|
206
|
+
m: f
|
|
315
207
|
};
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
u = this.prev,
|
|
337
|
-
c = i[1],
|
|
338
|
-
h = i[2];
|
|
339
|
-
if (-1 === i[0]) return n("end"), false;
|
|
340
|
-
if (!c && !h) throw Error("try statement without catch or finally");
|
|
341
|
-
if (null != i[0] && i[0] <= u) {
|
|
342
|
-
if (u < c) return this.method = "next", this.arg = t, n(c), true;
|
|
343
|
-
if (u < h) return n(h), false;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
},
|
|
347
|
-
abrupt: function (t, r) {
|
|
348
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
349
|
-
var n = this.tryEntries[e];
|
|
350
|
-
if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) {
|
|
351
|
-
var o = n;
|
|
352
|
-
break;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null);
|
|
356
|
-
var i = o ? o[4] : {};
|
|
357
|
-
return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i);
|
|
358
|
-
},
|
|
359
|
-
complete: function (t, r) {
|
|
360
|
-
if ("throw" === t.type) throw t.arg;
|
|
361
|
-
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 && r && (this.next = r), f;
|
|
362
|
-
},
|
|
363
|
-
finish: function (t) {
|
|
364
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
365
|
-
var e = this.tryEntries[r];
|
|
366
|
-
if (e[2] === t) return this.complete(e[4], e[3]), m(e), f;
|
|
367
|
-
}
|
|
368
|
-
},
|
|
369
|
-
catch: function (t) {
|
|
370
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
371
|
-
var e = this.tryEntries[r];
|
|
372
|
-
if (e[0] === t) {
|
|
373
|
-
var n = e[4];
|
|
374
|
-
if ("throw" === n.type) {
|
|
375
|
-
var o = n.arg;
|
|
376
|
-
m(e);
|
|
377
|
-
}
|
|
378
|
-
return o;
|
|
379
|
-
}
|
|
208
|
+
})();
|
|
209
|
+
}
|
|
210
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
211
|
+
var i = Object.defineProperty;
|
|
212
|
+
try {
|
|
213
|
+
i({}, "", {});
|
|
214
|
+
} catch (e) {
|
|
215
|
+
i = 0;
|
|
216
|
+
}
|
|
217
|
+
_regeneratorDefine = function (e, r, n, t) {
|
|
218
|
+
if (r) i ? i(e, r, {
|
|
219
|
+
value: n,
|
|
220
|
+
enumerable: !t,
|
|
221
|
+
configurable: !t,
|
|
222
|
+
writable: !t
|
|
223
|
+
}) : e[r] = n;else {
|
|
224
|
+
function o(r, n) {
|
|
225
|
+
_regeneratorDefine(e, r, function (e) {
|
|
226
|
+
return this._invoke(r, n, e);
|
|
227
|
+
});
|
|
380
228
|
}
|
|
381
|
-
|
|
382
|
-
},
|
|
383
|
-
delegateYield: function (r, e, n) {
|
|
384
|
-
return this.delegate = {
|
|
385
|
-
i: x(r),
|
|
386
|
-
r: e,
|
|
387
|
-
n: n
|
|
388
|
-
}, "next" === this.method && (this.arg = t), f;
|
|
229
|
+
o("next", 0), o("throw", 1), o("return", 2);
|
|
389
230
|
}
|
|
390
|
-
}, r;
|
|
231
|
+
}, _regeneratorDefine(e, r, n, t);
|
|
391
232
|
}
|
|
392
233
|
function _slicedToArray(r, e) {
|
|
393
234
|
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
@@ -409,6 +250,15 @@ function _toPropertyKey(t) {
|
|
|
409
250
|
var i = _toPrimitive(t, "string");
|
|
410
251
|
return "symbol" == typeof i ? i : i + "";
|
|
411
252
|
}
|
|
253
|
+
function _typeof(o) {
|
|
254
|
+
"@babel/helpers - typeof";
|
|
255
|
+
|
|
256
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
257
|
+
return typeof o;
|
|
258
|
+
} : function (o) {
|
|
259
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
260
|
+
}, _typeof(o);
|
|
261
|
+
}
|
|
412
262
|
function _unsupportedIterableToArray(r, a) {
|
|
413
263
|
if (r) {
|
|
414
264
|
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
@@ -449,47 +299,46 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
449
299
|
}, {
|
|
450
300
|
key: "init",
|
|
451
301
|
value: function () {
|
|
452
|
-
var _init = _asyncToGenerator(/*#__PURE__*/
|
|
453
|
-
var _this$_api;
|
|
454
|
-
return
|
|
455
|
-
while (1) switch (_context.
|
|
302
|
+
var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(node, _clientTtlMs) {
|
|
303
|
+
var _this$_api, _t;
|
|
304
|
+
return _regenerator().w(function (_context) {
|
|
305
|
+
while (1) switch (_context.n) {
|
|
456
306
|
case 0:
|
|
457
307
|
if (!this.initialized) {
|
|
458
|
-
_context.
|
|
308
|
+
_context.n = 1;
|
|
459
309
|
break;
|
|
460
310
|
}
|
|
461
|
-
return _context.
|
|
462
|
-
case
|
|
311
|
+
return _context.a(2);
|
|
312
|
+
case 1:
|
|
463
313
|
if (!(typeof this._api === 'string' || this._api instanceof Array)) {
|
|
464
|
-
_context.
|
|
314
|
+
_context.n = 3;
|
|
465
315
|
break;
|
|
466
316
|
}
|
|
467
|
-
_context.
|
|
317
|
+
_context.n = 2;
|
|
468
318
|
return this.createApiInstance(this._api);
|
|
469
|
-
case
|
|
470
|
-
this.api = _context.
|
|
471
|
-
_context.
|
|
319
|
+
case 2:
|
|
320
|
+
this.api = _context.v;
|
|
321
|
+
_context.n = 7;
|
|
472
322
|
break;
|
|
473
|
-
case
|
|
323
|
+
case 3:
|
|
474
324
|
if (!((_this$_api = this._api) !== null && _this$_api !== void 0)) {
|
|
475
|
-
_context.
|
|
325
|
+
_context.n = 4;
|
|
476
326
|
break;
|
|
477
327
|
}
|
|
478
|
-
|
|
479
|
-
_context.
|
|
328
|
+
_t = _this$_api;
|
|
329
|
+
_context.n = 6;
|
|
480
330
|
break;
|
|
481
|
-
case
|
|
482
|
-
_context.
|
|
331
|
+
case 4:
|
|
332
|
+
_context.n = 5;
|
|
483
333
|
return sdkCore.createApiInstanceForNode(this, node);
|
|
484
|
-
case
|
|
485
|
-
|
|
486
|
-
case
|
|
487
|
-
this.api =
|
|
488
|
-
case
|
|
334
|
+
case 5:
|
|
335
|
+
_t = _context.v;
|
|
336
|
+
case 6:
|
|
337
|
+
this.api = _t;
|
|
338
|
+
case 7:
|
|
489
339
|
this.initialized = true;
|
|
490
|
-
case
|
|
491
|
-
|
|
492
|
-
return _context.stop();
|
|
340
|
+
case 8:
|
|
341
|
+
return _context.a(2);
|
|
493
342
|
}
|
|
494
343
|
}, _callee, this);
|
|
495
344
|
}));
|
|
@@ -501,18 +350,15 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
501
350
|
}, {
|
|
502
351
|
key: "createApiInstance",
|
|
503
352
|
value: function () {
|
|
504
|
-
var _createApiInstance = _asyncToGenerator(/*#__PURE__*/
|
|
353
|
+
var _createApiInstance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(wsUrl) {
|
|
505
354
|
var wsProvider;
|
|
506
|
-
return
|
|
507
|
-
while (1) switch (_context2.
|
|
355
|
+
return _regenerator().w(function (_context2) {
|
|
356
|
+
while (1) switch (_context2.n) {
|
|
508
357
|
case 0:
|
|
509
358
|
wsProvider = new api.WsProvider(wsUrl);
|
|
510
|
-
return _context2.
|
|
359
|
+
return _context2.a(2, api.ApiPromise.create({
|
|
511
360
|
provider: wsProvider
|
|
512
361
|
}));
|
|
513
|
-
case 2:
|
|
514
|
-
case "end":
|
|
515
|
-
return _context2.stop();
|
|
516
362
|
}
|
|
517
363
|
}, _callee2);
|
|
518
364
|
}));
|
|
@@ -570,20 +416,17 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
570
416
|
}, {
|
|
571
417
|
key: "calculateTransactionFee",
|
|
572
418
|
value: function () {
|
|
573
|
-
var _calculateTransactionFee = _asyncToGenerator(/*#__PURE__*/
|
|
419
|
+
var _calculateTransactionFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(tx, address) {
|
|
574
420
|
var _yield$tx$paymentInfo, partialFee;
|
|
575
|
-
return
|
|
576
|
-
while (1) switch (_context3.
|
|
421
|
+
return _regenerator().w(function (_context3) {
|
|
422
|
+
while (1) switch (_context3.n) {
|
|
577
423
|
case 0:
|
|
578
|
-
_context3.
|
|
424
|
+
_context3.n = 1;
|
|
579
425
|
return tx.paymentInfo(address);
|
|
580
|
-
case
|
|
581
|
-
_yield$tx$paymentInfo = _context3.
|
|
426
|
+
case 1:
|
|
427
|
+
_yield$tx$paymentInfo = _context3.v;
|
|
582
428
|
partialFee = _yield$tx$paymentInfo.partialFee;
|
|
583
|
-
return _context3.
|
|
584
|
-
case 5:
|
|
585
|
-
case "end":
|
|
586
|
-
return _context3.stop();
|
|
429
|
+
return _context3.a(2, partialFee.toBigInt());
|
|
587
430
|
}
|
|
588
431
|
}, _callee3);
|
|
589
432
|
}));
|
|
@@ -595,22 +438,19 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
595
438
|
}, {
|
|
596
439
|
key: "quoteAhPrice",
|
|
597
440
|
value: function () {
|
|
598
|
-
var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/
|
|
441
|
+
var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(fromMl, toMl, amountIn) {
|
|
599
442
|
var includeFee,
|
|
600
443
|
quoted,
|
|
601
444
|
_args4 = arguments;
|
|
602
|
-
return
|
|
603
|
-
while (1) switch (_context4.
|
|
445
|
+
return _regenerator().w(function (_context4) {
|
|
446
|
+
while (1) switch (_context4.n) {
|
|
604
447
|
case 0:
|
|
605
448
|
includeFee = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : true;
|
|
606
|
-
_context4.
|
|
449
|
+
_context4.n = 1;
|
|
607
450
|
return this.api.call.assetConversionApi.quotePriceExactTokensForTokens(fromMl, toMl, amountIn.toString(), includeFee);
|
|
608
|
-
case
|
|
609
|
-
quoted = _context4.
|
|
610
|
-
return _context4.
|
|
611
|
-
case 5:
|
|
612
|
-
case "end":
|
|
613
|
-
return _context4.stop();
|
|
451
|
+
case 1:
|
|
452
|
+
quoted = _context4.v;
|
|
453
|
+
return _context4.a(2, quoted.toJSON() !== null ? BigInt(quoted.toString()) : undefined);
|
|
614
454
|
}
|
|
615
455
|
}, _callee4, this);
|
|
616
456
|
}));
|
|
@@ -622,19 +462,16 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
622
462
|
}, {
|
|
623
463
|
key: "getBalanceNative",
|
|
624
464
|
value: function () {
|
|
625
|
-
var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/
|
|
465
|
+
var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(address) {
|
|
626
466
|
var response;
|
|
627
|
-
return
|
|
628
|
-
while (1) switch (_context5.
|
|
467
|
+
return _regenerator().w(function (_context5) {
|
|
468
|
+
while (1) switch (_context5.n) {
|
|
629
469
|
case 0:
|
|
630
|
-
_context5.
|
|
470
|
+
_context5.n = 1;
|
|
631
471
|
return this.api.query.system.account(address);
|
|
632
|
-
case
|
|
633
|
-
response = _context5.
|
|
634
|
-
return _context5.
|
|
635
|
-
case 4:
|
|
636
|
-
case "end":
|
|
637
|
-
return _context5.stop();
|
|
472
|
+
case 1:
|
|
473
|
+
response = _context5.v;
|
|
474
|
+
return _context5.a(2, response.data.free.toBigInt());
|
|
638
475
|
}
|
|
639
476
|
}, _callee5, this);
|
|
640
477
|
}));
|
|
@@ -646,21 +483,18 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
646
483
|
}, {
|
|
647
484
|
key: "getBalanceForeignPolkadotXcm",
|
|
648
485
|
value: function () {
|
|
649
|
-
var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/
|
|
486
|
+
var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(address, id) {
|
|
650
487
|
var parsedId, response, obj;
|
|
651
|
-
return
|
|
652
|
-
while (1) switch (_context6.
|
|
488
|
+
return _regenerator().w(function (_context6) {
|
|
489
|
+
while (1) switch (_context6.n) {
|
|
653
490
|
case 0:
|
|
654
491
|
parsedId = new types.u32(this.api.registry, id);
|
|
655
|
-
_context6.
|
|
492
|
+
_context6.n = 1;
|
|
656
493
|
return this.api.query.assets.account(parsedId, address);
|
|
657
|
-
case
|
|
658
|
-
response = _context6.
|
|
494
|
+
case 1:
|
|
495
|
+
response = _context6.v;
|
|
659
496
|
obj = response.toJSON();
|
|
660
|
-
return _context6.
|
|
661
|
-
case 6:
|
|
662
|
-
case "end":
|
|
663
|
-
return _context6.stop();
|
|
497
|
+
return _context6.a(2, obj.balance ? BigInt(obj.balance) : 0n);
|
|
664
498
|
}
|
|
665
499
|
}, _callee6, this);
|
|
666
500
|
}));
|
|
@@ -672,20 +506,17 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
672
506
|
}, {
|
|
673
507
|
key: "getMythosForeignBalance",
|
|
674
508
|
value: function () {
|
|
675
|
-
var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/
|
|
509
|
+
var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(address) {
|
|
676
510
|
var response, obj;
|
|
677
|
-
return
|
|
678
|
-
while (1) switch (_context7.
|
|
511
|
+
return _regenerator().w(function (_context7) {
|
|
512
|
+
while (1) switch (_context7.n) {
|
|
679
513
|
case 0:
|
|
680
|
-
_context7.
|
|
514
|
+
_context7.n = 1;
|
|
681
515
|
return this.api.query.balances.account(address);
|
|
682
|
-
case
|
|
683
|
-
response = _context7.
|
|
516
|
+
case 1:
|
|
517
|
+
response = _context7.v;
|
|
684
518
|
obj = response.toJSON();
|
|
685
|
-
return _context7.
|
|
686
|
-
case 5:
|
|
687
|
-
case "end":
|
|
688
|
-
return _context7.stop();
|
|
519
|
+
return _context7.a(2, obj.free ? BigInt(obj.free) : 0n);
|
|
689
520
|
}
|
|
690
521
|
}, _callee7, this);
|
|
691
522
|
}));
|
|
@@ -697,20 +528,17 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
697
528
|
}, {
|
|
698
529
|
key: "getBalanceForeignAssetsPallet",
|
|
699
530
|
value: function () {
|
|
700
|
-
var _getBalanceForeignAssetsPallet = _asyncToGenerator(/*#__PURE__*/
|
|
531
|
+
var _getBalanceForeignAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(address, multiLocation) {
|
|
701
532
|
var response, obj;
|
|
702
|
-
return
|
|
703
|
-
while (1) switch (_context8.
|
|
533
|
+
return _regenerator().w(function (_context8) {
|
|
534
|
+
while (1) switch (_context8.n) {
|
|
704
535
|
case 0:
|
|
705
|
-
_context8.
|
|
536
|
+
_context8.n = 1;
|
|
706
537
|
return this.api.query.foreignAssets.account(multiLocation, address);
|
|
707
|
-
case
|
|
708
|
-
response = _context8.
|
|
538
|
+
case 1:
|
|
539
|
+
response = _context8.v;
|
|
709
540
|
obj = response.toJSON();
|
|
710
|
-
return _context8.
|
|
711
|
-
case 5:
|
|
712
|
-
case "end":
|
|
713
|
-
return _context8.stop();
|
|
541
|
+
return _context8.a(2, BigInt(obj === null || !obj.balance ? 0 : obj.balance));
|
|
714
542
|
}
|
|
715
543
|
}, _callee8, this);
|
|
716
544
|
}));
|
|
@@ -722,20 +550,17 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
722
550
|
}, {
|
|
723
551
|
key: "getForeignAssetsByIdBalance",
|
|
724
552
|
value: function () {
|
|
725
|
-
var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/
|
|
553
|
+
var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(address, assetId) {
|
|
726
554
|
var response, obj;
|
|
727
|
-
return
|
|
728
|
-
while (1) switch (_context9.
|
|
555
|
+
return _regenerator().w(function (_context9) {
|
|
556
|
+
while (1) switch (_context9.n) {
|
|
729
557
|
case 0:
|
|
730
|
-
_context9.
|
|
558
|
+
_context9.n = 1;
|
|
731
559
|
return this.api.query.foreignAssets.account(assetId, address);
|
|
732
|
-
case
|
|
733
|
-
response = _context9.
|
|
560
|
+
case 1:
|
|
561
|
+
response = _context9.v;
|
|
734
562
|
obj = response.toJSON();
|
|
735
|
-
return _context9.
|
|
736
|
-
case 5:
|
|
737
|
-
case "end":
|
|
738
|
-
return _context9.stop();
|
|
563
|
+
return _context9.a(2, BigInt(obj === null || !obj.balance ? 0 : obj.balance));
|
|
739
564
|
}
|
|
740
565
|
}, _callee9, this);
|
|
741
566
|
}));
|
|
@@ -747,21 +572,18 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
747
572
|
}, {
|
|
748
573
|
key: "getBalanceForeignBifrost",
|
|
749
574
|
value: function () {
|
|
750
|
-
var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/
|
|
575
|
+
var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(address, asset) {
|
|
751
576
|
var currencySelection, response, accountData;
|
|
752
|
-
return
|
|
753
|
-
while (1) switch (_context0.
|
|
577
|
+
return _regenerator().w(function (_context0) {
|
|
578
|
+
while (1) switch (_context0.n) {
|
|
754
579
|
case 0:
|
|
755
580
|
currencySelection = sdkCore.getNode('BifrostPolkadot').getCurrencySelection(asset);
|
|
756
|
-
_context0.
|
|
581
|
+
_context0.n = 1;
|
|
757
582
|
return this.api.query.tokens.accounts(address, currencySelection);
|
|
758
|
-
case
|
|
759
|
-
response = _context0.
|
|
583
|
+
case 1:
|
|
584
|
+
response = _context0.v;
|
|
760
585
|
accountData = response ? response : null;
|
|
761
|
-
return _context0.
|
|
762
|
-
case 6:
|
|
763
|
-
case "end":
|
|
764
|
-
return _context0.stop();
|
|
586
|
+
return _context0.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
765
587
|
}
|
|
766
588
|
}, _callee0, this);
|
|
767
589
|
}));
|
|
@@ -773,22 +595,19 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
773
595
|
}, {
|
|
774
596
|
key: "getBalanceNativeAcala",
|
|
775
597
|
value: function () {
|
|
776
|
-
var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/
|
|
598
|
+
var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(address, symbol) {
|
|
777
599
|
var response, accountData;
|
|
778
|
-
return
|
|
779
|
-
while (1) switch (_context1.
|
|
600
|
+
return _regenerator().w(function (_context1) {
|
|
601
|
+
while (1) switch (_context1.n) {
|
|
780
602
|
case 0:
|
|
781
|
-
_context1.
|
|
603
|
+
_context1.n = 1;
|
|
782
604
|
return this.api.query.tokens.accounts(address, {
|
|
783
605
|
Token: symbol
|
|
784
606
|
});
|
|
785
|
-
case
|
|
786
|
-
response = _context1.
|
|
607
|
+
case 1:
|
|
608
|
+
response = _context1.v;
|
|
787
609
|
accountData = response ? response : null;
|
|
788
|
-
return _context1.
|
|
789
|
-
case 5:
|
|
790
|
-
case "end":
|
|
791
|
-
return _context1.stop();
|
|
610
|
+
return _context1.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
792
611
|
}
|
|
793
612
|
}, _callee1, this);
|
|
794
613
|
}));
|
|
@@ -800,19 +619,19 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
800
619
|
}, {
|
|
801
620
|
key: "getBalanceForeignXTokens",
|
|
802
621
|
value: function () {
|
|
803
|
-
var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/
|
|
622
|
+
var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(node, address, asset) {
|
|
804
623
|
var pallet, response, entry, accountData;
|
|
805
|
-
return
|
|
806
|
-
while (1) switch (_context10.
|
|
624
|
+
return _regenerator().w(function (_context10) {
|
|
625
|
+
while (1) switch (_context10.n) {
|
|
807
626
|
case 0:
|
|
808
627
|
pallet = 'tokens';
|
|
809
628
|
if (node === 'Centrifuge' || node === 'Altair') {
|
|
810
629
|
pallet = 'ormlTokens';
|
|
811
630
|
}
|
|
812
|
-
_context10.
|
|
631
|
+
_context10.n = 1;
|
|
813
632
|
return this.api.query[pallet].accounts.entries(address);
|
|
814
|
-
case
|
|
815
|
-
response = _context10.
|
|
633
|
+
case 1:
|
|
634
|
+
response = _context10.v;
|
|
816
635
|
entry = response.find(function (_ref2) {
|
|
817
636
|
var _asset$symbol, _asset$assetId, _assetItem$toHuman, _asset$symbol2, _assetItem$toHuman2, _asset$assetId2;
|
|
818
637
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
@@ -824,10 +643,7 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
824
643
|
return assetSymbol === ((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toLowerCase()) || sdkCore.isForeignAsset(asset) && assetSymbol === ((_asset$assetId = asset.assetId) === null || _asset$assetId === void 0 ? void 0 : _asset$assetId.toLowerCase()) || Object.values((_assetItem$toHuman = assetItem.toHuman()) !== null && _assetItem$toHuman !== void 0 ? _assetItem$toHuman : {}).toString().toLowerCase() === ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === void 0 ? void 0 : _asset$symbol2.toLowerCase()) || sdkCore.isForeignAsset(asset) && Object.values((_assetItem$toHuman2 = assetItem.toHuman()) !== null && _assetItem$toHuman2 !== void 0 ? _assetItem$toHuman2 : {}).toString().toLowerCase() === ((_asset$assetId2 = asset.assetId) === null || _asset$assetId2 === void 0 ? void 0 : _asset$assetId2.toLowerCase());
|
|
825
644
|
});
|
|
826
645
|
accountData = entry ? entry[1] : null;
|
|
827
|
-
return _context10.
|
|
828
|
-
case 8:
|
|
829
|
-
case "end":
|
|
830
|
-
return _context10.stop();
|
|
646
|
+
return _context10.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
|
|
831
647
|
}
|
|
832
648
|
}, _callee10, this);
|
|
833
649
|
}));
|
|
@@ -839,20 +655,17 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
839
655
|
}, {
|
|
840
656
|
key: "getBalanceAssetsPallet",
|
|
841
657
|
value: function () {
|
|
842
|
-
var _getBalanceAssetsPallet = _asyncToGenerator(/*#__PURE__*/
|
|
658
|
+
var _getBalanceAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(address, assetId) {
|
|
843
659
|
var response, obj;
|
|
844
|
-
return
|
|
845
|
-
while (1) switch (_context11.
|
|
660
|
+
return _regenerator().w(function (_context11) {
|
|
661
|
+
while (1) switch (_context11.n) {
|
|
846
662
|
case 0:
|
|
847
|
-
_context11.
|
|
663
|
+
_context11.n = 1;
|
|
848
664
|
return this.api.query.assets.account(assetId, address);
|
|
849
|
-
case
|
|
850
|
-
response = _context11.
|
|
665
|
+
case 1:
|
|
666
|
+
response = _context11.v;
|
|
851
667
|
obj = response.toJSON();
|
|
852
|
-
return _context11.
|
|
853
|
-
case 5:
|
|
854
|
-
case "end":
|
|
855
|
-
return _context11.stop();
|
|
668
|
+
return _context11.a(2, BigInt(obj === null || !obj.balance ? 0 : obj.balance));
|
|
856
669
|
}
|
|
857
670
|
}, _callee11, this);
|
|
858
671
|
}));
|
|
@@ -869,26 +682,23 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
869
682
|
}, {
|
|
870
683
|
key: "getFromRpc",
|
|
871
684
|
value: function () {
|
|
872
|
-
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/
|
|
685
|
+
var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(module, method, key) {
|
|
873
686
|
var rpcModule, response;
|
|
874
|
-
return
|
|
875
|
-
while (1) switch (_context12.
|
|
687
|
+
return _regenerator().w(function (_context12) {
|
|
688
|
+
while (1) switch (_context12.n) {
|
|
876
689
|
case 0:
|
|
877
690
|
rpcModule = this.api.rpc[module];
|
|
878
691
|
if (!(!rpcModule || !rpcModule[method])) {
|
|
879
|
-
_context12.
|
|
692
|
+
_context12.n = 1;
|
|
880
693
|
break;
|
|
881
694
|
}
|
|
882
695
|
throw new sdkCore.InvalidParameterError("RPC method ".concat(module, ".").concat(method, " not available"));
|
|
883
|
-
case
|
|
884
|
-
_context12.
|
|
696
|
+
case 1:
|
|
697
|
+
_context12.n = 2;
|
|
885
698
|
return rpcModule[method](key);
|
|
886
|
-
case
|
|
887
|
-
response = _context12.
|
|
888
|
-
return _context12.
|
|
889
|
-
case 7:
|
|
890
|
-
case "end":
|
|
891
|
-
return _context12.stop();
|
|
699
|
+
case 2:
|
|
700
|
+
response = _context12.v;
|
|
701
|
+
return _context12.a(2, response.toHex());
|
|
892
702
|
}
|
|
893
703
|
}, _callee12, this);
|
|
894
704
|
}));
|
|
@@ -910,19 +720,16 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
910
720
|
}, {
|
|
911
721
|
key: "createApiForNode",
|
|
912
722
|
value: function () {
|
|
913
|
-
var _createApiForNode = _asyncToGenerator(/*#__PURE__*/
|
|
723
|
+
var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(node) {
|
|
914
724
|
var api;
|
|
915
|
-
return
|
|
916
|
-
while (1) switch (_context13.
|
|
725
|
+
return _regenerator().w(function (_context13) {
|
|
726
|
+
while (1) switch (_context13.n) {
|
|
917
727
|
case 0:
|
|
918
728
|
api = new PolkadotJsApi();
|
|
919
|
-
_context13.
|
|
729
|
+
_context13.n = 1;
|
|
920
730
|
return api.init(node);
|
|
921
|
-
case
|
|
922
|
-
return _context13.
|
|
923
|
-
case 4:
|
|
924
|
-
case "end":
|
|
925
|
-
return _context13.stop();
|
|
731
|
+
case 1:
|
|
732
|
+
return _context13.a(2, api);
|
|
926
733
|
}
|
|
927
734
|
}, _callee13);
|
|
928
735
|
}));
|
|
@@ -934,49 +741,49 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
934
741
|
}, {
|
|
935
742
|
key: "getDryRunCall",
|
|
936
743
|
value: function () {
|
|
937
|
-
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/
|
|
744
|
+
var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(_ref4) {
|
|
938
745
|
var _this$api$call$dryRun;
|
|
939
746
|
var tx, address, node, supportsDryRunApi, nodesRequiringVersionParam, needsVersionParam, DEFAULT_XCM_VERSION, response, result, resultJson, isSuccess, moduleError, failureReason, executionFee, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
940
|
-
return
|
|
941
|
-
while (1) switch (_context14.
|
|
747
|
+
return _regenerator().w(function (_context14) {
|
|
748
|
+
while (1) switch (_context14.n) {
|
|
942
749
|
case 0:
|
|
943
750
|
tx = _ref4.tx, address = _ref4.address, node = _ref4.node;
|
|
944
751
|
supportsDryRunApi = sdkCore.getAssetsObject(node).supportsDryRunApi;
|
|
945
752
|
if (supportsDryRunApi) {
|
|
946
|
-
_context14.
|
|
753
|
+
_context14.n = 1;
|
|
947
754
|
break;
|
|
948
755
|
}
|
|
949
756
|
throw new sdkCore.NodeNotSupportedError("DryRunApi is not available on node ".concat(node));
|
|
950
|
-
case
|
|
757
|
+
case 1:
|
|
951
758
|
nodesRequiringVersionParam = ['BifrostPolkadot', 'BifrostKusama', 'AssetHubKusama', 'AssetHubPolkadot', 'Kusama', 'Polkadot', 'Polimec', 'Astar'];
|
|
952
759
|
needsVersionParam = nodesRequiringVersionParam.includes(node);
|
|
953
760
|
DEFAULT_XCM_VERSION = 3;
|
|
954
|
-
_context14.
|
|
761
|
+
_context14.n = 2;
|
|
955
762
|
return (_this$api$call$dryRun = this.api.call.dryRunApi).dryRunCall.apply(_this$api$call$dryRun, [{
|
|
956
763
|
system: {
|
|
957
764
|
Signed: address
|
|
958
765
|
}
|
|
959
766
|
}, tx].concat(_toConsumableArray(needsVersionParam ? [DEFAULT_XCM_VERSION] : [])));
|
|
960
|
-
case
|
|
961
|
-
response = _context14.
|
|
767
|
+
case 2:
|
|
768
|
+
response = _context14.v;
|
|
962
769
|
result = response.toHuman();
|
|
963
770
|
resultJson = response.toJSON();
|
|
964
771
|
isSuccess = result.Ok && result.Ok.executionResult.Ok;
|
|
965
772
|
if (isSuccess) {
|
|
966
|
-
_context14.
|
|
773
|
+
_context14.n = 3;
|
|
967
774
|
break;
|
|
968
775
|
}
|
|
969
776
|
moduleError = result.Ok.executionResult.Err.error.Module;
|
|
970
777
|
failureReason = sdkCore.resolveModuleError(node, moduleError);
|
|
971
|
-
return _context14.
|
|
778
|
+
return _context14.a(2, {
|
|
972
779
|
success: false,
|
|
973
780
|
failureReason: failureReason
|
|
974
781
|
});
|
|
975
|
-
case
|
|
976
|
-
_context14.
|
|
782
|
+
case 3:
|
|
783
|
+
_context14.n = 4;
|
|
977
784
|
return this.calculateTransactionFee(tx, address);
|
|
978
|
-
case
|
|
979
|
-
executionFee = _context14.
|
|
785
|
+
case 4:
|
|
786
|
+
executionFee = _context14.v;
|
|
980
787
|
fee = sdkCore.computeFeeFromDryRunPjs(result, node, executionFee);
|
|
981
788
|
actualWeight = resultJson.ok.executionResult.ok.actualWeight;
|
|
982
789
|
weight = actualWeight ? {
|
|
@@ -987,16 +794,13 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
987
794
|
destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref5) {
|
|
988
795
|
return i.here === null ? 0 : (_ref5 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref5 === void 0 ? void 0 : _ref5.parachain;
|
|
989
796
|
}(Object.values(forwardedXcms[0])[0].interior);
|
|
990
|
-
return _context14.
|
|
797
|
+
return _context14.a(2, {
|
|
991
798
|
success: true,
|
|
992
799
|
fee: fee,
|
|
993
800
|
weight: weight,
|
|
994
801
|
forwardedXcms: forwardedXcms,
|
|
995
802
|
destParaId: destParaId
|
|
996
803
|
});
|
|
997
|
-
case 26:
|
|
998
|
-
case "end":
|
|
999
|
-
return _context14.stop();
|
|
1000
804
|
}
|
|
1001
805
|
}, _callee14, this);
|
|
1002
806
|
}));
|
|
@@ -1008,37 +812,37 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1008
812
|
}, {
|
|
1009
813
|
key: "getDryRunXcm",
|
|
1010
814
|
value: function () {
|
|
1011
|
-
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/
|
|
815
|
+
var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(_ref6) {
|
|
1012
816
|
var _ref7, _ref8, _ref9;
|
|
1013
817
|
var originLocation, xcm, node, origin, supportsDryRunApi, response, result, resultJson, isSuccess, failureReason, emitted, reversedEvents, palletsWithIssued, feeEvent, feeAmount, fee, actualWeight, weight, forwardedXcms, destParaId;
|
|
1014
|
-
return
|
|
1015
|
-
while (1) switch (_context15.
|
|
818
|
+
return _regenerator().w(function (_context15) {
|
|
819
|
+
while (1) switch (_context15.n) {
|
|
1016
820
|
case 0:
|
|
1017
821
|
originLocation = _ref6.originLocation, xcm = _ref6.xcm, node = _ref6.node, origin = _ref6.origin;
|
|
1018
822
|
supportsDryRunApi = sdkCore.getAssetsObject(node).supportsDryRunApi;
|
|
1019
823
|
if (supportsDryRunApi) {
|
|
1020
|
-
_context15.
|
|
824
|
+
_context15.n = 1;
|
|
1021
825
|
break;
|
|
1022
826
|
}
|
|
1023
827
|
throw new sdkCore.NodeNotSupportedError("DryRunApi is not available on node ".concat(node));
|
|
1024
|
-
case
|
|
1025
|
-
_context15.
|
|
828
|
+
case 1:
|
|
829
|
+
_context15.n = 2;
|
|
1026
830
|
return this.api.call.dryRunApi.dryRunXcm(originLocation, xcm);
|
|
1027
|
-
case
|
|
1028
|
-
response = _context15.
|
|
831
|
+
case 2:
|
|
832
|
+
response = _context15.v;
|
|
1029
833
|
result = response.toHuman();
|
|
1030
834
|
resultJson = response.toJSON();
|
|
1031
835
|
isSuccess = result.Ok && result.Ok.executionResult.Complete;
|
|
1032
836
|
if (isSuccess) {
|
|
1033
|
-
_context15.
|
|
837
|
+
_context15.n = 3;
|
|
1034
838
|
break;
|
|
1035
839
|
}
|
|
1036
840
|
failureReason = result.Ok.executionResult.Incomplete.error;
|
|
1037
|
-
return _context15.
|
|
841
|
+
return _context15.a(2, {
|
|
1038
842
|
success: false,
|
|
1039
843
|
failureReason: failureReason
|
|
1040
844
|
});
|
|
1041
|
-
case
|
|
845
|
+
case 3:
|
|
1042
846
|
emitted = result.Ok.emittedEvents; // We want to look for the last event
|
|
1043
847
|
reversedEvents = _toConsumableArray(emitted).reverse();
|
|
1044
848
|
palletsWithIssued = ['balances', 'foreignAssets', 'assets'];
|
|
@@ -1056,14 +860,14 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1056
860
|
return ['currencies', 'tokens'].includes(event.section) && event.method === 'Deposited';
|
|
1057
861
|
});
|
|
1058
862
|
if (feeEvent) {
|
|
1059
|
-
_context15.
|
|
863
|
+
_context15.n = 4;
|
|
1060
864
|
break;
|
|
1061
865
|
}
|
|
1062
|
-
return _context15.
|
|
866
|
+
return _context15.a(2, Promise.resolve({
|
|
1063
867
|
success: false,
|
|
1064
868
|
failureReason: 'Cannot determine destination fee. No Issued event found'
|
|
1065
869
|
}));
|
|
1066
|
-
case
|
|
870
|
+
case 4:
|
|
1067
871
|
feeAmount = feeEvent.section === 'assetConversion' ? feeEvent.data.amountIn : feeEvent.data.amount;
|
|
1068
872
|
fee = BigInt(feeAmount.replace(/,/g, ''));
|
|
1069
873
|
actualWeight = resultJson.ok.executionResult.used;
|
|
@@ -1075,16 +879,13 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1075
879
|
destParaId = forwardedXcms.length === 0 ? undefined : function (i, _ref0) {
|
|
1076
880
|
return i.Here ? 0 : (_ref0 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref0 === void 0 ? void 0 : _ref0.parachain;
|
|
1077
881
|
}(Object.values(forwardedXcms[0])[0].interior);
|
|
1078
|
-
return _context15.
|
|
882
|
+
return _context15.a(2, {
|
|
1079
883
|
success: true,
|
|
1080
884
|
fee: fee,
|
|
1081
885
|
weight: weight,
|
|
1082
886
|
forwardedXcms: forwardedXcms,
|
|
1083
887
|
destParaId: destParaId
|
|
1084
888
|
});
|
|
1085
|
-
case 26:
|
|
1086
|
-
case "end":
|
|
1087
|
-
return _context15.stop();
|
|
1088
889
|
}
|
|
1089
890
|
}, _callee15, this);
|
|
1090
891
|
}));
|
|
@@ -1096,19 +897,16 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1096
897
|
}, {
|
|
1097
898
|
key: "getBridgeStatus",
|
|
1098
899
|
value: function () {
|
|
1099
|
-
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/
|
|
900
|
+
var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
|
|
1100
901
|
var outboundOperatingMode;
|
|
1101
|
-
return
|
|
1102
|
-
while (1) switch (_context16.
|
|
902
|
+
return _regenerator().w(function (_context16) {
|
|
903
|
+
while (1) switch (_context16.n) {
|
|
1103
904
|
case 0:
|
|
1104
|
-
_context16.
|
|
905
|
+
_context16.n = 1;
|
|
1105
906
|
return this.api.query.ethereumOutboundQueue.operatingMode();
|
|
1106
|
-
case
|
|
1107
|
-
outboundOperatingMode = _context16.
|
|
1108
|
-
return _context16.
|
|
1109
|
-
case 4:
|
|
1110
|
-
case "end":
|
|
1111
|
-
return _context16.stop();
|
|
907
|
+
case 1:
|
|
908
|
+
outboundOperatingMode = _context16.v;
|
|
909
|
+
return _context16.a(2, outboundOperatingMode.toPrimitive());
|
|
1112
910
|
}
|
|
1113
911
|
}, _callee16, this);
|
|
1114
912
|
}));
|
|
@@ -1130,34 +928,33 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
1130
928
|
}, {
|
|
1131
929
|
key: "disconnect",
|
|
1132
930
|
value: function () {
|
|
1133
|
-
var _disconnect = _asyncToGenerator(/*#__PURE__*/
|
|
931
|
+
var _disconnect = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
|
|
1134
932
|
var force,
|
|
1135
933
|
_args17 = arguments;
|
|
1136
|
-
return
|
|
1137
|
-
while (1) switch (_context17.
|
|
934
|
+
return _regenerator().w(function (_context17) {
|
|
935
|
+
while (1) switch (_context17.n) {
|
|
1138
936
|
case 0:
|
|
1139
937
|
force = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : false;
|
|
1140
938
|
if (this.initialized) {
|
|
1141
|
-
_context17.
|
|
939
|
+
_context17.n = 1;
|
|
1142
940
|
break;
|
|
1143
941
|
}
|
|
1144
|
-
return _context17.
|
|
1145
|
-
case
|
|
942
|
+
return _context17.a(2, Promise.resolve());
|
|
943
|
+
case 1:
|
|
1146
944
|
if (!(!force && !this.disconnectAllowed)) {
|
|
1147
|
-
_context17.
|
|
945
|
+
_context17.n = 2;
|
|
1148
946
|
break;
|
|
1149
947
|
}
|
|
1150
|
-
return _context17.
|
|
1151
|
-
case
|
|
948
|
+
return _context17.a(2);
|
|
949
|
+
case 2:
|
|
1152
950
|
if (!(force || typeof this._api === 'string' || this._api === undefined)) {
|
|
1153
|
-
_context17.
|
|
951
|
+
_context17.n = 3;
|
|
1154
952
|
break;
|
|
1155
953
|
}
|
|
1156
|
-
_context17.
|
|
954
|
+
_context17.n = 3;
|
|
1157
955
|
return this.api.disconnect();
|
|
1158
|
-
case
|
|
1159
|
-
|
|
1160
|
-
return _context17.stop();
|
|
956
|
+
case 3:
|
|
957
|
+
return _context17.a(2);
|
|
1161
958
|
}
|
|
1162
959
|
}, _callee17, this);
|
|
1163
960
|
}));
|
|
@@ -1175,20 +972,17 @@ var createApiInstanceForNode = function createApiInstanceForNode(node) {
|
|
|
1175
972
|
};
|
|
1176
973
|
var createPolkadotJsApiCall = function createPolkadotJsApiCall(apiCall) {
|
|
1177
974
|
return /*#__PURE__*/function () {
|
|
1178
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/
|
|
975
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
1179
976
|
var pjsApi, optionsWithApi;
|
|
1180
|
-
return
|
|
1181
|
-
while (1) switch (_context.
|
|
977
|
+
return _regenerator().w(function (_context) {
|
|
978
|
+
while (1) switch (_context.n) {
|
|
1182
979
|
case 0:
|
|
1183
980
|
pjsApi = new PolkadotJsApi();
|
|
1184
981
|
pjsApi.setApi(options.api);
|
|
1185
982
|
optionsWithApi = _objectSpread2(_objectSpread2({}, options), {}, {
|
|
1186
983
|
api: pjsApi
|
|
1187
984
|
});
|
|
1188
|
-
return _context.
|
|
1189
|
-
case 4:
|
|
1190
|
-
case "end":
|
|
1191
|
-
return _context.stop();
|
|
985
|
+
return _context.a(2, apiCall(optionsWithApi));
|
|
1192
986
|
}
|
|
1193
987
|
}, _callee);
|
|
1194
988
|
}));
|
|
@@ -1197,6 +991,9 @@ var createPolkadotJsApiCall = function createPolkadotJsApiCall(apiCall) {
|
|
|
1197
991
|
};
|
|
1198
992
|
}();
|
|
1199
993
|
};
|
|
994
|
+
var isEthersSigner = function isEthersSigner(signer) {
|
|
995
|
+
return _typeof(signer) === 'object' && signer !== null && 'provider' in signer;
|
|
996
|
+
};
|
|
1200
997
|
|
|
1201
998
|
/**
|
|
1202
999
|
* Retrieves the native balance for a given account on a specified node.
|
|
@@ -1265,37 +1062,34 @@ var convertSs58 = function convertSs58(address, node) {
|
|
|
1265
1062
|
};
|
|
1266
1063
|
|
|
1267
1064
|
var approveToken = /*#__PURE__*/function () {
|
|
1268
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/
|
|
1065
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(signer, amount, symbol) {
|
|
1269
1066
|
var env, contract, weth9, result, receipt;
|
|
1270
|
-
return
|
|
1271
|
-
while (1) switch (_context.
|
|
1067
|
+
return _regenerator().w(function (_context) {
|
|
1068
|
+
while (1) switch (_context.n) {
|
|
1272
1069
|
case 0:
|
|
1273
1070
|
env = api$1.environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
|
|
1274
1071
|
contract = env.locations[0].erc20tokensReceivable.find(function (t) {
|
|
1275
1072
|
return t.id === symbol;
|
|
1276
1073
|
});
|
|
1277
1074
|
if (contract) {
|
|
1278
|
-
_context.
|
|
1075
|
+
_context.n = 1;
|
|
1279
1076
|
break;
|
|
1280
1077
|
}
|
|
1281
1078
|
throw new sdkCore.InvalidParameterError("Token ".concat(symbol, " not supported"));
|
|
1282
|
-
case
|
|
1079
|
+
case 1:
|
|
1283
1080
|
weth9 = contractTypes.WETH9__factory.connect(contract.address, signer);
|
|
1284
|
-
_context.
|
|
1081
|
+
_context.n = 2;
|
|
1285
1082
|
return weth9.approve(env.config.GATEWAY_CONTRACT, amount);
|
|
1286
|
-
case
|
|
1287
|
-
result = _context.
|
|
1288
|
-
_context.
|
|
1083
|
+
case 2:
|
|
1084
|
+
result = _context.v;
|
|
1085
|
+
_context.n = 3;
|
|
1289
1086
|
return result.wait();
|
|
1290
|
-
case
|
|
1291
|
-
receipt = _context.
|
|
1292
|
-
return _context.
|
|
1087
|
+
case 3:
|
|
1088
|
+
receipt = _context.v;
|
|
1089
|
+
return _context.a(2, {
|
|
1293
1090
|
result: result,
|
|
1294
1091
|
receipt: receipt
|
|
1295
1092
|
});
|
|
1296
|
-
case 12:
|
|
1297
|
-
case "end":
|
|
1298
|
-
return _context.stop();
|
|
1299
1093
|
}
|
|
1300
1094
|
}, _callee);
|
|
1301
1095
|
}));
|
|
@@ -1305,39 +1099,36 @@ var approveToken = /*#__PURE__*/function () {
|
|
|
1305
1099
|
}();
|
|
1306
1100
|
|
|
1307
1101
|
var depositToken = /*#__PURE__*/function () {
|
|
1308
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/
|
|
1102
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(signer, amount, symbol) {
|
|
1309
1103
|
var env, contract, weth9, result, receipt;
|
|
1310
|
-
return
|
|
1311
|
-
while (1) switch (_context.
|
|
1104
|
+
return _regenerator().w(function (_context) {
|
|
1105
|
+
while (1) switch (_context.n) {
|
|
1312
1106
|
case 0:
|
|
1313
1107
|
env = api$1.environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
|
|
1314
1108
|
contract = env.locations[0].erc20tokensReceivable.find(function (t) {
|
|
1315
1109
|
return t.id === symbol;
|
|
1316
1110
|
});
|
|
1317
1111
|
if (contract) {
|
|
1318
|
-
_context.
|
|
1112
|
+
_context.n = 1;
|
|
1319
1113
|
break;
|
|
1320
1114
|
}
|
|
1321
1115
|
throw new sdkCore.InvalidParameterError("Token ".concat(symbol, " not supported"));
|
|
1322
|
-
case
|
|
1116
|
+
case 1:
|
|
1323
1117
|
weth9 = contractTypes.WETH9__factory.connect(contract.address, signer);
|
|
1324
|
-
_context.
|
|
1118
|
+
_context.n = 2;
|
|
1325
1119
|
return weth9.deposit({
|
|
1326
1120
|
value: amount
|
|
1327
1121
|
});
|
|
1328
|
-
case
|
|
1329
|
-
result = _context.
|
|
1330
|
-
_context.
|
|
1122
|
+
case 2:
|
|
1123
|
+
result = _context.v;
|
|
1124
|
+
_context.n = 3;
|
|
1331
1125
|
return result.wait();
|
|
1332
|
-
case
|
|
1333
|
-
receipt = _context.
|
|
1334
|
-
return _context.
|
|
1126
|
+
case 3:
|
|
1127
|
+
receipt = _context.v;
|
|
1128
|
+
return _context.a(2, {
|
|
1335
1129
|
result: result,
|
|
1336
1130
|
receipt: receipt
|
|
1337
1131
|
});
|
|
1338
|
-
case 12:
|
|
1339
|
-
case "end":
|
|
1340
|
-
return _context.stop();
|
|
1341
1132
|
}
|
|
1342
1133
|
}, _callee);
|
|
1343
1134
|
}));
|
|
@@ -1379,52 +1170,52 @@ var createContext = function createContext(executionUrl, env) {
|
|
|
1379
1170
|
* @throws Will throw an error if the transfer validation fails or if the transfer cannot be completed.
|
|
1380
1171
|
*/
|
|
1381
1172
|
var transferEthToPolkadot$1 = /*#__PURE__*/function () {
|
|
1382
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/
|
|
1383
|
-
var provider, signer, address, to, currency, ethAsset, env, context, destParaId, overrides, registry, fee, sourceAddress, transfer, validation, tx, response, receipt, messageReceipt;
|
|
1384
|
-
return
|
|
1385
|
-
while (1) switch (_context.
|
|
1173
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
1174
|
+
var provider, signer, address, to, currency, ethAsset, env, context, destParaId, overrides, registry, fee, sourceAddress, transfer, validation, tx, response, receipt, messageReceipt, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10, _t11, _t12, _t13, _t14, _t15, _t16, _t17, _t18, _t19, _t20, _t21, _t22, _t23;
|
|
1175
|
+
return _regenerator().w(function (_context) {
|
|
1176
|
+
while (1) switch (_context.n) {
|
|
1386
1177
|
case 0:
|
|
1387
1178
|
provider = _ref.provider, signer = _ref.signer, address = _ref.address, to = _ref.to, currency = _ref.currency;
|
|
1388
1179
|
if (!('multiasset' in currency)) {
|
|
1389
|
-
_context.
|
|
1180
|
+
_context.n = 1;
|
|
1390
1181
|
break;
|
|
1391
1182
|
}
|
|
1392
1183
|
throw new sdkCore.InvalidParameterError('Multiassets syntax is not supported for Evm transfers');
|
|
1393
|
-
case
|
|
1184
|
+
case 1:
|
|
1394
1185
|
if (!('multilocation' in currency && sdkCore.isOverrideMultiLocationSpecifier(currency.multilocation))) {
|
|
1395
|
-
_context.
|
|
1186
|
+
_context.n = 2;
|
|
1396
1187
|
break;
|
|
1397
1188
|
}
|
|
1398
1189
|
throw new sdkCore.InvalidParameterError('Override multilocation is not supported for Evm transfers');
|
|
1399
|
-
case
|
|
1190
|
+
case 2:
|
|
1400
1191
|
if (provider) {
|
|
1401
|
-
_context.
|
|
1192
|
+
_context.n = 3;
|
|
1402
1193
|
break;
|
|
1403
1194
|
}
|
|
1404
1195
|
throw new sdkCore.InvalidParameterError('provider parameter is required for Snowbridge transfers.');
|
|
1405
|
-
case
|
|
1406
|
-
if (
|
|
1407
|
-
_context.
|
|
1196
|
+
case 3:
|
|
1197
|
+
if (isEthersSigner(signer)) {
|
|
1198
|
+
_context.n = 4;
|
|
1408
1199
|
break;
|
|
1409
1200
|
}
|
|
1410
1201
|
throw new sdkCore.InvalidParameterError('Snowbridge does not support Viem provider yet.');
|
|
1411
|
-
case
|
|
1202
|
+
case 4:
|
|
1412
1203
|
ethAsset = sdkCore.findAsset('Ethereum', currency, to);
|
|
1413
1204
|
if (!(ethAsset === null)) {
|
|
1414
|
-
_context.
|
|
1205
|
+
_context.n = 5;
|
|
1415
1206
|
break;
|
|
1416
1207
|
}
|
|
1417
1208
|
throw new sdkCore.InvalidCurrencyError("Origin node Ethereum does not support currency ".concat(JSON.stringify(currency), "."));
|
|
1418
|
-
case
|
|
1209
|
+
case 5:
|
|
1419
1210
|
env = api$1.environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
|
|
1420
1211
|
context = createContext(provider, env);
|
|
1421
1212
|
destParaId = sdkCore.getParaId(to);
|
|
1422
1213
|
if (!(!sdkCore.isForeignAsset(ethAsset) || ethAsset.assetId === undefined)) {
|
|
1423
|
-
_context.
|
|
1214
|
+
_context.n = 6;
|
|
1424
1215
|
break;
|
|
1425
1216
|
}
|
|
1426
1217
|
throw new sdkCore.InvalidCurrencyError('Selected asset has no asset id');
|
|
1427
|
-
case
|
|
1218
|
+
case 6:
|
|
1428
1219
|
overrides = {
|
|
1429
1220
|
precompiles: {
|
|
1430
1221
|
'2004': '0x000000000000000000000000000000000000081A'
|
|
@@ -1443,92 +1234,92 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
|
|
|
1443
1234
|
}]
|
|
1444
1235
|
}
|
|
1445
1236
|
};
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
_context.
|
|
1237
|
+
_t = api$1.assetsV2;
|
|
1238
|
+
_t2 = _objectSpread2;
|
|
1239
|
+
_t3 = _objectSpread2;
|
|
1240
|
+
_t4 = {};
|
|
1241
|
+
_context.n = 7;
|
|
1451
1242
|
return api$1.assetsV2.fromContext(context);
|
|
1452
|
-
case
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
_context.
|
|
1458
|
-
return
|
|
1459
|
-
case
|
|
1460
|
-
registry = _context.
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
_context.
|
|
1243
|
+
case 7:
|
|
1244
|
+
_t5 = _context.v;
|
|
1245
|
+
_t6 = _t3(_t4, _t5);
|
|
1246
|
+
_t7 = overrides;
|
|
1247
|
+
_t8 = _t2(_t6, _t7);
|
|
1248
|
+
_context.n = 8;
|
|
1249
|
+
return _t.buildRegistry.call(_t, _t8);
|
|
1250
|
+
case 8:
|
|
1251
|
+
registry = _context.v;
|
|
1252
|
+
_t9 = api$1.toPolkadotV2;
|
|
1253
|
+
_t0 = context.gateway();
|
|
1254
|
+
_context.n = 9;
|
|
1464
1255
|
return context.assetHub();
|
|
1465
|
-
case
|
|
1466
|
-
|
|
1467
|
-
_context.
|
|
1256
|
+
case 9:
|
|
1257
|
+
_t1 = _context.v;
|
|
1258
|
+
_context.n = 10;
|
|
1468
1259
|
return context.parachain(destParaId);
|
|
1469
|
-
case
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
gateway:
|
|
1473
|
-
assetHub:
|
|
1474
|
-
destination:
|
|
1260
|
+
case 10:
|
|
1261
|
+
_t10 = _context.v;
|
|
1262
|
+
_t11 = {
|
|
1263
|
+
gateway: _t0,
|
|
1264
|
+
assetHub: _t1,
|
|
1265
|
+
destination: _t10
|
|
1475
1266
|
};
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
_context.
|
|
1480
|
-
return
|
|
1481
|
-
case
|
|
1482
|
-
fee = _context.
|
|
1483
|
-
_context.
|
|
1267
|
+
_t12 = registry;
|
|
1268
|
+
_t13 = ethAsset.assetId;
|
|
1269
|
+
_t14 = destParaId;
|
|
1270
|
+
_context.n = 11;
|
|
1271
|
+
return _t9.getDeliveryFee.call(_t9, _t11, _t12, _t13, _t14);
|
|
1272
|
+
case 11:
|
|
1273
|
+
fee = _context.v;
|
|
1274
|
+
_context.n = 12;
|
|
1484
1275
|
return signer.getAddress();
|
|
1485
|
-
case
|
|
1486
|
-
sourceAddress = _context.
|
|
1487
|
-
_context.
|
|
1276
|
+
case 12:
|
|
1277
|
+
sourceAddress = _context.v;
|
|
1278
|
+
_context.n = 13;
|
|
1488
1279
|
return api$1.toPolkadotV2.createTransfer(registry, sourceAddress, address, ethAsset.assetId, destParaId, BigInt(currency.amount), fee);
|
|
1489
|
-
case
|
|
1490
|
-
transfer = _context.
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
_context.
|
|
1280
|
+
case 13:
|
|
1281
|
+
transfer = _context.v;
|
|
1282
|
+
_t15 = api$1.toPolkadotV2;
|
|
1283
|
+
_t16 = context.ethereum();
|
|
1284
|
+
_t17 = context.gateway();
|
|
1285
|
+
_context.n = 14;
|
|
1495
1286
|
return context.bridgeHub();
|
|
1496
|
-
case
|
|
1497
|
-
|
|
1498
|
-
_context.
|
|
1287
|
+
case 14:
|
|
1288
|
+
_t18 = _context.v;
|
|
1289
|
+
_context.n = 15;
|
|
1499
1290
|
return context.assetHub();
|
|
1500
|
-
case
|
|
1501
|
-
|
|
1291
|
+
case 15:
|
|
1292
|
+
_t19 = _context.v;
|
|
1502
1293
|
if (!(destParaId !== sdkCore.getParaId('AssetHubPolkadot'))) {
|
|
1503
|
-
_context.
|
|
1294
|
+
_context.n = 17;
|
|
1504
1295
|
break;
|
|
1505
1296
|
}
|
|
1506
|
-
_context.
|
|
1297
|
+
_context.n = 16;
|
|
1507
1298
|
return context.parachain(destParaId);
|
|
1508
|
-
case
|
|
1509
|
-
|
|
1510
|
-
_context.
|
|
1299
|
+
case 16:
|
|
1300
|
+
_t20 = _context.v;
|
|
1301
|
+
_context.n = 18;
|
|
1511
1302
|
break;
|
|
1512
|
-
case
|
|
1513
|
-
|
|
1514
|
-
case
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
ethereum:
|
|
1518
|
-
gateway:
|
|
1519
|
-
bridgeHub:
|
|
1520
|
-
assetHub:
|
|
1521
|
-
destParachain:
|
|
1303
|
+
case 17:
|
|
1304
|
+
_t20 = undefined;
|
|
1305
|
+
case 18:
|
|
1306
|
+
_t21 = _t20;
|
|
1307
|
+
_t22 = {
|
|
1308
|
+
ethereum: _t16,
|
|
1309
|
+
gateway: _t17,
|
|
1310
|
+
bridgeHub: _t18,
|
|
1311
|
+
assetHub: _t19,
|
|
1312
|
+
destParachain: _t21
|
|
1522
1313
|
};
|
|
1523
|
-
|
|
1524
|
-
_context.
|
|
1525
|
-
return
|
|
1526
|
-
case
|
|
1527
|
-
validation = _context.
|
|
1314
|
+
_t23 = transfer;
|
|
1315
|
+
_context.n = 19;
|
|
1316
|
+
return _t15.validateTransfer.call(_t15, _t22, _t23);
|
|
1317
|
+
case 19:
|
|
1318
|
+
validation = _context.v;
|
|
1528
1319
|
if (!validation.logs.find(function (l) {
|
|
1529
1320
|
return l.kind == api$1.toPolkadotV2.ValidationKind.Error;
|
|
1530
1321
|
})) {
|
|
1531
|
-
_context.
|
|
1322
|
+
_context.n = 20;
|
|
1532
1323
|
break;
|
|
1533
1324
|
}
|
|
1534
1325
|
throw new sdkCore.InvalidParameterError("Validation failed with following errors: \n\n ".concat(validation.logs.filter(function (l) {
|
|
@@ -1536,39 +1327,36 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
|
|
|
1536
1327
|
}).map(function (l) {
|
|
1537
1328
|
return l.message;
|
|
1538
1329
|
}).join('\n\n')));
|
|
1539
|
-
case
|
|
1330
|
+
case 20:
|
|
1540
1331
|
tx = transfer.tx;
|
|
1541
|
-
_context.
|
|
1332
|
+
_context.n = 21;
|
|
1542
1333
|
return signer.sendTransaction(tx);
|
|
1543
|
-
case
|
|
1544
|
-
response = _context.
|
|
1545
|
-
_context.
|
|
1334
|
+
case 21:
|
|
1335
|
+
response = _context.v;
|
|
1336
|
+
_context.n = 22;
|
|
1546
1337
|
return response.wait(1);
|
|
1547
|
-
case
|
|
1548
|
-
receipt = _context.
|
|
1338
|
+
case 22:
|
|
1339
|
+
receipt = _context.v;
|
|
1549
1340
|
if (receipt) {
|
|
1550
|
-
_context.
|
|
1341
|
+
_context.n = 23;
|
|
1551
1342
|
break;
|
|
1552
1343
|
}
|
|
1553
1344
|
throw new sdkCore.InvalidParameterError("Transaction ".concat(response.hash, " not included."));
|
|
1554
|
-
case
|
|
1555
|
-
_context.
|
|
1345
|
+
case 23:
|
|
1346
|
+
_context.n = 24;
|
|
1556
1347
|
return api$1.toPolkadotV2.getMessageReceipt(receipt);
|
|
1557
|
-
case
|
|
1558
|
-
messageReceipt = _context.
|
|
1348
|
+
case 24:
|
|
1349
|
+
messageReceipt = _context.v;
|
|
1559
1350
|
if (messageReceipt) {
|
|
1560
|
-
_context.
|
|
1351
|
+
_context.n = 25;
|
|
1561
1352
|
break;
|
|
1562
1353
|
}
|
|
1563
1354
|
throw new sdkCore.InvalidParameterError("Transaction ".concat(receipt.hash, " did not emit a message."));
|
|
1564
|
-
case
|
|
1565
|
-
return _context.
|
|
1355
|
+
case 25:
|
|
1356
|
+
return _context.a(2, {
|
|
1566
1357
|
response: response,
|
|
1567
1358
|
messageReceipt: messageReceipt
|
|
1568
1359
|
});
|
|
1569
|
-
case 91:
|
|
1570
|
-
case "end":
|
|
1571
|
-
return _context.stop();
|
|
1572
1360
|
}
|
|
1573
1361
|
}, _callee);
|
|
1574
1362
|
}));
|
|
@@ -1578,30 +1366,27 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
|
|
|
1578
1366
|
}();
|
|
1579
1367
|
|
|
1580
1368
|
var getTokenBalance = /*#__PURE__*/function () {
|
|
1581
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/
|
|
1369
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(signer, symbol) {
|
|
1582
1370
|
var env, contract, weth9, address;
|
|
1583
|
-
return
|
|
1584
|
-
while (1) switch (_context.
|
|
1371
|
+
return _regenerator().w(function (_context) {
|
|
1372
|
+
while (1) switch (_context.n) {
|
|
1585
1373
|
case 0:
|
|
1586
1374
|
env = api$1.environment.SNOWBRIDGE_ENV['polkadot_mainnet'];
|
|
1587
1375
|
contract = env.locations[0].erc20tokensReceivable.find(function (t) {
|
|
1588
1376
|
return t.id === symbol;
|
|
1589
1377
|
});
|
|
1590
1378
|
if (contract) {
|
|
1591
|
-
_context.
|
|
1379
|
+
_context.n = 1;
|
|
1592
1380
|
break;
|
|
1593
1381
|
}
|
|
1594
1382
|
throw new sdkCore.InvalidParameterError("Token ".concat(symbol, " not supported"));
|
|
1595
|
-
case
|
|
1383
|
+
case 1:
|
|
1596
1384
|
weth9 = contractTypes.WETH9__factory.connect(contract.address, signer);
|
|
1597
|
-
_context.
|
|
1385
|
+
_context.n = 2;
|
|
1598
1386
|
return signer.getAddress();
|
|
1599
|
-
case
|
|
1600
|
-
address = _context.
|
|
1601
|
-
return _context.
|
|
1602
|
-
case 9:
|
|
1603
|
-
case "end":
|
|
1604
|
-
return _context.stop();
|
|
1387
|
+
case 2:
|
|
1388
|
+
address = _context.v;
|
|
1389
|
+
return _context.a(2, weth9.balanceOf(address));
|
|
1605
1390
|
}
|
|
1606
1391
|
}, _callee);
|
|
1607
1392
|
}));
|
|
@@ -1698,34 +1483,47 @@ var EvmBuilderCore = /*#__PURE__*/function () {
|
|
|
1698
1483
|
}, {
|
|
1699
1484
|
key: "build",
|
|
1700
1485
|
value: (function () {
|
|
1701
|
-
var _build = _asyncToGenerator(/*#__PURE__*/
|
|
1702
|
-
var _this$_options, from, to, address, _yield$transferEthToP, response;
|
|
1703
|
-
return
|
|
1704
|
-
while (1) switch (_context.
|
|
1486
|
+
var _build = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
1487
|
+
var _this$_options, from, to, address, signer, _yield$transferEthToP, response;
|
|
1488
|
+
return _regenerator().w(function (_context) {
|
|
1489
|
+
while (1) switch (_context.n) {
|
|
1705
1490
|
case 0:
|
|
1706
|
-
_this$_options = this._options, from = _this$_options.from, to = _this$_options.to, address = _this$_options.address;
|
|
1491
|
+
_this$_options = this._options, from = _this$_options.from, to = _this$_options.to, address = _this$_options.address, signer = _this$_options.signer;
|
|
1707
1492
|
sdkCore.validateAddress(address, to);
|
|
1708
1493
|
if (!(from === 'Moonbeam' && to === 'Ethereum')) {
|
|
1709
|
-
_context.
|
|
1494
|
+
_context.n = 2;
|
|
1710
1495
|
break;
|
|
1711
1496
|
}
|
|
1712
|
-
|
|
1713
|
-
|
|
1497
|
+
if (!isEthersSigner(signer)) {
|
|
1498
|
+
_context.n = 1;
|
|
1499
|
+
break;
|
|
1500
|
+
}
|
|
1501
|
+
throw new sdkCore.InvalidParameterError('Ethers signer is not supported for Moonbeam to Ethereum transfers.');
|
|
1502
|
+
case 1:
|
|
1503
|
+
return _context.a(2, sdkCore.transferMoonbeamToEth(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
1504
|
+
signer: signer
|
|
1505
|
+
})));
|
|
1506
|
+
case 2:
|
|
1714
1507
|
if (!(from === 'Moonbeam' || from === 'Moonriver' || from === 'Darwinia')) {
|
|
1715
|
-
_context.
|
|
1508
|
+
_context.n = 4;
|
|
1716
1509
|
break;
|
|
1717
1510
|
}
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1511
|
+
if (!isEthersSigner(signer)) {
|
|
1512
|
+
_context.n = 3;
|
|
1513
|
+
break;
|
|
1514
|
+
}
|
|
1515
|
+
throw new sdkCore.InvalidParameterError('Ethers signer is not supported for Moonbeam to Ethereum transfers.');
|
|
1516
|
+
case 3:
|
|
1517
|
+
return _context.a(2, sdkCore.transferMoonbeamEvm(_objectSpread2(_objectSpread2({}, this._options), {}, {
|
|
1518
|
+
signer: signer
|
|
1519
|
+
})));
|
|
1520
|
+
case 4:
|
|
1521
|
+
_context.n = 5;
|
|
1721
1522
|
return transferEthToPolkadot$1(this._options);
|
|
1722
|
-
case
|
|
1723
|
-
_yield$transferEthToP = _context.
|
|
1523
|
+
case 5:
|
|
1524
|
+
_yield$transferEthToP = _context.v;
|
|
1724
1525
|
response = _yield$transferEthToP.response;
|
|
1725
|
-
return _context.
|
|
1726
|
-
case 13:
|
|
1727
|
-
case "end":
|
|
1728
|
-
return _context.stop();
|
|
1526
|
+
return _context.a(2, response.hash);
|
|
1729
1527
|
}
|
|
1730
1528
|
}, _callee, this);
|
|
1731
1529
|
}));
|
|
@@ -1779,20 +1577,17 @@ var transferEthToPolkadot = function transferEthToPolkadot(options) {
|
|
|
1779
1577
|
}));
|
|
1780
1578
|
};
|
|
1781
1579
|
var getParaEthTransferFees = /*#__PURE__*/function () {
|
|
1782
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/
|
|
1580
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api) {
|
|
1783
1581
|
var pjsApi;
|
|
1784
|
-
return
|
|
1785
|
-
while (1) switch (_context.
|
|
1582
|
+
return _regenerator().w(function (_context) {
|
|
1583
|
+
while (1) switch (_context.n) {
|
|
1786
1584
|
case 0:
|
|
1787
1585
|
pjsApi = new PolkadotJsApi();
|
|
1788
1586
|
pjsApi.setApi(api);
|
|
1789
|
-
_context.
|
|
1587
|
+
_context.n = 1;
|
|
1790
1588
|
return pjsApi.init('AssetHubPolkadot', sdkCore.DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
1791
|
-
case
|
|
1792
|
-
return _context.
|
|
1793
|
-
case 5:
|
|
1794
|
-
case "end":
|
|
1795
|
-
return _context.stop();
|
|
1589
|
+
case 1:
|
|
1590
|
+
return _context.a(2, sdkCore.getParaEthTransferFees(pjsApi));
|
|
1796
1591
|
}
|
|
1797
1592
|
}, _callee);
|
|
1798
1593
|
}));
|
|
@@ -1804,17 +1599,14 @@ var getParaEthTransferFees = /*#__PURE__*/function () {
|
|
|
1804
1599
|
* Gets the Ethereum bridge status.
|
|
1805
1600
|
*/
|
|
1806
1601
|
var getBridgeStatus = /*#__PURE__*/function () {
|
|
1807
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/
|
|
1602
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api) {
|
|
1808
1603
|
var pjsApi;
|
|
1809
|
-
return
|
|
1810
|
-
while (1) switch (_context2.
|
|
1604
|
+
return _regenerator().w(function (_context2) {
|
|
1605
|
+
while (1) switch (_context2.n) {
|
|
1811
1606
|
case 0:
|
|
1812
1607
|
pjsApi = new PolkadotJsApi();
|
|
1813
1608
|
pjsApi.setApi(api);
|
|
1814
|
-
return _context2.
|
|
1815
|
-
case 3:
|
|
1816
|
-
case "end":
|
|
1817
|
-
return _context2.stop();
|
|
1609
|
+
return _context2.a(2, sdkCore.getBridgeStatus(pjsApi));
|
|
1818
1610
|
}
|
|
1819
1611
|
}, _callee2);
|
|
1820
1612
|
}));
|