@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.cjs
CHANGED
|
@@ -15051,7 +15051,7 @@ var getExistentialDeposit$1 = function getExistentialDeposit(node) {
|
|
|
15051
15051
|
return edMap[node];
|
|
15052
15052
|
};
|
|
15053
15053
|
|
|
15054
|
-
var
|
|
15054
|
+
var getBalanceNativeInternal = function getBalanceNativeInternal(_a) {
|
|
15055
15055
|
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
15056
15056
|
var address = _ref.address,
|
|
15057
15057
|
node = _ref.node,
|
|
@@ -15075,6 +15075,31 @@ var getBalanceNative$1 = function getBalanceNative(_a) {
|
|
|
15075
15075
|
})();
|
|
15076
15076
|
});
|
|
15077
15077
|
};
|
|
15078
|
+
var getBalanceNative$1 = function getBalanceNative(options) {
|
|
15079
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
15080
|
+
var api;
|
|
15081
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
15082
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
15083
|
+
case 0:
|
|
15084
|
+
api = options.api;
|
|
15085
|
+
_context2.prev = 1;
|
|
15086
|
+
_context2.next = 4;
|
|
15087
|
+
return getBalanceNativeInternal(options);
|
|
15088
|
+
case 4:
|
|
15089
|
+
return _context2.abrupt("return", _context2.sent);
|
|
15090
|
+
case 5:
|
|
15091
|
+
_context2.prev = 5;
|
|
15092
|
+
_context2.next = 8;
|
|
15093
|
+
return api.disconnect();
|
|
15094
|
+
case 8:
|
|
15095
|
+
return _context2.finish(5);
|
|
15096
|
+
case 9:
|
|
15097
|
+
case "end":
|
|
15098
|
+
return _context2.stop();
|
|
15099
|
+
}
|
|
15100
|
+
}, _callee2, null, [[1,, 5, 9]]);
|
|
15101
|
+
}));
|
|
15102
|
+
};
|
|
15078
15103
|
|
|
15079
15104
|
var AssetHubPolkadot = {
|
|
15080
15105
|
defaultPallet: "PolkadotXcm",
|
|
@@ -15976,8 +16001,14 @@ var getBalanceForeignXTokens = function getBalanceForeignXTokens(api, node, addr
|
|
|
15976
16001
|
case 3:
|
|
15977
16002
|
return _context.abrupt("return", api.getBalanceForeignAssetsAccount(address, BigInt(asset.assetId)));
|
|
15978
16003
|
case 4:
|
|
16004
|
+
if (!(node === 'BifrostPolkadot' || node === 'BifrostKusama')) {
|
|
16005
|
+
_context.next = 6;
|
|
16006
|
+
break;
|
|
16007
|
+
}
|
|
16008
|
+
return _context.abrupt("return", api.getBalanceForeignBifrost(address, asset));
|
|
16009
|
+
case 6:
|
|
15979
16010
|
return _context.abrupt("return", api.getBalanceForeignXTokens(address, asset));
|
|
15980
|
-
case
|
|
16011
|
+
case 7:
|
|
15981
16012
|
case "end":
|
|
15982
16013
|
return _context.stop();
|
|
15983
16014
|
}
|
|
@@ -15985,14 +16016,14 @@ var getBalanceForeignXTokens = function getBalanceForeignXTokens(api, node, addr
|
|
|
15985
16016
|
}));
|
|
15986
16017
|
};
|
|
15987
16018
|
|
|
15988
|
-
var
|
|
16019
|
+
var getBalanceForeignInternal = function getBalanceForeignInternal(_a) {
|
|
15989
16020
|
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
15990
16021
|
var address = _ref.address,
|
|
15991
16022
|
node = _ref.node,
|
|
15992
16023
|
currency = _ref.currency,
|
|
15993
16024
|
api = _ref.api;
|
|
15994
16025
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
15995
|
-
var _b, asset;
|
|
16026
|
+
var _b, asset, defaultPallet;
|
|
15996
16027
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
15997
16028
|
while (1) switch (_context.prev = _context.next) {
|
|
15998
16029
|
case 0:
|
|
@@ -16006,26 +16037,27 @@ var getBalanceForeign$1 = function getBalanceForeign(_a) {
|
|
|
16006
16037
|
}
|
|
16007
16038
|
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(node));
|
|
16008
16039
|
case 5:
|
|
16009
|
-
|
|
16010
|
-
|
|
16040
|
+
defaultPallet = getDefaultPallet(node);
|
|
16041
|
+
if (!(defaultPallet === 'XTokens')) {
|
|
16042
|
+
_context.next = 12;
|
|
16011
16043
|
break;
|
|
16012
16044
|
}
|
|
16013
|
-
_context.next =
|
|
16045
|
+
_context.next = 9;
|
|
16014
16046
|
return getBalanceForeignXTokens(api, node, address, asset);
|
|
16015
|
-
case
|
|
16047
|
+
case 9:
|
|
16016
16048
|
return _context.abrupt("return", _context.sent);
|
|
16017
|
-
case
|
|
16018
|
-
if (!(
|
|
16019
|
-
_context.next =
|
|
16049
|
+
case 12:
|
|
16050
|
+
if (!(defaultPallet === 'PolkadotXcm')) {
|
|
16051
|
+
_context.next = 16;
|
|
16020
16052
|
break;
|
|
16021
16053
|
}
|
|
16022
|
-
_context.next =
|
|
16054
|
+
_context.next = 15;
|
|
16023
16055
|
return getBalanceForeignPolkadotXcm(api, node, address, asset);
|
|
16024
|
-
case 14:
|
|
16025
|
-
return _context.abrupt("return", _context.sent);
|
|
16026
16056
|
case 15:
|
|
16027
|
-
|
|
16057
|
+
return _context.abrupt("return", _context.sent);
|
|
16028
16058
|
case 16:
|
|
16059
|
+
throw new Error('Unsupported pallet');
|
|
16060
|
+
case 17:
|
|
16029
16061
|
case "end":
|
|
16030
16062
|
return _context.stop();
|
|
16031
16063
|
}
|
|
@@ -16033,8 +16065,33 @@ var getBalanceForeign$1 = function getBalanceForeign(_a) {
|
|
|
16033
16065
|
})();
|
|
16034
16066
|
});
|
|
16035
16067
|
};
|
|
16068
|
+
var getBalanceForeign$1 = function getBalanceForeign(options) {
|
|
16069
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
16070
|
+
var api;
|
|
16071
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
16072
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
16073
|
+
case 0:
|
|
16074
|
+
api = options.api;
|
|
16075
|
+
_context2.prev = 1;
|
|
16076
|
+
_context2.next = 4;
|
|
16077
|
+
return getBalanceForeignInternal(options);
|
|
16078
|
+
case 4:
|
|
16079
|
+
return _context2.abrupt("return", _context2.sent);
|
|
16080
|
+
case 5:
|
|
16081
|
+
_context2.prev = 5;
|
|
16082
|
+
_context2.next = 8;
|
|
16083
|
+
return api.disconnect();
|
|
16084
|
+
case 8:
|
|
16085
|
+
return _context2.finish(5);
|
|
16086
|
+
case 9:
|
|
16087
|
+
case "end":
|
|
16088
|
+
return _context2.stop();
|
|
16089
|
+
}
|
|
16090
|
+
}, _callee2, null, [[1,, 5, 9]]);
|
|
16091
|
+
}));
|
|
16092
|
+
};
|
|
16036
16093
|
|
|
16037
|
-
var
|
|
16094
|
+
var getAssetBalanceInternal = function getAssetBalanceInternal(_a) {
|
|
16038
16095
|
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
16039
16096
|
var address = _ref.address,
|
|
16040
16097
|
node = _ref.node,
|
|
@@ -16054,7 +16111,7 @@ var getAssetBalance$1 = function getAssetBalance(_a) {
|
|
|
16054
16111
|
break;
|
|
16055
16112
|
}
|
|
16056
16113
|
_context.next = 6;
|
|
16057
|
-
return
|
|
16114
|
+
return getBalanceNativeInternal({
|
|
16058
16115
|
address: address,
|
|
16059
16116
|
node: node,
|
|
16060
16117
|
api: api
|
|
@@ -16065,7 +16122,7 @@ var getAssetBalance$1 = function getAssetBalance(_a) {
|
|
|
16065
16122
|
break;
|
|
16066
16123
|
case 9:
|
|
16067
16124
|
_context.next = 11;
|
|
16068
|
-
return
|
|
16125
|
+
return getBalanceForeignInternal({
|
|
16069
16126
|
address: address,
|
|
16070
16127
|
node: node,
|
|
16071
16128
|
api: api,
|
|
@@ -16101,6 +16158,31 @@ var getAssetBalance$1 = function getAssetBalance(_a) {
|
|
|
16101
16158
|
})();
|
|
16102
16159
|
});
|
|
16103
16160
|
};
|
|
16161
|
+
var getAssetBalance$1 = function getAssetBalance(options) {
|
|
16162
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
16163
|
+
var api;
|
|
16164
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
16165
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
16166
|
+
case 0:
|
|
16167
|
+
api = options.api;
|
|
16168
|
+
_context2.prev = 1;
|
|
16169
|
+
_context2.next = 4;
|
|
16170
|
+
return getAssetBalanceInternal(options);
|
|
16171
|
+
case 4:
|
|
16172
|
+
return _context2.abrupt("return", _context2.sent);
|
|
16173
|
+
case 5:
|
|
16174
|
+
_context2.prev = 5;
|
|
16175
|
+
_context2.next = 8;
|
|
16176
|
+
return api.disconnect();
|
|
16177
|
+
case 8:
|
|
16178
|
+
return _context2.finish(5);
|
|
16179
|
+
case 9:
|
|
16180
|
+
case "end":
|
|
16181
|
+
return _context2.stop();
|
|
16182
|
+
}
|
|
16183
|
+
}, _callee2, null, [[1,, 5, 9]]);
|
|
16184
|
+
}));
|
|
16185
|
+
};
|
|
16104
16186
|
|
|
16105
16187
|
var palletsMap = edsMapJson;
|
|
16106
16188
|
var getExistentialDeposit = function getExistentialDeposit(node) {
|
|
@@ -16119,7 +16201,7 @@ var getMaxNativeTransferableAmount = function getMaxNativeTransferableAmount(api
|
|
|
16119
16201
|
case 0:
|
|
16120
16202
|
ed = getExistentialDeposit(node);
|
|
16121
16203
|
_context.next = 3;
|
|
16122
|
-
return
|
|
16204
|
+
return getBalanceNativeInternal({
|
|
16123
16205
|
address: address,
|
|
16124
16206
|
node: node,
|
|
16125
16207
|
api: api
|
|
@@ -16555,6 +16637,10 @@ var ParaToRelayBuilder = /*#__PURE__*/function () {
|
|
|
16555
16637
|
}]);
|
|
16556
16638
|
}();
|
|
16557
16639
|
|
|
16640
|
+
var isPjsClient = function isPjsClient(api) {
|
|
16641
|
+
return _typeof(api) === 'object' && api !== null && 'disconnect' in api && typeof api.disconnect === 'function';
|
|
16642
|
+
};
|
|
16643
|
+
|
|
16558
16644
|
var buildBeneficiaryInput = function buildBeneficiaryInput(api, address) {
|
|
16559
16645
|
if (isTMultiLocation(address)) {
|
|
16560
16646
|
return address;
|
|
@@ -16598,6 +16684,7 @@ var claimAssets$1 = function claimAssets(options) {
|
|
|
16598
16684
|
_context.next = 3;
|
|
16599
16685
|
return api.init(node);
|
|
16600
16686
|
case 3:
|
|
16687
|
+
_context.prev = 3;
|
|
16601
16688
|
args = buildClaimAssetsInput(options);
|
|
16602
16689
|
module = isRelayChain(node) ? 'XcmPallet' : 'PolkadotXcm';
|
|
16603
16690
|
call = {
|
|
@@ -16606,20 +16693,29 @@ var claimAssets$1 = function claimAssets(options) {
|
|
|
16606
16693
|
parameters: args
|
|
16607
16694
|
};
|
|
16608
16695
|
if (!(serializedApiCallEnabled === true)) {
|
|
16609
|
-
_context.next =
|
|
16696
|
+
_context.next = 9;
|
|
16610
16697
|
break;
|
|
16611
16698
|
}
|
|
16612
16699
|
return _context.abrupt("return", Object.assign(Object.assign({}, call), {
|
|
16613
|
-
// Keep compatible with the old SerializedCall type
|
|
16614
16700
|
parameters: Object.values(args)
|
|
16615
16701
|
}));
|
|
16616
|
-
case 8:
|
|
16617
|
-
return _context.abrupt("return", api.callTxMethod(call));
|
|
16618
16702
|
case 9:
|
|
16703
|
+
return _context.abrupt("return", api.callTxMethod(call));
|
|
16704
|
+
case 10:
|
|
16705
|
+
_context.prev = 10;
|
|
16706
|
+
if (!isPjsClient(api)) {
|
|
16707
|
+
_context.next = 14;
|
|
16708
|
+
break;
|
|
16709
|
+
}
|
|
16710
|
+
_context.next = 14;
|
|
16711
|
+
return api.disconnect();
|
|
16712
|
+
case 14:
|
|
16713
|
+
return _context.finish(10);
|
|
16714
|
+
case 15:
|
|
16619
16715
|
case "end":
|
|
16620
16716
|
return _context.stop();
|
|
16621
16717
|
}
|
|
16622
|
-
}, _callee);
|
|
16718
|
+
}, _callee, null, [[3,, 10, 15]]);
|
|
16623
16719
|
}));
|
|
16624
16720
|
};
|
|
16625
16721
|
|
|
@@ -17206,7 +17302,7 @@ var EvmBuilder = function EvmBuilder(provider) {
|
|
|
17206
17302
|
return new EvmBuilderClass(provider);
|
|
17207
17303
|
};
|
|
17208
17304
|
|
|
17209
|
-
var createTx$1 = function createTx(
|
|
17305
|
+
var createTx$1 = function createTx(api, address, amount, currency, originNode, destNode) {
|
|
17210
17306
|
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
17211
17307
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17212
17308
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -17216,7 +17312,7 @@ var createTx$1 = function createTx(originApi, address, amount, currency, originN
|
|
|
17216
17312
|
break;
|
|
17217
17313
|
}
|
|
17218
17314
|
_context.next = 3;
|
|
17219
|
-
return Builder$1(
|
|
17315
|
+
return Builder$1(api).to(destNode).amount(amount).address(address).build();
|
|
17220
17316
|
case 3:
|
|
17221
17317
|
return _context.abrupt("return", _context.sent);
|
|
17222
17318
|
case 6:
|
|
@@ -17225,12 +17321,12 @@ var createTx$1 = function createTx(originApi, address, amount, currency, originN
|
|
|
17225
17321
|
break;
|
|
17226
17322
|
}
|
|
17227
17323
|
_context.next = 9;
|
|
17228
|
-
return Builder$1(
|
|
17324
|
+
return Builder$1(api).from(originNode).amount(amount).address(address).build();
|
|
17229
17325
|
case 9:
|
|
17230
17326
|
return _context.abrupt("return", _context.sent);
|
|
17231
17327
|
case 12:
|
|
17232
17328
|
_context.next = 14;
|
|
17233
|
-
return Builder$1(
|
|
17329
|
+
return Builder$1(api).from(originNode).to(destNode).currency(currency).amount(amount).address(address).build();
|
|
17234
17330
|
case 14:
|
|
17235
17331
|
return _context.abrupt("return", _context.sent);
|
|
17236
17332
|
case 15:
|
|
@@ -17240,7 +17336,7 @@ var createTx$1 = function createTx(originApi, address, amount, currency, originN
|
|
|
17240
17336
|
}, _callee);
|
|
17241
17337
|
}));
|
|
17242
17338
|
};
|
|
17243
|
-
var
|
|
17339
|
+
var getOriginFeeDetailsInternal = function getOriginFeeDetailsInternal(_a) {
|
|
17244
17340
|
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
17245
17341
|
var api = _ref.api,
|
|
17246
17342
|
account = _ref.account,
|
|
@@ -17252,34 +17348,37 @@ var getOriginFeeDetails$1 = function getOriginFeeDetails(_a) {
|
|
|
17252
17348
|
_ref$feeMarginPercent = _ref.feeMarginPercentage,
|
|
17253
17349
|
feeMarginPercentage = _ref$feeMarginPercent === void 0 ? 10 : _ref$feeMarginPercent;
|
|
17254
17350
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
17255
|
-
var
|
|
17351
|
+
var tx, xcmFee, xcmFeeWithMargin, nativeBalance, minTransferableAmount, sufficientForXCM;
|
|
17256
17352
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
17257
17353
|
while (1) switch (_context2.prev = _context2.next) {
|
|
17258
17354
|
case 0:
|
|
17259
17355
|
_context2.next = 2;
|
|
17260
|
-
return
|
|
17261
|
-
address: account,
|
|
17262
|
-
node: origin,
|
|
17263
|
-
api: api
|
|
17264
|
-
});
|
|
17356
|
+
return api.init(origin);
|
|
17265
17357
|
case 2:
|
|
17266
|
-
|
|
17267
|
-
minTransferableAmount = getMinNativeTransferableAmount(origin);
|
|
17268
|
-
_context2.next = 6;
|
|
17358
|
+
_context2.next = 4;
|
|
17269
17359
|
return createTx$1(api, accountDestination, amount, currency, origin, destination);
|
|
17270
|
-
case
|
|
17360
|
+
case 4:
|
|
17271
17361
|
tx = _context2.sent;
|
|
17272
|
-
_context2.next =
|
|
17362
|
+
_context2.next = 7;
|
|
17273
17363
|
return api.calculateTransactionFee(tx, account);
|
|
17274
|
-
case
|
|
17364
|
+
case 7:
|
|
17275
17365
|
xcmFee = _context2.sent;
|
|
17276
17366
|
xcmFeeWithMargin = xcmFee + xcmFee / BigInt(feeMarginPercentage);
|
|
17367
|
+
_context2.next = 11;
|
|
17368
|
+
return getBalanceNativeInternal({
|
|
17369
|
+
address: account,
|
|
17370
|
+
node: origin,
|
|
17371
|
+
api: api
|
|
17372
|
+
});
|
|
17373
|
+
case 11:
|
|
17374
|
+
nativeBalance = _context2.sent;
|
|
17375
|
+
minTransferableAmount = getMinNativeTransferableAmount(origin);
|
|
17277
17376
|
sufficientForXCM = nativeBalance - minTransferableAmount - xcmFeeWithMargin > 0;
|
|
17278
17377
|
return _context2.abrupt("return", {
|
|
17279
17378
|
sufficientForXCM: sufficientForXCM,
|
|
17280
17379
|
xcmFee: xcmFee
|
|
17281
17380
|
});
|
|
17282
|
-
case
|
|
17381
|
+
case 15:
|
|
17283
17382
|
case "end":
|
|
17284
17383
|
return _context2.stop();
|
|
17285
17384
|
}
|
|
@@ -17287,6 +17386,33 @@ var getOriginFeeDetails$1 = function getOriginFeeDetails(_a) {
|
|
|
17287
17386
|
})();
|
|
17288
17387
|
});
|
|
17289
17388
|
};
|
|
17389
|
+
var getOriginFeeDetails$1 = function getOriginFeeDetails(options) {
|
|
17390
|
+
return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
17391
|
+
var api;
|
|
17392
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
17393
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
17394
|
+
case 0:
|
|
17395
|
+
api = options.api;
|
|
17396
|
+
api.setDisconnectAllowed(false);
|
|
17397
|
+
_context3.prev = 2;
|
|
17398
|
+
_context3.next = 5;
|
|
17399
|
+
return getOriginFeeDetailsInternal(options);
|
|
17400
|
+
case 5:
|
|
17401
|
+
return _context3.abrupt("return", _context3.sent);
|
|
17402
|
+
case 6:
|
|
17403
|
+
_context3.prev = 6;
|
|
17404
|
+
api.setDisconnectAllowed(true);
|
|
17405
|
+
_context3.next = 10;
|
|
17406
|
+
return api.disconnect();
|
|
17407
|
+
case 10:
|
|
17408
|
+
return _context3.finish(6);
|
|
17409
|
+
case 11:
|
|
17410
|
+
case "end":
|
|
17411
|
+
return _context3.stop();
|
|
17412
|
+
}
|
|
17413
|
+
}, _callee3, null, [[2,, 6, 11]]);
|
|
17414
|
+
}));
|
|
17415
|
+
};
|
|
17290
17416
|
|
|
17291
17417
|
var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
17292
17418
|
return __awaiter(void 0, [_a], void 0, function (_ref) {
|
|
@@ -17296,77 +17422,72 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
17296
17422
|
accountDestination = _ref.accountDestination,
|
|
17297
17423
|
currency = _ref.currency,
|
|
17298
17424
|
amount = _ref.amount,
|
|
17299
|
-
|
|
17425
|
+
api = _ref.api;
|
|
17300
17426
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
17301
17427
|
var _b, _c, _d, originBalance, xcmFeeDetails, expectedBalanceAfterXCMDelivery, asset;
|
|
17302
17428
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17303
17429
|
while (1) switch (_context.prev = _context.next) {
|
|
17304
17430
|
case 0:
|
|
17305
17431
|
_context.next = 2;
|
|
17306
|
-
return
|
|
17432
|
+
return api.init(origin);
|
|
17307
17433
|
case 2:
|
|
17308
|
-
|
|
17309
|
-
|
|
17434
|
+
api.setDisconnectAllowed(false);
|
|
17435
|
+
_context.prev = 3;
|
|
17436
|
+
_context.next = 6;
|
|
17437
|
+
return getBalanceNativeInternal({
|
|
17310
17438
|
address: accountOrigin,
|
|
17311
17439
|
node: origin,
|
|
17312
|
-
api:
|
|
17440
|
+
api: api
|
|
17313
17441
|
});
|
|
17314
|
-
case
|
|
17442
|
+
case 6:
|
|
17315
17443
|
originBalance = _context.sent;
|
|
17316
|
-
_context.next =
|
|
17317
|
-
return
|
|
17444
|
+
_context.next = 9;
|
|
17445
|
+
return getOriginFeeDetailsInternal({
|
|
17318
17446
|
origin: origin,
|
|
17319
17447
|
destination: destination,
|
|
17320
17448
|
currency: currency,
|
|
17321
17449
|
amount: amount,
|
|
17322
17450
|
account: accountOrigin,
|
|
17323
17451
|
accountDestination: accountDestination,
|
|
17324
|
-
api:
|
|
17452
|
+
api: api
|
|
17325
17453
|
});
|
|
17326
|
-
case
|
|
17454
|
+
case 9:
|
|
17327
17455
|
xcmFeeDetails = _context.sent;
|
|
17328
17456
|
expectedBalanceAfterXCMDelivery = originBalance - xcmFeeDetails.xcmFee;
|
|
17329
17457
|
asset = (_b = getAssetBySymbolOrId(origin, currency, destination)) !== null && _b !== void 0 ? _b : origin === 'AssetHubPolkadot' ? getAssetBySymbolOrId('Ethereum', currency, null) : null;
|
|
17330
17458
|
if (asset) {
|
|
17331
|
-
_context.next =
|
|
17459
|
+
_context.next = 14;
|
|
17332
17460
|
break;
|
|
17333
17461
|
}
|
|
17334
17462
|
throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " not found on ").concat(origin));
|
|
17335
|
-
case
|
|
17463
|
+
case 14:
|
|
17336
17464
|
_context.t0 = {
|
|
17337
17465
|
origin: origin,
|
|
17338
17466
|
destination: destination,
|
|
17339
17467
|
ecosystem: determineRelayChainSymbol(origin)
|
|
17340
17468
|
};
|
|
17341
|
-
_context.next =
|
|
17342
|
-
return
|
|
17343
|
-
api:
|
|
17469
|
+
_context.next = 17;
|
|
17470
|
+
return getAssetBalanceInternal({
|
|
17471
|
+
api: api,
|
|
17344
17472
|
address: accountOrigin,
|
|
17345
17473
|
node: origin,
|
|
17346
17474
|
currency: currency
|
|
17347
17475
|
});
|
|
17348
|
-
case
|
|
17476
|
+
case 17:
|
|
17349
17477
|
_context.t1 = _context.sent;
|
|
17350
17478
|
_context.t2 = (_c = asset === null || asset === void 0 ? void 0 : asset.symbol) !== null && _c !== void 0 ? _c : '';
|
|
17351
17479
|
_context.t3 = {
|
|
17352
17480
|
balance: _context.t1,
|
|
17353
17481
|
currency: _context.t2
|
|
17354
17482
|
};
|
|
17355
|
-
_context.
|
|
17356
|
-
return getBalanceNative$1({
|
|
17357
|
-
address: accountOrigin,
|
|
17358
|
-
node: origin,
|
|
17359
|
-
api: originApi
|
|
17360
|
-
});
|
|
17361
|
-
case 20:
|
|
17362
|
-
_context.t4 = _context.sent;
|
|
17483
|
+
_context.t4 = originBalance;
|
|
17363
17484
|
_context.t5 = expectedBalanceAfterXCMDelivery;
|
|
17364
17485
|
_context.t6 = xcmFeeDetails;
|
|
17365
17486
|
_context.t7 = BigInt((_d = getExistentialDeposit(origin)) !== null && _d !== void 0 ? _d : 0);
|
|
17366
17487
|
_context.t8 = getNativeAssetSymbol(origin);
|
|
17367
17488
|
_context.t9 = getMinNativeTransferableAmount(origin);
|
|
17368
17489
|
_context.next = 28;
|
|
17369
|
-
return getMaxNativeTransferableAmount(
|
|
17490
|
+
return getMaxNativeTransferableAmount(api, accountOrigin, origin);
|
|
17370
17491
|
case 28:
|
|
17371
17492
|
_context.t10 = _context.sent;
|
|
17372
17493
|
_context.t11 = {
|
|
@@ -17379,10 +17500,10 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
17379
17500
|
maxNativeTransferableAmount: _context.t10
|
|
17380
17501
|
};
|
|
17381
17502
|
_context.next = 32;
|
|
17382
|
-
return
|
|
17503
|
+
return getBalanceNativeInternal({
|
|
17383
17504
|
address: accountDestination,
|
|
17384
17505
|
node: destination,
|
|
17385
|
-
api:
|
|
17506
|
+
api: api
|
|
17386
17507
|
});
|
|
17387
17508
|
case 32:
|
|
17388
17509
|
_context.t12 = _context.sent;
|
|
@@ -17400,10 +17521,17 @@ var getTransferInfo$1 = function getTransferInfo(_a) {
|
|
|
17400
17521
|
destinationFeeBalance: _context.t15
|
|
17401
17522
|
});
|
|
17402
17523
|
case 37:
|
|
17524
|
+
_context.prev = 37;
|
|
17525
|
+
api.setDisconnectAllowed(true);
|
|
17526
|
+
_context.next = 41;
|
|
17527
|
+
return api.disconnect();
|
|
17528
|
+
case 41:
|
|
17529
|
+
return _context.finish(37);
|
|
17530
|
+
case 42:
|
|
17403
17531
|
case "end":
|
|
17404
17532
|
return _context.stop();
|
|
17405
17533
|
}
|
|
17406
|
-
}, _callee);
|
|
17534
|
+
}, _callee, null, [[3,, 37, 42]]);
|
|
17407
17535
|
})();
|
|
17408
17536
|
});
|
|
17409
17537
|
};
|
|
@@ -17538,7 +17666,7 @@ var checkKeepAlive = function checkKeepAlive(_a) {
|
|
|
17538
17666
|
asset = _ref.asset,
|
|
17539
17667
|
destNode = _ref.destNode;
|
|
17540
17668
|
return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
17541
|
-
var balance, balanceOrigin, amountBN, ed, edOrigin, tx, xcmFee, increasedFee, amountBNWithoutFee, amountOriginBNWithoutFee;
|
|
17669
|
+
var balance, balanceOrigin, amountBN, ed, edOrigin, oldDisconnectAllowed, tx, xcmFee, increasedFee, amountBNWithoutFee, amountOriginBNWithoutFee;
|
|
17542
17670
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17543
17671
|
while (1) switch (_context.prev = _context.next) {
|
|
17544
17672
|
case 0:
|
|
@@ -17571,47 +17699,50 @@ var checkKeepAlive = function checkKeepAlive(_a) {
|
|
|
17571
17699
|
amountBN = BigInt(amount);
|
|
17572
17700
|
ed = getExistentialDeposit$1(destNode !== null && destNode !== void 0 ? destNode : determineRelayChain(originNode));
|
|
17573
17701
|
edOrigin = getExistentialDeposit$1(originNode !== null && originNode !== void 0 ? originNode : determineRelayChain(destNode));
|
|
17574
|
-
|
|
17702
|
+
oldDisconnectAllowed = originApi.getDisconnectAllowed();
|
|
17703
|
+
originApi.setDisconnectAllowed(false);
|
|
17704
|
+
_context.next = 19;
|
|
17575
17705
|
return createTx(originApi, destApi, address, amount, asset.symbol, originNode, destNode);
|
|
17576
|
-
case
|
|
17706
|
+
case 19:
|
|
17577
17707
|
tx = _context.sent;
|
|
17708
|
+
originApi.setDisconnectAllowed(oldDisconnectAllowed);
|
|
17578
17709
|
if (!(tx === null)) {
|
|
17579
|
-
_context.next =
|
|
17710
|
+
_context.next = 23;
|
|
17580
17711
|
break;
|
|
17581
17712
|
}
|
|
17582
17713
|
throw new KeepAliveError('Transaction for XCM fee calculation could not be created.');
|
|
17583
|
-
case
|
|
17584
|
-
_context.next =
|
|
17714
|
+
case 23:
|
|
17715
|
+
_context.next = 25;
|
|
17585
17716
|
return originApi.calculateTransactionFee(tx, address);
|
|
17586
|
-
case
|
|
17717
|
+
case 25:
|
|
17587
17718
|
xcmFee = _context.sent;
|
|
17588
17719
|
if (!(ed === null)) {
|
|
17589
|
-
_context.next =
|
|
17720
|
+
_context.next = 28;
|
|
17590
17721
|
break;
|
|
17591
17722
|
}
|
|
17592
17723
|
throw new KeepAliveError('Existential deposit not found for destination parachain.');
|
|
17593
|
-
case
|
|
17724
|
+
case 28:
|
|
17594
17725
|
if (!(edOrigin === null)) {
|
|
17595
|
-
_context.next =
|
|
17726
|
+
_context.next = 30;
|
|
17596
17727
|
break;
|
|
17597
17728
|
}
|
|
17598
17729
|
throw new KeepAliveError('Existential deposit not found for origin parachain.');
|
|
17599
|
-
case
|
|
17730
|
+
case 30:
|
|
17600
17731
|
increasedFee = xcmFee + xcmFee / BigInt(2);
|
|
17601
17732
|
amountBNWithoutFee = amountBN - increasedFee;
|
|
17602
17733
|
if (!(balance + amountBNWithoutFee < BigInt(ed))) {
|
|
17603
|
-
_context.next =
|
|
17734
|
+
_context.next = 34;
|
|
17604
17735
|
break;
|
|
17605
17736
|
}
|
|
17606
17737
|
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."));
|
|
17607
|
-
case
|
|
17738
|
+
case 34:
|
|
17608
17739
|
amountOriginBNWithoutFee = amountBN - (xcmFee + xcmFee / BigInt(2));
|
|
17609
17740
|
if (!((asset.symbol === 'DOT' || asset.symbol === 'KSM') && balanceOrigin - amountOriginBNWithoutFee > BigInt(edOrigin))) {
|
|
17610
|
-
_context.next =
|
|
17741
|
+
_context.next = 37;
|
|
17611
17742
|
break;
|
|
17612
17743
|
}
|
|
17613
17744
|
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."));
|
|
17614
|
-
case
|
|
17745
|
+
case 37:
|
|
17615
17746
|
case "end":
|
|
17616
17747
|
return _context.stop();
|
|
17617
17748
|
}
|
|
@@ -17745,48 +17876,49 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
17745
17876
|
_context.next = 45;
|
|
17746
17877
|
return api.init(origin);
|
|
17747
17878
|
case 45:
|
|
17879
|
+
_context.prev = 45;
|
|
17748
17880
|
amountStr = amount === null || amount === void 0 ? void 0 : amount.toString();
|
|
17749
17881
|
if (!('multilocation' in currency || 'multiasset' in currency)) {
|
|
17750
|
-
_context.next =
|
|
17882
|
+
_context.next = 51;
|
|
17751
17883
|
break;
|
|
17752
17884
|
}
|
|
17753
17885
|
console.warn('Keep alive check is not supported when using MultiLocation as currency.');
|
|
17754
|
-
_context.next =
|
|
17886
|
+
_context.next = 69;
|
|
17755
17887
|
break;
|
|
17756
|
-
case
|
|
17888
|
+
case 51:
|
|
17757
17889
|
if (!(_typeof(address) === 'object')) {
|
|
17758
|
-
_context.next =
|
|
17890
|
+
_context.next = 55;
|
|
17759
17891
|
break;
|
|
17760
17892
|
}
|
|
17761
17893
|
console.warn('Keep alive check is not supported when using MultiLocation as address.');
|
|
17762
|
-
_context.next =
|
|
17894
|
+
_context.next = 69;
|
|
17763
17895
|
break;
|
|
17764
|
-
case
|
|
17896
|
+
case 55:
|
|
17765
17897
|
if (!(_typeof(destination) === 'object')) {
|
|
17766
|
-
_context.next =
|
|
17898
|
+
_context.next = 59;
|
|
17767
17899
|
break;
|
|
17768
17900
|
}
|
|
17769
17901
|
console.warn('Keep alive check is not supported when using MultiLocation as destination.');
|
|
17770
|
-
_context.next =
|
|
17902
|
+
_context.next = 69;
|
|
17771
17903
|
break;
|
|
17772
|
-
case
|
|
17904
|
+
case 59:
|
|
17773
17905
|
if (!(destination === 'Ethereum')) {
|
|
17774
|
-
_context.next =
|
|
17906
|
+
_context.next = 63;
|
|
17775
17907
|
break;
|
|
17776
17908
|
}
|
|
17777
17909
|
console.warn('Keep alive check is not supported when using Ethereum as origin or destination.');
|
|
17778
|
-
_context.next =
|
|
17910
|
+
_context.next = 69;
|
|
17779
17911
|
break;
|
|
17780
|
-
case
|
|
17912
|
+
case 63:
|
|
17781
17913
|
if (asset) {
|
|
17782
|
-
_context.next =
|
|
17914
|
+
_context.next = 67;
|
|
17783
17915
|
break;
|
|
17784
17916
|
}
|
|
17785
17917
|
console.warn('Keep alive check is not supported when asset check is disabled.');
|
|
17786
|
-
_context.next =
|
|
17918
|
+
_context.next = 69;
|
|
17787
17919
|
break;
|
|
17788
|
-
case
|
|
17789
|
-
_context.next =
|
|
17920
|
+
case 67:
|
|
17921
|
+
_context.next = 69;
|
|
17790
17922
|
return checkKeepAlive({
|
|
17791
17923
|
originApi: api,
|
|
17792
17924
|
address: address,
|
|
@@ -17796,7 +17928,7 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
17796
17928
|
asset: asset,
|
|
17797
17929
|
destNode: destination
|
|
17798
17930
|
});
|
|
17799
|
-
case
|
|
17931
|
+
case 69:
|
|
17800
17932
|
// In case asset check is disabled, we create asset object from currency symbol
|
|
17801
17933
|
resolvedAsset = asset !== null && asset !== void 0 ? asset : {
|
|
17802
17934
|
symbol: 'symbol' in currency ? currency.symbol : undefined
|
|
@@ -17815,11 +17947,21 @@ var sendCommon = function sendCommon(options_1) {
|
|
|
17815
17947
|
serializedApiCallEnabled: serializedApiCallEnabled,
|
|
17816
17948
|
ahAddress: ahAddress
|
|
17817
17949
|
}));
|
|
17818
|
-
case
|
|
17950
|
+
case 71:
|
|
17951
|
+
_context.prev = 71;
|
|
17952
|
+
if (!isPjsClient(api)) {
|
|
17953
|
+
_context.next = 75;
|
|
17954
|
+
break;
|
|
17955
|
+
}
|
|
17956
|
+
_context.next = 75;
|
|
17957
|
+
return api.disconnect();
|
|
17958
|
+
case 75:
|
|
17959
|
+
return _context.finish(71);
|
|
17960
|
+
case 76:
|
|
17819
17961
|
case "end":
|
|
17820
17962
|
return _context.stop();
|
|
17821
17963
|
}
|
|
17822
|
-
}, _callee);
|
|
17964
|
+
}, _callee, null, [[45,, 71, 76]]);
|
|
17823
17965
|
})();
|
|
17824
17966
|
});
|
|
17825
17967
|
};
|
|
@@ -17872,24 +18014,25 @@ var transferRelayToParaCommon = function transferRelayToParaCommon(options_1) {
|
|
|
17872
18014
|
_context4.next = 7;
|
|
17873
18015
|
return api.init(determineRelayChain(destination));
|
|
17874
18016
|
case 7:
|
|
18017
|
+
_context4.prev = 7;
|
|
17875
18018
|
amountStr = amount.toString();
|
|
17876
18019
|
if (!isMultiLocationDestination) {
|
|
17877
|
-
_context4.next =
|
|
18020
|
+
_context4.next = 13;
|
|
17878
18021
|
break;
|
|
17879
18022
|
}
|
|
17880
18023
|
console.warn('Keep alive check is not supported when using MultiLocation as destination.');
|
|
17881
|
-
_context4.next =
|
|
18024
|
+
_context4.next = 19;
|
|
17882
18025
|
break;
|
|
17883
|
-
case
|
|
18026
|
+
case 13:
|
|
17884
18027
|
if (!isAddressMultiLocation) {
|
|
17885
|
-
_context4.next =
|
|
18028
|
+
_context4.next = 17;
|
|
17886
18029
|
break;
|
|
17887
18030
|
}
|
|
17888
18031
|
console.warn('Keep alive check is not supported when using MultiLocation as address.');
|
|
17889
|
-
_context4.next =
|
|
18032
|
+
_context4.next = 19;
|
|
17890
18033
|
break;
|
|
17891
|
-
case
|
|
17892
|
-
_context4.next =
|
|
18034
|
+
case 17:
|
|
18035
|
+
_context4.next = 19;
|
|
17893
18036
|
return checkKeepAlive({
|
|
17894
18037
|
originApi: api,
|
|
17895
18038
|
address: address,
|
|
@@ -17900,7 +18043,7 @@ var transferRelayToParaCommon = function transferRelayToParaCommon(options_1) {
|
|
|
17900
18043
|
},
|
|
17901
18044
|
destNode: destination
|
|
17902
18045
|
});
|
|
17903
|
-
case
|
|
18046
|
+
case 19:
|
|
17904
18047
|
serializedApiCall = getNode(isMultiLocationDestination ? resolveTNodeFromMultiLocation(destination) : destination).transferRelayToPara({
|
|
17905
18048
|
api: api,
|
|
17906
18049
|
destination: destination,
|
|
@@ -17911,19 +18054,29 @@ var transferRelayToParaCommon = function transferRelayToParaCommon(options_1) {
|
|
|
17911
18054
|
version: version
|
|
17912
18055
|
});
|
|
17913
18056
|
if (!serializedApiCallEnabled) {
|
|
17914
|
-
_context4.next =
|
|
18057
|
+
_context4.next = 22;
|
|
17915
18058
|
break;
|
|
17916
18059
|
}
|
|
17917
18060
|
return _context4.abrupt("return", Object.assign(Object.assign({}, serializedApiCall), {
|
|
17918
18061
|
parameters: Object.values(serializedApiCall.parameters)
|
|
17919
18062
|
}));
|
|
17920
|
-
case 21:
|
|
17921
|
-
return _context4.abrupt("return", api.callTxMethod(serializedApiCall));
|
|
17922
18063
|
case 22:
|
|
18064
|
+
return _context4.abrupt("return", api.callTxMethod(serializedApiCall));
|
|
18065
|
+
case 23:
|
|
18066
|
+
_context4.prev = 23;
|
|
18067
|
+
if (!isPjsClient(api)) {
|
|
18068
|
+
_context4.next = 27;
|
|
18069
|
+
break;
|
|
18070
|
+
}
|
|
18071
|
+
_context4.next = 27;
|
|
18072
|
+
return api.disconnect();
|
|
18073
|
+
case 27:
|
|
18074
|
+
return _context4.finish(23);
|
|
18075
|
+
case 28:
|
|
17923
18076
|
case "end":
|
|
17924
18077
|
return _context4.stop();
|
|
17925
18078
|
}
|
|
17926
|
-
}, _callee4);
|
|
18079
|
+
}, _callee4, null, [[7,, 23, 28]]);
|
|
17927
18080
|
})();
|
|
17928
18081
|
});
|
|
17929
18082
|
};
|
|
@@ -17965,6 +18118,8 @@ var snakeToCamel = function snakeToCamel(str) {
|
|
|
17965
18118
|
var PolkadotJsApi = /*#__PURE__*/function () {
|
|
17966
18119
|
function PolkadotJsApi() {
|
|
17967
18120
|
_classCallCheck(this, PolkadotJsApi);
|
|
18121
|
+
this.initialized = false;
|
|
18122
|
+
this.disconnectAllowed = true;
|
|
17968
18123
|
}
|
|
17969
18124
|
return _createClass(PolkadotJsApi, [{
|
|
17970
18125
|
key: "setApi",
|
|
@@ -17984,32 +18139,40 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
17984
18139
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
17985
18140
|
while (1) switch (_context.prev = _context.next) {
|
|
17986
18141
|
case 0:
|
|
18142
|
+
if (!this.initialized) {
|
|
18143
|
+
_context.next = 2;
|
|
18144
|
+
break;
|
|
18145
|
+
}
|
|
18146
|
+
return _context.abrupt("return");
|
|
18147
|
+
case 2:
|
|
17987
18148
|
if (!(typeof this._api === 'string')) {
|
|
17988
|
-
_context.next =
|
|
18149
|
+
_context.next = 8;
|
|
17989
18150
|
break;
|
|
17990
18151
|
}
|
|
17991
|
-
_context.next =
|
|
18152
|
+
_context.next = 5;
|
|
17992
18153
|
return this.createApiInstance(this._api);
|
|
17993
|
-
case
|
|
18154
|
+
case 5:
|
|
17994
18155
|
this.api = _context.sent;
|
|
17995
|
-
_context.next =
|
|
18156
|
+
_context.next = 16;
|
|
17996
18157
|
break;
|
|
17997
|
-
case
|
|
18158
|
+
case 8:
|
|
17998
18159
|
if (!((_a = this._api) !== null && _a !== void 0)) {
|
|
17999
|
-
_context.next =
|
|
18160
|
+
_context.next = 12;
|
|
18000
18161
|
break;
|
|
18001
18162
|
}
|
|
18002
18163
|
_context.t0 = _a;
|
|
18003
|
-
_context.next =
|
|
18164
|
+
_context.next = 15;
|
|
18004
18165
|
break;
|
|
18005
|
-
case 10:
|
|
18006
|
-
_context.next = 12;
|
|
18007
|
-
return createApiInstanceForNode$1(this, node);
|
|
18008
18166
|
case 12:
|
|
18167
|
+
_context.next = 14;
|
|
18168
|
+
return createApiInstanceForNode$1(this, node);
|
|
18169
|
+
case 14:
|
|
18009
18170
|
_context.t0 = _context.sent;
|
|
18010
|
-
case
|
|
18171
|
+
case 15:
|
|
18011
18172
|
this.api = _context.t0;
|
|
18012
|
-
case
|
|
18173
|
+
case 16:
|
|
18174
|
+
this.initialized = true;
|
|
18175
|
+
case 17:
|
|
18013
18176
|
case "end":
|
|
18014
18177
|
return _context.stop();
|
|
18015
18178
|
}
|
|
@@ -18183,17 +18346,39 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
18183
18346
|
}));
|
|
18184
18347
|
}
|
|
18185
18348
|
}, {
|
|
18186
|
-
key: "
|
|
18187
|
-
value: function
|
|
18349
|
+
key: "getBalanceForeignBifrost",
|
|
18350
|
+
value: function getBalanceForeignBifrost(address, asset) {
|
|
18188
18351
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
18189
|
-
var
|
|
18352
|
+
var currencySelection, response, accountData;
|
|
18190
18353
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
18191
18354
|
while (1) switch (_context9.prev = _context9.next) {
|
|
18192
18355
|
case 0:
|
|
18193
|
-
|
|
18356
|
+
currencySelection = getNode('BifrostPolkadot').getCurrencySelection(asset);
|
|
18357
|
+
_context9.next = 3;
|
|
18358
|
+
return this.api.query.tokens.accounts(address, currencySelection);
|
|
18359
|
+
case 3:
|
|
18360
|
+
response = _context9.sent;
|
|
18361
|
+
accountData = response ? response : null;
|
|
18362
|
+
return _context9.abrupt("return", accountData ? BigInt(accountData.free.toString()) : BigInt(0));
|
|
18363
|
+
case 6:
|
|
18364
|
+
case "end":
|
|
18365
|
+
return _context9.stop();
|
|
18366
|
+
}
|
|
18367
|
+
}, _callee9, this);
|
|
18368
|
+
}));
|
|
18369
|
+
}
|
|
18370
|
+
}, {
|
|
18371
|
+
key: "getBalanceForeignXTokens",
|
|
18372
|
+
value: function getBalanceForeignXTokens(address, asset) {
|
|
18373
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
18374
|
+
var response, entry, accountData;
|
|
18375
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
18376
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
18377
|
+
case 0:
|
|
18378
|
+
_context10.next = 2;
|
|
18194
18379
|
return this.api.query.tokens.accounts.entries(address);
|
|
18195
18380
|
case 2:
|
|
18196
|
-
response =
|
|
18381
|
+
response = _context10.sent;
|
|
18197
18382
|
entry = response.find(function (_ref2) {
|
|
18198
18383
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
18199
18384
|
_ref3$0$args = _slicedToArray(_ref3[0].args, 2);
|
|
@@ -18205,53 +18390,53 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
18205
18390
|
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());
|
|
18206
18391
|
});
|
|
18207
18392
|
accountData = entry ? entry[1] : null;
|
|
18208
|
-
return
|
|
18393
|
+
return _context10.abrupt("return", accountData ? BigInt(accountData.free.toString()) : BigInt(0));
|
|
18209
18394
|
case 6:
|
|
18210
18395
|
case "end":
|
|
18211
|
-
return
|
|
18396
|
+
return _context10.stop();
|
|
18212
18397
|
}
|
|
18213
|
-
},
|
|
18398
|
+
}, _callee10, this);
|
|
18214
18399
|
}));
|
|
18215
18400
|
}
|
|
18216
18401
|
}, {
|
|
18217
18402
|
key: "getBalanceForeignAssetsAccount",
|
|
18218
18403
|
value: function getBalanceForeignAssetsAccount(address, assetId) {
|
|
18219
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
18404
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
18220
18405
|
var response, obj;
|
|
18221
|
-
return _regeneratorRuntime().wrap(function
|
|
18222
|
-
while (1) switch (
|
|
18406
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
18407
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
18223
18408
|
case 0:
|
|
18224
|
-
|
|
18409
|
+
_context11.next = 2;
|
|
18225
18410
|
return this.api.query.assets.account(assetId, address);
|
|
18226
18411
|
case 2:
|
|
18227
|
-
response =
|
|
18412
|
+
response = _context11.sent;
|
|
18228
18413
|
obj = response.toJSON();
|
|
18229
|
-
return
|
|
18414
|
+
return _context11.abrupt("return", BigInt(obj === null || !obj.balance ? 0 : obj.balance));
|
|
18230
18415
|
case 5:
|
|
18231
18416
|
case "end":
|
|
18232
|
-
return
|
|
18417
|
+
return _context11.stop();
|
|
18233
18418
|
}
|
|
18234
|
-
},
|
|
18419
|
+
}, _callee11, this);
|
|
18235
18420
|
}));
|
|
18236
18421
|
}
|
|
18237
18422
|
}, {
|
|
18238
18423
|
key: "getFromStorage",
|
|
18239
18424
|
value: function getFromStorage(key) {
|
|
18240
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
18425
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
18241
18426
|
var response;
|
|
18242
|
-
return _regeneratorRuntime().wrap(function
|
|
18243
|
-
while (1) switch (
|
|
18427
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
18428
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
18244
18429
|
case 0:
|
|
18245
|
-
|
|
18430
|
+
_context12.next = 2;
|
|
18246
18431
|
return this.api.rpc.state.getStorage(key);
|
|
18247
18432
|
case 2:
|
|
18248
|
-
response =
|
|
18249
|
-
return
|
|
18433
|
+
response = _context12.sent;
|
|
18434
|
+
return _context12.abrupt("return", response.toHex());
|
|
18250
18435
|
case 4:
|
|
18251
18436
|
case "end":
|
|
18252
|
-
return
|
|
18437
|
+
return _context12.stop();
|
|
18253
18438
|
}
|
|
18254
|
-
},
|
|
18439
|
+
}, _callee12, this);
|
|
18255
18440
|
}));
|
|
18256
18441
|
}
|
|
18257
18442
|
}, {
|
|
@@ -18262,21 +18447,57 @@ var PolkadotJsApi = /*#__PURE__*/function () {
|
|
|
18262
18447
|
}, {
|
|
18263
18448
|
key: "createApiForNode",
|
|
18264
18449
|
value: function createApiForNode(node) {
|
|
18265
|
-
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
18450
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
18266
18451
|
var api;
|
|
18267
|
-
return _regeneratorRuntime().wrap(function
|
|
18268
|
-
while (1) switch (
|
|
18452
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
18453
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
18269
18454
|
case 0:
|
|
18270
18455
|
api = new PolkadotJsApi();
|
|
18271
|
-
|
|
18456
|
+
_context13.next = 3;
|
|
18272
18457
|
return api.init(node);
|
|
18273
18458
|
case 3:
|
|
18274
|
-
return
|
|
18459
|
+
return _context13.abrupt("return", api);
|
|
18275
18460
|
case 4:
|
|
18276
18461
|
case "end":
|
|
18277
|
-
return
|
|
18462
|
+
return _context13.stop();
|
|
18463
|
+
}
|
|
18464
|
+
}, _callee13);
|
|
18465
|
+
}));
|
|
18466
|
+
}
|
|
18467
|
+
}, {
|
|
18468
|
+
key: "setDisconnectAllowed",
|
|
18469
|
+
value: function setDisconnectAllowed(allowed) {
|
|
18470
|
+
this.disconnectAllowed = allowed;
|
|
18471
|
+
}
|
|
18472
|
+
}, {
|
|
18473
|
+
key: "getDisconnectAllowed",
|
|
18474
|
+
value: function getDisconnectAllowed() {
|
|
18475
|
+
return this.disconnectAllowed;
|
|
18476
|
+
}
|
|
18477
|
+
}, {
|
|
18478
|
+
key: "disconnect",
|
|
18479
|
+
value: function disconnect() {
|
|
18480
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
18481
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
18482
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
18483
|
+
case 0:
|
|
18484
|
+
if (this.disconnectAllowed) {
|
|
18485
|
+
_context14.next = 2;
|
|
18486
|
+
break;
|
|
18487
|
+
}
|
|
18488
|
+
return _context14.abrupt("return");
|
|
18489
|
+
case 2:
|
|
18490
|
+
if (!(typeof this._api === 'string' || this._api === undefined)) {
|
|
18491
|
+
_context14.next = 5;
|
|
18492
|
+
break;
|
|
18493
|
+
}
|
|
18494
|
+
_context14.next = 5;
|
|
18495
|
+
return this.api.disconnect();
|
|
18496
|
+
case 5:
|
|
18497
|
+
case "end":
|
|
18498
|
+
return _context14.stop();
|
|
18278
18499
|
}
|
|
18279
|
-
},
|
|
18500
|
+
}, _callee14, this);
|
|
18280
18501
|
}));
|
|
18281
18502
|
}
|
|
18282
18503
|
}]);
|