@paraspell/sdk 7.2.0 → 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 +380 -159
- package/dist/index.d.ts +47 -1
- package/dist/index.mjs +380 -159
- package/dist/papi/index.cjs +368 -166
- package/dist/papi/index.d.ts +47 -1
- package/dist/papi/index.mjs +368 -166
- 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",
|
|
@@ -15974,8 +15999,14 @@ var getBalanceForeignXTokens = function getBalanceForeignXTokens(api, node, addr
|
|
|
15974
15999
|
case 3:
|
|
15975
16000
|
return _context.abrupt("return", api.getBalanceForeignAssetsAccount(address, BigInt(asset.assetId)));
|
|
15976
16001
|
case 4:
|
|
16002
|
+
if (!(node === 'BifrostPolkadot' || node === 'BifrostKusama')) {
|
|
16003
|
+
_context.next = 6;
|
|
16004
|
+
break;
|
|
16005
|
+
}
|
|
16006
|
+
return _context.abrupt("return", api.getBalanceForeignBifrost(address, asset));
|
|
16007
|
+
case 6:
|
|
15977
16008
|
return _context.abrupt("return", api.getBalanceForeignXTokens(address, asset));
|
|
15978
|
-
case
|
|
16009
|
+
case 7:
|
|
15979
16010
|
case "end":
|
|
15980
16011
|
return _context.stop();
|
|
15981
16012
|
}
|
|
@@ -15983,14 +16014,14 @@ var getBalanceForeignXTokens = function getBalanceForeignXTokens(api, node, addr
|
|
|
15983
16014
|
}));
|
|
15984
16015
|
};
|
|
15985
16016
|
|
|
15986
|
-
var
|
|
16017
|
+
var getBalanceForeignInternal = function getBalanceForeignInternal(_a) {
|
|
15987
16018
|
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
15988
16019
|
var address = _ref.address,
|
|
15989
16020
|
node = _ref.node,
|
|
15990
16021
|
currency = _ref.currency,
|
|
15991
16022
|
api = _ref.api;
|
|
15992
16023
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
15993
|
-
var _b, asset;
|
|
16024
|
+
var _b, asset, defaultPallet;
|
|
15994
16025
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
15995
16026
|
while (1) switch (_context.prev = _context.next) {
|
|
15996
16027
|
case 0:
|
|
@@ -16004,26 +16035,27 @@ var getBalanceForeign$1 = function getBalanceForeign(_a) {
|
|
|
16004
16035
|
}
|
|
16005
16036
|
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(node));
|
|
16006
16037
|
case 5:
|
|
16007
|
-
|
|
16008
|
-
|
|
16038
|
+
defaultPallet = getDefaultPallet(node);
|
|
16039
|
+
if (!(defaultPallet === 'XTokens')) {
|
|
16040
|
+
_context.next = 12;
|
|
16009
16041
|
break;
|
|
16010
16042
|
}
|
|
16011
|
-
_context.next =
|
|
16043
|
+
_context.next = 9;
|
|
16012
16044
|
return getBalanceForeignXTokens(api, node, address, asset);
|
|
16013
|
-
case
|
|
16045
|
+
case 9:
|
|
16014
16046
|
return _context.abrupt("return", _context.sent);
|
|
16015
|
-
case
|
|
16016
|
-
if (!(
|
|
16017
|
-
_context.next =
|
|
16047
|
+
case 12:
|
|
16048
|
+
if (!(defaultPallet === 'PolkadotXcm')) {
|
|
16049
|
+
_context.next = 16;
|
|
16018
16050
|
break;
|
|
16019
16051
|
}
|
|
16020
|
-
_context.next =
|
|
16052
|
+
_context.next = 15;
|
|
16021
16053
|
return getBalanceForeignPolkadotXcm(api, node, address, asset);
|
|
16022
|
-
case 14:
|
|
16023
|
-
return _context.abrupt("return", _context.sent);
|
|
16024
16054
|
case 15:
|
|
16025
|
-
|
|
16055
|
+
return _context.abrupt("return", _context.sent);
|
|
16026
16056
|
case 16:
|
|
16057
|
+
throw new Error('Unsupported pallet');
|
|
16058
|
+
case 17:
|
|
16027
16059
|
case "end":
|
|
16028
16060
|
return _context.stop();
|
|
16029
16061
|
}
|
|
@@ -16031,8 +16063,33 @@ var getBalanceForeign$1 = function getBalanceForeign(_a) {
|
|
|
16031
16063
|
})();
|
|
16032
16064
|
});
|
|
16033
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
|
+
};
|
|
16034
16091
|
|
|
16035
|
-
var
|
|
16092
|
+
var getAssetBalanceInternal = function getAssetBalanceInternal(_a) {
|
|
16036
16093
|
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
16037
16094
|
var address = _ref.address,
|
|
16038
16095
|
node = _ref.node,
|
|
@@ -16052,7 +16109,7 @@ var getAssetBalance$1 = function getAssetBalance(_a) {
|
|
|
16052
16109
|
break;
|
|
16053
16110
|
}
|
|
16054
16111
|
_context.next = 6;
|
|
16055
|
-
return
|
|
16112
|
+
return getBalanceNativeInternal({
|
|
16056
16113
|
address: address,
|
|
16057
16114
|
node: node,
|
|
16058
16115
|
api: api
|
|
@@ -16063,7 +16120,7 @@ var getAssetBalance$1 = function getAssetBalance(_a) {
|
|
|
16063
16120
|
break;
|
|
16064
16121
|
case 9:
|
|
16065
16122
|
_context.next = 11;
|
|
16066
|
-
return
|
|
16123
|
+
return getBalanceForeignInternal({
|
|
16067
16124
|
address: address,
|
|
16068
16125
|
node: node,
|
|
16069
16126
|
api: api,
|
|
@@ -16099,6 +16156,31 @@ var getAssetBalance$1 = function getAssetBalance(_a) {
|
|
|
16099
16156
|
})();
|
|
16100
16157
|
});
|
|
16101
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
|
+
};
|
|
16102
16184
|
|
|
16103
16185
|
var palletsMap = edsMapJson;
|
|
16104
16186
|
var getExistentialDeposit = function getExistentialDeposit(node) {
|
|
@@ -16117,7 +16199,7 @@ var getMaxNativeTransferableAmount = function getMaxNativeTransferableAmount(api
|
|
|
16117
16199
|
case 0:
|
|
16118
16200
|
ed = getExistentialDeposit(node);
|
|
16119
16201
|
_context.next = 3;
|
|
16120
|
-
return
|
|
16202
|
+
return getBalanceNativeInternal({
|
|
16121
16203
|
address: address,
|
|
16122
16204
|
node: node,
|
|
16123
16205
|
api: api
|
|
@@ -16553,6 +16635,10 @@ var ParaToRelayBuilder = /*#__PURE__*/function () {
|
|
|
16553
16635
|
}]);
|
|
16554
16636
|
}();
|
|
16555
16637
|
|
|
16638
|
+
var isPjsClient = function isPjsClient(api) {
|
|
16639
|
+
return _typeof(api) === 'object' && api !== null && 'disconnect' in api && typeof api.disconnect === 'function';
|
|
16640
|
+
};
|
|
16641
|
+
|
|
16556
16642
|
var buildBeneficiaryInput = function buildBeneficiaryInput(api, address) {
|
|
16557
16643
|
if (isTMultiLocation(address)) {
|
|
16558
16644
|
return address;
|
|
@@ -16596,6 +16682,7 @@ var claimAssets$1 = function claimAssets(options) {
|
|
|
16596
16682
|
_context.next = 3;
|
|
16597
16683
|
return api.init(node);
|
|
16598
16684
|
case 3:
|
|
16685
|
+
_context.prev = 3;
|
|
16599
16686
|
args = buildClaimAssetsInput(options);
|
|
16600
16687
|
module = isRelayChain(node) ? 'XcmPallet' : 'PolkadotXcm';
|
|
16601
16688
|
call = {
|
|
@@ -16604,20 +16691,29 @@ var claimAssets$1 = function claimAssets(options) {
|
|
|
16604
16691
|
parameters: args
|
|
16605
16692
|
};
|
|
16606
16693
|
if (!(serializedApiCallEnabled === true)) {
|
|
16607
|
-
_context.next =
|
|
16694
|
+
_context.next = 9;
|
|
16608
16695
|
break;
|
|
16609
16696
|
}
|
|
16610
16697
|
return _context.abrupt("return", Object.assign(Object.assign({}, call), {
|
|
16611
|
-
// Keep compatible with the old SerializedCall type
|
|
16612
16698
|
parameters: Object.values(args)
|
|
16613
16699
|
}));
|
|
16614
|
-
case 8:
|
|
16615
|
-
return _context.abrupt("return", api.callTxMethod(call));
|
|
16616
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:
|
|
16617
16713
|
case "end":
|
|
16618
16714
|
return _context.stop();
|
|
16619
16715
|
}
|
|
16620
|
-
}, _callee);
|
|
16716
|
+
}, _callee, null, [[3,, 10, 15]]);
|
|
16621
16717
|
}));
|
|
16622
16718
|
};
|
|
16623
16719
|
|
|
@@ -17204,7 +17300,7 @@ var EvmBuilder = function EvmBuilder(provider) {
|
|
|
17204
17300
|
return new EvmBuilderClass(provider);
|
|
17205
17301
|
};
|
|
17206
17302
|
|
|
17207
|
-
var createTx$1 = function createTx(
|
|
17303
|
+
var createTx$1 = function createTx(api, address, amount, currency, originNode, destNode) {
|
|
17208
17304
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
17209
17305
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17210
17306
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -17214,7 +17310,7 @@ var createTx$1 = function createTx(originApi, address, amount, currency, originN
|
|
|
17214
17310
|
break;
|
|
17215
17311
|
}
|
|
17216
17312
|
_context.next = 3;
|
|
17217
|
-
return Builder$1(
|
|
17313
|
+
return Builder$1(api).to(destNode).amount(amount).address(address).build();
|
|
17218
17314
|
case 3:
|
|
17219
17315
|
return _context.abrupt("return", _context.sent);
|
|
17220
17316
|
case 6:
|
|
@@ -17223,12 +17319,12 @@ var createTx$1 = function createTx(originApi, address, amount, currency, originN
|
|
|
17223
17319
|
break;
|
|
17224
17320
|
}
|
|
17225
17321
|
_context.next = 9;
|
|
17226
|
-
return Builder$1(
|
|
17322
|
+
return Builder$1(api).from(originNode).amount(amount).address(address).build();
|
|
17227
17323
|
case 9:
|
|
17228
17324
|
return _context.abrupt("return", _context.sent);
|
|
17229
17325
|
case 12:
|
|
17230
17326
|
_context.next = 14;
|
|
17231
|
-
return Builder$1(
|
|
17327
|
+
return Builder$1(api).from(originNode).to(destNode).currency(currency).amount(amount).address(address).build();
|
|
17232
17328
|
case 14:
|
|
17233
17329
|
return _context.abrupt("return", _context.sent);
|
|
17234
17330
|
case 15:
|
|
@@ -17238,7 +17334,7 @@ var createTx$1 = function createTx(originApi, address, amount, currency, originN
|
|
|
17238
17334
|
}, _callee);
|
|
17239
17335
|
}));
|
|
17240
17336
|
};
|
|
17241
|
-
var
|
|
17337
|
+
var getOriginFeeDetailsInternal = function getOriginFeeDetailsInternal(_a) {
|
|
17242
17338
|
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
17243
17339
|
var api = _ref.api,
|
|
17244
17340
|
account = _ref.account,
|
|
@@ -17250,34 +17346,37 @@ var getOriginFeeDetails$1 = function getOriginFeeDetails(_a) {
|
|
|
17250
17346
|
_ref$feeMarginPercent = _ref.feeMarginPercentage,
|
|
17251
17347
|
feeMarginPercentage = _ref$feeMarginPercent === void 0 ? 10 : _ref$feeMarginPercent;
|
|
17252
17348
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
17253
|
-
var
|
|
17349
|
+
var tx, xcmFee, xcmFeeWithMargin, nativeBalance, minTransferableAmount, sufficientForXCM;
|
|
17254
17350
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
17255
17351
|
while (1) switch (_context2.prev = _context2.next) {
|
|
17256
17352
|
case 0:
|
|
17257
17353
|
_context2.next = 2;
|
|
17258
|
-
return
|
|
17259
|
-
address: account,
|
|
17260
|
-
node: origin,
|
|
17261
|
-
api: api
|
|
17262
|
-
});
|
|
17354
|
+
return api.init(origin);
|
|
17263
17355
|
case 2:
|
|
17264
|
-
|
|
17265
|
-
minTransferableAmount = getMinNativeTransferableAmount(origin);
|
|
17266
|
-
_context2.next = 6;
|
|
17356
|
+
_context2.next = 4;
|
|
17267
17357
|
return createTx$1(api, accountDestination, amount, currency, origin, destination);
|
|
17268
|
-
case
|
|
17358
|
+
case 4:
|
|
17269
17359
|
tx = _context2.sent;
|
|
17270
|
-
_context2.next =
|
|
17360
|
+
_context2.next = 7;
|
|
17271
17361
|
return api.calculateTransactionFee(tx, account);
|
|
17272
|
-
case
|
|
17362
|
+
case 7:
|
|
17273
17363
|
xcmFee = _context2.sent;
|
|
17274
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);
|
|
17275
17374
|
sufficientForXCM = nativeBalance - minTransferableAmount - xcmFeeWithMargin > 0;
|
|
17276
17375
|
return _context2.abrupt("return", {
|
|
17277
17376
|
sufficientForXCM: sufficientForXCM,
|
|
17278
17377
|
xcmFee: xcmFee
|
|
17279
17378
|
});
|
|
17280
|
-
case
|
|
17379
|
+
case 15:
|
|
17281
17380
|
case "end":
|
|
17282
17381
|
return _context2.stop();
|
|
17283
17382
|
}
|
|
@@ -17285,6 +17384,33 @@ var getOriginFeeDetails$1 = function getOriginFeeDetails(_a) {
|
|
|
17285
17384
|
})();
|
|
17286
17385
|
});
|
|
17287
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
|
+
};
|
|
17288
17414
|
|
|
17289
17415
|
var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
17290
17416
|
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
@@ -17294,77 +17420,72 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
17294
17420
|
accountDestination = _ref.accountDestination,
|
|
17295
17421
|
currency = _ref.currency,
|
|
17296
17422
|
amount = _ref.amount,
|
|
17297
|
-
|
|
17423
|
+
api = _ref.api;
|
|
17298
17424
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
17299
17425
|
var _b, _c, _d, originBalance, xcmFeeDetails, expectedBalanceAfterXCMDelivery, asset;
|
|
17300
17426
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17301
17427
|
while (1) switch (_context.prev = _context.next) {
|
|
17302
17428
|
case 0:
|
|
17303
17429
|
_context.next = 2;
|
|
17304
|
-
return
|
|
17430
|
+
return api.init(origin);
|
|
17305
17431
|
case 2:
|
|
17306
|
-
|
|
17307
|
-
|
|
17432
|
+
api.setDisconnectAllowed(false);
|
|
17433
|
+
_context.prev = 3;
|
|
17434
|
+
_context.next = 6;
|
|
17435
|
+
return getBalanceNativeInternal({
|
|
17308
17436
|
address: accountOrigin,
|
|
17309
17437
|
node: origin,
|
|
17310
|
-
api:
|
|
17438
|
+
api: api
|
|
17311
17439
|
});
|
|
17312
|
-
case
|
|
17440
|
+
case 6:
|
|
17313
17441
|
originBalance = _context.sent;
|
|
17314
|
-
_context.next =
|
|
17315
|
-
return
|
|
17442
|
+
_context.next = 9;
|
|
17443
|
+
return getOriginFeeDetailsInternal({
|
|
17316
17444
|
origin: origin,
|
|
17317
17445
|
destination: destination,
|
|
17318
17446
|
currency: currency,
|
|
17319
17447
|
amount: amount,
|
|
17320
17448
|
account: accountOrigin,
|
|
17321
17449
|
accountDestination: accountDestination,
|
|
17322
|
-
api:
|
|
17450
|
+
api: api
|
|
17323
17451
|
});
|
|
17324
|
-
case
|
|
17452
|
+
case 9:
|
|
17325
17453
|
xcmFeeDetails = _context.sent;
|
|
17326
17454
|
expectedBalanceAfterXCMDelivery = originBalance - xcmFeeDetails.xcmFee;
|
|
17327
17455
|
asset = (_b = getAssetBySymbolOrId(origin, currency, destination)) !== null && _b !== void 0 ? _b : origin === 'AssetHubPolkadot' ? getAssetBySymbolOrId('Ethereum', currency, null) : null;
|
|
17328
17456
|
if (asset) {
|
|
17329
|
-
_context.next =
|
|
17457
|
+
_context.next = 14;
|
|
17330
17458
|
break;
|
|
17331
17459
|
}
|
|
17332
17460
|
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(origin));
|
|
17333
|
-
case
|
|
17461
|
+
case 14:
|
|
17334
17462
|
_context.t0 = {
|
|
17335
17463
|
origin: origin,
|
|
17336
17464
|
destination: destination,
|
|
17337
17465
|
ecosystem: determineRelayChainSymbol(origin)
|
|
17338
17466
|
};
|
|
17339
|
-
_context.next =
|
|
17340
|
-
return
|
|
17341
|
-
api:
|
|
17467
|
+
_context.next = 17;
|
|
17468
|
+
return getAssetBalanceInternal({
|
|
17469
|
+
api: api,
|
|
17342
17470
|
address: accountOrigin,
|
|
17343
17471
|
node: origin,
|
|
17344
17472
|
currency: currency
|
|
17345
17473
|
});
|
|
17346
|
-
case
|
|
17474
|
+
case 17:
|
|
17347
17475
|
_context.t1 = _context.sent;
|
|
17348
17476
|
_context.t2 = (_c = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _c !== void 0 ? _c : '';
|
|
17349
17477
|
_context.t3 = {
|
|
17350
17478
|
balance: _context.t1,
|
|
17351
17479
|
currency: _context.t2
|
|
17352
17480
|
};
|
|
17353
|
-
_context.
|
|
17354
|
-
return getBalanceNative$1({
|
|
17355
|
-
address: accountOrigin,
|
|
17356
|
-
node: origin,
|
|
17357
|
-
api: originApi
|
|
17358
|
-
});
|
|
17359
|
-
case 20:
|
|
17360
|
-
_context.t4 = _context.sent;
|
|
17481
|
+
_context.t4 = originBalance;
|
|
17361
17482
|
_context.t5 = expectedBalanceAfterXCMDelivery;
|
|
17362
17483
|
_context.t6 = xcmFeeDetails;
|
|
17363
17484
|
_context.t7 = BigInt((_d = getExistentialDeposit(origin)) !== null && _d !== void 0 ? _d : 0);
|
|
17364
17485
|
_context.t8 = getNativeAssetSymbol(origin);
|
|
17365
17486
|
_context.t9 = getMinNativeTransferableAmount(origin);
|
|
17366
17487
|
_context.next = 28;
|
|
17367
|
-
return getMaxNativeTransferableAmount(
|
|
17488
|
+
return getMaxNativeTransferableAmount(api, accountOrigin, origin);
|
|
17368
17489
|
case 28:
|
|
17369
17490
|
_context.t10 = _context.sent;
|
|
17370
17491
|
_context.t11 = {
|
|
@@ -17377,10 +17498,10 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
17377
17498
|
maxNativeTransferableAmount: _context.t10
|
|
17378
17499
|
};
|
|
17379
17500
|
_context.next = 32;
|
|
17380
|
-
return
|
|
17501
|
+
return getBalanceNativeInternal({
|
|
17381
17502
|
address: accountDestination,
|
|
17382
17503
|
node: destination,
|
|
17383
|
-
api:
|
|
17504
|
+
api: api
|
|
17384
17505
|
});
|
|
17385
17506
|
case 32:
|
|
17386
17507
|
_context.t12 = _context.sent;
|
|
@@ -17398,10 +17519,17 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
17398
17519
|
destinationFeeBalance: _context.t15
|
|
17399
17520
|
});
|
|
17400
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:
|
|
17401
17529
|
case "end":
|
|
17402
17530
|
return _context.stop();
|
|
17403
17531
|
}
|
|
17404
|
-
}, _callee);
|
|
17532
|
+
}, _callee, null, [[3,, 37, 42]]);
|
|
17405
17533
|
})();
|
|
17406
17534
|
});
|
|
17407
17535
|
};
|
|
@@ -17536,7 +17664,7 @@ var checkKeepAlive = function checkKeepAlive(_a) {
|
|
|
17536
17664
|
asset = _ref.asset,
|
|
17537
17665
|
destNode = _ref.destNode;
|
|
17538
17666
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
17539
|
-
var balance, balanceOrigin, amountBN, ed, edOrigin, tx, xcmFee, increasedFee, amountBNWithoutFee, amountOriginBNWithoutFee;
|
|
17667
|
+
var balance, balanceOrigin, amountBN, ed, edOrigin, oldDisconnectAllowed, tx, xcmFee, increasedFee, amountBNWithoutFee, amountOriginBNWithoutFee;
|
|
17540
17668
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17541
17669
|
while (1) switch (_context.prev = _context.next) {
|
|
17542
17670
|
case 0:
|
|
@@ -17569,47 +17697,50 @@ var checkKeepAlive = function checkKeepAlive(_a) {
|
|
|
17569
17697
|
amountBN = BigInt(amount);
|
|
17570
17698
|
ed = getExistentialDeposit$1(destNode !== null && destNode !== void 0 ? destNode : determineRelayChain(originNode));
|
|
17571
17699
|
edOrigin = getExistentialDeposit$1(originNode !== null && originNode !== void 0 ? originNode : determineRelayChain(destNode));
|
|
17572
|
-
|
|
17700
|
+
oldDisconnectAllowed = originApi.getDisconnectAllowed();
|
|
17701
|
+
originApi.setDisconnectAllowed(false);
|
|
17702
|
+
_context.next = 19;
|
|
17573
17703
|
return createTx(originApi, destApi, address, amount, asset.symbol, originNode, destNode);
|
|
17574
|
-
case
|
|
17704
|
+
case 19:
|
|
17575
17705
|
tx = _context.sent;
|
|
17706
|
+
originApi.setDisconnectAllowed(oldDisconnectAllowed);
|
|
17576
17707
|
if (!(tx === null)) {
|
|
17577
|
-
_context.next =
|
|
17708
|
+
_context.next = 23;
|
|
17578
17709
|
break;
|
|
17579
17710
|
}
|
|
17580
17711
|
throw new KeepAliveError('Transaction for XCM fee calculation could not be created.');
|
|
17581
|
-
case
|
|
17582
|
-
_context.next =
|
|
17712
|
+
case 23:
|
|
17713
|
+
_context.next = 25;
|
|
17583
17714
|
return originApi.calculateTransactionFee(tx, address);
|
|
17584
|
-
case
|
|
17715
|
+
case 25:
|
|
17585
17716
|
xcmFee = _context.sent;
|
|
17586
17717
|
if (!(ed === null)) {
|
|
17587
|
-
_context.next =
|
|
17718
|
+
_context.next = 28;
|
|
17588
17719
|
break;
|
|
17589
17720
|
}
|
|
17590
17721
|
throw new KeepAliveError('Existential deposit not found for destination parachain.');
|
|
17591
|
-
case
|
|
17722
|
+
case 28:
|
|
17592
17723
|
if (!(edOrigin === null)) {
|
|
17593
|
-
_context.next =
|
|
17724
|
+
_context.next = 30;
|
|
17594
17725
|
break;
|
|
17595
17726
|
}
|
|
17596
17727
|
throw new KeepAliveError('Existential deposit not found for origin parachain.');
|
|
17597
|
-
case
|
|
17728
|
+
case 30:
|
|
17598
17729
|
increasedFee = xcmFee + xcmFee / BigInt(2);
|
|
17599
17730
|
amountBNWithoutFee = amountBN - increasedFee;
|
|
17600
17731
|
if (!(balance + amountBNWithoutFee < BigInt(ed))) {
|
|
17601
|
-
_context.next =
|
|
17732
|
+
_context.next = 34;
|
|
17602
17733
|
break;
|
|
17603
17734
|
}
|
|
17604
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."));
|
|
17605
|
-
case
|
|
17736
|
+
case 34:
|
|
17606
17737
|
amountOriginBNWithoutFee = amountBN - (xcmFee + xcmFee / BigInt(2));
|
|
17607
17738
|
if (!((asset.symbol === 'DOT' || asset.symbol === 'KSM') && balanceOrigin - amountOriginBNWithoutFee > BigInt(edOrigin))) {
|
|
17608
|
-
_context.next =
|
|
17739
|
+
_context.next = 37;
|
|
17609
17740
|
break;
|
|
17610
17741
|
}
|
|
17611
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."));
|
|
17612
|
-
case
|
|
17743
|
+
case 37:
|
|
17613
17744
|
case "end":
|
|
17614
17745
|
return _context.stop();
|
|
17615
17746
|
}
|
|
@@ -17743,48 +17874,49 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
17743
17874
|
_context.next = 45;
|
|
17744
17875
|
return api.init(origin);
|
|
17745
17876
|
case 45:
|
|
17877
|
+
_context.prev = 45;
|
|
17746
17878
|
amountStr = amount === null || amount === void 0 ? void 0 : amount.toString();
|
|
17747
17879
|
if (!('multilocation' in currency || 'multiasset' in currency)) {
|
|
17748
|
-
_context.next =
|
|
17880
|
+
_context.next = 51;
|
|
17749
17881
|
break;
|
|
17750
17882
|
}
|
|
17751
17883
|
console.warn('Keep alive check is not supported when using MultiLocation as currency.');
|
|
17752
|
-
_context.next =
|
|
17884
|
+
_context.next = 69;
|
|
17753
17885
|
break;
|
|
17754
|
-
case
|
|
17886
|
+
case 51:
|
|
17755
17887
|
if (!(_typeof(address) === 'object')) {
|
|
17756
|
-
_context.next =
|
|
17888
|
+
_context.next = 55;
|
|
17757
17889
|
break;
|
|
17758
17890
|
}
|
|
17759
17891
|
console.warn('Keep alive check is not supported when using MultiLocation as address.');
|
|
17760
|
-
_context.next =
|
|
17892
|
+
_context.next = 69;
|
|
17761
17893
|
break;
|
|
17762
|
-
case
|
|
17894
|
+
case 55:
|
|
17763
17895
|
if (!(_typeof(destination) === 'object')) {
|
|
17764
|
-
_context.next =
|
|
17896
|
+
_context.next = 59;
|
|
17765
17897
|
break;
|
|
17766
17898
|
}
|
|
17767
17899
|
console.warn('Keep alive check is not supported when using MultiLocation as destination.');
|
|
17768
|
-
_context.next =
|
|
17900
|
+
_context.next = 69;
|
|
17769
17901
|
break;
|
|
17770
|
-
case
|
|
17902
|
+
case 59:
|
|
17771
17903
|
if (!(destination === 'Ethereum')) {
|
|
17772
|
-
_context.next =
|
|
17904
|
+
_context.next = 63;
|
|
17773
17905
|
break;
|
|
17774
17906
|
}
|
|
17775
17907
|
console.warn('Keep alive check is not supported when using Ethereum as origin or destination.');
|
|
17776
|
-
_context.next =
|
|
17908
|
+
_context.next = 69;
|
|
17777
17909
|
break;
|
|
17778
|
-
case
|
|
17910
|
+
case 63:
|
|
17779
17911
|
if (asset) {
|
|
17780
|
-
_context.next =
|
|
17912
|
+
_context.next = 67;
|
|
17781
17913
|
break;
|
|
17782
17914
|
}
|
|
17783
17915
|
console.warn('Keep alive check is not supported when asset check is disabled.');
|
|
17784
|
-
_context.next =
|
|
17916
|
+
_context.next = 69;
|
|
17785
17917
|
break;
|
|
17786
|
-
case
|
|
17787
|
-
_context.next =
|
|
17918
|
+
case 67:
|
|
17919
|
+
_context.next = 69;
|
|
17788
17920
|
return checkKeepAlive({
|
|
17789
17921
|
originApi: api,
|
|
17790
17922
|
address: address,
|
|
@@ -17794,7 +17926,7 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
17794
17926
|
asset: asset,
|
|
17795
17927
|
destNode: destination
|
|
17796
17928
|
});
|
|
17797
|
-
case
|
|
17929
|
+
case 69:
|
|
17798
17930
|
// In case asset check is disabled, we create asset object from currency symbol
|
|
17799
17931
|
resolvedAsset = asset !== null && asset !== void 0 ? asset : {
|
|
17800
17932
|
symbol: 'symbol' in currency ? currency.symbol : undefined
|
|
@@ -17813,11 +17945,21 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
17813
17945
|
serializedApiCallEnabled: serializedApiCallEnabled,
|
|
17814
17946
|
ahAddress: ahAddress
|
|
17815
17947
|
}));
|
|
17816
|
-
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:
|
|
17817
17959
|
case "end":
|
|
17818
17960
|
return _context.stop();
|
|
17819
17961
|
}
|
|
17820
|
-
}, _callee);
|
|
17962
|
+
}, _callee, null, [[45,, 71, 76]]);
|
|
17821
17963
|
})();
|
|
17822
17964
|
});
|
|
17823
17965
|
};
|
|
@@ -17870,24 +18012,25 @@ var transferRelayToParaCommon = function transferRelayToParaCommon(options_1) {
|
|
|
17870
18012
|
_context4.next = 7;
|
|
17871
18013
|
return api.init(determineRelayChain(destination));
|
|
17872
18014
|
case 7:
|
|
18015
|
+
_context4.prev = 7;
|
|
17873
18016
|
amountStr = amount.toString();
|
|
17874
18017
|
if (!isMultiLocationDestination) {
|
|
17875
|
-
_context4.next =
|
|
18018
|
+
_context4.next = 13;
|
|
17876
18019
|
break;
|
|
17877
18020
|
}
|
|
17878
18021
|
console.warn('Keep alive check is not supported when using MultiLocation as destination.');
|
|
17879
|
-
_context4.next =
|
|
18022
|
+
_context4.next = 19;
|
|
17880
18023
|
break;
|
|
17881
|
-
case
|
|
18024
|
+
case 13:
|
|
17882
18025
|
if (!isAddressMultiLocation) {
|
|
17883
|
-
_context4.next =
|
|
18026
|
+
_context4.next = 17;
|
|
17884
18027
|
break;
|
|
17885
18028
|
}
|
|
17886
18029
|
console.warn('Keep alive check is not supported when using MultiLocation as address.');
|
|
17887
|
-
_context4.next =
|
|
18030
|
+
_context4.next = 19;
|
|
17888
18031
|
break;
|
|
17889
|
-
case
|
|
17890
|
-
_context4.next =
|
|
18032
|
+
case 17:
|
|
18033
|
+
_context4.next = 19;
|
|
17891
18034
|
return checkKeepAlive({
|
|
17892
18035
|
originApi: api,
|
|
17893
18036
|
address: address,
|
|
@@ -17898,7 +18041,7 @@ var transferRelayToParaCommon = function transferRelayToParaCommon(options_1) {
|
|
|
17898
18041
|
},
|
|
17899
18042
|
destNode: destination
|
|
17900
18043
|
});
|
|
17901
|
-
case
|
|
18044
|
+
case 19:
|
|
17902
18045
|
serializedApiCall = getNode(isMultiLocationDestination ? resolveTNodeFromMultiLocation(destination) : destination).transferRelayToPara({
|
|
17903
18046
|
api: api,
|
|
17904
18047
|
destination: destination,
|
|
@@ -17909,19 +18052,29 @@ var transferRelayToParaCommon = function transferRelayToParaCommon(options_1) {
|
|
|
17909
18052
|
version: version
|
|
17910
18053
|
});
|
|
17911
18054
|
if (!serializedApiCallEnabled) {
|
|
17912
|
-
_context4.next =
|
|
18055
|
+
_context4.next = 22;
|
|
17913
18056
|
break;
|
|
17914
18057
|
}
|
|
17915
18058
|
return _context4.abrupt("return", Object.assign(Object.assign({}, serializedApiCall), {
|
|
17916
18059
|
parameters: Object.values(serializedApiCall.parameters)
|
|
17917
18060
|
}));
|
|
17918
|
-
case 21:
|
|
17919
|
-
return _context4.abrupt("return", api.callTxMethod(serializedApiCall));
|
|
17920
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:
|
|
17921
18074
|
case "end":
|
|
17922
18075
|
return _context4.stop();
|
|
17923
18076
|
}
|
|
17924
|
-
}, _callee4);
|
|
18077
|
+
}, _callee4, null, [[7,, 23, 28]]);
|
|
17925
18078
|
})();
|
|
17926
18079
|
});
|
|
17927
18080
|
};
|
|
@@ -17963,6 +18116,8 @@ var snakeToCamel = function snakeToCamel(str) {
|
|
|
17963
18116
|
var PolkadotJsApi = /*#__PURE__*/function () {
|
|
17964
18117
|
function PolkadotJsApi() {
|
|
17965
18118
|
_classCallCheck(this, PolkadotJsApi);
|
|
18119
|
+
this.initialized = false;
|
|
18120
|
+
this.disconnectAllowed = true;
|
|
17966
18121
|
}
|
|
17967
18122
|
return _createClass(PolkadotJsApi, [{
|
|
17968
18123
|
key: "setApi",
|
|
@@ -17982,32 +18137,40 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
17982
18137
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17983
18138
|
while (1) switch (_context.prev = _context.next) {
|
|
17984
18139
|
case 0:
|
|
18140
|
+
if (!this.initialized) {
|
|
18141
|
+
_context.next = 2;
|
|
18142
|
+
break;
|
|
18143
|
+
}
|
|
18144
|
+
return _context.abrupt("return");
|
|
18145
|
+
case 2:
|
|
17985
18146
|
if (!(typeof this._api === 'string')) {
|
|
17986
|
-
_context.next =
|
|
18147
|
+
_context.next = 8;
|
|
17987
18148
|
break;
|
|
17988
18149
|
}
|
|
17989
|
-
_context.next =
|
|
18150
|
+
_context.next = 5;
|
|
17990
18151
|
return this.createApiInstance(this._api);
|
|
17991
|
-
case
|
|
18152
|
+
case 5:
|
|
17992
18153
|
this.api = _context.sent;
|
|
17993
|
-
_context.next =
|
|
18154
|
+
_context.next = 16;
|
|
17994
18155
|
break;
|
|
17995
|
-
case
|
|
18156
|
+
case 8:
|
|
17996
18157
|
if (!((_a = this._api) !== null && _a !== void 0)) {
|
|
17997
|
-
_context.next =
|
|
18158
|
+
_context.next = 12;
|
|
17998
18159
|
break;
|
|
17999
18160
|
}
|
|
18000
18161
|
_context.t0 = _a;
|
|
18001
|
-
_context.next =
|
|
18162
|
+
_context.next = 15;
|
|
18002
18163
|
break;
|
|
18003
|
-
case 10:
|
|
18004
|
-
_context.next = 12;
|
|
18005
|
-
return createApiInstanceForNode$1(this, node);
|
|
18006
18164
|
case 12:
|
|
18165
|
+
_context.next = 14;
|
|
18166
|
+
return createApiInstanceForNode$1(this, node);
|
|
18167
|
+
case 14:
|
|
18007
18168
|
_context.t0 = _context.sent;
|
|
18008
|
-
case
|
|
18169
|
+
case 15:
|
|
18009
18170
|
this.api = _context.t0;
|
|
18010
|
-
case
|
|
18171
|
+
case 16:
|
|
18172
|
+
this.initialized = true;
|
|
18173
|
+
case 17:
|
|
18011
18174
|
case "end":
|
|
18012
18175
|
return _context.stop();
|
|
18013
18176
|
}
|
|
@@ -18181,17 +18344,39 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
18181
18344
|
}));
|
|
18182
18345
|
}
|
|
18183
18346
|
}, {
|
|
18184
|
-
key: "
|
|
18185
|
-
value: function
|
|
18347
|
+
key: "getBalanceForeignBifrost",
|
|
18348
|
+
value: function getBalanceForeignBifrost(address, asset) {
|
|
18186
18349
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
18187
|
-
var
|
|
18350
|
+
var currencySelection, response, accountData;
|
|
18188
18351
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
18189
18352
|
while (1) switch (_context9.prev = _context9.next) {
|
|
18190
18353
|
case 0:
|
|
18191
|
-
|
|
18354
|
+
currencySelection = getNode('BifrostPolkadot').getCurrencySelection(asset);
|
|
18355
|
+
_context9.next = 3;
|
|
18356
|
+
return this.api.query.tokens.accounts(address, currencySelection);
|
|
18357
|
+
case 3:
|
|
18358
|
+
response = _context9.sent;
|
|
18359
|
+
accountData = response ? response : null;
|
|
18360
|
+
return _context9.abrupt("return", accountData ? BigInt(accountData.free.toString()) : BigInt(0));
|
|
18361
|
+
case 6:
|
|
18362
|
+
case "end":
|
|
18363
|
+
return _context9.stop();
|
|
18364
|
+
}
|
|
18365
|
+
}, _callee9, this);
|
|
18366
|
+
}));
|
|
18367
|
+
}
|
|
18368
|
+
}, {
|
|
18369
|
+
key: "getBalanceForeignXTokens",
|
|
18370
|
+
value: function getBalanceForeignXTokens(address, asset) {
|
|
18371
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
18372
|
+
var response, entry, accountData;
|
|
18373
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
18374
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
18375
|
+
case 0:
|
|
18376
|
+
_context10.next = 2;
|
|
18192
18377
|
return this.api.query.tokens.accounts.entries(address);
|
|
18193
18378
|
case 2:
|
|
18194
|
-
response =
|
|
18379
|
+
response = _context10.sent;
|
|
18195
18380
|
entry = response.find(function (_ref2) {
|
|
18196
18381
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
18197
18382
|
_ref3$0$args = _slicedToArray(_ref3[0].args, 2);
|
|
@@ -18203,53 +18388,53 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
18203
18388
|
return assetSymbol === ((_a = asset.symbol) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || isForeignAsset(asset) && assetSymbol === ((_b = asset.assetId) === null || _b === void 0 ? void 0 : _b.toLowerCase()) || Object.values((_c = assetItem.toHuman()) !== null && _c !== void 0 ? _c : {}).toString().toLowerCase() === ((_d = asset.symbol) === null || _d === void 0 ? void 0 : _d.toLowerCase()) || isForeignAsset(asset) && Object.values((_e = assetItem.toHuman()) !== null && _e !== void 0 ? _e : {}).toString().toLowerCase() === ((_f = asset.assetId) === null || _f === void 0 ? void 0 : _f.toLowerCase());
|
|
18204
18389
|
});
|
|
18205
18390
|
accountData = entry ? entry[1] : null;
|
|
18206
|
-
return
|
|
18391
|
+
return _context10.abrupt("return", accountData ? BigInt(accountData.free.toString()) : BigInt(0));
|
|
18207
18392
|
case 6:
|
|
18208
18393
|
case "end":
|
|
18209
|
-
return
|
|
18394
|
+
return _context10.stop();
|
|
18210
18395
|
}
|
|
18211
|
-
},
|
|
18396
|
+
}, _callee10, this);
|
|
18212
18397
|
}));
|
|
18213
18398
|
}
|
|
18214
18399
|
}, {
|
|
18215
18400
|
key: "getBalanceForeignAssetsAccount",
|
|
18216
18401
|
value: function getBalanceForeignAssetsAccount(address, assetId) {
|
|
18217
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
18402
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
18218
18403
|
var response, obj;
|
|
18219
|
-
return _regeneratorRuntime().wrap(function
|
|
18220
|
-
while (1) switch (
|
|
18404
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
18405
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
18221
18406
|
case 0:
|
|
18222
|
-
|
|
18407
|
+
_context11.next = 2;
|
|
18223
18408
|
return this.api.query.assets.account(assetId, address);
|
|
18224
18409
|
case 2:
|
|
18225
|
-
response =
|
|
18410
|
+
response = _context11.sent;
|
|
18226
18411
|
obj = response.toJSON();
|
|
18227
|
-
return
|
|
18412
|
+
return _context11.abrupt("return", BigInt(obj === null || !obj.balance ? 0 : obj.balance));
|
|
18228
18413
|
case 5:
|
|
18229
18414
|
case "end":
|
|
18230
|
-
return
|
|
18415
|
+
return _context11.stop();
|
|
18231
18416
|
}
|
|
18232
|
-
},
|
|
18417
|
+
}, _callee11, this);
|
|
18233
18418
|
}));
|
|
18234
18419
|
}
|
|
18235
18420
|
}, {
|
|
18236
18421
|
key: "getFromStorage",
|
|
18237
18422
|
value: function getFromStorage(key) {
|
|
18238
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
18423
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
18239
18424
|
var response;
|
|
18240
|
-
return _regeneratorRuntime().wrap(function
|
|
18241
|
-
while (1) switch (
|
|
18425
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
18426
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
18242
18427
|
case 0:
|
|
18243
|
-
|
|
18428
|
+
_context12.next = 2;
|
|
18244
18429
|
return this.api.rpc.state.getStorage(key);
|
|
18245
18430
|
case 2:
|
|
18246
|
-
response =
|
|
18247
|
-
return
|
|
18431
|
+
response = _context12.sent;
|
|
18432
|
+
return _context12.abrupt("return", response.toHex());
|
|
18248
18433
|
case 4:
|
|
18249
18434
|
case "end":
|
|
18250
|
-
return
|
|
18435
|
+
return _context12.stop();
|
|
18251
18436
|
}
|
|
18252
|
-
},
|
|
18437
|
+
}, _callee12, this);
|
|
18253
18438
|
}));
|
|
18254
18439
|
}
|
|
18255
18440
|
}, {
|
|
@@ -18260,21 +18445,57 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
18260
18445
|
}, {
|
|
18261
18446
|
key: "createApiForNode",
|
|
18262
18447
|
value: function createApiForNode(node) {
|
|
18263
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
18448
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
18264
18449
|
var api;
|
|
18265
|
-
return _regeneratorRuntime().wrap(function
|
|
18266
|
-
while (1) switch (
|
|
18450
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
18451
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
18267
18452
|
case 0:
|
|
18268
18453
|
api = new PolkadotJsApi();
|
|
18269
|
-
|
|
18454
|
+
_context13.next = 3;
|
|
18270
18455
|
return api.init(node);
|
|
18271
18456
|
case 3:
|
|
18272
|
-
return
|
|
18457
|
+
return _context13.abrupt("return", api);
|
|
18273
18458
|
case 4:
|
|
18274
18459
|
case "end":
|
|
18275
|
-
return
|
|
18460
|
+
return _context13.stop();
|
|
18461
|
+
}
|
|
18462
|
+
}, _callee13);
|
|
18463
|
+
}));
|
|
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();
|
|
18276
18497
|
}
|
|
18277
|
-
},
|
|
18498
|
+
}, _callee14, this);
|
|
18278
18499
|
}));
|
|
18279
18500
|
}
|
|
18280
18501
|
}]);
|