@paraspell/sdk-core 8.0.0 → 8.0.2
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 +912 -1096
- package/dist/index.d.ts +13 -80
- package/dist/index.mjs +912 -1095
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -15,6 +15,31 @@ function _assertThisInitialized(e) {
|
|
|
15
15
|
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
16
16
|
return e;
|
|
17
17
|
}
|
|
18
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
19
|
+
try {
|
|
20
|
+
var i = n[a](c),
|
|
21
|
+
u = i.value;
|
|
22
|
+
} catch (n) {
|
|
23
|
+
return void e(n);
|
|
24
|
+
}
|
|
25
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
26
|
+
}
|
|
27
|
+
function _asyncToGenerator(n) {
|
|
28
|
+
return function () {
|
|
29
|
+
var t = this,
|
|
30
|
+
e = arguments;
|
|
31
|
+
return new Promise(function (r, o) {
|
|
32
|
+
var a = n.apply(t, e);
|
|
33
|
+
function _next(n) {
|
|
34
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
35
|
+
}
|
|
36
|
+
function _throw(n) {
|
|
37
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
38
|
+
}
|
|
39
|
+
_next(void 0);
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
}
|
|
18
43
|
function _callSuper(t, o, e) {
|
|
19
44
|
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
20
45
|
}
|
|
@@ -142,6 +167,27 @@ function _iterableToArray(r) {
|
|
|
142
167
|
function _nonIterableSpread() {
|
|
143
168
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
144
169
|
}
|
|
170
|
+
function ownKeys(e, r) {
|
|
171
|
+
var t = Object.keys(e);
|
|
172
|
+
if (Object.getOwnPropertySymbols) {
|
|
173
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
174
|
+
r && (o = o.filter(function (r) {
|
|
175
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
176
|
+
})), t.push.apply(t, o);
|
|
177
|
+
}
|
|
178
|
+
return t;
|
|
179
|
+
}
|
|
180
|
+
function _objectSpread2(e) {
|
|
181
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
182
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
183
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
184
|
+
_defineProperty(e, r, t[r]);
|
|
185
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
186
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
return e;
|
|
190
|
+
}
|
|
145
191
|
function _possibleConstructorReturn(t, e) {
|
|
146
192
|
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
147
193
|
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
@@ -519,38 +565,6 @@ function _wrapNativeSuper(t) {
|
|
|
519
565
|
}, _wrapNativeSuper(t);
|
|
520
566
|
}
|
|
521
567
|
|
|
522
|
-
/******************************************************************************
|
|
523
|
-
Copyright (c) Microsoft Corporation.
|
|
524
|
-
|
|
525
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
526
|
-
purpose with or without fee is hereby granted.
|
|
527
|
-
|
|
528
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
529
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
530
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
531
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
532
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
533
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
534
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
535
|
-
***************************************************************************** */
|
|
536
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
540
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
541
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
542
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
543
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
544
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
545
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
550
|
-
var e = new Error(message);
|
|
551
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
552
|
-
};
|
|
553
|
-
|
|
554
568
|
var Polkadot$2 = {
|
|
555
569
|
relayChainAssetSymbol: "DOT",
|
|
556
570
|
nativeAssetSymbol: "DOT",
|
|
@@ -11402,7 +11416,7 @@ exports.PolkadotXcmError = void 0;
|
|
|
11402
11416
|
})(exports.PolkadotXcmError || (exports.PolkadotXcmError = {}));
|
|
11403
11417
|
|
|
11404
11418
|
var DEFAULT_FEE_ASSET = 0;
|
|
11405
|
-
var ETH_CHAIN_ID =
|
|
11419
|
+
var ETH_CHAIN_ID = 1n;
|
|
11406
11420
|
var ETHEREUM_JUNCTION = {
|
|
11407
11421
|
GlobalConsensus: {
|
|
11408
11422
|
Ethereum: {
|
|
@@ -13099,7 +13113,7 @@ var constructRelayToParaParameters = function constructRelayToParaParameters(_re
|
|
|
13099
13113
|
includeFee = _ref2.includeFee;
|
|
13100
13114
|
var isRelayDestination = !isTMultiLocation(destination) && isRelayChain(destination);
|
|
13101
13115
|
var paraId = !isRelayDestination && _typeof(destination) !== 'object' ? paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination) : undefined;
|
|
13102
|
-
return
|
|
13116
|
+
return _objectSpread2({
|
|
13103
13117
|
dest: createPolkadotXcmHeader('RelayToPara', version, destination, paraId),
|
|
13104
13118
|
beneficiary: generateAddressPayload(api, 'RelayToPara', null, address, version, paraId),
|
|
13105
13119
|
assets: createCurrencySpec(asset.amount, version, exports.Parents.ZERO),
|
|
@@ -13185,14 +13199,14 @@ var createBridgePolkadotXcmDest = function createBridgePolkadotXcmDest(version,
|
|
|
13185
13199
|
return _defineProperty({}, version, isMultiLocationDestination ? destination : multiLocation);
|
|
13186
13200
|
};
|
|
13187
13201
|
var resolveTNodeFromMultiLocation = function resolveTNodeFromMultiLocation(relayChain, multiLocation) {
|
|
13188
|
-
var
|
|
13202
|
+
var _NODE_NAMES_DOT_KSM$f;
|
|
13189
13203
|
var parachainId = findParachainJunction(multiLocation);
|
|
13190
13204
|
if (parachainId === null) {
|
|
13191
13205
|
throw new Error('Parachain ID not found in destination multi location.');
|
|
13192
13206
|
}
|
|
13193
|
-
var node = (
|
|
13207
|
+
var node = (_NODE_NAMES_DOT_KSM$f = NODE_NAMES_DOT_KSM.find(function (nodeName) {
|
|
13194
13208
|
return getParaId(nodeName) === parachainId && determineRelayChain(nodeName) === relayChain;
|
|
13195
|
-
})) !== null &&
|
|
13209
|
+
})) !== null && _NODE_NAMES_DOT_KSM$f !== void 0 ? _NODE_NAMES_DOT_KSM$f : null;
|
|
13196
13210
|
if (node === null) {
|
|
13197
13211
|
throw new Error('Node with specified paraId not found in destination multi location.');
|
|
13198
13212
|
}
|
|
@@ -13224,8 +13238,8 @@ var buildMultiLocation = function buildMultiLocation(_ref) {
|
|
|
13224
13238
|
}
|
|
13225
13239
|
// If it is a native asset, search by symbol on AssetHub and use the multiLocation from there
|
|
13226
13240
|
var assetHubAsset = getOtherAssets(destination).find(function (ahAsset) {
|
|
13227
|
-
var
|
|
13228
|
-
return ((
|
|
13241
|
+
var _ahAsset$symbol, _asset$symbol;
|
|
13242
|
+
return ((_ahAsset$symbol = ahAsset.symbol) === null || _ahAsset$symbol === void 0 ? void 0 : _ahAsset$symbol.toLowerCase()) === ((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toLowerCase());
|
|
13229
13243
|
});
|
|
13230
13244
|
if (assetHubAsset === undefined) {
|
|
13231
13245
|
throw new InvalidCurrencyError("Asset ".concat(asset.symbol, " not found in AssetHub"));
|
|
@@ -13294,9 +13308,9 @@ var getXTokensParameters = function getXTokensParameters(isMultiAssetTransfer, c
|
|
|
13294
13308
|
var feeAssetIndex = isMultiAsset ? overriddenAsset.findIndex(function (asset) {
|
|
13295
13309
|
return asset.isFeeAsset;
|
|
13296
13310
|
}) : undefined;
|
|
13297
|
-
return
|
|
13311
|
+
return _objectSpread2(_objectSpread2(_defineProperty({}, isMultiAsset ? 'assets' : 'asset', currencySelection), isMultiAsset && {
|
|
13298
13312
|
fee_item: feeAssetIndex
|
|
13299
|
-
}), {
|
|
13313
|
+
}), {}, {
|
|
13300
13314
|
dest: addressSelection,
|
|
13301
13315
|
dest_weight_limit: fees
|
|
13302
13316
|
});
|
|
@@ -13317,7 +13331,6 @@ var XTokensTransferImpl = /*#__PURE__*/function () {
|
|
|
13317
13331
|
key: "transferXTokens",
|
|
13318
13332
|
value: function transferXTokens(input, currencySelection) {
|
|
13319
13333
|
var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Unlimited';
|
|
13320
|
-
var _a;
|
|
13321
13334
|
var api = input.api,
|
|
13322
13335
|
origin = input.origin,
|
|
13323
13336
|
asset = input.asset,
|
|
@@ -13340,7 +13353,7 @@ var XTokensTransferImpl = /*#__PURE__*/function () {
|
|
|
13340
13353
|
var section = shouldUseMultiasset ? isMultiAsset ? 'transfer_multiassets' : 'transfer_multiasset' : 'transfer';
|
|
13341
13354
|
var parameters = getXTokensParameters(shouldUseMultiasset, modifiedCurrencySelection, addressSelection, asset.amount, fees, overriddenAsset);
|
|
13342
13355
|
var call = {
|
|
13343
|
-
module:
|
|
13356
|
+
module: pallet !== null && pallet !== void 0 ? pallet : 'XTokens',
|
|
13344
13357
|
section: method !== null && method !== void 0 ? method : section,
|
|
13345
13358
|
parameters: parameters
|
|
13346
13359
|
};
|
|
@@ -13399,8 +13412,8 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
13399
13412
|
}
|
|
13400
13413
|
}, {
|
|
13401
13414
|
key: "transfer",
|
|
13402
|
-
value: function
|
|
13403
|
-
|
|
13415
|
+
value: function () {
|
|
13416
|
+
var _transfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
13404
13417
|
var api, asset, address, destination, paraIdTo, overriddenAsset, version, ahAddress, pallet, method, isRelayDestination, scenario, paraId, versionOrDefault, isBifrostOrigin, isAssetHubDest, shouldUseMultiasset, input;
|
|
13405
13418
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13406
13419
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -13488,7 +13501,11 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
13488
13501
|
}
|
|
13489
13502
|
}, _callee, this);
|
|
13490
13503
|
}));
|
|
13491
|
-
|
|
13504
|
+
function transfer(_x) {
|
|
13505
|
+
return _transfer.apply(this, arguments);
|
|
13506
|
+
}
|
|
13507
|
+
return transfer;
|
|
13508
|
+
}()
|
|
13492
13509
|
}, {
|
|
13493
13510
|
key: "getRelayToParaOverrides",
|
|
13494
13511
|
value: function getRelayToParaOverrides() {
|
|
@@ -13500,7 +13517,6 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
13500
13517
|
}, {
|
|
13501
13518
|
key: "transferRelayToPara",
|
|
13502
13519
|
value: function transferRelayToPara(options) {
|
|
13503
|
-
var _a;
|
|
13504
13520
|
var _options$version = options.version,
|
|
13505
13521
|
version = _options$version === void 0 ? exports.Version.V3 : _options$version,
|
|
13506
13522
|
pallet = options.pallet,
|
|
@@ -13509,7 +13525,7 @@ var ParachainNode = /*#__PURE__*/function () {
|
|
|
13509
13525
|
section = _this$getRelayToParaO.section,
|
|
13510
13526
|
includeFee = _this$getRelayToParaO.includeFee;
|
|
13511
13527
|
return {
|
|
13512
|
-
module:
|
|
13528
|
+
module: pallet !== null && pallet !== void 0 ? pallet : 'XcmPallet',
|
|
13513
13529
|
section: method !== null && method !== void 0 ? method : section,
|
|
13514
13530
|
parameters: constructRelayToParaParameters(options, version, {
|
|
13515
13531
|
includeFee: includeFee
|
|
@@ -13619,14 +13635,13 @@ var PolkadotXCMTransferImpl = /*#__PURE__*/function () {
|
|
|
13619
13635
|
pallet = _ref.pallet,
|
|
13620
13636
|
method = _ref.method;
|
|
13621
13637
|
var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
13622
|
-
var _a;
|
|
13623
13638
|
var feeAssetIndex = overriddenAsset === undefined || isTMultiLocation(overriddenAsset) ? DEFAULT_FEE_ASSET : overriddenAsset.findIndex(function (asset) {
|
|
13624
13639
|
return asset.isFeeAsset;
|
|
13625
13640
|
});
|
|
13626
13641
|
var call = {
|
|
13627
|
-
module:
|
|
13642
|
+
module: pallet !== null && pallet !== void 0 ? pallet : 'PolkadotXcm',
|
|
13628
13643
|
section: method !== null && method !== void 0 ? method : section,
|
|
13629
|
-
parameters:
|
|
13644
|
+
parameters: _objectSpread2({
|
|
13630
13645
|
dest: header,
|
|
13631
13646
|
beneficiary: addressSelection,
|
|
13632
13647
|
assets: currencySelection,
|
|
@@ -13687,14 +13702,14 @@ var BifrostPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
13687
13702
|
}, {
|
|
13688
13703
|
key: "transferPolkadotXCM",
|
|
13689
13704
|
value: function transferPolkadotXCM(input) {
|
|
13690
|
-
var
|
|
13705
|
+
var _getAssetId;
|
|
13691
13706
|
var overriddenAsset = input.overriddenAsset,
|
|
13692
13707
|
asset = input.asset;
|
|
13693
|
-
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(
|
|
13708
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(_objectSpread2(_objectSpread2({}, input), {}, {
|
|
13694
13709
|
currencySelection: createCurrencySpec(asset.amount, this.version, asset.symbol === 'DOT' ? exports.Parents.ONE : exports.Parents.TWO, overriddenAsset, asset.symbol === 'WETH' ? {
|
|
13695
13710
|
X2: [ETHEREUM_JUNCTION, {
|
|
13696
13711
|
AccountKey20: {
|
|
13697
|
-
key: (
|
|
13712
|
+
key: (_getAssetId = getAssetId('Ethereum', 'WETH')) !== null && _getAssetId !== void 0 ? _getAssetId : ''
|
|
13698
13713
|
}
|
|
13699
13714
|
}]
|
|
13700
13715
|
} : undefined)
|
|
@@ -13777,13 +13792,13 @@ var createEthereumTokenLocation = function createEthereumTokenLocation(currencyI
|
|
|
13777
13792
|
};
|
|
13778
13793
|
};
|
|
13779
13794
|
|
|
13780
|
-
var calculateFee = function
|
|
13781
|
-
|
|
13795
|
+
var calculateFee = /*#__PURE__*/function () {
|
|
13796
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(api) {
|
|
13782
13797
|
var DEFAULT_FEE, ahApi, feeStorageItem, leFeeHex, leFee, transfer_bridge_fee, transfer_assethub_execution_fee;
|
|
13783
13798
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13784
13799
|
while (1) switch (_context.prev = _context.next) {
|
|
13785
13800
|
case 0:
|
|
13786
|
-
DEFAULT_FEE =
|
|
13801
|
+
DEFAULT_FEE = 2750872500000n;
|
|
13787
13802
|
_context.next = 3;
|
|
13788
13803
|
return api.createApiForNode('AssetHubPolkadot');
|
|
13789
13804
|
case 3:
|
|
@@ -13794,8 +13809,8 @@ var calculateFee = function calculateFee(api) {
|
|
|
13794
13809
|
feeStorageItem = _context.sent;
|
|
13795
13810
|
leFeeHex = feeStorageItem.replace('0x', '');
|
|
13796
13811
|
leFee = BigInt('0x' + leFeeHex.split('').reverse().join(''));
|
|
13797
|
-
transfer_bridge_fee = leFee ===
|
|
13798
|
-
transfer_assethub_execution_fee =
|
|
13812
|
+
transfer_bridge_fee = leFee === 0n ? DEFAULT_FEE : BigInt(leFee.toString());
|
|
13813
|
+
transfer_assethub_execution_fee = 2200000000n;
|
|
13799
13814
|
return _context.abrupt("return", (transfer_bridge_fee + transfer_assethub_execution_fee).toString());
|
|
13800
13815
|
case 12:
|
|
13801
13816
|
case "end":
|
|
@@ -13803,11 +13818,14 @@ var calculateFee = function calculateFee(api) {
|
|
|
13803
13818
|
}
|
|
13804
13819
|
}, _callee);
|
|
13805
13820
|
}));
|
|
13806
|
-
|
|
13807
|
-
|
|
13808
|
-
|
|
13809
|
-
|
|
13810
|
-
|
|
13821
|
+
return function calculateFee(_x) {
|
|
13822
|
+
return _ref.apply(this, arguments);
|
|
13823
|
+
};
|
|
13824
|
+
}();
|
|
13825
|
+
var createCustomXcmAh = function createCustomXcmAh(_ref2, version) {
|
|
13826
|
+
var api = _ref2.api,
|
|
13827
|
+
scenario = _ref2.scenario,
|
|
13828
|
+
address = _ref2.address;
|
|
13811
13829
|
return _defineProperty({}, version, [{
|
|
13812
13830
|
DepositAsset: {
|
|
13813
13831
|
assets: {
|
|
@@ -13819,13 +13837,13 @@ var createCustomXcmAh = function createCustomXcmAh(_ref, version) {
|
|
|
13819
13837
|
}
|
|
13820
13838
|
}]);
|
|
13821
13839
|
};
|
|
13822
|
-
var createCustomXcmOnDest = function createCustomXcmOnDest(
|
|
13823
|
-
var
|
|
13824
|
-
|
|
13825
|
-
|
|
13826
|
-
|
|
13827
|
-
|
|
13828
|
-
|
|
13840
|
+
var createCustomXcmOnDest = function createCustomXcmOnDest(_ref4, version) {
|
|
13841
|
+
var _asset$assetId;
|
|
13842
|
+
var api = _ref4.api,
|
|
13843
|
+
address = _ref4.address,
|
|
13844
|
+
asset = _ref4.asset,
|
|
13845
|
+
scenario = _ref4.scenario,
|
|
13846
|
+
ahAddress = _ref4.ahAddress;
|
|
13829
13847
|
if (!isForeignAsset(asset)) {
|
|
13830
13848
|
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
|
|
13831
13849
|
}
|
|
@@ -13843,7 +13861,7 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref3, version) {
|
|
|
13843
13861
|
assets: {
|
|
13844
13862
|
Wild: {
|
|
13845
13863
|
AllOf: {
|
|
13846
|
-
id: createEthereumTokenLocation((
|
|
13864
|
+
id: createEthereumTokenLocation((_asset$assetId = asset.assetId) !== null && _asset$assetId !== void 0 ? _asset$assetId : ''),
|
|
13847
13865
|
fun: 'Fungible'
|
|
13848
13866
|
}
|
|
13849
13867
|
}
|
|
@@ -13869,7 +13887,7 @@ var createCustomXcmOnDest = function createCustomXcmOnDest(_ref3, version) {
|
|
|
13869
13887
|
}
|
|
13870
13888
|
},
|
|
13871
13889
|
fun: {
|
|
13872
|
-
Fungible:
|
|
13890
|
+
Fungible: 1n
|
|
13873
13891
|
}
|
|
13874
13892
|
},
|
|
13875
13893
|
weight_limit: 'Unlimited'
|
|
@@ -13905,9 +13923,10 @@ var Hydration$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
13905
13923
|
_inherits(Hydration, _ParachainNode);
|
|
13906
13924
|
return _createClass(Hydration, [{
|
|
13907
13925
|
key: "transferToEthereum",
|
|
13908
|
-
value: function
|
|
13909
|
-
|
|
13910
|
-
var
|
|
13926
|
+
value: function () {
|
|
13927
|
+
var _transferToEthereum = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input) {
|
|
13928
|
+
var _asset$symbol, _asset$assetId2;
|
|
13929
|
+
var api, address, asset, scenario, version, destination, ahAddress, versionOrDefault, ethMultiAsset, fee, call;
|
|
13911
13930
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
13912
13931
|
while (1) switch (_context2.prev = _context2.next) {
|
|
13913
13932
|
case 0:
|
|
@@ -13918,7 +13937,7 @@ var Hydration$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
13918
13937
|
}
|
|
13919
13938
|
throw new Error('Only Ethereum addresses are supported for Ethereum transfers');
|
|
13920
13939
|
case 3:
|
|
13921
|
-
if (!(((
|
|
13940
|
+
if (!(((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toUpperCase()) !== 'WETH')) {
|
|
13922
13941
|
_context2.next = 5;
|
|
13923
13942
|
break;
|
|
13924
13943
|
}
|
|
@@ -13937,7 +13956,7 @@ var Hydration$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
13937
13956
|
throw new Error('AssetHub address is required for Ethereum transfers');
|
|
13938
13957
|
case 9:
|
|
13939
13958
|
versionOrDefault = version !== null && version !== void 0 ? version : exports.Version.V4;
|
|
13940
|
-
ethMultiAsset = Object.values(createCurrencySpec(asset.amount, versionOrDefault, exports.Parents.TWO, createEthereumTokenLocation((
|
|
13959
|
+
ethMultiAsset = Object.values(createCurrencySpec(asset.amount, versionOrDefault, exports.Parents.TWO, createEthereumTokenLocation((_asset$assetId2 = asset.assetId) !== null && _asset$assetId2 !== void 0 ? _asset$assetId2 : '')))[0][0];
|
|
13941
13960
|
_context2.next = 13;
|
|
13942
13961
|
return calculateFee(api);
|
|
13943
13962
|
case 13:
|
|
@@ -13965,7 +13984,11 @@ var Hydration$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
13965
13984
|
}
|
|
13966
13985
|
}, _callee2, this);
|
|
13967
13986
|
}));
|
|
13968
|
-
|
|
13987
|
+
function transferToEthereum(_x2) {
|
|
13988
|
+
return _transferToEthereum.apply(this, arguments);
|
|
13989
|
+
}
|
|
13990
|
+
return transferToEthereum;
|
|
13991
|
+
}()
|
|
13969
13992
|
}, {
|
|
13970
13993
|
key: "transferToAssetHub",
|
|
13971
13994
|
value: function transferToAssetHub(input) {
|
|
@@ -13998,8 +14021,8 @@ var Hydration$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
13998
14021
|
// Handles WETH Ethereum transfers
|
|
13999
14022
|
}, {
|
|
14000
14023
|
key: "transferPolkadotXCM",
|
|
14001
|
-
value: function
|
|
14002
|
-
|
|
14024
|
+
value: function () {
|
|
14025
|
+
var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(input) {
|
|
14003
14026
|
var destination;
|
|
14004
14027
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
14005
14028
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -14018,7 +14041,11 @@ var Hydration$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14018
14041
|
}
|
|
14019
14042
|
}, _callee3, this);
|
|
14020
14043
|
}));
|
|
14021
|
-
|
|
14044
|
+
function transferPolkadotXCM(_x3) {
|
|
14045
|
+
return _transferPolkadotXCM.apply(this, arguments);
|
|
14046
|
+
}
|
|
14047
|
+
return transferPolkadotXCM;
|
|
14048
|
+
}()
|
|
14022
14049
|
}, {
|
|
14023
14050
|
key: "transferXTokens",
|
|
14024
14051
|
value: function transferXTokens(input) {
|
|
@@ -14033,9 +14060,9 @@ var Hydration$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14033
14060
|
}
|
|
14034
14061
|
}, {
|
|
14035
14062
|
key: "canUseXTokens",
|
|
14036
|
-
value: function canUseXTokens(
|
|
14037
|
-
var destination =
|
|
14038
|
-
asset =
|
|
14063
|
+
value: function canUseXTokens(_ref6) {
|
|
14064
|
+
var destination = _ref6.destination,
|
|
14065
|
+
asset = _ref6.asset;
|
|
14039
14066
|
return destination !== 'Ethereum' && !(destination === 'AssetHubPolkadot' && asset.symbol === 'DOT');
|
|
14040
14067
|
}
|
|
14041
14068
|
}]);
|
|
@@ -14109,7 +14136,7 @@ var Moonbeam$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14109
14136
|
version = _input$version === void 0 ? this.version : _input$version,
|
|
14110
14137
|
overriddenAsset = input.overriddenAsset;
|
|
14111
14138
|
var multiLocation = this.getJunctions(asset, scenario);
|
|
14112
|
-
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(
|
|
14139
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(_objectSpread2(_objectSpread2({}, input), {}, {
|
|
14113
14140
|
currencySelection: createCurrencySpec(asset.amount, version, multiLocation.parents, overriddenAsset, multiLocation.interior)
|
|
14114
14141
|
}), 'transfer_assets', 'Unlimited'));
|
|
14115
14142
|
}
|
|
@@ -14332,7 +14359,7 @@ var Moonriver$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14332
14359
|
version = _input$version === void 0 ? this.version : _input$version,
|
|
14333
14360
|
overriddenAsset = input.overriddenAsset;
|
|
14334
14361
|
var multiLocation = this.getJunctions(asset, scenario);
|
|
14335
|
-
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(
|
|
14362
|
+
return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(_objectSpread2(_objectSpread2({}, input), {}, {
|
|
14336
14363
|
currencySelection: createCurrencySpec(asset.amount, version, multiLocation.parents, overriddenAsset, multiLocation.interior)
|
|
14337
14364
|
}), 'transfer_assets', 'Unlimited'));
|
|
14338
14365
|
}
|
|
@@ -14498,9 +14525,9 @@ var generateAddressPayload = function generateAddressPayload(api, scenario, pall
|
|
|
14498
14525
|
return _defineProperty({}, version, {
|
|
14499
14526
|
parents: pallet === 'XTokens' ? exports.Parents.ONE : exports.Parents.ZERO,
|
|
14500
14527
|
interior: createX1Payload(version, {
|
|
14501
|
-
AccountId32:
|
|
14528
|
+
AccountId32: _objectSpread2(_objectSpread2({}, version === exports.Version.V1 && {
|
|
14502
14529
|
network: 'any'
|
|
14503
|
-
}), {
|
|
14530
|
+
}), {}, {
|
|
14504
14531
|
id: api.createAccountId(recipientAddress)
|
|
14505
14532
|
})
|
|
14506
14533
|
})
|
|
@@ -14513,15 +14540,15 @@ var generateAddressPayload = function generateAddressPayload(api, scenario, pall
|
|
|
14513
14540
|
X2: [{
|
|
14514
14541
|
Parachain: nodeId
|
|
14515
14542
|
}, isEthAddress ? {
|
|
14516
|
-
AccountKey20:
|
|
14543
|
+
AccountKey20: _objectSpread2(_objectSpread2({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
|
|
14517
14544
|
network: 'any'
|
|
14518
|
-
}), {
|
|
14545
|
+
}), {}, {
|
|
14519
14546
|
key: recipientAddress
|
|
14520
14547
|
})
|
|
14521
14548
|
} : {
|
|
14522
|
-
AccountId32:
|
|
14549
|
+
AccountId32: _objectSpread2(_objectSpread2({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
|
|
14523
14550
|
network: 'any'
|
|
14524
|
-
}), {
|
|
14551
|
+
}), {}, {
|
|
14525
14552
|
id: api.createAccountId(recipientAddress)
|
|
14526
14553
|
})
|
|
14527
14554
|
}]
|
|
@@ -14532,15 +14559,15 @@ var generateAddressPayload = function generateAddressPayload(api, scenario, pall
|
|
|
14532
14559
|
return _defineProperty({}, version, {
|
|
14533
14560
|
parents: exports.Parents.ZERO,
|
|
14534
14561
|
interior: createX1Payload(version, isEthAddress ? {
|
|
14535
|
-
AccountKey20:
|
|
14562
|
+
AccountKey20: _objectSpread2(_objectSpread2({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
|
|
14536
14563
|
network: 'any'
|
|
14537
|
-
}), {
|
|
14564
|
+
}), {}, {
|
|
14538
14565
|
key: recipientAddress
|
|
14539
14566
|
})
|
|
14540
14567
|
} : {
|
|
14541
|
-
AccountId32:
|
|
14568
|
+
AccountId32: _objectSpread2(_objectSpread2({}, (version === exports.Version.V1 || version === exports.Version.V2) && {
|
|
14542
14569
|
network: 'any'
|
|
14543
|
-
}), {
|
|
14570
|
+
}), {}, {
|
|
14544
14571
|
id: api.createAccountId(recipientAddress)
|
|
14545
14572
|
})
|
|
14546
14573
|
})
|
|
@@ -14579,7 +14606,7 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14579
14606
|
_classCallCheck(this, AssetHubPolkadot);
|
|
14580
14607
|
_this = _callSuper(this, AssetHubPolkadot, ['AssetHubPolkadot', 'PolkadotAssetHub', 'polkadot', exports.Version.V3]);
|
|
14581
14608
|
_this.handleBifrostEthTransfer = function (input) {
|
|
14582
|
-
var
|
|
14609
|
+
var _asset$assetId;
|
|
14583
14610
|
var api = input.api,
|
|
14584
14611
|
scenario = input.scenario,
|
|
14585
14612
|
version = input.version,
|
|
@@ -14589,7 +14616,7 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14589
14616
|
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset), " has no assetId"));
|
|
14590
14617
|
}
|
|
14591
14618
|
var versionOrDefault = version !== null && version !== void 0 ? version : _this.version;
|
|
14592
|
-
var ethereumTokenLocation = createEthereumTokenLocation((
|
|
14619
|
+
var ethereumTokenLocation = createEthereumTokenLocation((_asset$assetId = asset.assetId) !== null && _asset$assetId !== void 0 ? _asset$assetId : '');
|
|
14593
14620
|
var call = {
|
|
14594
14621
|
module: 'PolkadotXcm',
|
|
14595
14622
|
section: 'transfer_assets_using_type_and_then',
|
|
@@ -14613,16 +14640,16 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14613
14640
|
return _createClass(AssetHubPolkadot, [{
|
|
14614
14641
|
key: "handleBridgeTransfer",
|
|
14615
14642
|
value: function handleBridgeTransfer(input, targetChain) {
|
|
14616
|
-
var
|
|
14617
|
-
if (targetChain === 'Kusama' && ((
|
|
14618
|
-
var modifiedInput =
|
|
14643
|
+
var _input$asset$symbol, _input$asset$symbol2, _input$asset$symbol3, _input$asset$symbol4;
|
|
14644
|
+
if (targetChain === 'Kusama' && ((_input$asset$symbol = input.asset.symbol) === null || _input$asset$symbol === void 0 ? void 0 : _input$asset$symbol.toUpperCase()) === 'KSM' || targetChain === 'Polkadot' && ((_input$asset$symbol2 = input.asset.symbol) === null || _input$asset$symbol2 === void 0 ? void 0 : _input$asset$symbol2.toUpperCase()) === 'DOT') {
|
|
14645
|
+
var modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
|
|
14619
14646
|
header: createBridgePolkadotXcmDest(exports.Version.V4, targetChain, input.destination, input.paraIdTo),
|
|
14620
14647
|
addressSelection: generateAddressMultiLocationV4(input.api, input.address),
|
|
14621
14648
|
currencySelection: createBridgeCurrencySpec(input.asset.amount, targetChain)
|
|
14622
14649
|
});
|
|
14623
14650
|
return PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, 'transfer_assets', 'Unlimited');
|
|
14624
|
-
} else if (targetChain === 'Polkadot' && ((
|
|
14625
|
-
var _modifiedInput =
|
|
14651
|
+
} else if (targetChain === 'Polkadot' && ((_input$asset$symbol3 = input.asset.symbol) === null || _input$asset$symbol3 === void 0 ? void 0 : _input$asset$symbol3.toUpperCase()) === 'KSM' || targetChain === 'Kusama' && ((_input$asset$symbol4 = input.asset.symbol) === null || _input$asset$symbol4 === void 0 ? void 0 : _input$asset$symbol4.toUpperCase()) === 'DOT') {
|
|
14652
|
+
var _modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
|
|
14626
14653
|
header: createBridgePolkadotXcmDest(exports.Version.V3, targetChain, input.destination, input.paraIdTo),
|
|
14627
14654
|
currencySelection: createCurrencySpec(input.asset.amount, exports.Version.V3, exports.Parents.ONE, input.overriddenAsset)
|
|
14628
14655
|
});
|
|
@@ -14633,7 +14660,7 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14633
14660
|
}, {
|
|
14634
14661
|
key: "handleEthBridgeTransfer",
|
|
14635
14662
|
value: function handleEthBridgeTransfer(input) {
|
|
14636
|
-
var
|
|
14663
|
+
var _ethAsset$assetId;
|
|
14637
14664
|
var api = input.api,
|
|
14638
14665
|
scenario = input.scenario,
|
|
14639
14666
|
destination = input.destination,
|
|
@@ -14650,7 +14677,7 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14650
14677
|
if (!ethAsset) {
|
|
14651
14678
|
throw new InvalidCurrencyError("Currency ".concat(asset.symbol, " is not supported for Ethereum transfers"));
|
|
14652
14679
|
}
|
|
14653
|
-
var modifiedInput =
|
|
14680
|
+
var modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
|
|
14654
14681
|
header: createPolkadotXcmHeader(scenario, this.version, destination, paraIdTo, ETHEREUM_JUNCTION, exports.Parents.TWO),
|
|
14655
14682
|
addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, this.version, paraIdTo),
|
|
14656
14683
|
currencySelection: createCurrencySpec(input.asset.amount, exports.Version.V3, exports.Parents.TWO, {
|
|
@@ -14658,7 +14685,7 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14658
14685
|
interior: {
|
|
14659
14686
|
X2: [ETHEREUM_JUNCTION, {
|
|
14660
14687
|
AccountKey20: {
|
|
14661
|
-
key: (
|
|
14688
|
+
key: (_ethAsset$assetId = ethAsset.assetId) !== null && _ethAsset$assetId !== void 0 ? _ethAsset$assetId : ''
|
|
14662
14689
|
}
|
|
14663
14690
|
}]
|
|
14664
14691
|
}
|
|
@@ -14687,7 +14714,7 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14687
14714
|
}
|
|
14688
14715
|
}
|
|
14689
14716
|
};
|
|
14690
|
-
var modifiedInput =
|
|
14717
|
+
var modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
|
|
14691
14718
|
header: this.createPolkadotXcmHeader(scenario, version, destination, paraId),
|
|
14692
14719
|
addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, version, paraId),
|
|
14693
14720
|
currencySelection: this.createCurrencySpec(asset.amount, scenario, version, asset, overriddenAsset !== null && overriddenAsset !== void 0 ? overriddenAsset : customMultiLocation)
|
|
@@ -14697,7 +14724,7 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14697
14724
|
}, {
|
|
14698
14725
|
key: "patchInput",
|
|
14699
14726
|
value: function patchInput(input) {
|
|
14700
|
-
var
|
|
14727
|
+
var _asset$symbol, _asset$symbol2;
|
|
14701
14728
|
var asset = input.asset,
|
|
14702
14729
|
destination = input.destination,
|
|
14703
14730
|
paraIdTo = input.paraIdTo,
|
|
@@ -14706,9 +14733,10 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14706
14733
|
api = input.api,
|
|
14707
14734
|
version = input.version,
|
|
14708
14735
|
address = input.address;
|
|
14709
|
-
if ((((
|
|
14710
|
-
var
|
|
14711
|
-
|
|
14736
|
+
if ((((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toUpperCase()) === 'USDT' || ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === void 0 ? void 0 : _asset$symbol2.toUpperCase()) === 'USDC') && destination === 'BifrostPolkadot') {
|
|
14737
|
+
var _input$version;
|
|
14738
|
+
var versionOrDefault = (_input$version = input.version) !== null && _input$version !== void 0 ? _input$version : exports.Version.V2;
|
|
14739
|
+
return _objectSpread2(_objectSpread2({}, input), {}, {
|
|
14712
14740
|
header: this.createPolkadotXcmHeader(scenario, versionOrDefault, destination, paraIdTo),
|
|
14713
14741
|
addressSelection: generateAddressPayload(api, scenario, 'PolkadotXcm', address, versionOrDefault, paraIdTo),
|
|
14714
14742
|
currencySelection: this.createCurrencySpec(asset.amount, scenario, versionOrDefault, asset, overriddenAsset)
|
|
@@ -14716,7 +14744,7 @@ var AssetHubPolkadot$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
14716
14744
|
}
|
|
14717
14745
|
if ((destination === 'Hydration' || destination === 'Polimec') && asset.symbol === 'DOT') {
|
|
14718
14746
|
var _versionOrDefault = version !== null && version !== void 0 ? version : this.version;
|
|
14719
|
-
return
|
|
14747
|
+
return _objectSpread2(_objectSpread2({}, input), {}, {
|
|
14720
14748
|
currencySelection: _superPropGet(AssetHubPolkadot, "createCurrencySpec", this, 3)([asset.amount, 'ParaToRelay', _versionOrDefault, asset, overriddenAsset])
|
|
14721
14749
|
});
|
|
14722
14750
|
}
|
|
@@ -15355,7 +15383,6 @@ var XTransferTransferImpl = /*#__PURE__*/function () {
|
|
|
15355
15383
|
return _createClass(XTransferTransferImpl, null, [{
|
|
15356
15384
|
key: "transferXTransfer",
|
|
15357
15385
|
value: function transferXTransfer(input) {
|
|
15358
|
-
var _a;
|
|
15359
15386
|
var api = input.api,
|
|
15360
15387
|
origin = input.origin,
|
|
15361
15388
|
destination = input.destination,
|
|
@@ -15372,7 +15399,7 @@ var XTransferTransferImpl = /*#__PURE__*/function () {
|
|
|
15372
15399
|
var section = 'transfer';
|
|
15373
15400
|
var destWeight = origin === 'Khala' ? null : determineDestWeight(destination);
|
|
15374
15401
|
var call = {
|
|
15375
|
-
module:
|
|
15402
|
+
module: pallet !== null && pallet !== void 0 ? pallet : 'XTransfer',
|
|
15376
15403
|
section: method !== null && method !== void 0 ? method : section,
|
|
15377
15404
|
parameters: {
|
|
15378
15405
|
asset: currencySpec,
|
|
@@ -15601,7 +15628,7 @@ var Peaq$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
15601
15628
|
}]);
|
|
15602
15629
|
}(ParachainNode);
|
|
15603
15630
|
|
|
15604
|
-
var GAS_LIMIT =
|
|
15631
|
+
var GAS_LIMIT = 1000000000n;
|
|
15605
15632
|
var createCustomXcmPolimec = function createCustomXcmPolimec(api, address, scenario, destination, paraIdTo, version) {
|
|
15606
15633
|
var isRelayDestination = !isTMultiLocation(destination) && isRelayChain(destination);
|
|
15607
15634
|
var paraId = !isRelayDestination && _typeof(destination) !== 'object' && destination !== 'Ethereum' ? paraIdTo !== null && paraIdTo !== void 0 ? paraIdTo : getParaId(destination) : undefined;
|
|
@@ -15623,7 +15650,7 @@ var createCustomXcmPolimec = function createCustomXcmPolimec(api, address, scena
|
|
|
15623
15650
|
}
|
|
15624
15651
|
},
|
|
15625
15652
|
fun: {
|
|
15626
|
-
Fungible:
|
|
15653
|
+
Fungible: GAS_LIMIT
|
|
15627
15654
|
}
|
|
15628
15655
|
},
|
|
15629
15656
|
weight_limit: 'Unlimited'
|
|
@@ -15660,8 +15687,8 @@ var Polimec$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
15660
15687
|
_inherits(Polimec, _ParachainNode);
|
|
15661
15688
|
return _createClass(Polimec, [{
|
|
15662
15689
|
key: "transferPolkadotXCM",
|
|
15663
|
-
value: function
|
|
15664
|
-
|
|
15690
|
+
value: function () {
|
|
15691
|
+
var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(input) {
|
|
15665
15692
|
var api, _input$version, version, asset, destination, address, scenario, paraIdTo, currencySelection, versionOrDefault, call;
|
|
15666
15693
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
15667
15694
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -15672,7 +15699,7 @@ var Polimec$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
15672
15699
|
break;
|
|
15673
15700
|
}
|
|
15674
15701
|
currencySelection = _defineProperty({}, version, [createMultiAsset(version, asset.amount.toString(), this.getAssetMultiLocation(input.asset))]);
|
|
15675
|
-
return _context.abrupt("return", Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(
|
|
15702
|
+
return _context.abrupt("return", Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(_objectSpread2(_objectSpread2({}, input), {}, {
|
|
15676
15703
|
currencySelection: currencySelection
|
|
15677
15704
|
}), 'transfer_assets', 'Unlimited')));
|
|
15678
15705
|
case 4:
|
|
@@ -15708,7 +15735,11 @@ var Polimec$1 = /*#__PURE__*/function (_ParachainNode) {
|
|
|
15708
15735
|
}
|
|
15709
15736
|
}, _callee, this);
|
|
15710
15737
|
}));
|
|
15711
|
-
|
|
15738
|
+
function transferPolkadotXCM(_x) {
|
|
15739
|
+
return _transferPolkadotXCM.apply(this, arguments);
|
|
15740
|
+
}
|
|
15741
|
+
return transferPolkadotXCM;
|
|
15742
|
+
}()
|
|
15712
15743
|
}, {
|
|
15713
15744
|
key: "transferRelayToPara",
|
|
15714
15745
|
value: function transferRelayToPara(options) {
|
|
@@ -15850,8 +15881,8 @@ var findBestMatches = function findBestMatches(assets, value) {
|
|
|
15850
15881
|
}
|
|
15851
15882
|
// Case-insensitive match
|
|
15852
15883
|
matches = assets.filter(function (asset) {
|
|
15853
|
-
var
|
|
15854
|
-
return ((
|
|
15884
|
+
var _asset$property;
|
|
15885
|
+
return ((_asset$property = asset[property]) === null || _asset$property === void 0 ? void 0 : _asset$property.toLowerCase()) === lowerValue;
|
|
15855
15886
|
});
|
|
15856
15887
|
return matches;
|
|
15857
15888
|
};
|
|
@@ -16031,9 +16062,9 @@ var findAssetByMultiLocation = function findAssetByMultiLocation(foreignAssets,
|
|
|
16031
16062
|
if (typeof multiLocation === 'string') {
|
|
16032
16063
|
var sanitizedInput = sanitizeMultiLocation(multiLocation);
|
|
16033
16064
|
return foreignAssets.find(function (asset) {
|
|
16034
|
-
var
|
|
16035
|
-
var assetMLStr = JSON.stringify((
|
|
16036
|
-
var assetMLInteriorStr = JSON.stringify((
|
|
16065
|
+
var _asset$multiLocation, _asset$xcmInterior;
|
|
16066
|
+
var assetMLStr = JSON.stringify((_asset$multiLocation = asset.multiLocation) !== null && _asset$multiLocation !== void 0 ? _asset$multiLocation : '');
|
|
16067
|
+
var assetMLInteriorStr = JSON.stringify((_asset$xcmInterior = asset.xcmInterior) !== null && _asset$xcmInterior !== void 0 ? _asset$xcmInterior : '');
|
|
16037
16068
|
var sanitizedAssetMLStr = sanitizeMultiLocation(assetMLStr);
|
|
16038
16069
|
var sanitizedAssetMLInteriorStr = sanitizeMultiLocation(assetMLInteriorStr);
|
|
16039
16070
|
return (
|
|
@@ -16089,16 +16120,17 @@ var getAssetBySymbolOrId = function getAssetBySymbolOrId(node, currency, destina
|
|
|
16089
16120
|
* @returns The existential deposit as a string if available; otherwise, null.
|
|
16090
16121
|
*/
|
|
16091
16122
|
var getExistentialDeposit = function getExistentialDeposit(node, currency) {
|
|
16092
|
-
var
|
|
16123
|
+
var _getAssetBySymbolOrId, _asset$existentialDep;
|
|
16093
16124
|
var assetsObject = getAssetsObject(node);
|
|
16094
16125
|
if (!currency) {
|
|
16095
|
-
|
|
16126
|
+
var _assetsObject$nativeA;
|
|
16127
|
+
return (_assetsObject$nativeA = assetsObject.nativeAssets[0].existentialDeposit) !== null && _assetsObject$nativeA !== void 0 ? _assetsObject$nativeA : null;
|
|
16096
16128
|
}
|
|
16097
|
-
var asset = (
|
|
16129
|
+
var asset = (_getAssetBySymbolOrId = getAssetBySymbolOrId(node, currency, null)) !== null && _getAssetBySymbolOrId !== void 0 ? _getAssetBySymbolOrId : node === 'AssetHubPolkadot' ? getAssetBySymbolOrId('Ethereum', currency, null) : null;
|
|
16098
16130
|
if (!asset) {
|
|
16099
16131
|
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(node));
|
|
16100
16132
|
}
|
|
16101
|
-
return (
|
|
16133
|
+
return (_asset$existentialDep = asset.existentialDeposit) !== null && _asset$existentialDep !== void 0 ? _asset$existentialDep : null;
|
|
16102
16134
|
};
|
|
16103
16135
|
|
|
16104
16136
|
var assetsMap = assetsMapJson;
|
|
@@ -16251,13 +16283,13 @@ var getAssetDecimals = function getAssetDecimals(node, symbol) {
|
|
|
16251
16283
|
* @returns The node name if found; otherwise, null.
|
|
16252
16284
|
*/
|
|
16253
16285
|
var getTNode = function getTNode(paraId, ecosystem) {
|
|
16254
|
-
var
|
|
16286
|
+
var _NODE_NAMES_DOT_KSM$f;
|
|
16255
16287
|
if (paraId === 0) {
|
|
16256
16288
|
return ecosystem === 'polkadot' ? 'Polkadot' : 'Kusama';
|
|
16257
16289
|
}
|
|
16258
|
-
return (
|
|
16290
|
+
return (_NODE_NAMES_DOT_KSM$f = NODE_NAMES_DOT_KSM.find(function (nodeName) {
|
|
16259
16291
|
return getNode(nodeName).type === ecosystem && getParaId(nodeName) === paraId;
|
|
16260
|
-
})) !== null &&
|
|
16292
|
+
})) !== null && _NODE_NAMES_DOT_KSM$f !== void 0 ? _NODE_NAMES_DOT_KSM$f : null;
|
|
16261
16293
|
};
|
|
16262
16294
|
|
|
16263
16295
|
var AssetHubPolkadot = {
|
|
@@ -17087,8 +17119,8 @@ var getSupportedPalletsDetails = function getSupportedPalletsDetails(node) {
|
|
|
17087
17119
|
return palletsMap[node].supportedPallets;
|
|
17088
17120
|
};
|
|
17089
17121
|
|
|
17090
|
-
var getBalanceForeignPolkadotXcm = function
|
|
17091
|
-
|
|
17122
|
+
var getBalanceForeignPolkadotXcm = /*#__PURE__*/function () {
|
|
17123
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, node, address, asset) {
|
|
17092
17124
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17093
17125
|
while (1) switch (_context.prev = _context.next) {
|
|
17094
17126
|
case 0:
|
|
@@ -17147,10 +17179,13 @@ var getBalanceForeignPolkadotXcm = function getBalanceForeignPolkadotXcm(api, no
|
|
|
17147
17179
|
}
|
|
17148
17180
|
}, _callee);
|
|
17149
17181
|
}));
|
|
17150
|
-
|
|
17182
|
+
return function getBalanceForeignPolkadotXcm(_x, _x2, _x3, _x4) {
|
|
17183
|
+
return _ref.apply(this, arguments);
|
|
17184
|
+
};
|
|
17185
|
+
}();
|
|
17151
17186
|
|
|
17152
|
-
var getBalanceForeignXTokens = function
|
|
17153
|
-
|
|
17187
|
+
var getBalanceForeignXTokens = /*#__PURE__*/function () {
|
|
17188
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, node, address, asset) {
|
|
17154
17189
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17155
17190
|
while (1) switch (_context.prev = _context.next) {
|
|
17156
17191
|
case 0:
|
|
@@ -17179,53 +17214,55 @@ var getBalanceForeignXTokens = function getBalanceForeignXTokens(api, node, addr
|
|
|
17179
17214
|
}
|
|
17180
17215
|
}, _callee);
|
|
17181
17216
|
}));
|
|
17182
|
-
|
|
17217
|
+
return function getBalanceForeignXTokens(_x, _x2, _x3, _x4) {
|
|
17218
|
+
return _ref.apply(this, arguments);
|
|
17219
|
+
};
|
|
17220
|
+
}();
|
|
17183
17221
|
|
|
17184
|
-
var getBalanceForeignInternal = function
|
|
17185
|
-
|
|
17186
|
-
var
|
|
17187
|
-
|
|
17188
|
-
|
|
17189
|
-
|
|
17190
|
-
|
|
17191
|
-
|
|
17192
|
-
|
|
17193
|
-
|
|
17194
|
-
|
|
17195
|
-
|
|
17196
|
-
|
|
17197
|
-
|
|
17198
|
-
|
|
17199
|
-
|
|
17200
|
-
|
|
17201
|
-
|
|
17202
|
-
|
|
17203
|
-
|
|
17204
|
-
|
|
17205
|
-
|
|
17206
|
-
|
|
17207
|
-
|
|
17208
|
-
|
|
17209
|
-
|
|
17210
|
-
|
|
17211
|
-
|
|
17212
|
-
|
|
17213
|
-
|
|
17214
|
-
|
|
17215
|
-
|
|
17216
|
-
|
|
17217
|
-
|
|
17218
|
-
|
|
17219
|
-
|
|
17220
|
-
|
|
17221
|
-
|
|
17222
|
-
|
|
17223
|
-
|
|
17224
|
-
|
|
17225
|
-
|
|
17226
|
-
|
|
17227
|
-
var
|
|
17228
|
-
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
17222
|
+
var getBalanceForeignInternal = /*#__PURE__*/function () {
|
|
17223
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
17224
|
+
var _getAssetBySymbolOrId;
|
|
17225
|
+
var address, node, currency, api, asset, defaultPallet;
|
|
17226
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17227
|
+
while (1) switch (_context.prev = _context.next) {
|
|
17228
|
+
case 0:
|
|
17229
|
+
address = _ref.address, node = _ref.node, currency = _ref.currency, api = _ref.api;
|
|
17230
|
+
_context.next = 3;
|
|
17231
|
+
return api.init(node);
|
|
17232
|
+
case 3:
|
|
17233
|
+
asset = (_getAssetBySymbolOrId = getAssetBySymbolOrId(node, currency, null)) !== null && _getAssetBySymbolOrId !== void 0 ? _getAssetBySymbolOrId : node === 'AssetHubPolkadot' ? getAssetBySymbolOrId('Ethereum', currency, null) : null;
|
|
17234
|
+
if (asset) {
|
|
17235
|
+
_context.next = 6;
|
|
17236
|
+
break;
|
|
17237
|
+
}
|
|
17238
|
+
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(node));
|
|
17239
|
+
case 6:
|
|
17240
|
+
defaultPallet = getDefaultPallet(node);
|
|
17241
|
+
if (!(defaultPallet === 'XTokens')) {
|
|
17242
|
+
_context.next = 11;
|
|
17243
|
+
break;
|
|
17244
|
+
}
|
|
17245
|
+
return _context.abrupt("return", getBalanceForeignXTokens(api, node, address, asset));
|
|
17246
|
+
case 11:
|
|
17247
|
+
if (!(defaultPallet === 'PolkadotXcm')) {
|
|
17248
|
+
_context.next = 13;
|
|
17249
|
+
break;
|
|
17250
|
+
}
|
|
17251
|
+
return _context.abrupt("return", getBalanceForeignPolkadotXcm(api, node, address, asset));
|
|
17252
|
+
case 13:
|
|
17253
|
+
throw new Error('Unsupported pallet');
|
|
17254
|
+
case 14:
|
|
17255
|
+
case "end":
|
|
17256
|
+
return _context.stop();
|
|
17257
|
+
}
|
|
17258
|
+
}, _callee);
|
|
17259
|
+
}));
|
|
17260
|
+
return function getBalanceForeignInternal(_x) {
|
|
17261
|
+
return _ref2.apply(this, arguments);
|
|
17262
|
+
};
|
|
17263
|
+
}();
|
|
17264
|
+
var getBalanceForeign = /*#__PURE__*/function () {
|
|
17265
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
17229
17266
|
var api;
|
|
17230
17267
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
17231
17268
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -17248,59 +17285,60 @@ var getBalanceForeign = function getBalanceForeign(options) {
|
|
|
17248
17285
|
}
|
|
17249
17286
|
}, _callee2, null, [[1,, 5, 9]]);
|
|
17250
17287
|
}));
|
|
17251
|
-
|
|
17288
|
+
return function getBalanceForeign(_x2) {
|
|
17289
|
+
return _ref3.apply(this, arguments);
|
|
17290
|
+
};
|
|
17291
|
+
}();
|
|
17252
17292
|
|
|
17253
|
-
var getBalanceNativeInternal = function
|
|
17254
|
-
|
|
17255
|
-
var address
|
|
17256
|
-
|
|
17257
|
-
|
|
17258
|
-
|
|
17259
|
-
|
|
17260
|
-
|
|
17261
|
-
|
|
17262
|
-
|
|
17263
|
-
|
|
17264
|
-
_context.next =
|
|
17265
|
-
|
|
17266
|
-
|
|
17267
|
-
|
|
17268
|
-
|
|
17269
|
-
|
|
17270
|
-
|
|
17271
|
-
|
|
17272
|
-
|
|
17273
|
-
node: node,
|
|
17274
|
-
api: api,
|
|
17275
|
-
currency: {
|
|
17276
|
-
symbol: currency ? currency.symbol : getAssetsObject(node).nativeAssetSymbol
|
|
17277
|
-
}
|
|
17278
|
-
}));
|
|
17279
|
-
case 4:
|
|
17280
|
-
if (!(currency && currency.symbol !== getNativeAssetSymbol(node) && (node === 'Acala' || node === 'Karura'))) {
|
|
17281
|
-
_context.next = 9;
|
|
17282
|
-
break;
|
|
17283
|
-
}
|
|
17284
|
-
symbol = currency.symbol === 'aSEED' ? 'AUSD' : currency.symbol;
|
|
17285
|
-
if (!(symbol.toLowerCase() === 'lcdot')) {
|
|
17286
|
-
_context.next = 8;
|
|
17287
|
-
break;
|
|
17293
|
+
var getBalanceNativeInternal = /*#__PURE__*/function () {
|
|
17294
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
17295
|
+
var address, node, api, currency, symbol;
|
|
17296
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17297
|
+
while (1) switch (_context.prev = _context.next) {
|
|
17298
|
+
case 0:
|
|
17299
|
+
address = _ref.address, node = _ref.node, api = _ref.api, currency = _ref.currency;
|
|
17300
|
+
_context.next = 3;
|
|
17301
|
+
return api.init(node);
|
|
17302
|
+
case 3:
|
|
17303
|
+
if (!(node === 'Interlay' || node === 'Kintsugi')) {
|
|
17304
|
+
_context.next = 5;
|
|
17305
|
+
break;
|
|
17306
|
+
}
|
|
17307
|
+
return _context.abrupt("return", getBalanceForeignInternal({
|
|
17308
|
+
address: address,
|
|
17309
|
+
node: node,
|
|
17310
|
+
api: api,
|
|
17311
|
+
currency: {
|
|
17312
|
+
symbol: currency ? currency.symbol : getAssetsObject(node).nativeAssetSymbol
|
|
17288
17313
|
}
|
|
17289
|
-
|
|
17290
|
-
|
|
17291
|
-
|
|
17292
|
-
|
|
17293
|
-
|
|
17294
|
-
|
|
17295
|
-
|
|
17296
|
-
|
|
17297
|
-
|
|
17298
|
-
|
|
17299
|
-
|
|
17300
|
-
|
|
17301
|
-
|
|
17302
|
-
|
|
17303
|
-
|
|
17314
|
+
}));
|
|
17315
|
+
case 5:
|
|
17316
|
+
if (!(currency && currency.symbol !== getNativeAssetSymbol(node) && (node === 'Acala' || node === 'Karura'))) {
|
|
17317
|
+
_context.next = 10;
|
|
17318
|
+
break;
|
|
17319
|
+
}
|
|
17320
|
+
symbol = currency.symbol === 'aSEED' ? 'AUSD' : currency.symbol;
|
|
17321
|
+
if (!(symbol.toLowerCase() === 'lcdot')) {
|
|
17322
|
+
_context.next = 9;
|
|
17323
|
+
break;
|
|
17324
|
+
}
|
|
17325
|
+
throw new InvalidCurrencyError('LcDOT balance is not supported');
|
|
17326
|
+
case 9:
|
|
17327
|
+
return _context.abrupt("return", api.getBalanceNativeAcala(address, symbol));
|
|
17328
|
+
case 10:
|
|
17329
|
+
return _context.abrupt("return", api.getBalanceNative(address));
|
|
17330
|
+
case 11:
|
|
17331
|
+
case "end":
|
|
17332
|
+
return _context.stop();
|
|
17333
|
+
}
|
|
17334
|
+
}, _callee);
|
|
17335
|
+
}));
|
|
17336
|
+
return function getBalanceNativeInternal(_x) {
|
|
17337
|
+
return _ref2.apply(this, arguments);
|
|
17338
|
+
};
|
|
17339
|
+
}();
|
|
17340
|
+
var getBalanceNative = /*#__PURE__*/function () {
|
|
17341
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
17304
17342
|
var api;
|
|
17305
17343
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
17306
17344
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -17323,77 +17361,79 @@ var getBalanceNative = function getBalanceNative(options) {
|
|
|
17323
17361
|
}
|
|
17324
17362
|
}, _callee2, null, [[1,, 5, 9]]);
|
|
17325
17363
|
}));
|
|
17326
|
-
|
|
17364
|
+
return function getBalanceNative(_x2) {
|
|
17365
|
+
return _ref3.apply(this, arguments);
|
|
17366
|
+
};
|
|
17367
|
+
}();
|
|
17327
17368
|
|
|
17328
|
-
var getAssetBalanceInternal = function
|
|
17329
|
-
|
|
17330
|
-
var
|
|
17331
|
-
|
|
17332
|
-
|
|
17333
|
-
|
|
17334
|
-
|
|
17335
|
-
|
|
17336
|
-
|
|
17337
|
-
|
|
17338
|
-
|
|
17339
|
-
|
|
17340
|
-
|
|
17341
|
-
|
|
17342
|
-
isNativeSymbol = 'symbol' in currency ? getNativeAssetSymbol(node) === currency.symbol : false;
|
|
17343
|
-
if (!(isNativeSymbol && node !== 'Interlay' && node !== 'Kintsugi')) {
|
|
17344
|
-
_context.next = 9;
|
|
17345
|
-
break;
|
|
17346
|
-
}
|
|
17347
|
-
_context.next = 6;
|
|
17348
|
-
return getBalanceNativeInternal({
|
|
17349
|
-
address: address,
|
|
17350
|
-
node: node,
|
|
17351
|
-
api: api
|
|
17352
|
-
});
|
|
17353
|
-
case 6:
|
|
17354
|
-
_context.t0 = _context.sent;
|
|
17355
|
-
_context.next = 21;
|
|
17369
|
+
var getAssetBalanceInternal = /*#__PURE__*/function () {
|
|
17370
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
17371
|
+
var _yield$getBalanceFore;
|
|
17372
|
+
var address, node, currency, api, isNativeSymbol;
|
|
17373
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17374
|
+
while (1) switch (_context.prev = _context.next) {
|
|
17375
|
+
case 0:
|
|
17376
|
+
address = _ref.address, node = _ref.node, currency = _ref.currency, api = _ref.api;
|
|
17377
|
+
_context.next = 3;
|
|
17378
|
+
return api.init(node);
|
|
17379
|
+
case 3:
|
|
17380
|
+
isNativeSymbol = 'symbol' in currency ? getNativeAssetSymbol(node) === currency.symbol : false;
|
|
17381
|
+
if (!(isNativeSymbol && node !== 'Interlay' && node !== 'Kintsugi')) {
|
|
17382
|
+
_context.next = 10;
|
|
17356
17383
|
break;
|
|
17357
|
-
|
|
17358
|
-
|
|
17359
|
-
|
|
17360
|
-
|
|
17361
|
-
|
|
17362
|
-
|
|
17363
|
-
|
|
17364
|
-
|
|
17365
|
-
|
|
17366
|
-
|
|
17367
|
-
|
|
17368
|
-
|
|
17369
|
-
|
|
17370
|
-
|
|
17371
|
-
|
|
17372
|
-
|
|
17373
|
-
|
|
17374
|
-
|
|
17375
|
-
|
|
17376
|
-
|
|
17377
|
-
|
|
17378
|
-
|
|
17384
|
+
}
|
|
17385
|
+
_context.next = 7;
|
|
17386
|
+
return getBalanceNativeInternal({
|
|
17387
|
+
address: address,
|
|
17388
|
+
node: node,
|
|
17389
|
+
api: api
|
|
17390
|
+
});
|
|
17391
|
+
case 7:
|
|
17392
|
+
_context.t0 = _context.sent;
|
|
17393
|
+
_context.next = 22;
|
|
17394
|
+
break;
|
|
17395
|
+
case 10:
|
|
17396
|
+
_context.next = 12;
|
|
17397
|
+
return getBalanceForeignInternal({
|
|
17398
|
+
address: address,
|
|
17399
|
+
node: node,
|
|
17400
|
+
api: api,
|
|
17401
|
+
currency: currency
|
|
17402
|
+
});
|
|
17403
|
+
case 12:
|
|
17404
|
+
_context.t2 = _yield$getBalanceFore = _context.sent;
|
|
17405
|
+
_context.t1 = _context.t2 !== null;
|
|
17406
|
+
if (!_context.t1) {
|
|
17407
|
+
_context.next = 16;
|
|
17408
|
+
break;
|
|
17409
|
+
}
|
|
17410
|
+
_context.t1 = _yield$getBalanceFore !== void 0;
|
|
17411
|
+
case 16:
|
|
17412
|
+
if (!_context.t1) {
|
|
17379
17413
|
_context.next = 20;
|
|
17380
17414
|
break;
|
|
17381
|
-
|
|
17382
|
-
|
|
17383
|
-
|
|
17384
|
-
|
|
17385
|
-
|
|
17386
|
-
|
|
17387
|
-
|
|
17388
|
-
|
|
17389
|
-
|
|
17390
|
-
|
|
17391
|
-
|
|
17392
|
-
|
|
17393
|
-
|
|
17394
|
-
}
|
|
17395
|
-
|
|
17396
|
-
|
|
17415
|
+
}
|
|
17416
|
+
_context.t3 = _yield$getBalanceFore;
|
|
17417
|
+
_context.next = 21;
|
|
17418
|
+
break;
|
|
17419
|
+
case 20:
|
|
17420
|
+
_context.t3 = 0n;
|
|
17421
|
+
case 21:
|
|
17422
|
+
_context.t0 = _context.t3;
|
|
17423
|
+
case 22:
|
|
17424
|
+
return _context.abrupt("return", _context.t0);
|
|
17425
|
+
case 23:
|
|
17426
|
+
case "end":
|
|
17427
|
+
return _context.stop();
|
|
17428
|
+
}
|
|
17429
|
+
}, _callee);
|
|
17430
|
+
}));
|
|
17431
|
+
return function getAssetBalanceInternal(_x) {
|
|
17432
|
+
return _ref2.apply(this, arguments);
|
|
17433
|
+
};
|
|
17434
|
+
}();
|
|
17435
|
+
var getAssetBalance = /*#__PURE__*/function () {
|
|
17436
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
17397
17437
|
var api;
|
|
17398
17438
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
17399
17439
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -17416,7 +17456,10 @@ var getAssetBalance = function getAssetBalance(options) {
|
|
|
17416
17456
|
}
|
|
17417
17457
|
}, _callee2, null, [[1,, 5, 9]]);
|
|
17418
17458
|
}));
|
|
17419
|
-
|
|
17459
|
+
return function getAssetBalance(_x2) {
|
|
17460
|
+
return _ref3.apply(this, arguments);
|
|
17461
|
+
};
|
|
17462
|
+
}();
|
|
17420
17463
|
|
|
17421
17464
|
var isPjsClient = function isPjsClient(api) {
|
|
17422
17465
|
return _typeof(api) === 'object' && api !== null && 'disconnect' in api && typeof api.disconnect === 'function';
|
|
@@ -17455,8 +17498,8 @@ var buildClaimAssetsInput = function buildClaimAssetsInput(_ref) {
|
|
|
17455
17498
|
};
|
|
17456
17499
|
};
|
|
17457
17500
|
|
|
17458
|
-
var claimAssets = function
|
|
17459
|
-
|
|
17501
|
+
var claimAssets = /*#__PURE__*/function () {
|
|
17502
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
17460
17503
|
var api, node, args, module, call;
|
|
17461
17504
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17462
17505
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -17490,7 +17533,10 @@ var claimAssets = function claimAssets(options) {
|
|
|
17490
17533
|
}
|
|
17491
17534
|
}, _callee, null, [[3,, 8, 13]]);
|
|
17492
17535
|
}));
|
|
17493
|
-
|
|
17536
|
+
return function claimAssets(_x) {
|
|
17537
|
+
return _ref.apply(this, arguments);
|
|
17538
|
+
};
|
|
17539
|
+
}();
|
|
17494
17540
|
|
|
17495
17541
|
/**
|
|
17496
17542
|
* Builder class for constructing asset claim transactions.
|
|
@@ -17556,8 +17602,8 @@ var AssetClaimBuilder = /*#__PURE__*/function () {
|
|
|
17556
17602
|
*/
|
|
17557
17603
|
}, {
|
|
17558
17604
|
key: "build",
|
|
17559
|
-
value: function
|
|
17560
|
-
|
|
17605
|
+
value: (function () {
|
|
17606
|
+
var _build = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
17561
17607
|
var options;
|
|
17562
17608
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17563
17609
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -17573,7 +17619,11 @@ var AssetClaimBuilder = /*#__PURE__*/function () {
|
|
|
17573
17619
|
}
|
|
17574
17620
|
}, _callee, this);
|
|
17575
17621
|
}));
|
|
17576
|
-
|
|
17622
|
+
function build() {
|
|
17623
|
+
return _build.apply(this, arguments);
|
|
17624
|
+
}
|
|
17625
|
+
return build;
|
|
17626
|
+
}())
|
|
17577
17627
|
}], [{
|
|
17578
17628
|
key: "create",
|
|
17579
17629
|
value: function create(api, node) {
|
|
@@ -17599,58 +17649,64 @@ var BatchTransactionManager = /*#__PURE__*/function () {
|
|
|
17599
17649
|
}
|
|
17600
17650
|
}, {
|
|
17601
17651
|
key: "buildBatch",
|
|
17602
|
-
value: function
|
|
17603
|
-
|
|
17604
|
-
var
|
|
17605
|
-
|
|
17606
|
-
|
|
17607
|
-
|
|
17608
|
-
|
|
17609
|
-
|
|
17610
|
-
|
|
17611
|
-
|
|
17612
|
-
|
|
17613
|
-
|
|
17614
|
-
|
|
17615
|
-
|
|
17616
|
-
|
|
17617
|
-
|
|
17618
|
-
|
|
17619
|
-
|
|
17620
|
-
|
|
17621
|
-
|
|
17622
|
-
|
|
17623
|
-
|
|
17624
|
-
|
|
17625
|
-
|
|
17626
|
-
|
|
17627
|
-
|
|
17628
|
-
|
|
17652
|
+
value: function () {
|
|
17653
|
+
var _buildBatch = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, from) {
|
|
17654
|
+
var options,
|
|
17655
|
+
mode,
|
|
17656
|
+
sameFrom,
|
|
17657
|
+
results,
|
|
17658
|
+
txs,
|
|
17659
|
+
_args = arguments;
|
|
17660
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17661
|
+
while (1) switch (_context.prev = _context.next) {
|
|
17662
|
+
case 0:
|
|
17663
|
+
options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {
|
|
17664
|
+
mode: exports.BatchMode.BATCH_ALL
|
|
17665
|
+
};
|
|
17666
|
+
_context.next = 3;
|
|
17667
|
+
return api.init(from);
|
|
17668
|
+
case 3:
|
|
17669
|
+
mode = options.mode;
|
|
17670
|
+
if (!(this.transactionOptions.length === 0)) {
|
|
17671
|
+
_context.next = 6;
|
|
17672
|
+
break;
|
|
17673
|
+
}
|
|
17674
|
+
throw new Error('No transactions to batch.');
|
|
17675
|
+
case 6:
|
|
17676
|
+
sameFrom = this.transactionOptions.every(function (tx) {
|
|
17677
|
+
return tx.origin === from;
|
|
17678
|
+
});
|
|
17679
|
+
if (sameFrom) {
|
|
17680
|
+
_context.next = 9;
|
|
17681
|
+
break;
|
|
17682
|
+
}
|
|
17683
|
+
throw new Error('All transactions must have the same origin.');
|
|
17684
|
+
case 9:
|
|
17685
|
+
results = this.transactionOptions.map(function (options) {
|
|
17686
|
+
return send(options);
|
|
17687
|
+
});
|
|
17688
|
+
_context.next = 12;
|
|
17689
|
+
return Promise.all(results);
|
|
17690
|
+
case 12:
|
|
17691
|
+
txs = _context.sent;
|
|
17692
|
+
return _context.abrupt("return", api.callTxMethod({
|
|
17693
|
+
module: 'Utility',
|
|
17694
|
+
section: mode === exports.BatchMode.BATCH_ALL ? 'batch_all' : 'batch',
|
|
17695
|
+
parameters: {
|
|
17696
|
+
data: [txs]
|
|
17629
17697
|
}
|
|
17630
|
-
|
|
17631
|
-
|
|
17632
|
-
|
|
17633
|
-
|
|
17634
|
-
|
|
17635
|
-
|
|
17636
|
-
|
|
17637
|
-
|
|
17638
|
-
|
|
17639
|
-
|
|
17640
|
-
|
|
17641
|
-
|
|
17642
|
-
parameters: {
|
|
17643
|
-
data: [txs]
|
|
17644
|
-
}
|
|
17645
|
-
}));
|
|
17646
|
-
case 13:
|
|
17647
|
-
case "end":
|
|
17648
|
-
return _context.stop();
|
|
17649
|
-
}
|
|
17650
|
-
}, _callee);
|
|
17651
|
-
})();
|
|
17652
|
-
});
|
|
17653
|
-
}
|
|
17698
|
+
}));
|
|
17699
|
+
case 14:
|
|
17700
|
+
case "end":
|
|
17701
|
+
return _context.stop();
|
|
17702
|
+
}
|
|
17703
|
+
}, _callee, this);
|
|
17704
|
+
}));
|
|
17705
|
+
function buildBatch(_x, _x2) {
|
|
17706
|
+
return _buildBatch.apply(this, arguments);
|
|
17707
|
+
}
|
|
17708
|
+
return buildBatch;
|
|
17709
|
+
}()
|
|
17654
17710
|
}]);
|
|
17655
17711
|
}();
|
|
17656
17712
|
|
|
@@ -17731,19 +17787,6 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
17731
17787
|
this._ahAddress = ahAddress;
|
|
17732
17788
|
return this;
|
|
17733
17789
|
}
|
|
17734
|
-
/**
|
|
17735
|
-
* Specifies to use the keep-alive option for the destination account to keep account active.
|
|
17736
|
-
*
|
|
17737
|
-
* @param destApi - The API instance of the destination chain.
|
|
17738
|
-
* @returns An instance of Builder
|
|
17739
|
-
*/
|
|
17740
|
-
}, {
|
|
17741
|
-
key: "useKeepAlive",
|
|
17742
|
-
value: function useKeepAlive(destApi) {
|
|
17743
|
-
this._destApi = this.api.clone();
|
|
17744
|
-
this._destApi.setApi(destApi);
|
|
17745
|
-
return this;
|
|
17746
|
-
}
|
|
17747
17790
|
/**
|
|
17748
17791
|
* Sets the XCM version to be used for the transfer.
|
|
17749
17792
|
*
|
|
@@ -17779,7 +17822,6 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
17779
17822
|
address: this._address,
|
|
17780
17823
|
destination: this._to,
|
|
17781
17824
|
paraIdTo: this._paraIdTo,
|
|
17782
|
-
destApiForKeepAlive: this._destApi,
|
|
17783
17825
|
version: this._version,
|
|
17784
17826
|
ahAddress: this._ahAddress,
|
|
17785
17827
|
pallet: this._pallet,
|
|
@@ -17805,8 +17847,8 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
17805
17847
|
*/
|
|
17806
17848
|
}, {
|
|
17807
17849
|
key: "buildBatch",
|
|
17808
|
-
value: function
|
|
17809
|
-
|
|
17850
|
+
value: (function () {
|
|
17851
|
+
var _buildBatch = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
17810
17852
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17811
17853
|
while (1) switch (_context.prev = _context.next) {
|
|
17812
17854
|
case 0:
|
|
@@ -17817,16 +17859,21 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
17817
17859
|
}
|
|
17818
17860
|
}, _callee, this);
|
|
17819
17861
|
}));
|
|
17820
|
-
|
|
17862
|
+
function buildBatch(_x) {
|
|
17863
|
+
return _buildBatch.apply(this, arguments);
|
|
17864
|
+
}
|
|
17865
|
+
return buildBatch;
|
|
17866
|
+
}()
|
|
17821
17867
|
/**
|
|
17822
17868
|
* Builds and returns the transfer extrinsic.
|
|
17823
17869
|
*
|
|
17824
17870
|
* @returns A Promise that resolves to the transfer extrinsic.
|
|
17825
17871
|
*/
|
|
17872
|
+
)
|
|
17826
17873
|
}, {
|
|
17827
17874
|
key: "build",
|
|
17828
|
-
value: function
|
|
17829
|
-
|
|
17875
|
+
value: (function () {
|
|
17876
|
+
var _build = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
17830
17877
|
var options;
|
|
17831
17878
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
17832
17879
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -17851,11 +17898,15 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
17851
17898
|
}
|
|
17852
17899
|
}, _callee2, this);
|
|
17853
17900
|
}));
|
|
17854
|
-
|
|
17901
|
+
function build() {
|
|
17902
|
+
return _build.apply(this, arguments);
|
|
17903
|
+
}
|
|
17904
|
+
return build;
|
|
17905
|
+
}())
|
|
17855
17906
|
}, {
|
|
17856
17907
|
key: "dryRun",
|
|
17857
|
-
value: function
|
|
17858
|
-
|
|
17908
|
+
value: function () {
|
|
17909
|
+
var _dryRun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
17859
17910
|
var tx;
|
|
17860
17911
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
17861
17912
|
while (1) switch (_context3.prev = _context3.next) {
|
|
@@ -17884,7 +17935,11 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
17884
17935
|
}
|
|
17885
17936
|
}, _callee3, this);
|
|
17886
17937
|
}));
|
|
17887
|
-
|
|
17938
|
+
function dryRun() {
|
|
17939
|
+
return _dryRun.apply(this, arguments);
|
|
17940
|
+
}
|
|
17941
|
+
return dryRun;
|
|
17942
|
+
}()
|
|
17888
17943
|
}]);
|
|
17889
17944
|
}();
|
|
17890
17945
|
/**
|
|
@@ -17897,57 +17952,52 @@ var Builder = function Builder(api) {
|
|
|
17897
17952
|
return new GeneralBuilder(new BatchTransactionManager(), api);
|
|
17898
17953
|
};
|
|
17899
17954
|
|
|
17900
|
-
var getOriginFeeDetailsInternal = function
|
|
17901
|
-
|
|
17902
|
-
var
|
|
17903
|
-
|
|
17904
|
-
|
|
17905
|
-
|
|
17906
|
-
|
|
17907
|
-
|
|
17908
|
-
|
|
17909
|
-
|
|
17910
|
-
|
|
17911
|
-
|
|
17912
|
-
|
|
17913
|
-
|
|
17914
|
-
|
|
17915
|
-
|
|
17916
|
-
|
|
17917
|
-
|
|
17918
|
-
|
|
17919
|
-
|
|
17920
|
-
|
|
17921
|
-
|
|
17922
|
-
|
|
17923
|
-
|
|
17924
|
-
|
|
17925
|
-
|
|
17926
|
-
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
|
|
17930
|
-
|
|
17931
|
-
|
|
17932
|
-
|
|
17933
|
-
|
|
17934
|
-
|
|
17935
|
-
|
|
17936
|
-
|
|
17937
|
-
|
|
17938
|
-
|
|
17939
|
-
|
|
17940
|
-
|
|
17941
|
-
|
|
17942
|
-
|
|
17943
|
-
|
|
17944
|
-
|
|
17945
|
-
|
|
17946
|
-
})();
|
|
17947
|
-
});
|
|
17948
|
-
};
|
|
17949
|
-
var getOriginFeeDetails = function getOriginFeeDetails(options) {
|
|
17950
|
-
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
17955
|
+
var getOriginFeeDetailsInternal = /*#__PURE__*/function () {
|
|
17956
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
17957
|
+
var _getExistentialDeposi;
|
|
17958
|
+
var api, account, accountDestination, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
|
|
17959
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17960
|
+
while (1) switch (_context.prev = _context.next) {
|
|
17961
|
+
case 0:
|
|
17962
|
+
api = _ref.api, account = _ref.account, accountDestination = _ref.accountDestination, currency = _ref.currency, origin = _ref.origin, destination = _ref.destination, _ref$feeMarginPercent = _ref.feeMarginPercentage, feeMarginPercentage = _ref$feeMarginPercent === void 0 ? 10 : _ref$feeMarginPercent;
|
|
17963
|
+
_context.next = 3;
|
|
17964
|
+
return api.init(origin);
|
|
17965
|
+
case 3:
|
|
17966
|
+
_context.next = 5;
|
|
17967
|
+
return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination).build();
|
|
17968
|
+
case 5:
|
|
17969
|
+
tx = _context.sent;
|
|
17970
|
+
_context.next = 8;
|
|
17971
|
+
return api.calculateTransactionFee(tx, account);
|
|
17972
|
+
case 8:
|
|
17973
|
+
xcmFee = _context.sent;
|
|
17974
|
+
xcmFeeWithMargin = xcmFee + xcmFee / BigInt(feeMarginPercentage);
|
|
17975
|
+
_context.next = 12;
|
|
17976
|
+
return getBalanceNativeInternal({
|
|
17977
|
+
address: account,
|
|
17978
|
+
node: origin,
|
|
17979
|
+
api: api
|
|
17980
|
+
});
|
|
17981
|
+
case 12:
|
|
17982
|
+
nativeBalance = _context.sent;
|
|
17983
|
+
existentialDeposit = BigInt((_getExistentialDeposi = getExistentialDeposit(origin)) !== null && _getExistentialDeposi !== void 0 ? _getExistentialDeposi : '0');
|
|
17984
|
+
sufficientForXCM = nativeBalance - existentialDeposit - xcmFeeWithMargin > 0;
|
|
17985
|
+
return _context.abrupt("return", {
|
|
17986
|
+
sufficientForXCM: sufficientForXCM,
|
|
17987
|
+
xcmFee: xcmFee
|
|
17988
|
+
});
|
|
17989
|
+
case 16:
|
|
17990
|
+
case "end":
|
|
17991
|
+
return _context.stop();
|
|
17992
|
+
}
|
|
17993
|
+
}, _callee);
|
|
17994
|
+
}));
|
|
17995
|
+
return function getOriginFeeDetailsInternal(_x) {
|
|
17996
|
+
return _ref2.apply(this, arguments);
|
|
17997
|
+
};
|
|
17998
|
+
}();
|
|
17999
|
+
var getOriginFeeDetails = /*#__PURE__*/function () {
|
|
18000
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
17951
18001
|
var api;
|
|
17952
18002
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
17953
18003
|
while (1) switch (_context2.prev = _context2.next) {
|
|
@@ -17972,7 +18022,10 @@ var getOriginFeeDetails = function getOriginFeeDetails(options) {
|
|
|
17972
18022
|
}
|
|
17973
18023
|
}, _callee2, null, [[2,, 6, 11]]);
|
|
17974
18024
|
}));
|
|
17975
|
-
|
|
18025
|
+
return function getOriginFeeDetails(_x2) {
|
|
18026
|
+
return _ref3.apply(this, arguments);
|
|
18027
|
+
};
|
|
18028
|
+
}();
|
|
17976
18029
|
|
|
17977
18030
|
var validateAddress = function validateAddress(address, node) {
|
|
17978
18031
|
var isDestination = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
@@ -17989,276 +18042,268 @@ var validateAddress = function validateAddress(address, node) {
|
|
|
17989
18042
|
}
|
|
17990
18043
|
};
|
|
17991
18044
|
|
|
17992
|
-
var getMaxNativeTransferableAmount = function
|
|
17993
|
-
|
|
17994
|
-
var api
|
|
17995
|
-
|
|
17996
|
-
|
|
17997
|
-
|
|
17998
|
-
|
|
17999
|
-
|
|
18000
|
-
|
|
18001
|
-
|
|
18002
|
-
|
|
18003
|
-
|
|
18004
|
-
|
|
18005
|
-
|
|
18006
|
-
|
|
18007
|
-
|
|
18008
|
-
|
|
18009
|
-
|
|
18010
|
-
|
|
18011
|
-
|
|
18012
|
-
|
|
18013
|
-
|
|
18014
|
-
|
|
18015
|
-
|
|
18016
|
-
|
|
18017
|
-
|
|
18018
|
-
|
|
18019
|
-
|
|
18020
|
-
|
|
18021
|
-
|
|
18022
|
-
|
|
18023
|
-
|
|
18024
|
-
|
|
18025
|
-
|
|
18026
|
-
|
|
18027
|
-
|
|
18028
|
-
|
|
18029
|
-
|
|
18030
|
-
|
|
18031
|
-
var
|
|
18032
|
-
|
|
18033
|
-
|
|
18034
|
-
|
|
18035
|
-
|
|
18036
|
-
|
|
18037
|
-
|
|
18038
|
-
|
|
18039
|
-
|
|
18040
|
-
|
|
18041
|
-
|
|
18042
|
-
|
|
18043
|
-
|
|
18044
|
-
|
|
18045
|
-
|
|
18046
|
-
|
|
18047
|
-
|
|
18048
|
-
|
|
18049
|
-
|
|
18050
|
-
|
|
18051
|
-
|
|
18052
|
-
|
|
18053
|
-
|
|
18054
|
-
|
|
18055
|
-
|
|
18056
|
-
|
|
18057
|
-
|
|
18058
|
-
|
|
18059
|
-
|
|
18060
|
-
|
|
18061
|
-
|
|
18062
|
-
|
|
18063
|
-
|
|
18064
|
-
|
|
18065
|
-
|
|
18066
|
-
|
|
18067
|
-
|
|
18068
|
-
|
|
18069
|
-
|
|
18070
|
-
|
|
18071
|
-
|
|
18072
|
-
|
|
18073
|
-
|
|
18074
|
-
|
|
18075
|
-
|
|
18076
|
-
|
|
18077
|
-
|
|
18078
|
-
|
|
18079
|
-
|
|
18080
|
-
|
|
18081
|
-
|
|
18082
|
-
|
|
18083
|
-
var
|
|
18084
|
-
|
|
18085
|
-
|
|
18086
|
-
|
|
18087
|
-
|
|
18088
|
-
|
|
18089
|
-
|
|
18090
|
-
|
|
18091
|
-
|
|
18092
|
-
|
|
18093
|
-
|
|
18094
|
-
|
|
18095
|
-
|
|
18096
|
-
|
|
18097
|
-
|
|
18098
|
-
|
|
18099
|
-
|
|
18100
|
-
|
|
18101
|
-
|
|
18102
|
-
|
|
18103
|
-
|
|
18104
|
-
|
|
18105
|
-
|
|
18106
|
-
|
|
18107
|
-
|
|
18108
|
-
|
|
18109
|
-
|
|
18110
|
-
|
|
18111
|
-
|
|
18112
|
-
|
|
18113
|
-
return _context3.abrupt("return", getMaxNativeTransferableAmount({
|
|
18114
|
-
api: api,
|
|
18115
|
-
address: address,
|
|
18116
|
-
node: node,
|
|
18117
|
-
currency: {
|
|
18118
|
-
symbol: asset.symbol
|
|
18119
|
-
}
|
|
18120
|
-
}));
|
|
18121
|
-
case 9:
|
|
18122
|
-
case "end":
|
|
18123
|
-
return _context3.stop();
|
|
18124
|
-
}
|
|
18125
|
-
}, _callee3);
|
|
18126
|
-
})();
|
|
18127
|
-
});
|
|
18128
|
-
};
|
|
18129
|
-
|
|
18130
|
-
var getTransferInfo = function getTransferInfo(_a) {
|
|
18131
|
-
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
18132
|
-
var origin = _ref.origin,
|
|
18133
|
-
destination = _ref.destination,
|
|
18134
|
-
accountOrigin = _ref.accountOrigin,
|
|
18135
|
-
accountDestination = _ref.accountDestination,
|
|
18136
|
-
currency = _ref.currency,
|
|
18137
|
-
api = _ref.api;
|
|
18138
|
-
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
18139
|
-
var _b, _c, _d, _e, _f, destApi, originBalance, xcmFeeDetails, expectedBalanceAfterXCMDelivery, asset;
|
|
18140
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18141
|
-
while (1) switch (_context.prev = _context.next) {
|
|
18142
|
-
case 0:
|
|
18143
|
-
_context.next = 2;
|
|
18144
|
-
return api.init(origin);
|
|
18145
|
-
case 2:
|
|
18146
|
-
api.setDisconnectAllowed(false);
|
|
18147
|
-
destApi = api.clone();
|
|
18148
|
-
_context.next = 6;
|
|
18149
|
-
return destApi.init(destination);
|
|
18150
|
-
case 6:
|
|
18151
|
-
destApi.setDisconnectAllowed(false);
|
|
18152
|
-
_context.prev = 7;
|
|
18153
|
-
_context.next = 10;
|
|
18154
|
-
return getBalanceNativeInternal({
|
|
18155
|
-
address: accountOrigin,
|
|
18156
|
-
node: origin,
|
|
18157
|
-
api: api
|
|
18158
|
-
});
|
|
18159
|
-
case 10:
|
|
18160
|
-
originBalance = _context.sent;
|
|
18161
|
-
_context.next = 13;
|
|
18162
|
-
return getOriginFeeDetailsInternal({
|
|
18163
|
-
origin: origin,
|
|
18164
|
-
destination: destination,
|
|
18165
|
-
currency: currency,
|
|
18166
|
-
account: accountOrigin,
|
|
18167
|
-
accountDestination: accountDestination,
|
|
18168
|
-
api: api
|
|
18169
|
-
});
|
|
18170
|
-
case 13:
|
|
18171
|
-
xcmFeeDetails = _context.sent;
|
|
18172
|
-
expectedBalanceAfterXCMDelivery = originBalance - xcmFeeDetails.xcmFee;
|
|
18173
|
-
asset = (_b = getAssetBySymbolOrId(origin, currency, destination)) !== null && _b !== void 0 ? _b : origin === 'AssetHubPolkadot' ? getAssetBySymbolOrId('Ethereum', currency, null) : null;
|
|
18174
|
-
if (asset) {
|
|
18175
|
-
_context.next = 18;
|
|
18176
|
-
break;
|
|
18045
|
+
var getMaxNativeTransferableAmount = /*#__PURE__*/function () {
|
|
18046
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
18047
|
+
var api, address, node, currency, ed, edBN, nativeBalance, maxTransferableAmount;
|
|
18048
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18049
|
+
while (1) switch (_context.prev = _context.next) {
|
|
18050
|
+
case 0:
|
|
18051
|
+
api = _ref.api, address = _ref.address, node = _ref.node, currency = _ref.currency;
|
|
18052
|
+
validateAddress(address, node, false);
|
|
18053
|
+
ed = getExistentialDeposit(node, currency);
|
|
18054
|
+
if (!(ed === null)) {
|
|
18055
|
+
_context.next = 5;
|
|
18056
|
+
break;
|
|
18057
|
+
}
|
|
18058
|
+
throw new Error("Cannot get existential deposit for node ".concat(node));
|
|
18059
|
+
case 5:
|
|
18060
|
+
edBN = BigInt(ed);
|
|
18061
|
+
_context.next = 8;
|
|
18062
|
+
return getBalanceNativeInternal({
|
|
18063
|
+
address: address,
|
|
18064
|
+
node: node,
|
|
18065
|
+
api: api,
|
|
18066
|
+
currency: currency
|
|
18067
|
+
});
|
|
18068
|
+
case 8:
|
|
18069
|
+
nativeBalance = _context.sent;
|
|
18070
|
+
maxTransferableAmount = nativeBalance - edBN;
|
|
18071
|
+
return _context.abrupt("return", maxTransferableAmount > 0n ? maxTransferableAmount : 0n);
|
|
18072
|
+
case 11:
|
|
18073
|
+
case "end":
|
|
18074
|
+
return _context.stop();
|
|
18075
|
+
}
|
|
18076
|
+
}, _callee);
|
|
18077
|
+
}));
|
|
18078
|
+
return function getMaxNativeTransferableAmount(_x) {
|
|
18079
|
+
return _ref2.apply(this, arguments);
|
|
18080
|
+
};
|
|
18081
|
+
}();
|
|
18082
|
+
var getMaxForeignTransferableAmount = /*#__PURE__*/function () {
|
|
18083
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
|
|
18084
|
+
var _getAssetBySymbolOrId;
|
|
18085
|
+
var api, address, node, currency, asset, ed, edBN, balance, maxTransferableAmount;
|
|
18086
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
18087
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
18088
|
+
case 0:
|
|
18089
|
+
api = _ref3.api, address = _ref3.address, node = _ref3.node, currency = _ref3.currency;
|
|
18090
|
+
validateAddress(address, node, false);
|
|
18091
|
+
asset = (_getAssetBySymbolOrId = getAssetBySymbolOrId(node, currency, null)) !== null && _getAssetBySymbolOrId !== void 0 ? _getAssetBySymbolOrId : node === 'AssetHubPolkadot' ? getAssetBySymbolOrId('Ethereum', currency, null) : null;
|
|
18092
|
+
if (asset) {
|
|
18093
|
+
_context2.next = 5;
|
|
18094
|
+
break;
|
|
18095
|
+
}
|
|
18096
|
+
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(node));
|
|
18097
|
+
case 5:
|
|
18098
|
+
if (isForeignAsset(asset)) {
|
|
18099
|
+
_context2.next = 7;
|
|
18100
|
+
break;
|
|
18101
|
+
}
|
|
18102
|
+
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " is not a foreign asset"));
|
|
18103
|
+
case 7:
|
|
18104
|
+
ed = asset.existentialDeposit;
|
|
18105
|
+
if (ed) {
|
|
18106
|
+
_context2.next = 10;
|
|
18107
|
+
break;
|
|
18108
|
+
}
|
|
18109
|
+
throw new Error("Cannot get existential deposit for asset ".concat(JSON.stringify(asset)));
|
|
18110
|
+
case 10:
|
|
18111
|
+
edBN = BigInt(ed);
|
|
18112
|
+
_context2.next = 13;
|
|
18113
|
+
return getBalanceForeignInternal({
|
|
18114
|
+
address: address,
|
|
18115
|
+
node: node,
|
|
18116
|
+
api: api,
|
|
18117
|
+
currency: currency
|
|
18118
|
+
});
|
|
18119
|
+
case 13:
|
|
18120
|
+
balance = _context2.sent;
|
|
18121
|
+
maxTransferableAmount = balance - edBN;
|
|
18122
|
+
return _context2.abrupt("return", maxTransferableAmount > 0n ? maxTransferableAmount : 0n);
|
|
18123
|
+
case 16:
|
|
18124
|
+
case "end":
|
|
18125
|
+
return _context2.stop();
|
|
18126
|
+
}
|
|
18127
|
+
}, _callee2);
|
|
18128
|
+
}));
|
|
18129
|
+
return function getMaxForeignTransferableAmount(_x2) {
|
|
18130
|
+
return _ref4.apply(this, arguments);
|
|
18131
|
+
};
|
|
18132
|
+
}();
|
|
18133
|
+
var getTransferableAmount = /*#__PURE__*/function () {
|
|
18134
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref5) {
|
|
18135
|
+
var _getAssetBySymbolOrId2;
|
|
18136
|
+
var api, address, node, currency, asset;
|
|
18137
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
18138
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
18139
|
+
case 0:
|
|
18140
|
+
api = _ref5.api, address = _ref5.address, node = _ref5.node, currency = _ref5.currency;
|
|
18141
|
+
validateAddress(address, node, false);
|
|
18142
|
+
asset = (_getAssetBySymbolOrId2 = getAssetBySymbolOrId(node, currency, null)) !== null && _getAssetBySymbolOrId2 !== void 0 ? _getAssetBySymbolOrId2 : node === 'AssetHubPolkadot' ? getAssetBySymbolOrId('Ethereum', currency, null) : null;
|
|
18143
|
+
if (asset) {
|
|
18144
|
+
_context3.next = 5;
|
|
18145
|
+
break;
|
|
18146
|
+
}
|
|
18147
|
+
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(node));
|
|
18148
|
+
case 5:
|
|
18149
|
+
if (!(isForeignAsset(asset) && !isRelayChain(node))) {
|
|
18150
|
+
_context3.next = 9;
|
|
18151
|
+
break;
|
|
18152
|
+
}
|
|
18153
|
+
return _context3.abrupt("return", getMaxForeignTransferableAmount({
|
|
18154
|
+
api: api,
|
|
18155
|
+
address: address,
|
|
18156
|
+
node: node,
|
|
18157
|
+
currency: currency
|
|
18158
|
+
}));
|
|
18159
|
+
case 9:
|
|
18160
|
+
return _context3.abrupt("return", getMaxNativeTransferableAmount({
|
|
18161
|
+
api: api,
|
|
18162
|
+
address: address,
|
|
18163
|
+
node: node,
|
|
18164
|
+
currency: {
|
|
18165
|
+
symbol: asset.symbol
|
|
18177
18166
|
}
|
|
18178
|
-
|
|
18179
|
-
|
|
18180
|
-
|
|
18181
|
-
|
|
18182
|
-
|
|
18183
|
-
|
|
18184
|
-
|
|
18185
|
-
|
|
18186
|
-
|
|
18187
|
-
|
|
18188
|
-
|
|
18189
|
-
|
|
18190
|
-
|
|
18191
|
-
|
|
18192
|
-
|
|
18193
|
-
|
|
18194
|
-
|
|
18195
|
-
|
|
18196
|
-
|
|
18197
|
-
|
|
18198
|
-
|
|
18199
|
-
|
|
18200
|
-
|
|
18201
|
-
|
|
18202
|
-
|
|
18203
|
-
|
|
18204
|
-
|
|
18205
|
-
|
|
18206
|
-
|
|
18207
|
-
|
|
18208
|
-
|
|
18209
|
-
|
|
18210
|
-
|
|
18211
|
-
|
|
18212
|
-
|
|
18213
|
-
|
|
18214
|
-
|
|
18215
|
-
|
|
18216
|
-
|
|
18217
|
-
|
|
18218
|
-
|
|
18219
|
-
|
|
18220
|
-
|
|
18221
|
-
|
|
18222
|
-
|
|
18223
|
-
|
|
18224
|
-
|
|
18225
|
-
|
|
18226
|
-
|
|
18227
|
-
|
|
18228
|
-
|
|
18229
|
-
_context.
|
|
18230
|
-
|
|
18231
|
-
|
|
18232
|
-
|
|
18233
|
-
|
|
18234
|
-
|
|
18235
|
-
|
|
18236
|
-
|
|
18237
|
-
|
|
18238
|
-
|
|
18239
|
-
|
|
18240
|
-
|
|
18241
|
-
|
|
18242
|
-
|
|
18243
|
-
|
|
18244
|
-
|
|
18245
|
-
|
|
18246
|
-
|
|
18247
|
-
|
|
18248
|
-
|
|
18249
|
-
|
|
18250
|
-
_context.
|
|
18251
|
-
|
|
18252
|
-
|
|
18253
|
-
|
|
18254
|
-
|
|
18255
|
-
|
|
18256
|
-
|
|
18257
|
-
|
|
18258
|
-
|
|
18259
|
-
|
|
18260
|
-
|
|
18261
|
-
|
|
18167
|
+
}));
|
|
18168
|
+
case 10:
|
|
18169
|
+
case "end":
|
|
18170
|
+
return _context3.stop();
|
|
18171
|
+
}
|
|
18172
|
+
}, _callee3);
|
|
18173
|
+
}));
|
|
18174
|
+
return function getTransferableAmount(_x3) {
|
|
18175
|
+
return _ref6.apply(this, arguments);
|
|
18176
|
+
};
|
|
18177
|
+
}();
|
|
18178
|
+
|
|
18179
|
+
var getTransferInfo = /*#__PURE__*/function () {
|
|
18180
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
18181
|
+
var origin, destination, accountOrigin, accountDestination, currency, api, destApi, _getAssetBySymbolOrId, _asset$symbol, _getExistentialDeposi, _getExistentialDeposi2, _getExistentialDeposi3, originBalance, xcmFeeDetails, expectedBalanceAfterXCMDelivery, asset;
|
|
18182
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18183
|
+
while (1) switch (_context.prev = _context.next) {
|
|
18184
|
+
case 0:
|
|
18185
|
+
origin = _ref.origin, destination = _ref.destination, accountOrigin = _ref.accountOrigin, accountDestination = _ref.accountDestination, currency = _ref.currency, api = _ref.api;
|
|
18186
|
+
_context.next = 3;
|
|
18187
|
+
return api.init(origin);
|
|
18188
|
+
case 3:
|
|
18189
|
+
api.setDisconnectAllowed(false);
|
|
18190
|
+
destApi = api.clone();
|
|
18191
|
+
_context.next = 7;
|
|
18192
|
+
return destApi.init(destination);
|
|
18193
|
+
case 7:
|
|
18194
|
+
destApi.setDisconnectAllowed(false);
|
|
18195
|
+
_context.prev = 8;
|
|
18196
|
+
_context.next = 11;
|
|
18197
|
+
return getBalanceNativeInternal({
|
|
18198
|
+
address: accountOrigin,
|
|
18199
|
+
node: origin,
|
|
18200
|
+
api: api
|
|
18201
|
+
});
|
|
18202
|
+
case 11:
|
|
18203
|
+
originBalance = _context.sent;
|
|
18204
|
+
_context.next = 14;
|
|
18205
|
+
return getOriginFeeDetailsInternal({
|
|
18206
|
+
origin: origin,
|
|
18207
|
+
destination: destination,
|
|
18208
|
+
currency: currency,
|
|
18209
|
+
account: accountOrigin,
|
|
18210
|
+
accountDestination: accountDestination,
|
|
18211
|
+
api: api
|
|
18212
|
+
});
|
|
18213
|
+
case 14:
|
|
18214
|
+
xcmFeeDetails = _context.sent;
|
|
18215
|
+
expectedBalanceAfterXCMDelivery = originBalance - xcmFeeDetails.xcmFee;
|
|
18216
|
+
asset = (_getAssetBySymbolOrId = getAssetBySymbolOrId(origin, currency, destination)) !== null && _getAssetBySymbolOrId !== void 0 ? _getAssetBySymbolOrId : origin === 'AssetHubPolkadot' ? getAssetBySymbolOrId('Ethereum', currency, null) : null;
|
|
18217
|
+
if (asset) {
|
|
18218
|
+
_context.next = 19;
|
|
18219
|
+
break;
|
|
18220
|
+
}
|
|
18221
|
+
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(origin));
|
|
18222
|
+
case 19:
|
|
18223
|
+
_context.t0 = {
|
|
18224
|
+
origin: origin,
|
|
18225
|
+
destination: destination,
|
|
18226
|
+
ecosystem: getRelayChainSymbol(origin)
|
|
18227
|
+
};
|
|
18228
|
+
_context.next = 22;
|
|
18229
|
+
return getAssetBalanceInternal({
|
|
18230
|
+
api: api,
|
|
18231
|
+
address: accountOrigin,
|
|
18232
|
+
node: origin,
|
|
18233
|
+
currency: currency
|
|
18234
|
+
});
|
|
18235
|
+
case 22:
|
|
18236
|
+
_context.t1 = _context.sent;
|
|
18237
|
+
_context.t2 = (_asset$symbol = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _asset$symbol !== void 0 ? _asset$symbol : '';
|
|
18238
|
+
_context.t3 = {
|
|
18239
|
+
balance: _context.t1,
|
|
18240
|
+
currency: _context.t2
|
|
18241
|
+
};
|
|
18242
|
+
_context.t4 = originBalance;
|
|
18243
|
+
_context.t5 = expectedBalanceAfterXCMDelivery;
|
|
18244
|
+
_context.t6 = xcmFeeDetails;
|
|
18245
|
+
_context.t7 = BigInt((_getExistentialDeposi = getExistentialDeposit(origin)) !== null && _getExistentialDeposi !== void 0 ? _getExistentialDeposi : 0);
|
|
18246
|
+
_context.t8 = getNativeAssetSymbol(origin);
|
|
18247
|
+
_context.t9 = BigInt((_getExistentialDeposi2 = getExistentialDeposit(origin)) !== null && _getExistentialDeposi2 !== void 0 ? _getExistentialDeposi2 : 0);
|
|
18248
|
+
_context.next = 33;
|
|
18249
|
+
return getMaxNativeTransferableAmount({
|
|
18250
|
+
api: api,
|
|
18251
|
+
address: accountOrigin,
|
|
18252
|
+
node: origin
|
|
18253
|
+
});
|
|
18254
|
+
case 33:
|
|
18255
|
+
_context.t10 = _context.sent;
|
|
18256
|
+
_context.t11 = {
|
|
18257
|
+
balance: _context.t4,
|
|
18258
|
+
expectedBalanceAfterXCMFee: _context.t5,
|
|
18259
|
+
xcmFee: _context.t6,
|
|
18260
|
+
existentialDeposit: _context.t7,
|
|
18261
|
+
asset: _context.t8,
|
|
18262
|
+
minNativeTransferableAmount: _context.t9,
|
|
18263
|
+
maxNativeTransferableAmount: _context.t10
|
|
18264
|
+
};
|
|
18265
|
+
_context.next = 37;
|
|
18266
|
+
return getBalanceNativeInternal({
|
|
18267
|
+
address: accountDestination,
|
|
18268
|
+
node: destination,
|
|
18269
|
+
api: destApi
|
|
18270
|
+
});
|
|
18271
|
+
case 37:
|
|
18272
|
+
_context.t12 = _context.sent;
|
|
18273
|
+
_context.t13 = getNativeAssetSymbol(destination);
|
|
18274
|
+
_context.t14 = BigInt((_getExistentialDeposi3 = getExistentialDeposit(destination)) !== null && _getExistentialDeposi3 !== void 0 ? _getExistentialDeposi3 : 0);
|
|
18275
|
+
_context.t15 = {
|
|
18276
|
+
balance: _context.t12,
|
|
18277
|
+
currency: _context.t13,
|
|
18278
|
+
existentialDeposit: _context.t14
|
|
18279
|
+
};
|
|
18280
|
+
return _context.abrupt("return", {
|
|
18281
|
+
chain: _context.t0,
|
|
18282
|
+
currencyBalanceOrigin: _context.t3,
|
|
18283
|
+
originFeeBalance: _context.t11,
|
|
18284
|
+
destinationFeeBalance: _context.t15
|
|
18285
|
+
});
|
|
18286
|
+
case 42:
|
|
18287
|
+
_context.prev = 42;
|
|
18288
|
+
api.setDisconnectAllowed(true);
|
|
18289
|
+
api.setDisconnectAllowed(true);
|
|
18290
|
+
_context.next = 47;
|
|
18291
|
+
return api.disconnect();
|
|
18292
|
+
case 47:
|
|
18293
|
+
_context.next = 49;
|
|
18294
|
+
return destApi.disconnect();
|
|
18295
|
+
case 49:
|
|
18296
|
+
return _context.finish(42);
|
|
18297
|
+
case 50:
|
|
18298
|
+
case "end":
|
|
18299
|
+
return _context.stop();
|
|
18300
|
+
}
|
|
18301
|
+
}, _callee, null, [[8,, 42, 50]]);
|
|
18302
|
+
}));
|
|
18303
|
+
return function getTransferInfo(_x) {
|
|
18304
|
+
return _ref2.apply(this, arguments);
|
|
18305
|
+
};
|
|
18306
|
+
}();
|
|
18262
18307
|
|
|
18263
18308
|
var Native = function Native(symbol) {
|
|
18264
18309
|
return {
|
|
@@ -18337,42 +18382,6 @@ var getSupportedAssets = function getSupportedAssets(origin, destination) {
|
|
|
18337
18382
|
return supportedAssets;
|
|
18338
18383
|
};
|
|
18339
18384
|
|
|
18340
|
-
var index$1 = /*#__PURE__*/Object.freeze({
|
|
18341
|
-
__proto__: null,
|
|
18342
|
-
Foreign: Foreign,
|
|
18343
|
-
ForeignAbstract: ForeignAbstract,
|
|
18344
|
-
Native: Native,
|
|
18345
|
-
Override: Override,
|
|
18346
|
-
claimAssets: claimAssets,
|
|
18347
|
-
getAllAssetsSymbols: getAllAssetsSymbols,
|
|
18348
|
-
getAssetBalance: getAssetBalance,
|
|
18349
|
-
getAssetBalanceInternal: getAssetBalanceInternal,
|
|
18350
|
-
getAssetBySymbolOrId: getAssetBySymbolOrId,
|
|
18351
|
-
getAssetDecimals: getAssetDecimals,
|
|
18352
|
-
getAssetId: getAssetId,
|
|
18353
|
-
getAssets: getAssets,
|
|
18354
|
-
getAssetsObject: getAssetsObject,
|
|
18355
|
-
getBalanceForeign: getBalanceForeign,
|
|
18356
|
-
getBalanceForeignInternal: getBalanceForeignInternal,
|
|
18357
|
-
getBalanceNative: getBalanceNative,
|
|
18358
|
-
getBalanceNativeInternal: getBalanceNativeInternal,
|
|
18359
|
-
getExistentialDeposit: getExistentialDeposit,
|
|
18360
|
-
getMaxForeignTransferableAmount: getMaxForeignTransferableAmount,
|
|
18361
|
-
getMaxNativeTransferableAmount: getMaxNativeTransferableAmount,
|
|
18362
|
-
getNativeAssetSymbol: getNativeAssetSymbol,
|
|
18363
|
-
getNativeAssets: getNativeAssets,
|
|
18364
|
-
getOriginFeeDetails: getOriginFeeDetails,
|
|
18365
|
-
getOriginFeeDetailsInternal: getOriginFeeDetailsInternal,
|
|
18366
|
-
getOtherAssets: getOtherAssets,
|
|
18367
|
-
getRelayChainSymbol: getRelayChainSymbol,
|
|
18368
|
-
getSupportedAssets: getSupportedAssets,
|
|
18369
|
-
getTNode: getTNode,
|
|
18370
|
-
getTransferInfo: getTransferInfo,
|
|
18371
|
-
getTransferableAmount: getTransferableAmount,
|
|
18372
|
-
hasSupportForAsset: hasSupportForAsset,
|
|
18373
|
-
isNodeEvm: isNodeEvm
|
|
18374
|
-
});
|
|
18375
|
-
|
|
18376
18385
|
var isPrimitive = function isPrimitive(obj) {
|
|
18377
18386
|
return obj !== Object(obj);
|
|
18378
18387
|
};
|
|
@@ -18446,8 +18455,8 @@ var getNode = function getNode(node) {
|
|
|
18446
18455
|
return nodeMap[node];
|
|
18447
18456
|
};
|
|
18448
18457
|
|
|
18449
|
-
var createApiInstanceForNode = function
|
|
18450
|
-
|
|
18458
|
+
var createApiInstanceForNode = /*#__PURE__*/function () {
|
|
18459
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, node) {
|
|
18451
18460
|
var wsUrl;
|
|
18452
18461
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18453
18462
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -18460,7 +18469,10 @@ var createApiInstanceForNode = function createApiInstanceForNode(api, node) {
|
|
|
18460
18469
|
}
|
|
18461
18470
|
}, _callee);
|
|
18462
18471
|
}));
|
|
18463
|
-
|
|
18472
|
+
return function createApiInstanceForNode(_x, _x2) {
|
|
18473
|
+
return _ref.apply(this, arguments);
|
|
18474
|
+
};
|
|
18475
|
+
}();
|
|
18464
18476
|
|
|
18465
18477
|
var resolveModuleError = function resolveModuleError(node, error) {
|
|
18466
18478
|
var palletDetails = getSupportedPalletsDetails(node).find(function (p) {
|
|
@@ -18486,7 +18498,6 @@ var resolveModuleError = function resolveModuleError(node, error) {
|
|
|
18486
18498
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
18487
18499
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
18488
18500
|
var getMultiLocationTokenId = function getMultiLocationTokenId(location, node) {
|
|
18489
|
-
var _a, _b;
|
|
18490
18501
|
if (location.interior.type === 'Here') {
|
|
18491
18502
|
// native token
|
|
18492
18503
|
return getNativeAssetSymbol(node);
|
|
@@ -18494,10 +18505,11 @@ var getMultiLocationTokenId = function getMultiLocationTokenId(location, node) {
|
|
|
18494
18505
|
var foreignAssets = getOtherAssets(node);
|
|
18495
18506
|
if (location.interior.type === 'X2') {
|
|
18496
18507
|
if (location.interior.value[0].type === 'PalletInstance' && location.interior.value[0].value === 50 && location.interior.value[1].type === 'GeneralIndex') {
|
|
18508
|
+
var _foreignAssets$find$a, _foreignAssets$find;
|
|
18497
18509
|
var assetId = location.interior.value[1].value;
|
|
18498
|
-
return (
|
|
18510
|
+
return (_foreignAssets$find$a = (_foreignAssets$find = foreignAssets.find(function (asset) {
|
|
18499
18511
|
return asset.assetId === String(assetId);
|
|
18500
|
-
})) === null ||
|
|
18512
|
+
})) === null || _foreignAssets$find === void 0 ? void 0 : _foreignAssets$find.assetId) !== null && _foreignAssets$find$a !== void 0 ? _foreignAssets$find$a : null;
|
|
18501
18513
|
}
|
|
18502
18514
|
}
|
|
18503
18515
|
return null;
|
|
@@ -18546,7 +18558,7 @@ var computeFeeFromDryRun = function computeFeeFromDryRun(dryRun, node, execution
|
|
|
18546
18558
|
return df.tokenSymbol === nativeAssetSymbol;
|
|
18547
18559
|
}).reduce(function (acc, df) {
|
|
18548
18560
|
return acc + df.plancks;
|
|
18549
|
-
},
|
|
18561
|
+
}, 0n);
|
|
18550
18562
|
return totalDeliveryFees + executionFee;
|
|
18551
18563
|
};
|
|
18552
18564
|
|
|
@@ -18554,7 +18566,6 @@ var computeFeeFromDryRun = function computeFeeFromDryRun(dryRun, node, execution
|
|
|
18554
18566
|
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
18555
18567
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
18556
18568
|
var getMultiLocationTokenIdPjs = function getMultiLocationTokenIdPjs(location, node) {
|
|
18557
|
-
var _a, _b;
|
|
18558
18569
|
if (location.interior === 'Here') {
|
|
18559
18570
|
// native token
|
|
18560
18571
|
return getNativeAssetSymbol(node);
|
|
@@ -18563,10 +18574,11 @@ var getMultiLocationTokenIdPjs = function getMultiLocationTokenIdPjs(location, n
|
|
|
18563
18574
|
if (Object.keys(location.interior)[0] === 'X2') {
|
|
18564
18575
|
var junctions = Object.values(location.interior)[0];
|
|
18565
18576
|
if (Object.keys(junctions[0])[0] === 'PalletInstance' && junctions[0].PalletInstance === '50' && Object.keys(junctions[1])[0] === 'GeneralIndex') {
|
|
18577
|
+
var _foreignAssets$find$s, _foreignAssets$find;
|
|
18566
18578
|
var assetId = junctions[1].GeneralIndex;
|
|
18567
|
-
return (
|
|
18579
|
+
return (_foreignAssets$find$s = (_foreignAssets$find = foreignAssets.find(function (asset) {
|
|
18568
18580
|
return asset.assetId === String(assetId);
|
|
18569
|
-
})) === null ||
|
|
18581
|
+
})) === null || _foreignAssets$find === void 0 ? void 0 : _foreignAssets$find.symbol) !== null && _foreignAssets$find$s !== void 0 ? _foreignAssets$find$s : null;
|
|
18570
18582
|
}
|
|
18571
18583
|
}
|
|
18572
18584
|
return null;
|
|
@@ -18615,7 +18627,7 @@ var computeFeeFromDryRunPjs = function computeFeeFromDryRunPjs(dryRun, node, exe
|
|
|
18615
18627
|
return df.tokenSymbol === nativeAssetSymbol;
|
|
18616
18628
|
}).reduce(function (acc, df) {
|
|
18617
18629
|
return acc + df.plancks;
|
|
18618
|
-
},
|
|
18630
|
+
}, 0n);
|
|
18619
18631
|
return totalDeliveryFees + executionFee;
|
|
18620
18632
|
};
|
|
18621
18633
|
|
|
@@ -18655,175 +18667,6 @@ var isBridgeTransfer = function isBridgeTransfer(origin, destination) {
|
|
|
18655
18667
|
return origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama' || origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot';
|
|
18656
18668
|
};
|
|
18657
18669
|
|
|
18658
|
-
var KeepAliveError = /*#__PURE__*/function (_Error) {
|
|
18659
|
-
function KeepAliveError(message) {
|
|
18660
|
-
var _this;
|
|
18661
|
-
_classCallCheck(this, KeepAliveError);
|
|
18662
|
-
_this = _callSuper(this, KeepAliveError, [message]);
|
|
18663
|
-
_this.name = 'KeepAliveError';
|
|
18664
|
-
return _this;
|
|
18665
|
-
}
|
|
18666
|
-
_inherits(KeepAliveError, _Error);
|
|
18667
|
-
return _createClass(KeepAliveError);
|
|
18668
|
-
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
18669
|
-
|
|
18670
|
-
var checkKeepAlive = function checkKeepAlive(_a) {
|
|
18671
|
-
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
18672
|
-
var api = _ref.api,
|
|
18673
|
-
address = _ref.address,
|
|
18674
|
-
origin = _ref.origin,
|
|
18675
|
-
destApi = _ref.destApi,
|
|
18676
|
-
asset = _ref.asset,
|
|
18677
|
-
destination = _ref.destination;
|
|
18678
|
-
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
18679
|
-
var symbol, amount, balance, balanceOrigin, amountBN, ed, edOrigin, oldDisconnectAllowed, tx, xcmFee, increasedFee, amountBNWithoutFee, amountOriginBNWithoutFee;
|
|
18680
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18681
|
-
while (1) switch (_context.prev = _context.next) {
|
|
18682
|
-
case 0:
|
|
18683
|
-
if (!(destApi.getApi() === undefined)) {
|
|
18684
|
-
_context.next = 2;
|
|
18685
|
-
break;
|
|
18686
|
-
}
|
|
18687
|
-
return _context.abrupt("return");
|
|
18688
|
-
case 2:
|
|
18689
|
-
symbol = asset.symbol, amount = asset.amount;
|
|
18690
|
-
if (!(symbol !== getAssetsObject(destination).nativeAssetSymbol)) {
|
|
18691
|
-
_context.next = 5;
|
|
18692
|
-
break;
|
|
18693
|
-
}
|
|
18694
|
-
throw new KeepAliveError('Keep alive check is only supported when sending native asset of destination parachain.');
|
|
18695
|
-
case 5:
|
|
18696
|
-
_context.next = 7;
|
|
18697
|
-
return destApi.getBalanceNative(address);
|
|
18698
|
-
case 7:
|
|
18699
|
-
balance = _context.sent;
|
|
18700
|
-
_context.next = 10;
|
|
18701
|
-
return api.getBalanceNative(address);
|
|
18702
|
-
case 10:
|
|
18703
|
-
balanceOrigin = _context.sent;
|
|
18704
|
-
amountBN = BigInt(amount);
|
|
18705
|
-
ed = getExistentialDeposit(destination);
|
|
18706
|
-
edOrigin = getExistentialDeposit(origin);
|
|
18707
|
-
oldDisconnectAllowed = api.getDisconnectAllowed();
|
|
18708
|
-
api.setDisconnectAllowed(false);
|
|
18709
|
-
_context.next = 18;
|
|
18710
|
-
return Builder(api).from(origin).to(destination).currency({
|
|
18711
|
-
symbol: symbol,
|
|
18712
|
-
amount: amount
|
|
18713
|
-
}).address(address).build();
|
|
18714
|
-
case 18:
|
|
18715
|
-
tx = _context.sent;
|
|
18716
|
-
api.setDisconnectAllowed(oldDisconnectAllowed);
|
|
18717
|
-
if (!(tx === null)) {
|
|
18718
|
-
_context.next = 22;
|
|
18719
|
-
break;
|
|
18720
|
-
}
|
|
18721
|
-
throw new KeepAliveError('Transaction for XCM fee calculation could not be created.');
|
|
18722
|
-
case 22:
|
|
18723
|
-
_context.next = 24;
|
|
18724
|
-
return api.calculateTransactionFee(tx, address);
|
|
18725
|
-
case 24:
|
|
18726
|
-
xcmFee = _context.sent;
|
|
18727
|
-
if (!(ed === null)) {
|
|
18728
|
-
_context.next = 27;
|
|
18729
|
-
break;
|
|
18730
|
-
}
|
|
18731
|
-
throw new KeepAliveError('Existential deposit not found for destination parachain.');
|
|
18732
|
-
case 27:
|
|
18733
|
-
if (!(edOrigin === null)) {
|
|
18734
|
-
_context.next = 29;
|
|
18735
|
-
break;
|
|
18736
|
-
}
|
|
18737
|
-
throw new KeepAliveError('Existential deposit not found for origin parachain.');
|
|
18738
|
-
case 29:
|
|
18739
|
-
increasedFee = xcmFee + xcmFee / BigInt(2);
|
|
18740
|
-
amountBNWithoutFee = amountBN - increasedFee;
|
|
18741
|
-
if (!(balance + amountBNWithoutFee < BigInt(ed))) {
|
|
18742
|
-
_context.next = 33;
|
|
18743
|
-
break;
|
|
18744
|
-
}
|
|
18745
|
-
throw new KeepAliveError("Keep alive check failed: Sending ".concat(amount, " ").concat(symbol, " to ").concat(destination, " would result in an account balance below the required existential deposit.\n Please increase the amount to meet the minimum balance requirement of the destination chain."));
|
|
18746
|
-
case 33:
|
|
18747
|
-
amountOriginBNWithoutFee = amountBN - (xcmFee + xcmFee / BigInt(2));
|
|
18748
|
-
if (!((symbol === 'DOT' || symbol === 'KSM') && balanceOrigin - amountOriginBNWithoutFee > BigInt(edOrigin))) {
|
|
18749
|
-
_context.next = 36;
|
|
18750
|
-
break;
|
|
18751
|
-
}
|
|
18752
|
-
throw new KeepAliveError("Keep alive check failed: Sending ".concat(amount, " ").concat(symbol, " to ").concat(destination, " would result in an account balance below the required existential deposit on origin.\n Please decrease the amount to meet the minimum balance requirement of the origin chain."));
|
|
18753
|
-
case 36:
|
|
18754
|
-
case "end":
|
|
18755
|
-
return _context.stop();
|
|
18756
|
-
}
|
|
18757
|
-
}, _callee);
|
|
18758
|
-
})();
|
|
18759
|
-
});
|
|
18760
|
-
};
|
|
18761
|
-
|
|
18762
|
-
var performKeepAliveCheck = function performKeepAliveCheck(options, asset) {
|
|
18763
|
-
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
18764
|
-
var api, origin, destination, currency, address, destApiForKeepAlive, destApi;
|
|
18765
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18766
|
-
while (1) switch (_context.prev = _context.next) {
|
|
18767
|
-
case 0:
|
|
18768
|
-
api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, address = options.address, destApiForKeepAlive = options.destApiForKeepAlive;
|
|
18769
|
-
if (!('multilocation' in currency || 'multiasset' in currency)) {
|
|
18770
|
-
_context.next = 5;
|
|
18771
|
-
break;
|
|
18772
|
-
}
|
|
18773
|
-
console.warn('Keep alive check is not supported when using MultiLocation / MultiAsset as currency.');
|
|
18774
|
-
_context.next = 24;
|
|
18775
|
-
break;
|
|
18776
|
-
case 5:
|
|
18777
|
-
if (!(_typeof(address) === 'object')) {
|
|
18778
|
-
_context.next = 9;
|
|
18779
|
-
break;
|
|
18780
|
-
}
|
|
18781
|
-
console.warn('Keep alive check is not supported when using MultiLocation as address.');
|
|
18782
|
-
_context.next = 24;
|
|
18783
|
-
break;
|
|
18784
|
-
case 9:
|
|
18785
|
-
if (!(_typeof(destination) === 'object')) {
|
|
18786
|
-
_context.next = 13;
|
|
18787
|
-
break;
|
|
18788
|
-
}
|
|
18789
|
-
console.warn('Keep alive check is not supported when using MultiLocation as destination.');
|
|
18790
|
-
_context.next = 24;
|
|
18791
|
-
break;
|
|
18792
|
-
case 13:
|
|
18793
|
-
if (!(destination === 'Ethereum')) {
|
|
18794
|
-
_context.next = 17;
|
|
18795
|
-
break;
|
|
18796
|
-
}
|
|
18797
|
-
console.warn('Keep alive check is not supported when using Ethereum as origin or destination.');
|
|
18798
|
-
_context.next = 24;
|
|
18799
|
-
break;
|
|
18800
|
-
case 17:
|
|
18801
|
-
if (asset) {
|
|
18802
|
-
_context.next = 21;
|
|
18803
|
-
break;
|
|
18804
|
-
}
|
|
18805
|
-
console.warn('Keep alive check is not supported when asset check is disabled.');
|
|
18806
|
-
_context.next = 24;
|
|
18807
|
-
break;
|
|
18808
|
-
case 21:
|
|
18809
|
-
destApi = destApiForKeepAlive !== null && destApiForKeepAlive !== void 0 ? destApiForKeepAlive : api.clone();
|
|
18810
|
-
_context.next = 24;
|
|
18811
|
-
return checkKeepAlive({
|
|
18812
|
-
api: api,
|
|
18813
|
-
origin: origin,
|
|
18814
|
-
destination: destination,
|
|
18815
|
-
address: address,
|
|
18816
|
-
destApi: destApi,
|
|
18817
|
-
asset: asset
|
|
18818
|
-
});
|
|
18819
|
-
case 24:
|
|
18820
|
-
case "end":
|
|
18821
|
-
return _context.stop();
|
|
18822
|
-
}
|
|
18823
|
-
}, _callee);
|
|
18824
|
-
}));
|
|
18825
|
-
};
|
|
18826
|
-
|
|
18827
18670
|
var resolveAsset = function resolveAsset(currency, origin, destination, assetCheckEnabled) {
|
|
18828
18671
|
return assetCheckEnabled ? getAssetBySymbolOrId(origin, currency, !isTMultiLocation(destination) ? destination : null) : null;
|
|
18829
18672
|
};
|
|
@@ -18888,8 +18731,8 @@ var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled
|
|
|
18888
18731
|
});
|
|
18889
18732
|
}
|
|
18890
18733
|
if ('symbol' in currency && nativeAssets.some(function (nativeAsset) {
|
|
18891
|
-
var
|
|
18892
|
-
return nativeAsset.symbol.toLowerCase() === (
|
|
18734
|
+
var _asset$symbol;
|
|
18735
|
+
return nativeAsset.symbol.toLowerCase() === (asset === null || asset === void 0 || (_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toLowerCase());
|
|
18893
18736
|
})) {
|
|
18894
18737
|
throw new InvalidCurrencyError("".concat(JSON.stringify(asset === null || asset === void 0 ? void 0 : asset.symbol), " is not supported for transfers to ").concat(destination, "."));
|
|
18895
18738
|
}
|
|
@@ -18902,82 +18745,56 @@ var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled
|
|
|
18902
18745
|
}
|
|
18903
18746
|
};
|
|
18904
18747
|
|
|
18905
|
-
var transferRelayToPara = function
|
|
18906
|
-
|
|
18907
|
-
var api, origin, destination, asset, address, paraIdTo,
|
|
18748
|
+
var transferRelayToPara = /*#__PURE__*/function () {
|
|
18749
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
18750
|
+
var api, origin, destination, asset, address, paraIdTo, version, pallet, method, isMultiLocationDestination, serializedApiCall;
|
|
18908
18751
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18909
18752
|
while (1) switch (_context.prev = _context.next) {
|
|
18910
18753
|
case 0:
|
|
18911
|
-
api = options.api, origin = options.origin, destination = options.destination, asset = options.asset, address = options.address, paraIdTo = options.paraIdTo,
|
|
18754
|
+
api = options.api, origin = options.origin, destination = options.destination, asset = options.asset, address = options.address, paraIdTo = options.paraIdTo, version = options.version, pallet = options.pallet, method = options.method;
|
|
18912
18755
|
isMultiLocationDestination = _typeof(destination) === 'object';
|
|
18913
|
-
isAddressMultiLocation = _typeof(address) === 'object';
|
|
18914
18756
|
if (!(api.getApiOrUrl() === undefined && isMultiLocationDestination)) {
|
|
18915
|
-
_context.next =
|
|
18757
|
+
_context.next = 4;
|
|
18916
18758
|
break;
|
|
18917
18759
|
}
|
|
18918
18760
|
throw new Error('API is required when using MultiLocation as destination.');
|
|
18919
|
-
case
|
|
18920
|
-
_context.next =
|
|
18761
|
+
case 4:
|
|
18762
|
+
_context.next = 6;
|
|
18921
18763
|
return api.init(origin);
|
|
18922
|
-
case
|
|
18923
|
-
_context.prev =
|
|
18924
|
-
if (!isMultiLocationDestination) {
|
|
18925
|
-
_context.next = 12;
|
|
18926
|
-
break;
|
|
18927
|
-
}
|
|
18928
|
-
console.warn('Keep alive check is not supported when using MultiLocation as destination.');
|
|
18929
|
-
_context.next = 19;
|
|
18930
|
-
break;
|
|
18931
|
-
case 12:
|
|
18932
|
-
if (!isAddressMultiLocation) {
|
|
18933
|
-
_context.next = 16;
|
|
18934
|
-
break;
|
|
18935
|
-
}
|
|
18936
|
-
console.warn('Keep alive check is not supported when using MultiLocation as address.');
|
|
18937
|
-
_context.next = 19;
|
|
18938
|
-
break;
|
|
18939
|
-
case 16:
|
|
18940
|
-
destApi = destApiForKeepAlive !== null && destApiForKeepAlive !== void 0 ? destApiForKeepAlive : api.clone();
|
|
18941
|
-
_context.next = 19;
|
|
18942
|
-
return checkKeepAlive({
|
|
18943
|
-
api: api,
|
|
18944
|
-
address: address,
|
|
18945
|
-
destApi: destApi,
|
|
18946
|
-
asset: asset,
|
|
18947
|
-
origin: origin,
|
|
18948
|
-
destination: destination
|
|
18949
|
-
});
|
|
18950
|
-
case 19:
|
|
18764
|
+
case 6:
|
|
18765
|
+
_context.prev = 6;
|
|
18951
18766
|
serializedApiCall = getNode(isMultiLocationDestination ? resolveTNodeFromMultiLocation(origin, destination) : destination).transferRelayToPara({
|
|
18952
18767
|
api: api,
|
|
18953
18768
|
origin: origin,
|
|
18954
18769
|
destination: destination,
|
|
18955
18770
|
address: address,
|
|
18956
18771
|
paraIdTo: paraIdTo,
|
|
18957
|
-
destApiForKeepAlive: destApiForKeepAlive,
|
|
18958
18772
|
asset: asset,
|
|
18959
18773
|
version: version,
|
|
18960
18774
|
pallet: pallet,
|
|
18961
18775
|
method: method
|
|
18962
18776
|
});
|
|
18963
18777
|
return _context.abrupt("return", api.callTxMethod(serializedApiCall));
|
|
18964
|
-
case
|
|
18965
|
-
_context.prev =
|
|
18778
|
+
case 9:
|
|
18779
|
+
_context.prev = 9;
|
|
18966
18780
|
if (!isPjsClient(api.getApi())) {
|
|
18967
|
-
_context.next =
|
|
18781
|
+
_context.next = 13;
|
|
18968
18782
|
break;
|
|
18969
18783
|
}
|
|
18970
|
-
_context.next =
|
|
18784
|
+
_context.next = 13;
|
|
18971
18785
|
return api.disconnect();
|
|
18972
|
-
case
|
|
18973
|
-
return _context.finish(
|
|
18974
|
-
case
|
|
18786
|
+
case 13:
|
|
18787
|
+
return _context.finish(9);
|
|
18788
|
+
case 14:
|
|
18975
18789
|
case "end":
|
|
18976
18790
|
return _context.stop();
|
|
18977
18791
|
}
|
|
18978
|
-
}, _callee, null, [[
|
|
18792
|
+
}, _callee, null, [[6,, 9, 14]]);
|
|
18979
18793
|
}));
|
|
18980
|
-
|
|
18794
|
+
return function transferRelayToPara(_x) {
|
|
18795
|
+
return _ref.apply(this, arguments);
|
|
18796
|
+
};
|
|
18797
|
+
}();
|
|
18981
18798
|
|
|
18982
18799
|
var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge, assetCheckEnabled) {
|
|
18983
18800
|
var currency = options.currency,
|
|
@@ -18994,7 +18811,7 @@ var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge,
|
|
|
18994
18811
|
}
|
|
18995
18812
|
// MultiAsset is an array of TCurrencyCore, search for assets
|
|
18996
18813
|
var assets = currency.multiasset.map(function (currency) {
|
|
18997
|
-
var
|
|
18814
|
+
var _currency$isFeeAsset;
|
|
18998
18815
|
var asset = getAssetBySymbolOrId(origin, currency, !isTMultiLocation(destination) ? destination : null);
|
|
18999
18816
|
if (asset && (!isForeignAsset(asset) || !asset.multiLocation)) {
|
|
19000
18817
|
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " does not have a multiLocation"));
|
|
@@ -19002,8 +18819,8 @@ var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge,
|
|
|
19002
18819
|
validateAssetSupport(options, assetCheckEnabled, isBridge, asset);
|
|
19003
18820
|
var originTyped = origin;
|
|
19004
18821
|
var originNode = getNode(originTyped);
|
|
19005
|
-
return
|
|
19006
|
-
isFeeAsset: (
|
|
18822
|
+
return _objectSpread2({
|
|
18823
|
+
isFeeAsset: (_currency$isFeeAsset = currency.isFeeAsset) !== null && _currency$isFeeAsset !== void 0 ? _currency$isFeeAsset : false
|
|
19007
18824
|
}, createMultiAsset(originNode.version, currency.amount, asset === null || asset === void 0 ? void 0 : asset.multiLocation));
|
|
19008
18825
|
});
|
|
19009
18826
|
return assets;
|
|
@@ -19011,13 +18828,13 @@ var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge,
|
|
|
19011
18828
|
return undefined;
|
|
19012
18829
|
};
|
|
19013
18830
|
|
|
19014
|
-
var send = function
|
|
19015
|
-
|
|
19016
|
-
var api, origin, currency, address, destination, paraIdTo,
|
|
18831
|
+
var send = /*#__PURE__*/function () {
|
|
18832
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
18833
|
+
var api, origin, currency, address, destination, paraIdTo, version, ahAddress, pallet, method, isBridge, assetCheckEnabled, asset, overriddenAsset, resolvedAsset, originNode;
|
|
19017
18834
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
19018
18835
|
while (1) switch (_context.prev = _context.next) {
|
|
19019
18836
|
case 0:
|
|
19020
|
-
api = options.api, origin = options.origin, currency = options.currency, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo,
|
|
18837
|
+
api = options.api, origin = options.origin, currency = options.currency, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, version = options.version, ahAddress = options.ahAddress, pallet = options.pallet, method = options.method;
|
|
19021
18838
|
validateCurrency(currency);
|
|
19022
18839
|
validateDestination(origin, destination);
|
|
19023
18840
|
validateDestinationAddress(address, destination);
|
|
@@ -19053,11 +18870,10 @@ var send = function send(options) {
|
|
|
19053
18870
|
origin: origin,
|
|
19054
18871
|
destination: destination,
|
|
19055
18872
|
address: address,
|
|
19056
|
-
asset:
|
|
18873
|
+
asset: _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
19057
18874
|
amount: 'multiasset' in currency ? 0 : currency.amount
|
|
19058
18875
|
}),
|
|
19059
18876
|
paraIdTo: paraIdTo,
|
|
19060
|
-
destApiForKeepAlive: destApiForKeepAlive,
|
|
19061
18877
|
version: version,
|
|
19062
18878
|
pallet: pallet,
|
|
19063
18879
|
method: method
|
|
@@ -19068,20 +18884,15 @@ var send = function send(options) {
|
|
|
19068
18884
|
return api.init(origin);
|
|
19069
18885
|
case 20:
|
|
19070
18886
|
_context.prev = 20;
|
|
19071
|
-
_context.next = 23;
|
|
19072
|
-
return performKeepAliveCheck(options, asset ? Object.assign(Object.assign({}, asset), {
|
|
19073
|
-
amount: 'multiasset' in currency ? 0 : currency.amount
|
|
19074
|
-
}) : null);
|
|
19075
|
-
case 23:
|
|
19076
18887
|
// In case asset check is disabled, we create asset object from currency symbol
|
|
19077
18888
|
resolvedAsset = asset !== null && asset !== void 0 ? asset : {
|
|
19078
18889
|
symbol: 'symbol' in currency ? currency.symbol : undefined
|
|
19079
18890
|
};
|
|
19080
18891
|
originNode = getNode(origin);
|
|
19081
|
-
_context.next =
|
|
18892
|
+
_context.next = 25;
|
|
19082
18893
|
return originNode.transfer({
|
|
19083
18894
|
api: api,
|
|
19084
|
-
asset:
|
|
18895
|
+
asset: _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
|
|
19085
18896
|
amount: 'multiasset' in currency ? 0 : currency.amount
|
|
19086
18897
|
}),
|
|
19087
18898
|
address: address,
|
|
@@ -19089,33 +18900,35 @@ var send = function send(options) {
|
|
|
19089
18900
|
paraIdTo: paraIdTo,
|
|
19090
18901
|
overriddenAsset: overriddenAsset,
|
|
19091
18902
|
version: version,
|
|
19092
|
-
destApiForKeepAlive: destApiForKeepAlive,
|
|
19093
18903
|
ahAddress: ahAddress,
|
|
19094
18904
|
pallet: pallet,
|
|
19095
18905
|
method: method
|
|
19096
18906
|
});
|
|
19097
|
-
case
|
|
18907
|
+
case 25:
|
|
19098
18908
|
return _context.abrupt("return", _context.sent);
|
|
19099
|
-
case
|
|
19100
|
-
_context.prev =
|
|
18909
|
+
case 26:
|
|
18910
|
+
_context.prev = 26;
|
|
19101
18911
|
if (!isPjsClient(api.getApi())) {
|
|
19102
|
-
_context.next =
|
|
18912
|
+
_context.next = 30;
|
|
19103
18913
|
break;
|
|
19104
18914
|
}
|
|
19105
|
-
_context.next =
|
|
18915
|
+
_context.next = 30;
|
|
19106
18916
|
return api.disconnect();
|
|
19107
|
-
case
|
|
19108
|
-
return _context.finish(
|
|
19109
|
-
case
|
|
18917
|
+
case 30:
|
|
18918
|
+
return _context.finish(26);
|
|
18919
|
+
case 31:
|
|
19110
18920
|
case "end":
|
|
19111
18921
|
return _context.stop();
|
|
19112
18922
|
}
|
|
19113
|
-
}, _callee, null, [[20,,
|
|
18923
|
+
}, _callee, null, [[20,, 26, 31]]);
|
|
19114
18924
|
}));
|
|
19115
|
-
|
|
18925
|
+
return function send(_x) {
|
|
18926
|
+
return _ref.apply(this, arguments);
|
|
18927
|
+
};
|
|
18928
|
+
}();
|
|
19116
18929
|
|
|
19117
|
-
var getDryRun = function
|
|
19118
|
-
|
|
18930
|
+
var getDryRun = /*#__PURE__*/function () {
|
|
18931
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
19119
18932
|
var api, node;
|
|
19120
18933
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
19121
18934
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -19147,7 +18960,10 @@ var getDryRun = function getDryRun(options) {
|
|
|
19147
18960
|
}
|
|
19148
18961
|
}, _callee, null, [[5,, 9, 13]]);
|
|
19149
18962
|
}));
|
|
19150
|
-
|
|
18963
|
+
return function getDryRun(_x) {
|
|
18964
|
+
return _ref.apply(this, arguments);
|
|
18965
|
+
};
|
|
18966
|
+
}();
|
|
19151
18967
|
|
|
19152
18968
|
var isEthersSigner = function isEthersSigner(signer) {
|
|
19153
18969
|
return _typeof(signer) === 'object' && signer !== null && 'provider' in signer;
|
|
@@ -19178,7 +18994,7 @@ var getDestinationMultilocation = function getDestinationMultilocation(api, addr
|
|
|
19178
18994
|
var acc = "0x".concat(accountType).concat(addressHex, "00");
|
|
19179
18995
|
var _getNodeConfig = getNodeConfig(destination),
|
|
19180
18996
|
paraId = _getNodeConfig.paraId;
|
|
19181
|
-
return [1, ["0x0000000".concat(paraId.toString(16)), acc]];
|
|
18997
|
+
return [1, paraId ? ["0x0000000".concat(paraId.toString(16)), acc] : [acc]];
|
|
19182
18998
|
};
|
|
19183
18999
|
|
|
19184
19000
|
var abi = [
|
|
@@ -19278,107 +19094,108 @@ var abi = [
|
|
|
19278
19094
|
}
|
|
19279
19095
|
];
|
|
19280
19096
|
|
|
19281
|
-
var U_64_MAX =
|
|
19097
|
+
var U_64_MAX = 18446744073709551615n;
|
|
19282
19098
|
var CONTRACT_ADDRESS = '0x0000000000000000000000000000000000000804';
|
|
19283
19099
|
var NATIVE_ASSET_ID = '0x0000000000000000000000000000000000000802';
|
|
19284
19100
|
// Partially inspired by Moonbeam XCM-SDK
|
|
19285
|
-
var transferMoonbeamEvm = function
|
|
19286
|
-
|
|
19287
|
-
var
|
|
19288
|
-
|
|
19289
|
-
|
|
19290
|
-
|
|
19291
|
-
|
|
19292
|
-
|
|
19293
|
-
|
|
19294
|
-
|
|
19295
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
19296
|
-
while (1) switch (_context.prev = _context.next) {
|
|
19297
|
-
case 0:
|
|
19298
|
-
contract = isEthersSigner(signer) ? new ethers.Contract(CONTRACT_ADDRESS, abi, signer) : viem.getContract({
|
|
19299
|
-
abi: abi,
|
|
19300
|
-
address: CONTRACT_ADDRESS,
|
|
19301
|
-
client: {
|
|
19302
|
-
"public": viem.createPublicClient({
|
|
19303
|
-
chain: signer.chain,
|
|
19304
|
-
transport: viem.http()
|
|
19305
|
-
}),
|
|
19306
|
-
wallet: signer
|
|
19307
|
-
}
|
|
19308
|
-
});
|
|
19309
|
-
foundAsset = getAssetBySymbolOrId(from, currency, to);
|
|
19310
|
-
if (!(foundAsset === null)) {
|
|
19311
|
-
_context.next = 4;
|
|
19312
|
-
break;
|
|
19313
|
-
}
|
|
19314
|
-
throw new InvalidCurrencyError("Origin node ".concat(from, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
19315
|
-
case 4:
|
|
19316
|
-
if (!(foundAsset.symbol === getNativeAssetSymbol(from))) {
|
|
19317
|
-
_context.next = 8;
|
|
19318
|
-
break;
|
|
19319
|
-
}
|
|
19320
|
-
asset = NATIVE_ASSET_ID;
|
|
19321
|
-
_context.next = 11;
|
|
19101
|
+
var transferMoonbeamEvm = /*#__PURE__*/function () {
|
|
19102
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
19103
|
+
var _usdtAsset$assetId;
|
|
19104
|
+
var api, from, to, signer, address, currency, contract, foundAsset, asset, destMultiLocation, weight, createTx, multiCurrencySymbols, useMultiAssets, usdtAsset, tx;
|
|
19105
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
19106
|
+
while (1) switch (_context.prev = _context.next) {
|
|
19107
|
+
case 0:
|
|
19108
|
+
api = _ref.api, from = _ref.from, to = _ref.to, signer = _ref.signer, address = _ref.address, currency = _ref.currency;
|
|
19109
|
+
if (!('multiasset' in currency)) {
|
|
19110
|
+
_context.next = 3;
|
|
19322
19111
|
break;
|
|
19323
|
-
|
|
19324
|
-
|
|
19325
|
-
|
|
19326
|
-
|
|
19112
|
+
}
|
|
19113
|
+
throw new Error('Multiassets syntax is not supported for Evm transfers');
|
|
19114
|
+
case 3:
|
|
19115
|
+
if (!('multilocation' in currency && isOverrideMultiLocationSpecifier(currency.multilocation))) {
|
|
19116
|
+
_context.next = 5;
|
|
19117
|
+
break;
|
|
19118
|
+
}
|
|
19119
|
+
throw new Error('Override multilocation is not supported for Evm transfers');
|
|
19120
|
+
case 5:
|
|
19121
|
+
contract = isEthersSigner(signer) ? new ethers.Contract(CONTRACT_ADDRESS, abi, signer) : viem.getContract({
|
|
19122
|
+
abi: abi,
|
|
19123
|
+
address: CONTRACT_ADDRESS,
|
|
19124
|
+
client: {
|
|
19125
|
+
"public": viem.createPublicClient({
|
|
19126
|
+
chain: signer.chain,
|
|
19127
|
+
transport: viem.http()
|
|
19128
|
+
}),
|
|
19129
|
+
wallet: signer
|
|
19327
19130
|
}
|
|
19328
|
-
|
|
19329
|
-
|
|
19330
|
-
|
|
19331
|
-
|
|
19332
|
-
|
|
19333
|
-
|
|
19334
|
-
|
|
19335
|
-
|
|
19336
|
-
|
|
19337
|
-
|
|
19338
|
-
|
|
19339
|
-
|
|
19340
|
-
|
|
19341
|
-
|
|
19342
|
-
|
|
19343
|
-
|
|
19344
|
-
|
|
19345
|
-
|
|
19346
|
-
|
|
19347
|
-
|
|
19348
|
-
|
|
19131
|
+
});
|
|
19132
|
+
foundAsset = getAssetBySymbolOrId(from, currency, to);
|
|
19133
|
+
if (!(foundAsset === null)) {
|
|
19134
|
+
_context.next = 9;
|
|
19135
|
+
break;
|
|
19136
|
+
}
|
|
19137
|
+
throw new InvalidCurrencyError("Origin node ".concat(from, " does not support currency ").concat(JSON.stringify(currency), "."));
|
|
19138
|
+
case 9:
|
|
19139
|
+
if (!(foundAsset.symbol === getNativeAssetSymbol(from))) {
|
|
19140
|
+
_context.next = 13;
|
|
19141
|
+
break;
|
|
19142
|
+
}
|
|
19143
|
+
asset = NATIVE_ASSET_ID;
|
|
19144
|
+
_context.next = 16;
|
|
19145
|
+
break;
|
|
19146
|
+
case 13:
|
|
19147
|
+
if (!(!isForeignAsset(foundAsset) || !foundAsset.assetId)) {
|
|
19148
|
+
_context.next = 15;
|
|
19149
|
+
break;
|
|
19150
|
+
}
|
|
19151
|
+
throw new InvalidCurrencyError('Currency must be a foreign asset with valid assetId');
|
|
19152
|
+
case 15:
|
|
19153
|
+
asset = formatAssetIdToERC20(foundAsset.assetId);
|
|
19154
|
+
case 16:
|
|
19155
|
+
destMultiLocation = getDestinationMultilocation(api, address, to);
|
|
19156
|
+
weight = U_64_MAX; // Partially inspired by Moonbeam XCM-SDK
|
|
19157
|
+
// https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/sdk/src/contract/contracts/Xtokens/Xtokens.ts#L53
|
|
19158
|
+
createTx = function createTx(func, args) {
|
|
19159
|
+
if (isEthersContract(contract)) {
|
|
19160
|
+
return contract[func].apply(contract, _toConsumableArray(args));
|
|
19349
19161
|
}
|
|
19350
|
-
|
|
19351
|
-
|
|
19352
|
-
|
|
19353
|
-
|
|
19354
|
-
|
|
19355
|
-
|
|
19356
|
-
|
|
19162
|
+
return contract.write[func](args);
|
|
19163
|
+
};
|
|
19164
|
+
multiCurrencySymbols = ['xcPINK', 'xcDED', 'xcSTINK', 'xcWIFD', 'xcNCTR'];
|
|
19165
|
+
useMultiAssets = from === 'Moonbeam' && to === 'AssetHubPolkadot' && multiCurrencySymbols.includes(foundAsset.symbol);
|
|
19166
|
+
usdtAsset = getAssetBySymbolOrId(from, {
|
|
19167
|
+
symbol: 'xcUSDT'
|
|
19168
|
+
}, to);
|
|
19169
|
+
if (!useMultiAssets) {
|
|
19170
|
+
_context.next = 28;
|
|
19357
19171
|
break;
|
|
19358
|
-
|
|
19359
|
-
|
|
19360
|
-
|
|
19361
|
-
|
|
19362
|
-
|
|
19363
|
-
|
|
19364
|
-
|
|
19365
|
-
|
|
19366
|
-
|
|
19367
|
-
|
|
19368
|
-
|
|
19369
|
-
|
|
19370
|
-
|
|
19371
|
-
|
|
19372
|
-
|
|
19373
|
-
|
|
19374
|
-
|
|
19375
|
-
|
|
19376
|
-
|
|
19377
|
-
|
|
19378
|
-
|
|
19379
|
-
|
|
19380
|
-
|
|
19381
|
-
|
|
19172
|
+
}
|
|
19173
|
+
_context.next = 25;
|
|
19174
|
+
return createTx('transferMultiCurrencies', [[[asset, currency.amount], [formatAssetIdToERC20((_usdtAsset$assetId = usdtAsset.assetId) !== null && _usdtAsset$assetId !== void 0 ? _usdtAsset$assetId : ''), '200000']], 1,
|
|
19175
|
+
// index of the fee asset
|
|
19176
|
+
destMultiLocation, weight]);
|
|
19177
|
+
case 25:
|
|
19178
|
+
_context.t0 = _context.sent;
|
|
19179
|
+
_context.next = 31;
|
|
19180
|
+
break;
|
|
19181
|
+
case 28:
|
|
19182
|
+
_context.next = 30;
|
|
19183
|
+
return createTx('transfer', [asset, currency.amount, destMultiLocation, weight]);
|
|
19184
|
+
case 30:
|
|
19185
|
+
_context.t0 = _context.sent;
|
|
19186
|
+
case 31:
|
|
19187
|
+
tx = _context.t0;
|
|
19188
|
+
return _context.abrupt("return", _typeof(tx) === 'object' ? tx.hash : tx);
|
|
19189
|
+
case 33:
|
|
19190
|
+
case "end":
|
|
19191
|
+
return _context.stop();
|
|
19192
|
+
}
|
|
19193
|
+
}, _callee);
|
|
19194
|
+
}));
|
|
19195
|
+
return function transferMoonbeamEvm(_x) {
|
|
19196
|
+
return _ref2.apply(this, arguments);
|
|
19197
|
+
};
|
|
19198
|
+
}();
|
|
19382
19199
|
|
|
19383
19200
|
exports.Builder = Builder;
|
|
19384
19201
|
exports.DuplicateAssetError = DuplicateAssetError;
|
|
@@ -19399,7 +19216,6 @@ exports.NodeNotSupportedError = NodeNotSupportedError;
|
|
|
19399
19216
|
exports.Override = Override;
|
|
19400
19217
|
exports.SUPPORTED_PALLETS = SUPPORTED_PALLETS;
|
|
19401
19218
|
exports.ScenarioNotSupportedError = ScenarioNotSupportedError;
|
|
19402
|
-
exports.assets = index$1;
|
|
19403
19219
|
exports.claimAssets = claimAssets;
|
|
19404
19220
|
exports.computeFeeFromDryRun = computeFeeFromDryRun;
|
|
19405
19221
|
exports.computeFeeFromDryRunPjs = computeFeeFromDryRunPjs;
|
|
@@ -19446,9 +19262,9 @@ exports.getTransferableAmount = getTransferableAmount;
|
|
|
19446
19262
|
exports.hasSupportForAsset = hasSupportForAsset;
|
|
19447
19263
|
exports.isForeignAsset = isForeignAsset;
|
|
19448
19264
|
exports.isNodeEvm = isNodeEvm;
|
|
19265
|
+
exports.isOverrideMultiLocationSpecifier = isOverrideMultiLocationSpecifier;
|
|
19449
19266
|
exports.isRelayChain = isRelayChain;
|
|
19450
19267
|
exports.resolveModuleError = resolveModuleError;
|
|
19451
19268
|
exports.send = send;
|
|
19452
19269
|
exports.transferMoonbeamEvm = transferMoonbeamEvm;
|
|
19453
19270
|
exports.transferRelayToPara = transferRelayToPara;
|
|
19454
|
-
exports.xcmPallet = index;
|