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