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