@paraspell/sdk 7.2.1 → 7.2.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 +320 -127
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +320 -127
- package/dist/papi/index.cjs +306 -129
- package/dist/papi/index.d.ts +3 -0
- package/dist/papi/index.mjs +306 -129
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -15049,7 +15049,7 @@ var getExistentialDeposit$1 = function getExistentialDeposit(node) {
|
|
|
15049
15049
|
return edMap[node];
|
|
15050
15050
|
};
|
|
15051
15051
|
|
|
15052
|
-
var
|
|
15052
|
+
var getBalanceNativeInternal = function getBalanceNativeInternal(_a) {
|
|
15053
15053
|
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
15054
15054
|
var address = _ref.address,
|
|
15055
15055
|
node = _ref.node,
|
|
@@ -15073,6 +15073,31 @@ var getBalanceNative$1 = function getBalanceNative(_a) {
|
|
|
15073
15073
|
})();
|
|
15074
15074
|
});
|
|
15075
15075
|
};
|
|
15076
|
+
var getBalanceNative$1 = function getBalanceNative(options) {
|
|
15077
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
15078
|
+
var api;
|
|
15079
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
15080
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
15081
|
+
case 0:
|
|
15082
|
+
api = options.api;
|
|
15083
|
+
_context2.prev = 1;
|
|
15084
|
+
_context2.next = 4;
|
|
15085
|
+
return getBalanceNativeInternal(options);
|
|
15086
|
+
case 4:
|
|
15087
|
+
return _context2.abrupt("return", _context2.sent);
|
|
15088
|
+
case 5:
|
|
15089
|
+
_context2.prev = 5;
|
|
15090
|
+
_context2.next = 8;
|
|
15091
|
+
return api.disconnect();
|
|
15092
|
+
case 8:
|
|
15093
|
+
return _context2.finish(5);
|
|
15094
|
+
case 9:
|
|
15095
|
+
case "end":
|
|
15096
|
+
return _context2.stop();
|
|
15097
|
+
}
|
|
15098
|
+
}, _callee2, null, [[1,, 5, 9]]);
|
|
15099
|
+
}));
|
|
15100
|
+
};
|
|
15076
15101
|
|
|
15077
15102
|
var AssetHubPolkadot = {
|
|
15078
15103
|
defaultPallet: "PolkadotXcm",
|
|
@@ -15989,14 +16014,14 @@ var getBalanceForeignXTokens = function getBalanceForeignXTokens(api, node, addr
|
|
|
15989
16014
|
}));
|
|
15990
16015
|
};
|
|
15991
16016
|
|
|
15992
|
-
var
|
|
16017
|
+
var getBalanceForeignInternal = function getBalanceForeignInternal(_a) {
|
|
15993
16018
|
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
15994
16019
|
var address = _ref.address,
|
|
15995
16020
|
node = _ref.node,
|
|
15996
16021
|
currency = _ref.currency,
|
|
15997
16022
|
api = _ref.api;
|
|
15998
16023
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
15999
|
-
var _b, asset;
|
|
16024
|
+
var _b, asset, defaultPallet;
|
|
16000
16025
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
16001
16026
|
while (1) switch (_context.prev = _context.next) {
|
|
16002
16027
|
case 0:
|
|
@@ -16010,26 +16035,27 @@ var getBalanceForeign$1 = function getBalanceForeign(_a) {
|
|
|
16010
16035
|
}
|
|
16011
16036
|
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(node));
|
|
16012
16037
|
case 5:
|
|
16013
|
-
|
|
16014
|
-
|
|
16038
|
+
defaultPallet = getDefaultPallet(node);
|
|
16039
|
+
if (!(defaultPallet === 'XTokens')) {
|
|
16040
|
+
_context.next = 12;
|
|
16015
16041
|
break;
|
|
16016
16042
|
}
|
|
16017
|
-
_context.next =
|
|
16043
|
+
_context.next = 9;
|
|
16018
16044
|
return getBalanceForeignXTokens(api, node, address, asset);
|
|
16019
|
-
case
|
|
16045
|
+
case 9:
|
|
16020
16046
|
return _context.abrupt("return", _context.sent);
|
|
16021
|
-
case
|
|
16022
|
-
if (!(
|
|
16023
|
-
_context.next =
|
|
16047
|
+
case 12:
|
|
16048
|
+
if (!(defaultPallet === 'PolkadotXcm')) {
|
|
16049
|
+
_context.next = 16;
|
|
16024
16050
|
break;
|
|
16025
16051
|
}
|
|
16026
|
-
_context.next =
|
|
16052
|
+
_context.next = 15;
|
|
16027
16053
|
return getBalanceForeignPolkadotXcm(api, node, address, asset);
|
|
16028
|
-
case 14:
|
|
16029
|
-
return _context.abrupt("return", _context.sent);
|
|
16030
16054
|
case 15:
|
|
16031
|
-
|
|
16055
|
+
return _context.abrupt("return", _context.sent);
|
|
16032
16056
|
case 16:
|
|
16057
|
+
throw new Error('Unsupported pallet');
|
|
16058
|
+
case 17:
|
|
16033
16059
|
case "end":
|
|
16034
16060
|
return _context.stop();
|
|
16035
16061
|
}
|
|
@@ -16037,8 +16063,33 @@ var getBalanceForeign$1 = function getBalanceForeign(_a) {
|
|
|
16037
16063
|
})();
|
|
16038
16064
|
});
|
|
16039
16065
|
};
|
|
16066
|
+
var getBalanceForeign$1 = function getBalanceForeign(options) {
|
|
16067
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
16068
|
+
var api;
|
|
16069
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
16070
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
16071
|
+
case 0:
|
|
16072
|
+
api = options.api;
|
|
16073
|
+
_context2.prev = 1;
|
|
16074
|
+
_context2.next = 4;
|
|
16075
|
+
return getBalanceForeignInternal(options);
|
|
16076
|
+
case 4:
|
|
16077
|
+
return _context2.abrupt("return", _context2.sent);
|
|
16078
|
+
case 5:
|
|
16079
|
+
_context2.prev = 5;
|
|
16080
|
+
_context2.next = 8;
|
|
16081
|
+
return api.disconnect();
|
|
16082
|
+
case 8:
|
|
16083
|
+
return _context2.finish(5);
|
|
16084
|
+
case 9:
|
|
16085
|
+
case "end":
|
|
16086
|
+
return _context2.stop();
|
|
16087
|
+
}
|
|
16088
|
+
}, _callee2, null, [[1,, 5, 9]]);
|
|
16089
|
+
}));
|
|
16090
|
+
};
|
|
16040
16091
|
|
|
16041
|
-
var
|
|
16092
|
+
var getAssetBalanceInternal = function getAssetBalanceInternal(_a) {
|
|
16042
16093
|
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
16043
16094
|
var address = _ref.address,
|
|
16044
16095
|
node = _ref.node,
|
|
@@ -16058,7 +16109,7 @@ var getAssetBalance$1 = function getAssetBalance(_a) {
|
|
|
16058
16109
|
break;
|
|
16059
16110
|
}
|
|
16060
16111
|
_context.next = 6;
|
|
16061
|
-
return
|
|
16112
|
+
return getBalanceNativeInternal({
|
|
16062
16113
|
address: address,
|
|
16063
16114
|
node: node,
|
|
16064
16115
|
api: api
|
|
@@ -16069,7 +16120,7 @@ var getAssetBalance$1 = function getAssetBalance(_a) {
|
|
|
16069
16120
|
break;
|
|
16070
16121
|
case 9:
|
|
16071
16122
|
_context.next = 11;
|
|
16072
|
-
return
|
|
16123
|
+
return getBalanceForeignInternal({
|
|
16073
16124
|
address: address,
|
|
16074
16125
|
node: node,
|
|
16075
16126
|
api: api,
|
|
@@ -16105,6 +16156,31 @@ var getAssetBalance$1 = function getAssetBalance(_a) {
|
|
|
16105
16156
|
})();
|
|
16106
16157
|
});
|
|
16107
16158
|
};
|
|
16159
|
+
var getAssetBalance$1 = function getAssetBalance(options) {
|
|
16160
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
16161
|
+
var api;
|
|
16162
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
16163
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
16164
|
+
case 0:
|
|
16165
|
+
api = options.api;
|
|
16166
|
+
_context2.prev = 1;
|
|
16167
|
+
_context2.next = 4;
|
|
16168
|
+
return getAssetBalanceInternal(options);
|
|
16169
|
+
case 4:
|
|
16170
|
+
return _context2.abrupt("return", _context2.sent);
|
|
16171
|
+
case 5:
|
|
16172
|
+
_context2.prev = 5;
|
|
16173
|
+
_context2.next = 8;
|
|
16174
|
+
return api.disconnect();
|
|
16175
|
+
case 8:
|
|
16176
|
+
return _context2.finish(5);
|
|
16177
|
+
case 9:
|
|
16178
|
+
case "end":
|
|
16179
|
+
return _context2.stop();
|
|
16180
|
+
}
|
|
16181
|
+
}, _callee2, null, [[1,, 5, 9]]);
|
|
16182
|
+
}));
|
|
16183
|
+
};
|
|
16108
16184
|
|
|
16109
16185
|
var palletsMap = edsMapJson;
|
|
16110
16186
|
var getExistentialDeposit = function getExistentialDeposit(node) {
|
|
@@ -16123,7 +16199,7 @@ var getMaxNativeTransferableAmount = function getMaxNativeTransferableAmount(api
|
|
|
16123
16199
|
case 0:
|
|
16124
16200
|
ed = getExistentialDeposit(node);
|
|
16125
16201
|
_context.next = 3;
|
|
16126
|
-
return
|
|
16202
|
+
return getBalanceNativeInternal({
|
|
16127
16203
|
address: address,
|
|
16128
16204
|
node: node,
|
|
16129
16205
|
api: api
|
|
@@ -16559,6 +16635,10 @@ var ParaToRelayBuilder = /*#__PURE__*/function () {
|
|
|
16559
16635
|
}]);
|
|
16560
16636
|
}();
|
|
16561
16637
|
|
|
16638
|
+
var isPjsClient = function isPjsClient(api) {
|
|
16639
|
+
return _typeof(api) === 'object' && api !== null && 'disconnect' in api && typeof api.disconnect === 'function';
|
|
16640
|
+
};
|
|
16641
|
+
|
|
16562
16642
|
var buildBeneficiaryInput = function buildBeneficiaryInput(api, address) {
|
|
16563
16643
|
if (isTMultiLocation(address)) {
|
|
16564
16644
|
return address;
|
|
@@ -16602,6 +16682,7 @@ var claimAssets$1 = function claimAssets(options) {
|
|
|
16602
16682
|
_context.next = 3;
|
|
16603
16683
|
return api.init(node);
|
|
16604
16684
|
case 3:
|
|
16685
|
+
_context.prev = 3;
|
|
16605
16686
|
args = buildClaimAssetsInput(options);
|
|
16606
16687
|
module = isRelayChain(node) ? 'XcmPallet' : 'PolkadotXcm';
|
|
16607
16688
|
call = {
|
|
@@ -16610,20 +16691,29 @@ var claimAssets$1 = function claimAssets(options) {
|
|
|
16610
16691
|
parameters: args
|
|
16611
16692
|
};
|
|
16612
16693
|
if (!(serializedApiCallEnabled === true)) {
|
|
16613
|
-
_context.next =
|
|
16694
|
+
_context.next = 9;
|
|
16614
16695
|
break;
|
|
16615
16696
|
}
|
|
16616
16697
|
return _context.abrupt("return", Object.assign(Object.assign({}, call), {
|
|
16617
|
-
// Keep compatible with the old SerializedCall type
|
|
16618
16698
|
parameters: Object.values(args)
|
|
16619
16699
|
}));
|
|
16620
|
-
case 8:
|
|
16621
|
-
return _context.abrupt("return", api.callTxMethod(call));
|
|
16622
16700
|
case 9:
|
|
16701
|
+
return _context.abrupt("return", api.callTxMethod(call));
|
|
16702
|
+
case 10:
|
|
16703
|
+
_context.prev = 10;
|
|
16704
|
+
if (!isPjsClient(api)) {
|
|
16705
|
+
_context.next = 14;
|
|
16706
|
+
break;
|
|
16707
|
+
}
|
|
16708
|
+
_context.next = 14;
|
|
16709
|
+
return api.disconnect();
|
|
16710
|
+
case 14:
|
|
16711
|
+
return _context.finish(10);
|
|
16712
|
+
case 15:
|
|
16623
16713
|
case "end":
|
|
16624
16714
|
return _context.stop();
|
|
16625
16715
|
}
|
|
16626
|
-
}, _callee);
|
|
16716
|
+
}, _callee, null, [[3,, 10, 15]]);
|
|
16627
16717
|
}));
|
|
16628
16718
|
};
|
|
16629
16719
|
|
|
@@ -17210,7 +17300,7 @@ var EvmBuilder = function EvmBuilder(provider) {
|
|
|
17210
17300
|
return new EvmBuilderClass(provider);
|
|
17211
17301
|
};
|
|
17212
17302
|
|
|
17213
|
-
var createTx$1 = function createTx(
|
|
17303
|
+
var createTx$1 = function createTx(api, address, amount, currency, originNode, destNode) {
|
|
17214
17304
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
17215
17305
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17216
17306
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -17220,7 +17310,7 @@ var createTx$1 = function createTx(originApi, address, amount, currency, originN
|
|
|
17220
17310
|
break;
|
|
17221
17311
|
}
|
|
17222
17312
|
_context.next = 3;
|
|
17223
|
-
return Builder$1(
|
|
17313
|
+
return Builder$1(api).to(destNode).amount(amount).address(address).build();
|
|
17224
17314
|
case 3:
|
|
17225
17315
|
return _context.abrupt("return", _context.sent);
|
|
17226
17316
|
case 6:
|
|
@@ -17229,12 +17319,12 @@ var createTx$1 = function createTx(originApi, address, amount, currency, originN
|
|
|
17229
17319
|
break;
|
|
17230
17320
|
}
|
|
17231
17321
|
_context.next = 9;
|
|
17232
|
-
return Builder$1(
|
|
17322
|
+
return Builder$1(api).from(originNode).amount(amount).address(address).build();
|
|
17233
17323
|
case 9:
|
|
17234
17324
|
return _context.abrupt("return", _context.sent);
|
|
17235
17325
|
case 12:
|
|
17236
17326
|
_context.next = 14;
|
|
17237
|
-
return Builder$1(
|
|
17327
|
+
return Builder$1(api).from(originNode).to(destNode).currency(currency).amount(amount).address(address).build();
|
|
17238
17328
|
case 14:
|
|
17239
17329
|
return _context.abrupt("return", _context.sent);
|
|
17240
17330
|
case 15:
|
|
@@ -17244,7 +17334,7 @@ var createTx$1 = function createTx(originApi, address, amount, currency, originN
|
|
|
17244
17334
|
}, _callee);
|
|
17245
17335
|
}));
|
|
17246
17336
|
};
|
|
17247
|
-
var
|
|
17337
|
+
var getOriginFeeDetailsInternal = function getOriginFeeDetailsInternal(_a) {
|
|
17248
17338
|
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
17249
17339
|
var api = _ref.api,
|
|
17250
17340
|
account = _ref.account,
|
|
@@ -17256,34 +17346,37 @@ var getOriginFeeDetails$1 = function getOriginFeeDetails(_a) {
|
|
|
17256
17346
|
_ref$feeMarginPercent = _ref.feeMarginPercentage,
|
|
17257
17347
|
feeMarginPercentage = _ref$feeMarginPercent === void 0 ? 10 : _ref$feeMarginPercent;
|
|
17258
17348
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
17259
|
-
var
|
|
17349
|
+
var tx, xcmFee, xcmFeeWithMargin, nativeBalance, minTransferableAmount, sufficientForXCM;
|
|
17260
17350
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
17261
17351
|
while (1) switch (_context2.prev = _context2.next) {
|
|
17262
17352
|
case 0:
|
|
17263
17353
|
_context2.next = 2;
|
|
17264
|
-
return
|
|
17265
|
-
address: account,
|
|
17266
|
-
node: origin,
|
|
17267
|
-
api: api
|
|
17268
|
-
});
|
|
17354
|
+
return api.init(origin);
|
|
17269
17355
|
case 2:
|
|
17270
|
-
|
|
17271
|
-
minTransferableAmount = getMinNativeTransferableAmount(origin);
|
|
17272
|
-
_context2.next = 6;
|
|
17356
|
+
_context2.next = 4;
|
|
17273
17357
|
return createTx$1(api, accountDestination, amount, currency, origin, destination);
|
|
17274
|
-
case
|
|
17358
|
+
case 4:
|
|
17275
17359
|
tx = _context2.sent;
|
|
17276
|
-
_context2.next =
|
|
17360
|
+
_context2.next = 7;
|
|
17277
17361
|
return api.calculateTransactionFee(tx, account);
|
|
17278
|
-
case
|
|
17362
|
+
case 7:
|
|
17279
17363
|
xcmFee = _context2.sent;
|
|
17280
17364
|
xcmFeeWithMargin = xcmFee + xcmFee / BigInt(feeMarginPercentage);
|
|
17365
|
+
_context2.next = 11;
|
|
17366
|
+
return getBalanceNativeInternal({
|
|
17367
|
+
address: account,
|
|
17368
|
+
node: origin,
|
|
17369
|
+
api: api
|
|
17370
|
+
});
|
|
17371
|
+
case 11:
|
|
17372
|
+
nativeBalance = _context2.sent;
|
|
17373
|
+
minTransferableAmount = getMinNativeTransferableAmount(origin);
|
|
17281
17374
|
sufficientForXCM = nativeBalance - minTransferableAmount - xcmFeeWithMargin > 0;
|
|
17282
17375
|
return _context2.abrupt("return", {
|
|
17283
17376
|
sufficientForXCM: sufficientForXCM,
|
|
17284
17377
|
xcmFee: xcmFee
|
|
17285
17378
|
});
|
|
17286
|
-
case
|
|
17379
|
+
case 15:
|
|
17287
17380
|
case "end":
|
|
17288
17381
|
return _context2.stop();
|
|
17289
17382
|
}
|
|
@@ -17291,6 +17384,33 @@ var getOriginFeeDetails$1 = function getOriginFeeDetails(_a) {
|
|
|
17291
17384
|
})();
|
|
17292
17385
|
});
|
|
17293
17386
|
};
|
|
17387
|
+
var getOriginFeeDetails$1 = function getOriginFeeDetails(options) {
|
|
17388
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
17389
|
+
var api;
|
|
17390
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
17391
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
17392
|
+
case 0:
|
|
17393
|
+
api = options.api;
|
|
17394
|
+
api.setDisconnectAllowed(false);
|
|
17395
|
+
_context3.prev = 2;
|
|
17396
|
+
_context3.next = 5;
|
|
17397
|
+
return getOriginFeeDetailsInternal(options);
|
|
17398
|
+
case 5:
|
|
17399
|
+
return _context3.abrupt("return", _context3.sent);
|
|
17400
|
+
case 6:
|
|
17401
|
+
_context3.prev = 6;
|
|
17402
|
+
api.setDisconnectAllowed(true);
|
|
17403
|
+
_context3.next = 10;
|
|
17404
|
+
return api.disconnect();
|
|
17405
|
+
case 10:
|
|
17406
|
+
return _context3.finish(6);
|
|
17407
|
+
case 11:
|
|
17408
|
+
case "end":
|
|
17409
|
+
return _context3.stop();
|
|
17410
|
+
}
|
|
17411
|
+
}, _callee3, null, [[2,, 6, 11]]);
|
|
17412
|
+
}));
|
|
17413
|
+
};
|
|
17294
17414
|
|
|
17295
17415
|
var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
17296
17416
|
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
@@ -17300,77 +17420,72 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
17300
17420
|
accountDestination = _ref.accountDestination,
|
|
17301
17421
|
currency = _ref.currency,
|
|
17302
17422
|
amount = _ref.amount,
|
|
17303
|
-
|
|
17423
|
+
api = _ref.api;
|
|
17304
17424
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
17305
17425
|
var _b, _c, _d, originBalance, xcmFeeDetails, expectedBalanceAfterXCMDelivery, asset;
|
|
17306
17426
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17307
17427
|
while (1) switch (_context.prev = _context.next) {
|
|
17308
17428
|
case 0:
|
|
17309
17429
|
_context.next = 2;
|
|
17310
|
-
return
|
|
17430
|
+
return api.init(origin);
|
|
17311
17431
|
case 2:
|
|
17312
|
-
|
|
17313
|
-
|
|
17432
|
+
api.setDisconnectAllowed(false);
|
|
17433
|
+
_context.prev = 3;
|
|
17434
|
+
_context.next = 6;
|
|
17435
|
+
return getBalanceNativeInternal({
|
|
17314
17436
|
address: accountOrigin,
|
|
17315
17437
|
node: origin,
|
|
17316
|
-
api:
|
|
17438
|
+
api: api
|
|
17317
17439
|
});
|
|
17318
|
-
case
|
|
17440
|
+
case 6:
|
|
17319
17441
|
originBalance = _context.sent;
|
|
17320
|
-
_context.next =
|
|
17321
|
-
return
|
|
17442
|
+
_context.next = 9;
|
|
17443
|
+
return getOriginFeeDetailsInternal({
|
|
17322
17444
|
origin: origin,
|
|
17323
17445
|
destination: destination,
|
|
17324
17446
|
currency: currency,
|
|
17325
17447
|
amount: amount,
|
|
17326
17448
|
account: accountOrigin,
|
|
17327
17449
|
accountDestination: accountDestination,
|
|
17328
|
-
api:
|
|
17450
|
+
api: api
|
|
17329
17451
|
});
|
|
17330
|
-
case
|
|
17452
|
+
case 9:
|
|
17331
17453
|
xcmFeeDetails = _context.sent;
|
|
17332
17454
|
expectedBalanceAfterXCMDelivery = originBalance - xcmFeeDetails.xcmFee;
|
|
17333
17455
|
asset = (_b = getAssetBySymbolOrId(origin, currency, destination)) !== null && _b !== void 0 ? _b : origin === 'AssetHubPolkadot' ? getAssetBySymbolOrId('Ethereum', currency, null) : null;
|
|
17334
17456
|
if (asset) {
|
|
17335
|
-
_context.next =
|
|
17457
|
+
_context.next = 14;
|
|
17336
17458
|
break;
|
|
17337
17459
|
}
|
|
17338
17460
|
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(origin));
|
|
17339
|
-
case
|
|
17461
|
+
case 14:
|
|
17340
17462
|
_context.t0 = {
|
|
17341
17463
|
origin: origin,
|
|
17342
17464
|
destination: destination,
|
|
17343
17465
|
ecosystem: determineRelayChainSymbol(origin)
|
|
17344
17466
|
};
|
|
17345
|
-
_context.next =
|
|
17346
|
-
return
|
|
17347
|
-
api:
|
|
17467
|
+
_context.next = 17;
|
|
17468
|
+
return getAssetBalanceInternal({
|
|
17469
|
+
api: api,
|
|
17348
17470
|
address: accountOrigin,
|
|
17349
17471
|
node: origin,
|
|
17350
17472
|
currency: currency
|
|
17351
17473
|
});
|
|
17352
|
-
case
|
|
17474
|
+
case 17:
|
|
17353
17475
|
_context.t1 = _context.sent;
|
|
17354
17476
|
_context.t2 = (_c = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _c !== void 0 ? _c : '';
|
|
17355
17477
|
_context.t3 = {
|
|
17356
17478
|
balance: _context.t1,
|
|
17357
17479
|
currency: _context.t2
|
|
17358
17480
|
};
|
|
17359
|
-
_context.
|
|
17360
|
-
return getBalanceNative$1({
|
|
17361
|
-
address: accountOrigin,
|
|
17362
|
-
node: origin,
|
|
17363
|
-
api: originApi
|
|
17364
|
-
});
|
|
17365
|
-
case 20:
|
|
17366
|
-
_context.t4 = _context.sent;
|
|
17481
|
+
_context.t4 = originBalance;
|
|
17367
17482
|
_context.t5 = expectedBalanceAfterXCMDelivery;
|
|
17368
17483
|
_context.t6 = xcmFeeDetails;
|
|
17369
17484
|
_context.t7 = BigInt((_d = getExistentialDeposit(origin)) !== null && _d !== void 0 ? _d : 0);
|
|
17370
17485
|
_context.t8 = getNativeAssetSymbol(origin);
|
|
17371
17486
|
_context.t9 = getMinNativeTransferableAmount(origin);
|
|
17372
17487
|
_context.next = 28;
|
|
17373
|
-
return getMaxNativeTransferableAmount(
|
|
17488
|
+
return getMaxNativeTransferableAmount(api, accountOrigin, origin);
|
|
17374
17489
|
case 28:
|
|
17375
17490
|
_context.t10 = _context.sent;
|
|
17376
17491
|
_context.t11 = {
|
|
@@ -17383,10 +17498,10 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
17383
17498
|
maxNativeTransferableAmount: _context.t10
|
|
17384
17499
|
};
|
|
17385
17500
|
_context.next = 32;
|
|
17386
|
-
return
|
|
17501
|
+
return getBalanceNativeInternal({
|
|
17387
17502
|
address: accountDestination,
|
|
17388
17503
|
node: destination,
|
|
17389
|
-
api:
|
|
17504
|
+
api: api
|
|
17390
17505
|
});
|
|
17391
17506
|
case 32:
|
|
17392
17507
|
_context.t12 = _context.sent;
|
|
@@ -17404,10 +17519,17 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
17404
17519
|
destinationFeeBalance: _context.t15
|
|
17405
17520
|
});
|
|
17406
17521
|
case 37:
|
|
17522
|
+
_context.prev = 37;
|
|
17523
|
+
api.setDisconnectAllowed(true);
|
|
17524
|
+
_context.next = 41;
|
|
17525
|
+
return api.disconnect();
|
|
17526
|
+
case 41:
|
|
17527
|
+
return _context.finish(37);
|
|
17528
|
+
case 42:
|
|
17407
17529
|
case "end":
|
|
17408
17530
|
return _context.stop();
|
|
17409
17531
|
}
|
|
17410
|
-
}, _callee);
|
|
17532
|
+
}, _callee, null, [[3,, 37, 42]]);
|
|
17411
17533
|
})();
|
|
17412
17534
|
});
|
|
17413
17535
|
};
|
|
@@ -17542,7 +17664,7 @@ var checkKeepAlive = function checkKeepAlive(_a) {
|
|
|
17542
17664
|
asset = _ref.asset,
|
|
17543
17665
|
destNode = _ref.destNode;
|
|
17544
17666
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
17545
|
-
var balance, balanceOrigin, amountBN, ed, edOrigin, tx, xcmFee, increasedFee, amountBNWithoutFee, amountOriginBNWithoutFee;
|
|
17667
|
+
var balance, balanceOrigin, amountBN, ed, edOrigin, oldDisconnectAllowed, tx, xcmFee, increasedFee, amountBNWithoutFee, amountOriginBNWithoutFee;
|
|
17546
17668
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17547
17669
|
while (1) switch (_context.prev = _context.next) {
|
|
17548
17670
|
case 0:
|
|
@@ -17575,47 +17697,50 @@ var checkKeepAlive = function checkKeepAlive(_a) {
|
|
|
17575
17697
|
amountBN = BigInt(amount);
|
|
17576
17698
|
ed = getExistentialDeposit$1(destNode !== null && destNode !== void 0 ? destNode : determineRelayChain(originNode));
|
|
17577
17699
|
edOrigin = getExistentialDeposit$1(originNode !== null && originNode !== void 0 ? originNode : determineRelayChain(destNode));
|
|
17578
|
-
|
|
17700
|
+
oldDisconnectAllowed = originApi.getDisconnectAllowed();
|
|
17701
|
+
originApi.setDisconnectAllowed(false);
|
|
17702
|
+
_context.next = 19;
|
|
17579
17703
|
return createTx(originApi, destApi, address, amount, asset.symbol, originNode, destNode);
|
|
17580
|
-
case
|
|
17704
|
+
case 19:
|
|
17581
17705
|
tx = _context.sent;
|
|
17706
|
+
originApi.setDisconnectAllowed(oldDisconnectAllowed);
|
|
17582
17707
|
if (!(tx === null)) {
|
|
17583
|
-
_context.next =
|
|
17708
|
+
_context.next = 23;
|
|
17584
17709
|
break;
|
|
17585
17710
|
}
|
|
17586
17711
|
throw new KeepAliveError('Transaction for XCM fee calculation could not be created.');
|
|
17587
|
-
case
|
|
17588
|
-
_context.next =
|
|
17712
|
+
case 23:
|
|
17713
|
+
_context.next = 25;
|
|
17589
17714
|
return originApi.calculateTransactionFee(tx, address);
|
|
17590
|
-
case
|
|
17715
|
+
case 25:
|
|
17591
17716
|
xcmFee = _context.sent;
|
|
17592
17717
|
if (!(ed === null)) {
|
|
17593
|
-
_context.next =
|
|
17718
|
+
_context.next = 28;
|
|
17594
17719
|
break;
|
|
17595
17720
|
}
|
|
17596
17721
|
throw new KeepAliveError('Existential deposit not found for destination parachain.');
|
|
17597
|
-
case
|
|
17722
|
+
case 28:
|
|
17598
17723
|
if (!(edOrigin === null)) {
|
|
17599
|
-
_context.next =
|
|
17724
|
+
_context.next = 30;
|
|
17600
17725
|
break;
|
|
17601
17726
|
}
|
|
17602
17727
|
throw new KeepAliveError('Existential deposit not found for origin parachain.');
|
|
17603
|
-
case
|
|
17728
|
+
case 30:
|
|
17604
17729
|
increasedFee = xcmFee + xcmFee / BigInt(2);
|
|
17605
17730
|
amountBNWithoutFee = amountBN - increasedFee;
|
|
17606
17731
|
if (!(balance + amountBNWithoutFee < BigInt(ed))) {
|
|
17607
|
-
_context.next =
|
|
17732
|
+
_context.next = 34;
|
|
17608
17733
|
break;
|
|
17609
17734
|
}
|
|
17610
17735
|
throw new KeepAliveError("Keep alive check failed: Sending ".concat(amount, " ").concat(asset.symbol, " to ").concat(destNode, " 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."));
|
|
17611
|
-
case
|
|
17736
|
+
case 34:
|
|
17612
17737
|
amountOriginBNWithoutFee = amountBN - (xcmFee + xcmFee / BigInt(2));
|
|
17613
17738
|
if (!((asset.symbol === 'DOT' || asset.symbol === 'KSM') && balanceOrigin - amountOriginBNWithoutFee > BigInt(edOrigin))) {
|
|
17614
|
-
_context.next =
|
|
17739
|
+
_context.next = 37;
|
|
17615
17740
|
break;
|
|
17616
17741
|
}
|
|
17617
17742
|
throw new KeepAliveError("Keep alive check failed: Sending ".concat(amount, " ").concat(asset.symbol, " to ").concat(destNode, " 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."));
|
|
17618
|
-
case
|
|
17743
|
+
case 37:
|
|
17619
17744
|
case "end":
|
|
17620
17745
|
return _context.stop();
|
|
17621
17746
|
}
|
|
@@ -17749,48 +17874,49 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
17749
17874
|
_context.next = 45;
|
|
17750
17875
|
return api.init(origin);
|
|
17751
17876
|
case 45:
|
|
17877
|
+
_context.prev = 45;
|
|
17752
17878
|
amountStr = amount === null || amount === void 0 ? void 0 : amount.toString();
|
|
17753
17879
|
if (!('multilocation' in currency || 'multiasset' in currency)) {
|
|
17754
|
-
_context.next =
|
|
17880
|
+
_context.next = 51;
|
|
17755
17881
|
break;
|
|
17756
17882
|
}
|
|
17757
17883
|
console.warn('Keep alive check is not supported when using MultiLocation as currency.');
|
|
17758
|
-
_context.next =
|
|
17884
|
+
_context.next = 69;
|
|
17759
17885
|
break;
|
|
17760
|
-
case
|
|
17886
|
+
case 51:
|
|
17761
17887
|
if (!(_typeof(address) === 'object')) {
|
|
17762
|
-
_context.next =
|
|
17888
|
+
_context.next = 55;
|
|
17763
17889
|
break;
|
|
17764
17890
|
}
|
|
17765
17891
|
console.warn('Keep alive check is not supported when using MultiLocation as address.');
|
|
17766
|
-
_context.next =
|
|
17892
|
+
_context.next = 69;
|
|
17767
17893
|
break;
|
|
17768
|
-
case
|
|
17894
|
+
case 55:
|
|
17769
17895
|
if (!(_typeof(destination) === 'object')) {
|
|
17770
|
-
_context.next =
|
|
17896
|
+
_context.next = 59;
|
|
17771
17897
|
break;
|
|
17772
17898
|
}
|
|
17773
17899
|
console.warn('Keep alive check is not supported when using MultiLocation as destination.');
|
|
17774
|
-
_context.next =
|
|
17900
|
+
_context.next = 69;
|
|
17775
17901
|
break;
|
|
17776
|
-
case
|
|
17902
|
+
case 59:
|
|
17777
17903
|
if (!(destination === 'Ethereum')) {
|
|
17778
|
-
_context.next =
|
|
17904
|
+
_context.next = 63;
|
|
17779
17905
|
break;
|
|
17780
17906
|
}
|
|
17781
17907
|
console.warn('Keep alive check is not supported when using Ethereum as origin or destination.');
|
|
17782
|
-
_context.next =
|
|
17908
|
+
_context.next = 69;
|
|
17783
17909
|
break;
|
|
17784
|
-
case
|
|
17910
|
+
case 63:
|
|
17785
17911
|
if (asset) {
|
|
17786
|
-
_context.next =
|
|
17912
|
+
_context.next = 67;
|
|
17787
17913
|
break;
|
|
17788
17914
|
}
|
|
17789
17915
|
console.warn('Keep alive check is not supported when asset check is disabled.');
|
|
17790
|
-
_context.next =
|
|
17916
|
+
_context.next = 69;
|
|
17791
17917
|
break;
|
|
17792
|
-
case
|
|
17793
|
-
_context.next =
|
|
17918
|
+
case 67:
|
|
17919
|
+
_context.next = 69;
|
|
17794
17920
|
return checkKeepAlive({
|
|
17795
17921
|
originApi: api,
|
|
17796
17922
|
address: address,
|
|
@@ -17800,7 +17926,7 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
17800
17926
|
asset: asset,
|
|
17801
17927
|
destNode: destination
|
|
17802
17928
|
});
|
|
17803
|
-
case
|
|
17929
|
+
case 69:
|
|
17804
17930
|
// In case asset check is disabled, we create asset object from currency symbol
|
|
17805
17931
|
resolvedAsset = asset !== null && asset !== void 0 ? asset : {
|
|
17806
17932
|
symbol: 'symbol' in currency ? currency.symbol : undefined
|
|
@@ -17819,11 +17945,21 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
17819
17945
|
serializedApiCallEnabled: serializedApiCallEnabled,
|
|
17820
17946
|
ahAddress: ahAddress
|
|
17821
17947
|
}));
|
|
17822
|
-
case
|
|
17948
|
+
case 71:
|
|
17949
|
+
_context.prev = 71;
|
|
17950
|
+
if (!isPjsClient(api)) {
|
|
17951
|
+
_context.next = 75;
|
|
17952
|
+
break;
|
|
17953
|
+
}
|
|
17954
|
+
_context.next = 75;
|
|
17955
|
+
return api.disconnect();
|
|
17956
|
+
case 75:
|
|
17957
|
+
return _context.finish(71);
|
|
17958
|
+
case 76:
|
|
17823
17959
|
case "end":
|
|
17824
17960
|
return _context.stop();
|
|
17825
17961
|
}
|
|
17826
|
-
}, _callee);
|
|
17962
|
+
}, _callee, null, [[45,, 71, 76]]);
|
|
17827
17963
|
})();
|
|
17828
17964
|
});
|
|
17829
17965
|
};
|
|
@@ -17876,24 +18012,25 @@ var transferRelayToParaCommon = function transferRelayToParaCommon(options_1) {
|
|
|
17876
18012
|
_context4.next = 7;
|
|
17877
18013
|
return api.init(determineRelayChain(destination));
|
|
17878
18014
|
case 7:
|
|
18015
|
+
_context4.prev = 7;
|
|
17879
18016
|
amountStr = amount.toString();
|
|
17880
18017
|
if (!isMultiLocationDestination) {
|
|
17881
|
-
_context4.next =
|
|
18018
|
+
_context4.next = 13;
|
|
17882
18019
|
break;
|
|
17883
18020
|
}
|
|
17884
18021
|
console.warn('Keep alive check is not supported when using MultiLocation as destination.');
|
|
17885
|
-
_context4.next =
|
|
18022
|
+
_context4.next = 19;
|
|
17886
18023
|
break;
|
|
17887
|
-
case
|
|
18024
|
+
case 13:
|
|
17888
18025
|
if (!isAddressMultiLocation) {
|
|
17889
|
-
_context4.next =
|
|
18026
|
+
_context4.next = 17;
|
|
17890
18027
|
break;
|
|
17891
18028
|
}
|
|
17892
18029
|
console.warn('Keep alive check is not supported when using MultiLocation as address.');
|
|
17893
|
-
_context4.next =
|
|
18030
|
+
_context4.next = 19;
|
|
17894
18031
|
break;
|
|
17895
|
-
case
|
|
17896
|
-
_context4.next =
|
|
18032
|
+
case 17:
|
|
18033
|
+
_context4.next = 19;
|
|
17897
18034
|
return checkKeepAlive({
|
|
17898
18035
|
originApi: api,
|
|
17899
18036
|
address: address,
|
|
@@ -17904,7 +18041,7 @@ var transferRelayToParaCommon = function transferRelayToParaCommon(options_1) {
|
|
|
17904
18041
|
},
|
|
17905
18042
|
destNode: destination
|
|
17906
18043
|
});
|
|
17907
|
-
case
|
|
18044
|
+
case 19:
|
|
17908
18045
|
serializedApiCall = getNode(isMultiLocationDestination ? resolveTNodeFromMultiLocation(destination) : destination).transferRelayToPara({
|
|
17909
18046
|
api: api,
|
|
17910
18047
|
destination: destination,
|
|
@@ -17915,19 +18052,29 @@ var transferRelayToParaCommon = function transferRelayToParaCommon(options_1) {
|
|
|
17915
18052
|
version: version
|
|
17916
18053
|
});
|
|
17917
18054
|
if (!serializedApiCallEnabled) {
|
|
17918
|
-
_context4.next =
|
|
18055
|
+
_context4.next = 22;
|
|
17919
18056
|
break;
|
|
17920
18057
|
}
|
|
17921
18058
|
return _context4.abrupt("return", Object.assign(Object.assign({}, serializedApiCall), {
|
|
17922
18059
|
parameters: Object.values(serializedApiCall.parameters)
|
|
17923
18060
|
}));
|
|
17924
|
-
case 21:
|
|
17925
|
-
return _context4.abrupt("return", api.callTxMethod(serializedApiCall));
|
|
17926
18061
|
case 22:
|
|
18062
|
+
return _context4.abrupt("return", api.callTxMethod(serializedApiCall));
|
|
18063
|
+
case 23:
|
|
18064
|
+
_context4.prev = 23;
|
|
18065
|
+
if (!isPjsClient(api)) {
|
|
18066
|
+
_context4.next = 27;
|
|
18067
|
+
break;
|
|
18068
|
+
}
|
|
18069
|
+
_context4.next = 27;
|
|
18070
|
+
return api.disconnect();
|
|
18071
|
+
case 27:
|
|
18072
|
+
return _context4.finish(23);
|
|
18073
|
+
case 28:
|
|
17927
18074
|
case "end":
|
|
17928
18075
|
return _context4.stop();
|
|
17929
18076
|
}
|
|
17930
|
-
}, _callee4);
|
|
18077
|
+
}, _callee4, null, [[7,, 23, 28]]);
|
|
17931
18078
|
})();
|
|
17932
18079
|
});
|
|
17933
18080
|
};
|
|
@@ -17969,6 +18116,8 @@ var snakeToCamel = function snakeToCamel(str) {
|
|
|
17969
18116
|
var PolkadotJsApi = /*#__PURE__*/function () {
|
|
17970
18117
|
function PolkadotJsApi() {
|
|
17971
18118
|
_classCallCheck(this, PolkadotJsApi);
|
|
18119
|
+
this.initialized = false;
|
|
18120
|
+
this.disconnectAllowed = true;
|
|
17972
18121
|
}
|
|
17973
18122
|
return _createClass(PolkadotJsApi, [{
|
|
17974
18123
|
key: "setApi",
|
|
@@ -17988,32 +18137,40 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
17988
18137
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17989
18138
|
while (1) switch (_context.prev = _context.next) {
|
|
17990
18139
|
case 0:
|
|
18140
|
+
if (!this.initialized) {
|
|
18141
|
+
_context.next = 2;
|
|
18142
|
+
break;
|
|
18143
|
+
}
|
|
18144
|
+
return _context.abrupt("return");
|
|
18145
|
+
case 2:
|
|
17991
18146
|
if (!(typeof this._api === 'string')) {
|
|
17992
|
-
_context.next =
|
|
18147
|
+
_context.next = 8;
|
|
17993
18148
|
break;
|
|
17994
18149
|
}
|
|
17995
|
-
_context.next =
|
|
18150
|
+
_context.next = 5;
|
|
17996
18151
|
return this.createApiInstance(this._api);
|
|
17997
|
-
case
|
|
18152
|
+
case 5:
|
|
17998
18153
|
this.api = _context.sent;
|
|
17999
|
-
_context.next =
|
|
18154
|
+
_context.next = 16;
|
|
18000
18155
|
break;
|
|
18001
|
-
case
|
|
18156
|
+
case 8:
|
|
18002
18157
|
if (!((_a = this._api) !== null && _a !== void 0)) {
|
|
18003
|
-
_context.next =
|
|
18158
|
+
_context.next = 12;
|
|
18004
18159
|
break;
|
|
18005
18160
|
}
|
|
18006
18161
|
_context.t0 = _a;
|
|
18007
|
-
_context.next =
|
|
18162
|
+
_context.next = 15;
|
|
18008
18163
|
break;
|
|
18009
|
-
case 10:
|
|
18010
|
-
_context.next = 12;
|
|
18011
|
-
return createApiInstanceForNode$1(this, node);
|
|
18012
18164
|
case 12:
|
|
18165
|
+
_context.next = 14;
|
|
18166
|
+
return createApiInstanceForNode$1(this, node);
|
|
18167
|
+
case 14:
|
|
18013
18168
|
_context.t0 = _context.sent;
|
|
18014
|
-
case
|
|
18169
|
+
case 15:
|
|
18015
18170
|
this.api = _context.t0;
|
|
18016
|
-
case
|
|
18171
|
+
case 16:
|
|
18172
|
+
this.initialized = true;
|
|
18173
|
+
case 17:
|
|
18017
18174
|
case "end":
|
|
18018
18175
|
return _context.stop();
|
|
18019
18176
|
}
|
|
@@ -18305,6 +18462,42 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
18305
18462
|
}, _callee13);
|
|
18306
18463
|
}));
|
|
18307
18464
|
}
|
|
18465
|
+
}, {
|
|
18466
|
+
key: "setDisconnectAllowed",
|
|
18467
|
+
value: function setDisconnectAllowed(allowed) {
|
|
18468
|
+
this.disconnectAllowed = allowed;
|
|
18469
|
+
}
|
|
18470
|
+
}, {
|
|
18471
|
+
key: "getDisconnectAllowed",
|
|
18472
|
+
value: function getDisconnectAllowed() {
|
|
18473
|
+
return this.disconnectAllowed;
|
|
18474
|
+
}
|
|
18475
|
+
}, {
|
|
18476
|
+
key: "disconnect",
|
|
18477
|
+
value: function disconnect() {
|
|
18478
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
18479
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
18480
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
18481
|
+
case 0:
|
|
18482
|
+
if (this.disconnectAllowed) {
|
|
18483
|
+
_context14.next = 2;
|
|
18484
|
+
break;
|
|
18485
|
+
}
|
|
18486
|
+
return _context14.abrupt("return");
|
|
18487
|
+
case 2:
|
|
18488
|
+
if (!(typeof this._api === 'string' || this._api === undefined)) {
|
|
18489
|
+
_context14.next = 5;
|
|
18490
|
+
break;
|
|
18491
|
+
}
|
|
18492
|
+
_context14.next = 5;
|
|
18493
|
+
return this.api.disconnect();
|
|
18494
|
+
case 5:
|
|
18495
|
+
case "end":
|
|
18496
|
+
return _context14.stop();
|
|
18497
|
+
}
|
|
18498
|
+
}, _callee14, this);
|
|
18499
|
+
}));
|
|
18500
|
+
}
|
|
18308
18501
|
}]);
|
|
18309
18502
|
}();
|
|
18310
18503
|
|