@paraspell/sdk-core 10.1.0 → 10.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +93 -87
- package/dist/index.d.ts +6 -3
- package/dist/index.mjs +93 -88
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -609,7 +609,7 @@ var DryRunFailedError = /*#__PURE__*/function (_Error) {
|
|
|
609
609
|
_classCallCheck(this, DryRunFailedError);
|
|
610
610
|
var message = "Dry run failed: ".concat(reason);
|
|
611
611
|
if (dryRunType) {
|
|
612
|
-
message = "Dry run ".concat(dryRunType, " failed: ").concat(reason);
|
|
612
|
+
message = "Dry run on ".concat(dryRunType, " failed: ").concat(reason);
|
|
613
613
|
}
|
|
614
614
|
_this = _callSuper(this, DryRunFailedError, [message]);
|
|
615
615
|
_this.name = 'DryRunFailedError';
|
|
@@ -2778,6 +2778,10 @@ var getNode = function getNode(node) {
|
|
|
2778
2778
|
return nodeMap[node];
|
|
2779
2779
|
};
|
|
2780
2780
|
|
|
2781
|
+
var replaceBigInt = function replaceBigInt(_key, value) {
|
|
2782
|
+
return typeof value === 'bigint' ? value.toString() : value;
|
|
2783
|
+
};
|
|
2784
|
+
|
|
2781
2785
|
var resolveParaId = function resolveParaId(paraId, destination) {
|
|
2782
2786
|
if (sdkCommon.isTMultiLocation(destination) || sdkCommon.isRelayChain(destination) || destination === 'Ethereum') {
|
|
2783
2787
|
return undefined;
|
|
@@ -4084,11 +4088,11 @@ var createOriginLocation = function createOriginLocation(origin, destination) {
|
|
|
4084
4088
|
};
|
|
4085
4089
|
var getDestXcmFee = /*#__PURE__*/function () {
|
|
4086
4090
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
4087
|
-
var api, origin, destination, currency, forwardedXcms, asset, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, dryRunResult, fee, newForwardedXcms, destParaId;
|
|
4091
|
+
var api, origin, hopNode, destination, currency, forwardedXcms, asset, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, dryRunResult, fee, newForwardedXcms, destParaId;
|
|
4088
4092
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
4089
4093
|
while (1) switch (_context2.prev = _context2.next) {
|
|
4090
4094
|
case 0:
|
|
4091
|
-
api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, feeAsset = options.feeAsset, originFee = options.originFee, disableFallback = options.disableFallback;
|
|
4095
|
+
api = options.api, origin = options.origin, hopNode = options.prevNode, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, feeAsset = options.feeAsset, originFee = options.originFee, disableFallback = options.disableFallback;
|
|
4092
4096
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
4093
4097
|
calcPaymentInfoFee = /*#__PURE__*/function () {
|
|
4094
4098
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
@@ -4107,7 +4111,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4107
4111
|
_context.next = 5;
|
|
4108
4112
|
break;
|
|
4109
4113
|
}
|
|
4110
|
-
throw new assets.InvalidCurrencyError("Currency ".concat(JSON.stringify(currency), " not found in ").concat(origin));
|
|
4114
|
+
throw new assets.InvalidCurrencyError("Currency ".concat(JSON.stringify(currency, replaceBigInt), " not found in ").concat(origin));
|
|
4111
4115
|
case 5:
|
|
4112
4116
|
if (!originAsset.multiLocation) {
|
|
4113
4117
|
_context.next = 19;
|
|
@@ -4173,7 +4177,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4173
4177
|
case 8:
|
|
4174
4178
|
_context2.next = 10;
|
|
4175
4179
|
return api.getDryRunXcm({
|
|
4176
|
-
originLocation: addXcmVersionHeader(createOriginLocation(
|
|
4180
|
+
originLocation: addXcmVersionHeader(createOriginLocation(hopNode, destination), exports.Version.V4),
|
|
4177
4181
|
xcm: forwardedXcms[1][0],
|
|
4178
4182
|
node: destination,
|
|
4179
4183
|
origin: origin,
|
|
@@ -4553,7 +4557,7 @@ var getOriginXcmFeeEstimate = /*#__PURE__*/function () {
|
|
|
4553
4557
|
|
|
4554
4558
|
var getXcmFee = /*#__PURE__*/function () {
|
|
4555
4559
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
4556
|
-
var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, asset, _yield$getOriginXcmFe, originFee, originCurrency, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, destApi, destFeeRes, assetHubNode, bridgeHubNode, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, nextChain, hopApi, hopResult, failingRecord, hopIsDestination, destFallback, processedBridgeHubData, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee;
|
|
4560
|
+
var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, asset, _yield$getOriginXcmFe, originFee, originCurrency, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, destApi, destFeeRes, assetHubNode, bridgeHubNode, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, nextChain, hopApi, hopResult, failingRecord, hopIsDestination, _destApi, destFallback, processedBridgeHubData, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee;
|
|
4557
4561
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4558
4562
|
while (1) switch (_context.prev = _context.next) {
|
|
4559
4563
|
case 0:
|
|
@@ -4602,6 +4606,7 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
4602
4606
|
forwardedXcms: undefined,
|
|
4603
4607
|
// force paymentInfo
|
|
4604
4608
|
origin: origin,
|
|
4609
|
+
prevNode: origin,
|
|
4605
4610
|
destination: destination,
|
|
4606
4611
|
currency: currency,
|
|
4607
4612
|
address: address,
|
|
@@ -4650,7 +4655,7 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
4650
4655
|
destinationFeeType = destination === 'Ethereum' ? 'noFeeRequired' : 'paymentInfo';
|
|
4651
4656
|
case 38:
|
|
4652
4657
|
if (!(Array.isArray(forwardedXcms) && forwardedXcms.length > 0 && forwardedXcms[1].length > 0 && ('disconnect' in api.getApi() ? Object.values(forwardedXcms[1][0]).length : forwardedXcms[1][0].value.length) > 0 && nextParaId !== undefined)) {
|
|
4653
|
-
_context.next =
|
|
4658
|
+
_context.next = 74;
|
|
4654
4659
|
break;
|
|
4655
4660
|
}
|
|
4656
4661
|
nextChain = getTNode(nextParaId, determineRelayChain(origin) === 'Polkadot' ? 'polkadot' : 'kusama');
|
|
@@ -4669,7 +4674,8 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
4669
4674
|
return getDestXcmFee({
|
|
4670
4675
|
api: hopApi,
|
|
4671
4676
|
forwardedXcms: forwardedXcms,
|
|
4672
|
-
origin:
|
|
4677
|
+
origin: origin,
|
|
4678
|
+
prevNode: currentOrigin,
|
|
4673
4679
|
destination: nextChain,
|
|
4674
4680
|
currency: currency,
|
|
4675
4681
|
address: address,
|
|
@@ -4682,7 +4688,7 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
4682
4688
|
case 48:
|
|
4683
4689
|
hopResult = _context.sent;
|
|
4684
4690
|
if (!hopResult.dryRunError) {
|
|
4685
|
-
_context.next =
|
|
4691
|
+
_context.next = 64;
|
|
4686
4692
|
break;
|
|
4687
4693
|
}
|
|
4688
4694
|
failingRecord = {
|
|
@@ -4703,14 +4709,23 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
4703
4709
|
}
|
|
4704
4710
|
// We failed before the true destination, use fallback via paymentInfo.
|
|
4705
4711
|
if (hopIsDestination) {
|
|
4706
|
-
_context.next =
|
|
4712
|
+
_context.next = 63;
|
|
4707
4713
|
break;
|
|
4708
4714
|
}
|
|
4709
|
-
|
|
4715
|
+
_destApi = api.clone();
|
|
4716
|
+
if (!(destination !== 'Ethereum')) {
|
|
4717
|
+
_context.next = 58;
|
|
4718
|
+
break;
|
|
4719
|
+
}
|
|
4720
|
+
_context.next = 58;
|
|
4721
|
+
return _destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
4722
|
+
case 58:
|
|
4723
|
+
_context.next = 60;
|
|
4710
4724
|
return getDestXcmFee({
|
|
4711
|
-
api:
|
|
4725
|
+
api: _destApi,
|
|
4712
4726
|
forwardedXcms: undefined,
|
|
4713
|
-
origin:
|
|
4727
|
+
origin: origin,
|
|
4728
|
+
prevNode: currentOrigin,
|
|
4714
4729
|
destination: destination,
|
|
4715
4730
|
currency: currency,
|
|
4716
4731
|
address: address,
|
|
@@ -4719,13 +4734,13 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
4719
4734
|
senderAddress: senderAddress,
|
|
4720
4735
|
disableFallback: disableFallback
|
|
4721
4736
|
});
|
|
4722
|
-
case
|
|
4737
|
+
case 60:
|
|
4723
4738
|
destFallback = _context.sent;
|
|
4724
4739
|
destinationFee = destFallback.fee;
|
|
4725
4740
|
destinationFeeType = destFallback.feeType;
|
|
4726
|
-
case
|
|
4727
|
-
return _context.abrupt("break",
|
|
4728
|
-
case
|
|
4741
|
+
case 63:
|
|
4742
|
+
return _context.abrupt("break", 74);
|
|
4743
|
+
case 64:
|
|
4729
4744
|
if (nextChain === destination || sdkCommon.isRelayChain(nextChain) && !sdkCommon.isRelayChain(destination)) {
|
|
4730
4745
|
destinationFee = hopResult.fee;
|
|
4731
4746
|
destinationFeeType = hopResult.feeType;
|
|
@@ -4745,35 +4760,35 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
4745
4760
|
forwardedXcms = hopResult.forwardedXcms;
|
|
4746
4761
|
nextParaId = hopResult.destParaId;
|
|
4747
4762
|
currentOrigin = nextChain;
|
|
4748
|
-
case 64:
|
|
4749
|
-
_context.prev = 64;
|
|
4750
|
-
_context.next = 67;
|
|
4751
|
-
return hopApi.disconnect();
|
|
4752
|
-
case 67:
|
|
4753
|
-
return _context.finish(64);
|
|
4754
4763
|
case 68:
|
|
4764
|
+
_context.prev = 68;
|
|
4765
|
+
_context.next = 71;
|
|
4766
|
+
return hopApi.disconnect();
|
|
4767
|
+
case 71:
|
|
4768
|
+
return _context.finish(68);
|
|
4769
|
+
case 72:
|
|
4755
4770
|
_context.next = 38;
|
|
4756
4771
|
break;
|
|
4757
|
-
case
|
|
4772
|
+
case 74:
|
|
4758
4773
|
processedBridgeHubData = intermediateFees.bridgeHub;
|
|
4759
4774
|
if (!(intermediateFees.bridgeHub && !intermediateFees.bridgeHub.dryRunError && destination === 'Ethereum')) {
|
|
4760
|
-
_context.next =
|
|
4775
|
+
_context.next = 85;
|
|
4761
4776
|
break;
|
|
4762
4777
|
}
|
|
4763
4778
|
ahApi = api.clone();
|
|
4764
|
-
_context.next =
|
|
4779
|
+
_context.next = 79;
|
|
4765
4780
|
return ahApi.init(assetHubNode, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
4766
|
-
case
|
|
4767
|
-
_context.next =
|
|
4781
|
+
case 79:
|
|
4782
|
+
_context.next = 81;
|
|
4768
4783
|
return getParaEthTransferFees(ahApi);
|
|
4769
|
-
case
|
|
4784
|
+
case 81:
|
|
4770
4785
|
_yield$getParaEthTran = _context.sent;
|
|
4771
4786
|
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 1);
|
|
4772
4787
|
bridgeFee = _yield$getParaEthTran2[0];
|
|
4773
4788
|
processedBridgeHubData = _objectSpread2(_objectSpread2({}, intermediateFees.bridgeHub), {}, {
|
|
4774
4789
|
fee: intermediateFees.bridgeHub.fee + bridgeFee
|
|
4775
4790
|
});
|
|
4776
|
-
case
|
|
4791
|
+
case 85:
|
|
4777
4792
|
intermediateFees.bridgeHub = processedBridgeHubData;
|
|
4778
4793
|
return _context.abrupt("return", _objectSpread2(_objectSpread2({
|
|
4779
4794
|
origin: _objectSpread2(_objectSpread2(_objectSpread2({}, originFee && {
|
|
@@ -4796,11 +4811,11 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
4796
4811
|
dryRunError: destinationDryRunError
|
|
4797
4812
|
})
|
|
4798
4813
|
}));
|
|
4799
|
-
case
|
|
4814
|
+
case 87:
|
|
4800
4815
|
case "end":
|
|
4801
4816
|
return _context.stop();
|
|
4802
4817
|
}
|
|
4803
|
-
}, _callee, null, [[16,, 25, 30], [43,,
|
|
4818
|
+
}, _callee, null, [[16,, 25, 30], [43,, 68, 72]]);
|
|
4804
4819
|
}));
|
|
4805
4820
|
return function getXcmFee(_x) {
|
|
4806
4821
|
return _ref2.apply(this, arguments);
|
|
@@ -4874,6 +4889,7 @@ var getXcmFeeEstimate = /*#__PURE__*/function () {
|
|
|
4874
4889
|
case 18:
|
|
4875
4890
|
_context.next = 20;
|
|
4876
4891
|
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4892
|
+
api: destApi,
|
|
4877
4893
|
destination: destination
|
|
4878
4894
|
}), currencyInput);
|
|
4879
4895
|
case 20:
|
|
@@ -6072,7 +6088,7 @@ var createExecuteXcm = function createExecuteXcm(input, weight, executionFee) {
|
|
|
6072
6088
|
},
|
|
6073
6089
|
weight_limit: {
|
|
6074
6090
|
Limited: {
|
|
6075
|
-
ref_time:
|
|
6091
|
+
ref_time: 150n,
|
|
6076
6092
|
proof_size: 0n
|
|
6077
6093
|
}
|
|
6078
6094
|
}
|
|
@@ -6093,7 +6109,7 @@ var createExecuteXcm = function createExecuteXcm(input, weight, executionFee) {
|
|
|
6093
6109
|
fees: {
|
|
6094
6110
|
id: asset.multiLocation,
|
|
6095
6111
|
fun: {
|
|
6096
|
-
Fungible: amountWithoutFee
|
|
6112
|
+
Fungible: amountWithoutFee - executionFee
|
|
6097
6113
|
}
|
|
6098
6114
|
},
|
|
6099
6115
|
weight_limit: 'Unlimited'
|
|
@@ -6443,11 +6459,11 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
6443
6459
|
key: "handleExecuteTransfer",
|
|
6444
6460
|
value: function () {
|
|
6445
6461
|
var _handleExecuteTransfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(input) {
|
|
6446
|
-
var api, senderAddress, asset, decimals, multiplier, base, scaledMultiplier, MIN_FEE, maxU64, dummyTx, dryRunResult
|
|
6462
|
+
var api, senderAddress, asset, feeAsset, decimals, multiplier, base, scaledMultiplier, MIN_FEE, maxU64, dummyTx, dryRunResult;
|
|
6447
6463
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
6448
6464
|
while (1) switch (_context3.prev = _context3.next) {
|
|
6449
6465
|
case 0:
|
|
6450
|
-
api = input.api, senderAddress = input.senderAddress, asset = input.asset;
|
|
6466
|
+
api = input.api, senderAddress = input.senderAddress, asset = input.asset, feeAsset = input.feeAsset;
|
|
6451
6467
|
if (senderAddress) {
|
|
6452
6468
|
_context3.next = 3;
|
|
6453
6469
|
break;
|
|
@@ -6470,7 +6486,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
6470
6486
|
node: this.node,
|
|
6471
6487
|
tx: dummyTx,
|
|
6472
6488
|
address: senderAddress,
|
|
6473
|
-
isFeeAsset:
|
|
6489
|
+
isFeeAsset: !!feeAsset
|
|
6474
6490
|
});
|
|
6475
6491
|
case 13:
|
|
6476
6492
|
dryRunResult = _context3.sent;
|
|
@@ -6478,35 +6494,16 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
6478
6494
|
_context3.next = 16;
|
|
6479
6495
|
break;
|
|
6480
6496
|
}
|
|
6481
|
-
throw new DryRunFailedError(
|
|
6497
|
+
throw new DryRunFailedError(dryRunResult.failureReason);
|
|
6482
6498
|
case 16:
|
|
6483
6499
|
if (dryRunResult.weight) {
|
|
6484
6500
|
_context3.next = 18;
|
|
6485
6501
|
break;
|
|
6486
6502
|
}
|
|
6487
|
-
throw new DryRunFailedError('
|
|
6503
|
+
throw new DryRunFailedError('weight not found');
|
|
6488
6504
|
case 18:
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
_context3.next = 22;
|
|
6492
|
-
return api.quoteAhPrice(DOT_MULTILOCATION, toMl, feeDotShifted);
|
|
6493
|
-
case 22:
|
|
6494
|
-
feeConverted = _context3.sent;
|
|
6495
|
-
if (feeConverted) {
|
|
6496
|
-
_context3.next = 25;
|
|
6497
|
-
break;
|
|
6498
|
-
}
|
|
6499
|
-
throw new InvalidParameterError("Pool DOT -> ".concat(asset.symbol, " not found."));
|
|
6500
|
-
case 25:
|
|
6501
|
-
if (!(BigInt(asset.amount) - feeConverted < 0)) {
|
|
6502
|
-
_context3.next = 27;
|
|
6503
|
-
break;
|
|
6504
|
-
}
|
|
6505
|
-
throw new InvalidParameterError("Insufficient balance. Fee: ".concat(feeConverted, ", Amount: ").concat(asset.amount));
|
|
6506
|
-
case 27:
|
|
6507
|
-
feeConvertedPadded = feeConverted * 3n / 2n; // increases fee by 50%
|
|
6508
|
-
return _context3.abrupt("return", createExecuteXcm(input, dryRunResult.weight, feeConvertedPadded));
|
|
6509
|
-
case 29:
|
|
6505
|
+
return _context3.abrupt("return", createExecuteXcm(input, dryRunResult.weight, dryRunResult.fee));
|
|
6506
|
+
case 19:
|
|
6510
6507
|
case "end":
|
|
6511
6508
|
return _context3.stop();
|
|
6512
6509
|
}
|
|
@@ -8993,7 +8990,7 @@ function _getEthErc20Balance() {
|
|
|
8993
8990
|
|
|
8994
8991
|
var buildDestInfo = /*#__PURE__*/function () {
|
|
8995
8992
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
8996
|
-
var api, origin, destination, address, currency, originFee, destAsset, isFeeAssetAh, destFeeDetail, assetHubFee, bridgeFee, destApi, destCurrency, edDest, edDestBn, destBalance, destAmount, destBalanceSufficient, destBalanceSufficientResult, destBalanceAfter, destbalanceAfterResult, receivedAmount, isAssetHubToAssetHubRoute, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
|
|
8993
|
+
var api, origin, destination, address, currency, originFee, destAsset, isFeeAssetAh, destFeeDetail, assetHubFee, bridgeFee, destApi, destCurrency, edDest, edDestBn, destBalance, destAmount, effectiveAmountForBalance, destBalanceSufficient, destBalanceSufficientResult, destBalanceAfter, destbalanceAfterResult, receivedAmount, isAssetHubToAssetHubRoute, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
|
|
8997
8994
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
8998
8995
|
while (1) switch (_context.prev = _context.next) {
|
|
8999
8996
|
case 0:
|
|
@@ -9042,9 +9039,13 @@ var buildDestInfo = /*#__PURE__*/function () {
|
|
|
9042
9039
|
case 19:
|
|
9043
9040
|
destBalance = _context.t0;
|
|
9044
9041
|
destAmount = isFeeAssetAh ? BigInt(currency.amount) - originFee : BigInt(currency.amount);
|
|
9045
|
-
|
|
9042
|
+
effectiveAmountForBalance = destAmount;
|
|
9043
|
+
if (destination === 'Ethereum' && assetHubFee !== undefined) {
|
|
9044
|
+
effectiveAmountForBalance -= assetHubFee;
|
|
9045
|
+
}
|
|
9046
|
+
destBalanceSufficient = effectiveAmountForBalance - destFeeDetail.fee > (destBalance < edDestBn ? edDestBn : 0);
|
|
9046
9047
|
destBalanceSufficientResult = destFeeDetail.currency !== destAsset.symbol && destination !== 'Ethereum' ? new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same') : destBalanceSufficient;
|
|
9047
|
-
destBalanceAfter = destBalance - (destFeeDetail.currency === destAsset.symbol ? destFeeDetail.fee : 0n) +
|
|
9048
|
+
destBalanceAfter = destBalance - (destFeeDetail.currency === destAsset.symbol ? destFeeDetail.fee : 0n) + effectiveAmountForBalance;
|
|
9048
9049
|
destbalanceAfterResult = destFeeDetail.currency !== destAsset.symbol && destination !== 'Ethereum' ? new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same') : destBalanceAfter;
|
|
9049
9050
|
isAssetHubToAssetHubRoute = origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot' || origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama';
|
|
9050
9051
|
if (isAssetHubToAssetHubRoute) {
|
|
@@ -9069,44 +9070,41 @@ var buildDestInfo = /*#__PURE__*/function () {
|
|
|
9069
9070
|
receivedAmount = destbalanceAfterResult - destBalance;
|
|
9070
9071
|
}
|
|
9071
9072
|
}
|
|
9072
|
-
if (destination === 'Ethereum' && assetHubFee && !(receivedAmount instanceof UnableToComputeError)) {
|
|
9073
|
-
receivedAmount -= assetHubFee;
|
|
9074
|
-
}
|
|
9075
9073
|
isDestFeeInNativeCurrency = destFeeDetail.currency === assets.getNativeAssetSymbol(destination);
|
|
9076
9074
|
if (!isDestFeeInNativeCurrency) {
|
|
9077
|
-
_context.next =
|
|
9075
|
+
_context.next = 44;
|
|
9078
9076
|
break;
|
|
9079
9077
|
}
|
|
9080
9078
|
if (!(destination === 'Ethereum')) {
|
|
9081
|
-
_context.next =
|
|
9079
|
+
_context.next = 37;
|
|
9082
9080
|
break;
|
|
9083
9081
|
}
|
|
9084
|
-
_context.next =
|
|
9082
|
+
_context.next = 34;
|
|
9085
9083
|
return getEthErc20Balance({
|
|
9086
9084
|
symbol: assets.getNativeAssetSymbol(destination)
|
|
9087
9085
|
}, address);
|
|
9088
|
-
case
|
|
9086
|
+
case 34:
|
|
9089
9087
|
_context.t1 = _context.sent;
|
|
9090
|
-
_context.next =
|
|
9088
|
+
_context.next = 40;
|
|
9091
9089
|
break;
|
|
9092
|
-
case
|
|
9093
|
-
_context.next =
|
|
9090
|
+
case 37:
|
|
9091
|
+
_context.next = 39;
|
|
9094
9092
|
return getBalanceNativeInternal({
|
|
9095
9093
|
address: address,
|
|
9096
9094
|
node: destination,
|
|
9097
9095
|
api: destApi
|
|
9098
9096
|
});
|
|
9099
|
-
case 38:
|
|
9100
|
-
_context.t1 = _context.sent;
|
|
9101
9097
|
case 39:
|
|
9098
|
+
_context.t1 = _context.sent;
|
|
9099
|
+
case 40:
|
|
9102
9100
|
destRecipientNativeBalance = _context.t1;
|
|
9103
9101
|
destXcmFeeBalance = destRecipientNativeBalance;
|
|
9104
|
-
_context.next =
|
|
9102
|
+
_context.next = 45;
|
|
9105
9103
|
break;
|
|
9106
|
-
case 43:
|
|
9107
|
-
destXcmFeeBalance = destBalance;
|
|
9108
9104
|
case 44:
|
|
9109
|
-
|
|
9105
|
+
destXcmFeeBalance = destBalance;
|
|
9106
|
+
case 45:
|
|
9107
|
+
destXcmFeeBalanceAfter = isFeeAssetAh ? destBalanceAfter : destXcmFeeBalance - destFeeDetail.fee + (destFeeDetail.currency === destAsset.symbol ? effectiveAmountForBalance : 0n);
|
|
9110
9108
|
return _context.abrupt("return", {
|
|
9111
9109
|
receivedCurrency: {
|
|
9112
9110
|
sufficient: destBalanceSufficientResult,
|
|
@@ -9123,7 +9121,7 @@ var buildDestInfo = /*#__PURE__*/function () {
|
|
|
9123
9121
|
currencySymbol: destFeeDetail.currency
|
|
9124
9122
|
}
|
|
9125
9123
|
});
|
|
9126
|
-
case
|
|
9124
|
+
case 47:
|
|
9127
9125
|
case "end":
|
|
9128
9126
|
return _context.stop();
|
|
9129
9127
|
}
|
|
@@ -9420,7 +9418,7 @@ var calculateTotalXcmFee = function calculateTotalXcmFee(feeResult) {
|
|
|
9420
9418
|
};
|
|
9421
9419
|
var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
9422
9420
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
9423
|
-
var api, tx, origin, destination, address, senderAddress, feeAsset, currency, destApi, asset, destCurrency, ed, edBN, balance, xcmFeeResult, dryRunError, _xcmFeeResult$destina, destFee, destFeeCurrency, destDryRunError, totalFee, method, feeToSubtract;
|
|
9421
|
+
var api, tx, origin, destination, address, senderAddress, feeAsset, currency, destApi, asset, destCurrency, ed, edBN, balance, xcmFeeResult, dryRunError, assetHubFeeResult, bridgeHubFeeResult, _xcmFeeResult$destina, destFee, destFeeCurrency, destDryRunError, hopDryRunError, totalFee, method, feeToSubtract;
|
|
9424
9422
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9425
9423
|
while (1) switch (_context.prev = _context.next) {
|
|
9426
9424
|
case 0:
|
|
@@ -9485,7 +9483,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
9485
9483
|
});
|
|
9486
9484
|
case 22:
|
|
9487
9485
|
xcmFeeResult = _context.sent;
|
|
9488
|
-
dryRunError = xcmFeeResult.origin.dryRunError, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeCurrency = _xcmFeeResult$destina.currency, destDryRunError = _xcmFeeResult$destina.dryRunError;
|
|
9486
|
+
dryRunError = xcmFeeResult.origin.dryRunError, assetHubFeeResult = xcmFeeResult.assetHub, bridgeHubFeeResult = xcmFeeResult.bridgeHub, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeCurrency = _xcmFeeResult$destina.currency, destDryRunError = _xcmFeeResult$destina.dryRunError;
|
|
9489
9487
|
if (!(destFee === undefined)) {
|
|
9490
9488
|
_context.next = 26;
|
|
9491
9489
|
break;
|
|
@@ -9498,18 +9496,25 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
9498
9496
|
}
|
|
9499
9497
|
throw new DryRunFailedError(dryRunError, 'origin');
|
|
9500
9498
|
case 28:
|
|
9499
|
+
hopDryRunError = (assetHubFeeResult === null || assetHubFeeResult === void 0 ? void 0 : assetHubFeeResult.dryRunError) || (bridgeHubFeeResult === null || bridgeHubFeeResult === void 0 ? void 0 : bridgeHubFeeResult.dryRunError);
|
|
9500
|
+
if (!hopDryRunError) {
|
|
9501
|
+
_context.next = 31;
|
|
9502
|
+
break;
|
|
9503
|
+
}
|
|
9504
|
+
throw new DryRunFailedError(hopDryRunError, assetHubFeeResult !== null && assetHubFeeResult !== void 0 && assetHubFeeResult.dryRunError ? 'assetHub' : 'bridgeHub');
|
|
9505
|
+
case 31:
|
|
9501
9506
|
if (!destDryRunError) {
|
|
9502
|
-
_context.next =
|
|
9507
|
+
_context.next = 33;
|
|
9503
9508
|
break;
|
|
9504
9509
|
}
|
|
9505
9510
|
throw new UnableToComputeError("Unable to compute fee for the destination asset. Destination dry run error: ".concat(destDryRunError));
|
|
9506
|
-
case
|
|
9511
|
+
case 33:
|
|
9507
9512
|
if (!(assets.normalizeSymbol(asset.symbol) !== assets.normalizeSymbol(destFeeCurrency))) {
|
|
9508
|
-
_context.next =
|
|
9513
|
+
_context.next = 35;
|
|
9509
9514
|
break;
|
|
9510
9515
|
}
|
|
9511
9516
|
throw new UnableToComputeError("The XCM fee could not be calculated because the origin or destination chain does not support DryRun.\n As a result, fee estimation is only available through PaymentInfo, which provides the cost in the native asset.\n This limitation restricts support to transfers involving the native asset of the Destination chain only.");
|
|
9512
|
-
case
|
|
9517
|
+
case 35:
|
|
9513
9518
|
totalFee = calculateTotalXcmFee(xcmFeeResult);
|
|
9514
9519
|
method = api.getMethod(tx);
|
|
9515
9520
|
if (method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen') {
|
|
@@ -9518,7 +9523,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
9518
9523
|
feeToSubtract = destFee;
|
|
9519
9524
|
}
|
|
9520
9525
|
return _context.abrupt("return", BigInt(currency.amount) - feeToSubtract > (balance < edBN ? edBN : 0));
|
|
9521
|
-
case
|
|
9526
|
+
case 39:
|
|
9522
9527
|
case "end":
|
|
9523
9528
|
return _context.stop();
|
|
9524
9529
|
}
|
|
@@ -10358,6 +10363,7 @@ exports.getXcmFee = getXcmFee;
|
|
|
10358
10363
|
exports.getXcmFeeEstimate = getXcmFeeEstimate;
|
|
10359
10364
|
exports.isEthersContract = isEthersContract;
|
|
10360
10365
|
exports.isEthersSigner = isEthersSigner;
|
|
10366
|
+
exports.replaceBigInt = replaceBigInt;
|
|
10361
10367
|
exports.resolveModuleError = resolveModuleError;
|
|
10362
10368
|
exports.resolveParaId = resolveParaId;
|
|
10363
10369
|
exports.reverseTransformMultiLocation = reverseTransformMultiLocation;
|
package/dist/index.d.ts
CHANGED
|
@@ -673,7 +673,7 @@ declare class DryRunFailedError extends Error {
|
|
|
673
673
|
* @param reason - The reason why the dry run failed.
|
|
674
674
|
* @param dryRunType - Optional. Specifies if the error is related to the 'origin' or 'destination' dry run.
|
|
675
675
|
*/
|
|
676
|
-
constructor(reason: string, dryRunType?: 'origin' | 'destination');
|
|
676
|
+
constructor(reason: string, dryRunType?: 'origin' | 'destination' | 'assetHub' | 'bridgeHub');
|
|
677
677
|
}
|
|
678
678
|
|
|
679
679
|
/**
|
|
@@ -869,6 +869,7 @@ type TGetOriginXcmFeeBaseOptions<TRes> = {
|
|
|
869
869
|
};
|
|
870
870
|
type TGetOriginXcmFeeOptions<TApi, TRes> = WithApi<TGetOriginXcmFeeBaseOptions<TRes>, TApi, TRes>;
|
|
871
871
|
type TGetFeeForDestNodeBaseOptions = {
|
|
872
|
+
prevNode: TNodeDotKsmWithRelayChains;
|
|
872
873
|
origin: TNodeDotKsmWithRelayChains;
|
|
873
874
|
destination: TNodeWithRelayChains;
|
|
874
875
|
senderAddress: string;
|
|
@@ -881,7 +882,7 @@ type TGetFeeForDestNodeBaseOptions = {
|
|
|
881
882
|
disableFallback: boolean;
|
|
882
883
|
};
|
|
883
884
|
type TGetFeeForDestNodeOptions<TApi, TRes> = WithApi<TGetFeeForDestNodeBaseOptions, TApi, TRes>;
|
|
884
|
-
type TGetReverseTxFeeOptions<TApi, TRes> = Omit<TGetFeeForDestNodeOptions<TApi, TRes>, 'destination' | 'disableFallback' | 'forwardedXcms' | 'asset' | 'originFee'> & {
|
|
885
|
+
type TGetReverseTxFeeOptions<TApi, TRes> = Omit<TGetFeeForDestNodeOptions<TApi, TRes>, 'destination' | 'disableFallback' | 'forwardedXcms' | 'asset' | 'originFee' | 'prevNode'> & {
|
|
885
886
|
destination: TNodeDotKsmWithRelayChains;
|
|
886
887
|
};
|
|
887
888
|
type THubKey = 'assetHub' | 'bridgeHub';
|
|
@@ -1869,6 +1870,8 @@ declare const reverseTransformMultiLocation: (multiLocation: TMultiLocation) =>
|
|
|
1869
1870
|
*/
|
|
1870
1871
|
declare const transformMultiLocation: (multiLocation: TMultiLocation) => TMultiLocation;
|
|
1871
1872
|
|
|
1873
|
+
declare const replaceBigInt: (_key: string, value: unknown) => unknown;
|
|
1874
|
+
|
|
1872
1875
|
declare const resolveParaId: (paraId: number | undefined, destination: TDestination) => number | undefined;
|
|
1873
1876
|
|
|
1874
1877
|
declare const validateAddress: (address: TAddress, node: TNodeWithRelayChains, isDestination?: boolean) => void;
|
|
@@ -1881,5 +1884,5 @@ declare const validateAddress: (address: TAddress, node: TNodeWithRelayChains, i
|
|
|
1881
1884
|
*/
|
|
1882
1885
|
declare const determineRelayChain: (node: TNodeWithRelayChains) => TRelaychain;
|
|
1883
1886
|
|
|
1884
|
-
export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, Version, XTokensError, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, generateAddressMultiLocationV4, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
|
|
1887
|
+
export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, Version, XTokensError, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, generateAddressMultiLocationV4, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, replaceBigInt, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
|
|
1885
1888
|
export type { IPolkadotApi, IPolkadotXCMTransfer, IXTokensTransfer, IXTransferTransfer, OneKey, TAddress, TApiOrUrl, TAssetClaimOptions, TAssetClaimOptionsBase, TBalanceResponse, TBatchOptions, TBifrostToken, TBridgeStatus, TCreateBeneficiaryOptions, TDestWeight, TDestination, TDryRunBaseOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunNodeFailure, TDryRunNodeResult, TDryRunNodeResultInternal, TDryRunNodeSuccess, TDryRunOptions, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEdJsonMap, TEvmBuilderOptions, TEvmBuilderOptionsBase, TEvmNodeFrom, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceForeignOptions, TGetBalanceForeignOptionsBase, TGetBalanceNativeOptions, TGetBalanceNativeOptionsBase, TGetFeeForDestNodeBaseOptions, TGetFeeForDestNodeOptions, TGetMaxForeignTransferableAmountOptions, TGetMaxForeignTransferableAmountOptionsBase, TGetMaxNativeTransferableAmountOptions, TGetMaxNativeTransferableAmountOptionsBase, TGetOriginFeeDetailsOptions, TGetOriginFeeDetailsOptionsBase, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeEstimateOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeEstimateDetail, TGetXcmFeeEstimateOptions, TGetXcmFeeEstimateResult, TGetXcmFeeOptions, TGetXcmFeeResult, THubKey, TMantaAsset, TModuleError, TNativeTokenAsset, TNodeConfig, TNodeConfigMap, TNodleAsset, TOriginFeeDetails, TOtherReserveAsset, TPolkadotXCMTransferOptions, TPolkadotXcmSection, TProviderEntry, TRelayToParaDestination, TRelayToParaOptions, TRelayToParaOverrides, TRelaychain, TReserveAsset, TScenario, TSelfReserveAsset, TSendBaseOptions, TSendBaseOptionsWithSenderAddress, TSendInternalOptions, TSendOptions, TSerializeEthTransferOptions, TSerializedApiCall, TSerializedEthTransfer, TTransferInfo, TTransferLocalOptions, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TVersionClaimAssets, TWeight, TXTokensCurrencySelection, TXTokensSection, TXTokensTransferOptions, TXTransferSection, TXTransferTransferOptions, TXcmAsset, TXcmFeeBase, TXcmFeeDetail, TXcmForeignAsset, TXcmPalletSection, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSenderAddress };
|
package/dist/index.mjs
CHANGED
|
@@ -610,7 +610,7 @@ var DryRunFailedError = /*#__PURE__*/function (_Error) {
|
|
|
610
610
|
_classCallCheck(this, DryRunFailedError);
|
|
611
611
|
var message = "Dry run failed: ".concat(reason);
|
|
612
612
|
if (dryRunType) {
|
|
613
|
-
message = "Dry run ".concat(dryRunType, " failed: ").concat(reason);
|
|
613
|
+
message = "Dry run on ".concat(dryRunType, " failed: ").concat(reason);
|
|
614
614
|
}
|
|
615
615
|
_this = _callSuper(this, DryRunFailedError, [message]);
|
|
616
616
|
_this.name = 'DryRunFailedError';
|
|
@@ -2779,6 +2779,10 @@ var getNode = function getNode(node) {
|
|
|
2779
2779
|
return nodeMap[node];
|
|
2780
2780
|
};
|
|
2781
2781
|
|
|
2782
|
+
var replaceBigInt = function replaceBigInt(_key, value) {
|
|
2783
|
+
return typeof value === 'bigint' ? value.toString() : value;
|
|
2784
|
+
};
|
|
2785
|
+
|
|
2782
2786
|
var resolveParaId = function resolveParaId(paraId, destination) {
|
|
2783
2787
|
if (isTMultiLocation(destination) || isRelayChain(destination) || destination === 'Ethereum') {
|
|
2784
2788
|
return undefined;
|
|
@@ -4085,11 +4089,11 @@ var createOriginLocation = function createOriginLocation(origin, destination) {
|
|
|
4085
4089
|
};
|
|
4086
4090
|
var getDestXcmFee = /*#__PURE__*/function () {
|
|
4087
4091
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
4088
|
-
var api, origin, destination, currency, forwardedXcms, asset, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, dryRunResult, fee, newForwardedXcms, destParaId;
|
|
4092
|
+
var api, origin, hopNode, destination, currency, forwardedXcms, asset, feeAsset, originFee, disableFallback, resolvedFeeAsset, calcPaymentInfoFee, dryRunResult, fee, newForwardedXcms, destParaId;
|
|
4089
4093
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
4090
4094
|
while (1) switch (_context2.prev = _context2.next) {
|
|
4091
4095
|
case 0:
|
|
4092
|
-
api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, feeAsset = options.feeAsset, originFee = options.originFee, disableFallback = options.disableFallback;
|
|
4096
|
+
api = options.api, origin = options.origin, hopNode = options.prevNode, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, feeAsset = options.feeAsset, originFee = options.originFee, disableFallback = options.disableFallback;
|
|
4093
4097
|
resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
|
|
4094
4098
|
calcPaymentInfoFee = /*#__PURE__*/function () {
|
|
4095
4099
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
@@ -4108,7 +4112,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4108
4112
|
_context.next = 5;
|
|
4109
4113
|
break;
|
|
4110
4114
|
}
|
|
4111
|
-
throw new InvalidCurrencyError("Currency ".concat(JSON.stringify(currency), " not found in ").concat(origin));
|
|
4115
|
+
throw new InvalidCurrencyError("Currency ".concat(JSON.stringify(currency, replaceBigInt), " not found in ").concat(origin));
|
|
4112
4116
|
case 5:
|
|
4113
4117
|
if (!originAsset.multiLocation) {
|
|
4114
4118
|
_context.next = 19;
|
|
@@ -4174,7 +4178,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4174
4178
|
case 8:
|
|
4175
4179
|
_context2.next = 10;
|
|
4176
4180
|
return api.getDryRunXcm({
|
|
4177
|
-
originLocation: addXcmVersionHeader(createOriginLocation(
|
|
4181
|
+
originLocation: addXcmVersionHeader(createOriginLocation(hopNode, destination), Version.V4),
|
|
4178
4182
|
xcm: forwardedXcms[1][0],
|
|
4179
4183
|
node: destination,
|
|
4180
4184
|
origin: origin,
|
|
@@ -4554,7 +4558,7 @@ var getOriginXcmFeeEstimate = /*#__PURE__*/function () {
|
|
|
4554
4558
|
|
|
4555
4559
|
var getXcmFee = /*#__PURE__*/function () {
|
|
4556
4560
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
4557
|
-
var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, asset, _yield$getOriginXcmFe, originFee, originCurrency, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, destApi, destFeeRes, assetHubNode, bridgeHubNode, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, nextChain, hopApi, hopResult, failingRecord, hopIsDestination, destFallback, processedBridgeHubData, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee;
|
|
4561
|
+
var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, asset, _yield$getOriginXcmFe, originFee, originCurrency, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, destApi, destFeeRes, assetHubNode, bridgeHubNode, currentOrigin, forwardedXcms, nextParaId, intermediateFees, destinationFee, destinationFeeType, destinationDryRunError, nextChain, hopApi, hopResult, failingRecord, hopIsDestination, _destApi, destFallback, processedBridgeHubData, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee;
|
|
4558
4562
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4559
4563
|
while (1) switch (_context.prev = _context.next) {
|
|
4560
4564
|
case 0:
|
|
@@ -4603,6 +4607,7 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
4603
4607
|
forwardedXcms: undefined,
|
|
4604
4608
|
// force paymentInfo
|
|
4605
4609
|
origin: origin,
|
|
4610
|
+
prevNode: origin,
|
|
4606
4611
|
destination: destination,
|
|
4607
4612
|
currency: currency,
|
|
4608
4613
|
address: address,
|
|
@@ -4651,7 +4656,7 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
4651
4656
|
destinationFeeType = destination === 'Ethereum' ? 'noFeeRequired' : 'paymentInfo';
|
|
4652
4657
|
case 38:
|
|
4653
4658
|
if (!(Array.isArray(forwardedXcms) && forwardedXcms.length > 0 && forwardedXcms[1].length > 0 && ('disconnect' in api.getApi() ? Object.values(forwardedXcms[1][0]).length : forwardedXcms[1][0].value.length) > 0 && nextParaId !== undefined)) {
|
|
4654
|
-
_context.next =
|
|
4659
|
+
_context.next = 74;
|
|
4655
4660
|
break;
|
|
4656
4661
|
}
|
|
4657
4662
|
nextChain = getTNode(nextParaId, determineRelayChain(origin) === 'Polkadot' ? 'polkadot' : 'kusama');
|
|
@@ -4670,7 +4675,8 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
4670
4675
|
return getDestXcmFee({
|
|
4671
4676
|
api: hopApi,
|
|
4672
4677
|
forwardedXcms: forwardedXcms,
|
|
4673
|
-
origin:
|
|
4678
|
+
origin: origin,
|
|
4679
|
+
prevNode: currentOrigin,
|
|
4674
4680
|
destination: nextChain,
|
|
4675
4681
|
currency: currency,
|
|
4676
4682
|
address: address,
|
|
@@ -4683,7 +4689,7 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
4683
4689
|
case 48:
|
|
4684
4690
|
hopResult = _context.sent;
|
|
4685
4691
|
if (!hopResult.dryRunError) {
|
|
4686
|
-
_context.next =
|
|
4692
|
+
_context.next = 64;
|
|
4687
4693
|
break;
|
|
4688
4694
|
}
|
|
4689
4695
|
failingRecord = {
|
|
@@ -4704,14 +4710,23 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
4704
4710
|
}
|
|
4705
4711
|
// We failed before the true destination, use fallback via paymentInfo.
|
|
4706
4712
|
if (hopIsDestination) {
|
|
4707
|
-
_context.next =
|
|
4713
|
+
_context.next = 63;
|
|
4708
4714
|
break;
|
|
4709
4715
|
}
|
|
4710
|
-
|
|
4716
|
+
_destApi = api.clone();
|
|
4717
|
+
if (!(destination !== 'Ethereum')) {
|
|
4718
|
+
_context.next = 58;
|
|
4719
|
+
break;
|
|
4720
|
+
}
|
|
4721
|
+
_context.next = 58;
|
|
4722
|
+
return _destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
4723
|
+
case 58:
|
|
4724
|
+
_context.next = 60;
|
|
4711
4725
|
return getDestXcmFee({
|
|
4712
|
-
api:
|
|
4726
|
+
api: _destApi,
|
|
4713
4727
|
forwardedXcms: undefined,
|
|
4714
|
-
origin:
|
|
4728
|
+
origin: origin,
|
|
4729
|
+
prevNode: currentOrigin,
|
|
4715
4730
|
destination: destination,
|
|
4716
4731
|
currency: currency,
|
|
4717
4732
|
address: address,
|
|
@@ -4720,13 +4735,13 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
4720
4735
|
senderAddress: senderAddress,
|
|
4721
4736
|
disableFallback: disableFallback
|
|
4722
4737
|
});
|
|
4723
|
-
case
|
|
4738
|
+
case 60:
|
|
4724
4739
|
destFallback = _context.sent;
|
|
4725
4740
|
destinationFee = destFallback.fee;
|
|
4726
4741
|
destinationFeeType = destFallback.feeType;
|
|
4727
|
-
case
|
|
4728
|
-
return _context.abrupt("break",
|
|
4729
|
-
case
|
|
4742
|
+
case 63:
|
|
4743
|
+
return _context.abrupt("break", 74);
|
|
4744
|
+
case 64:
|
|
4730
4745
|
if (nextChain === destination || isRelayChain(nextChain) && !isRelayChain(destination)) {
|
|
4731
4746
|
destinationFee = hopResult.fee;
|
|
4732
4747
|
destinationFeeType = hopResult.feeType;
|
|
@@ -4746,35 +4761,35 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
4746
4761
|
forwardedXcms = hopResult.forwardedXcms;
|
|
4747
4762
|
nextParaId = hopResult.destParaId;
|
|
4748
4763
|
currentOrigin = nextChain;
|
|
4749
|
-
case 64:
|
|
4750
|
-
_context.prev = 64;
|
|
4751
|
-
_context.next = 67;
|
|
4752
|
-
return hopApi.disconnect();
|
|
4753
|
-
case 67:
|
|
4754
|
-
return _context.finish(64);
|
|
4755
4764
|
case 68:
|
|
4765
|
+
_context.prev = 68;
|
|
4766
|
+
_context.next = 71;
|
|
4767
|
+
return hopApi.disconnect();
|
|
4768
|
+
case 71:
|
|
4769
|
+
return _context.finish(68);
|
|
4770
|
+
case 72:
|
|
4756
4771
|
_context.next = 38;
|
|
4757
4772
|
break;
|
|
4758
|
-
case
|
|
4773
|
+
case 74:
|
|
4759
4774
|
processedBridgeHubData = intermediateFees.bridgeHub;
|
|
4760
4775
|
if (!(intermediateFees.bridgeHub && !intermediateFees.bridgeHub.dryRunError && destination === 'Ethereum')) {
|
|
4761
|
-
_context.next =
|
|
4776
|
+
_context.next = 85;
|
|
4762
4777
|
break;
|
|
4763
4778
|
}
|
|
4764
4779
|
ahApi = api.clone();
|
|
4765
|
-
_context.next =
|
|
4780
|
+
_context.next = 79;
|
|
4766
4781
|
return ahApi.init(assetHubNode, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
4767
|
-
case
|
|
4768
|
-
_context.next =
|
|
4782
|
+
case 79:
|
|
4783
|
+
_context.next = 81;
|
|
4769
4784
|
return getParaEthTransferFees(ahApi);
|
|
4770
|
-
case
|
|
4785
|
+
case 81:
|
|
4771
4786
|
_yield$getParaEthTran = _context.sent;
|
|
4772
4787
|
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 1);
|
|
4773
4788
|
bridgeFee = _yield$getParaEthTran2[0];
|
|
4774
4789
|
processedBridgeHubData = _objectSpread2(_objectSpread2({}, intermediateFees.bridgeHub), {}, {
|
|
4775
4790
|
fee: intermediateFees.bridgeHub.fee + bridgeFee
|
|
4776
4791
|
});
|
|
4777
|
-
case
|
|
4792
|
+
case 85:
|
|
4778
4793
|
intermediateFees.bridgeHub = processedBridgeHubData;
|
|
4779
4794
|
return _context.abrupt("return", _objectSpread2(_objectSpread2({
|
|
4780
4795
|
origin: _objectSpread2(_objectSpread2(_objectSpread2({}, originFee && {
|
|
@@ -4797,11 +4812,11 @@ var getXcmFee = /*#__PURE__*/function () {
|
|
|
4797
4812
|
dryRunError: destinationDryRunError
|
|
4798
4813
|
})
|
|
4799
4814
|
}));
|
|
4800
|
-
case
|
|
4815
|
+
case 87:
|
|
4801
4816
|
case "end":
|
|
4802
4817
|
return _context.stop();
|
|
4803
4818
|
}
|
|
4804
|
-
}, _callee, null, [[16,, 25, 30], [43,,
|
|
4819
|
+
}, _callee, null, [[16,, 25, 30], [43,, 68, 72]]);
|
|
4805
4820
|
}));
|
|
4806
4821
|
return function getXcmFee(_x) {
|
|
4807
4822
|
return _ref2.apply(this, arguments);
|
|
@@ -4875,6 +4890,7 @@ var getXcmFeeEstimate = /*#__PURE__*/function () {
|
|
|
4875
4890
|
case 18:
|
|
4876
4891
|
_context.next = 20;
|
|
4877
4892
|
return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
|
|
4893
|
+
api: destApi,
|
|
4878
4894
|
destination: destination
|
|
4879
4895
|
}), currencyInput);
|
|
4880
4896
|
case 20:
|
|
@@ -6073,7 +6089,7 @@ var createExecuteXcm = function createExecuteXcm(input, weight, executionFee) {
|
|
|
6073
6089
|
},
|
|
6074
6090
|
weight_limit: {
|
|
6075
6091
|
Limited: {
|
|
6076
|
-
ref_time:
|
|
6092
|
+
ref_time: 150n,
|
|
6077
6093
|
proof_size: 0n
|
|
6078
6094
|
}
|
|
6079
6095
|
}
|
|
@@ -6094,7 +6110,7 @@ var createExecuteXcm = function createExecuteXcm(input, weight, executionFee) {
|
|
|
6094
6110
|
fees: {
|
|
6095
6111
|
id: asset.multiLocation,
|
|
6096
6112
|
fun: {
|
|
6097
|
-
Fungible: amountWithoutFee
|
|
6113
|
+
Fungible: amountWithoutFee - executionFee
|
|
6098
6114
|
}
|
|
6099
6115
|
},
|
|
6100
6116
|
weight_limit: 'Unlimited'
|
|
@@ -6444,11 +6460,11 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
6444
6460
|
key: "handleExecuteTransfer",
|
|
6445
6461
|
value: function () {
|
|
6446
6462
|
var _handleExecuteTransfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(input) {
|
|
6447
|
-
var api, senderAddress, asset, decimals, multiplier, base, scaledMultiplier, MIN_FEE, maxU64, dummyTx, dryRunResult
|
|
6463
|
+
var api, senderAddress, asset, feeAsset, decimals, multiplier, base, scaledMultiplier, MIN_FEE, maxU64, dummyTx, dryRunResult;
|
|
6448
6464
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
6449
6465
|
while (1) switch (_context3.prev = _context3.next) {
|
|
6450
6466
|
case 0:
|
|
6451
|
-
api = input.api, senderAddress = input.senderAddress, asset = input.asset;
|
|
6467
|
+
api = input.api, senderAddress = input.senderAddress, asset = input.asset, feeAsset = input.feeAsset;
|
|
6452
6468
|
if (senderAddress) {
|
|
6453
6469
|
_context3.next = 3;
|
|
6454
6470
|
break;
|
|
@@ -6471,7 +6487,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
6471
6487
|
node: this.node,
|
|
6472
6488
|
tx: dummyTx,
|
|
6473
6489
|
address: senderAddress,
|
|
6474
|
-
isFeeAsset:
|
|
6490
|
+
isFeeAsset: !!feeAsset
|
|
6475
6491
|
});
|
|
6476
6492
|
case 13:
|
|
6477
6493
|
dryRunResult = _context3.sent;
|
|
@@ -6479,35 +6495,16 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
|
|
|
6479
6495
|
_context3.next = 16;
|
|
6480
6496
|
break;
|
|
6481
6497
|
}
|
|
6482
|
-
throw new DryRunFailedError(
|
|
6498
|
+
throw new DryRunFailedError(dryRunResult.failureReason);
|
|
6483
6499
|
case 16:
|
|
6484
6500
|
if (dryRunResult.weight) {
|
|
6485
6501
|
_context3.next = 18;
|
|
6486
6502
|
break;
|
|
6487
6503
|
}
|
|
6488
|
-
throw new DryRunFailedError('
|
|
6504
|
+
throw new DryRunFailedError('weight not found');
|
|
6489
6505
|
case 18:
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
_context3.next = 22;
|
|
6493
|
-
return api.quoteAhPrice(DOT_MULTILOCATION, toMl, feeDotShifted);
|
|
6494
|
-
case 22:
|
|
6495
|
-
feeConverted = _context3.sent;
|
|
6496
|
-
if (feeConverted) {
|
|
6497
|
-
_context3.next = 25;
|
|
6498
|
-
break;
|
|
6499
|
-
}
|
|
6500
|
-
throw new InvalidParameterError("Pool DOT -> ".concat(asset.symbol, " not found."));
|
|
6501
|
-
case 25:
|
|
6502
|
-
if (!(BigInt(asset.amount) - feeConverted < 0)) {
|
|
6503
|
-
_context3.next = 27;
|
|
6504
|
-
break;
|
|
6505
|
-
}
|
|
6506
|
-
throw new InvalidParameterError("Insufficient balance. Fee: ".concat(feeConverted, ", Amount: ").concat(asset.amount));
|
|
6507
|
-
case 27:
|
|
6508
|
-
feeConvertedPadded = feeConverted * 3n / 2n; // increases fee by 50%
|
|
6509
|
-
return _context3.abrupt("return", createExecuteXcm(input, dryRunResult.weight, feeConvertedPadded));
|
|
6510
|
-
case 29:
|
|
6506
|
+
return _context3.abrupt("return", createExecuteXcm(input, dryRunResult.weight, dryRunResult.fee));
|
|
6507
|
+
case 19:
|
|
6511
6508
|
case "end":
|
|
6512
6509
|
return _context3.stop();
|
|
6513
6510
|
}
|
|
@@ -8994,7 +8991,7 @@ function _getEthErc20Balance() {
|
|
|
8994
8991
|
|
|
8995
8992
|
var buildDestInfo = /*#__PURE__*/function () {
|
|
8996
8993
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
8997
|
-
var api, origin, destination, address, currency, originFee, destAsset, isFeeAssetAh, destFeeDetail, assetHubFee, bridgeFee, destApi, destCurrency, edDest, edDestBn, destBalance, destAmount, destBalanceSufficient, destBalanceSufficientResult, destBalanceAfter, destbalanceAfterResult, receivedAmount, isAssetHubToAssetHubRoute, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
|
|
8994
|
+
var api, origin, destination, address, currency, originFee, destAsset, isFeeAssetAh, destFeeDetail, assetHubFee, bridgeFee, destApi, destCurrency, edDest, edDestBn, destBalance, destAmount, effectiveAmountForBalance, destBalanceSufficient, destBalanceSufficientResult, destBalanceAfter, destbalanceAfterResult, receivedAmount, isAssetHubToAssetHubRoute, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
|
|
8998
8995
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
8999
8996
|
while (1) switch (_context.prev = _context.next) {
|
|
9000
8997
|
case 0:
|
|
@@ -9043,9 +9040,13 @@ var buildDestInfo = /*#__PURE__*/function () {
|
|
|
9043
9040
|
case 19:
|
|
9044
9041
|
destBalance = _context.t0;
|
|
9045
9042
|
destAmount = isFeeAssetAh ? BigInt(currency.amount) - originFee : BigInt(currency.amount);
|
|
9046
|
-
|
|
9043
|
+
effectiveAmountForBalance = destAmount;
|
|
9044
|
+
if (destination === 'Ethereum' && assetHubFee !== undefined) {
|
|
9045
|
+
effectiveAmountForBalance -= assetHubFee;
|
|
9046
|
+
}
|
|
9047
|
+
destBalanceSufficient = effectiveAmountForBalance - destFeeDetail.fee > (destBalance < edDestBn ? edDestBn : 0);
|
|
9047
9048
|
destBalanceSufficientResult = destFeeDetail.currency !== destAsset.symbol && destination !== 'Ethereum' ? new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same') : destBalanceSufficient;
|
|
9048
|
-
destBalanceAfter = destBalance - (destFeeDetail.currency === destAsset.symbol ? destFeeDetail.fee : 0n) +
|
|
9049
|
+
destBalanceAfter = destBalance - (destFeeDetail.currency === destAsset.symbol ? destFeeDetail.fee : 0n) + effectiveAmountForBalance;
|
|
9049
9050
|
destbalanceAfterResult = destFeeDetail.currency !== destAsset.symbol && destination !== 'Ethereum' ? new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same') : destBalanceAfter;
|
|
9050
9051
|
isAssetHubToAssetHubRoute = origin === 'AssetHubKusama' && destination === 'AssetHubPolkadot' || origin === 'AssetHubPolkadot' && destination === 'AssetHubKusama';
|
|
9051
9052
|
if (isAssetHubToAssetHubRoute) {
|
|
@@ -9070,44 +9071,41 @@ var buildDestInfo = /*#__PURE__*/function () {
|
|
|
9070
9071
|
receivedAmount = destbalanceAfterResult - destBalance;
|
|
9071
9072
|
}
|
|
9072
9073
|
}
|
|
9073
|
-
if (destination === 'Ethereum' && assetHubFee && !(receivedAmount instanceof UnableToComputeError)) {
|
|
9074
|
-
receivedAmount -= assetHubFee;
|
|
9075
|
-
}
|
|
9076
9074
|
isDestFeeInNativeCurrency = destFeeDetail.currency === getNativeAssetSymbol(destination);
|
|
9077
9075
|
if (!isDestFeeInNativeCurrency) {
|
|
9078
|
-
_context.next =
|
|
9076
|
+
_context.next = 44;
|
|
9079
9077
|
break;
|
|
9080
9078
|
}
|
|
9081
9079
|
if (!(destination === 'Ethereum')) {
|
|
9082
|
-
_context.next =
|
|
9080
|
+
_context.next = 37;
|
|
9083
9081
|
break;
|
|
9084
9082
|
}
|
|
9085
|
-
_context.next =
|
|
9083
|
+
_context.next = 34;
|
|
9086
9084
|
return getEthErc20Balance({
|
|
9087
9085
|
symbol: getNativeAssetSymbol(destination)
|
|
9088
9086
|
}, address);
|
|
9089
|
-
case
|
|
9087
|
+
case 34:
|
|
9090
9088
|
_context.t1 = _context.sent;
|
|
9091
|
-
_context.next =
|
|
9089
|
+
_context.next = 40;
|
|
9092
9090
|
break;
|
|
9093
|
-
case
|
|
9094
|
-
_context.next =
|
|
9091
|
+
case 37:
|
|
9092
|
+
_context.next = 39;
|
|
9095
9093
|
return getBalanceNativeInternal({
|
|
9096
9094
|
address: address,
|
|
9097
9095
|
node: destination,
|
|
9098
9096
|
api: destApi
|
|
9099
9097
|
});
|
|
9100
|
-
case 38:
|
|
9101
|
-
_context.t1 = _context.sent;
|
|
9102
9098
|
case 39:
|
|
9099
|
+
_context.t1 = _context.sent;
|
|
9100
|
+
case 40:
|
|
9103
9101
|
destRecipientNativeBalance = _context.t1;
|
|
9104
9102
|
destXcmFeeBalance = destRecipientNativeBalance;
|
|
9105
|
-
_context.next =
|
|
9103
|
+
_context.next = 45;
|
|
9106
9104
|
break;
|
|
9107
|
-
case 43:
|
|
9108
|
-
destXcmFeeBalance = destBalance;
|
|
9109
9105
|
case 44:
|
|
9110
|
-
|
|
9106
|
+
destXcmFeeBalance = destBalance;
|
|
9107
|
+
case 45:
|
|
9108
|
+
destXcmFeeBalanceAfter = isFeeAssetAh ? destBalanceAfter : destXcmFeeBalance - destFeeDetail.fee + (destFeeDetail.currency === destAsset.symbol ? effectiveAmountForBalance : 0n);
|
|
9111
9109
|
return _context.abrupt("return", {
|
|
9112
9110
|
receivedCurrency: {
|
|
9113
9111
|
sufficient: destBalanceSufficientResult,
|
|
@@ -9124,7 +9122,7 @@ var buildDestInfo = /*#__PURE__*/function () {
|
|
|
9124
9122
|
currencySymbol: destFeeDetail.currency
|
|
9125
9123
|
}
|
|
9126
9124
|
});
|
|
9127
|
-
case
|
|
9125
|
+
case 47:
|
|
9128
9126
|
case "end":
|
|
9129
9127
|
return _context.stop();
|
|
9130
9128
|
}
|
|
@@ -9421,7 +9419,7 @@ var calculateTotalXcmFee = function calculateTotalXcmFee(feeResult) {
|
|
|
9421
9419
|
};
|
|
9422
9420
|
var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
9423
9421
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
9424
|
-
var api, tx, origin, destination, address, senderAddress, feeAsset, currency, destApi, asset, destCurrency, ed, edBN, balance, xcmFeeResult, dryRunError, _xcmFeeResult$destina, destFee, destFeeCurrency, destDryRunError, totalFee, method, feeToSubtract;
|
|
9422
|
+
var api, tx, origin, destination, address, senderAddress, feeAsset, currency, destApi, asset, destCurrency, ed, edBN, balance, xcmFeeResult, dryRunError, assetHubFeeResult, bridgeHubFeeResult, _xcmFeeResult$destina, destFee, destFeeCurrency, destDryRunError, hopDryRunError, totalFee, method, feeToSubtract;
|
|
9425
9423
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9426
9424
|
while (1) switch (_context.prev = _context.next) {
|
|
9427
9425
|
case 0:
|
|
@@ -9486,7 +9484,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
9486
9484
|
});
|
|
9487
9485
|
case 22:
|
|
9488
9486
|
xcmFeeResult = _context.sent;
|
|
9489
|
-
dryRunError = xcmFeeResult.origin.dryRunError, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeCurrency = _xcmFeeResult$destina.currency, destDryRunError = _xcmFeeResult$destina.dryRunError;
|
|
9487
|
+
dryRunError = xcmFeeResult.origin.dryRunError, assetHubFeeResult = xcmFeeResult.assetHub, bridgeHubFeeResult = xcmFeeResult.bridgeHub, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeCurrency = _xcmFeeResult$destina.currency, destDryRunError = _xcmFeeResult$destina.dryRunError;
|
|
9490
9488
|
if (!(destFee === undefined)) {
|
|
9491
9489
|
_context.next = 26;
|
|
9492
9490
|
break;
|
|
@@ -9499,18 +9497,25 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
9499
9497
|
}
|
|
9500
9498
|
throw new DryRunFailedError(dryRunError, 'origin');
|
|
9501
9499
|
case 28:
|
|
9500
|
+
hopDryRunError = (assetHubFeeResult === null || assetHubFeeResult === void 0 ? void 0 : assetHubFeeResult.dryRunError) || (bridgeHubFeeResult === null || bridgeHubFeeResult === void 0 ? void 0 : bridgeHubFeeResult.dryRunError);
|
|
9501
|
+
if (!hopDryRunError) {
|
|
9502
|
+
_context.next = 31;
|
|
9503
|
+
break;
|
|
9504
|
+
}
|
|
9505
|
+
throw new DryRunFailedError(hopDryRunError, assetHubFeeResult !== null && assetHubFeeResult !== void 0 && assetHubFeeResult.dryRunError ? 'assetHub' : 'bridgeHub');
|
|
9506
|
+
case 31:
|
|
9502
9507
|
if (!destDryRunError) {
|
|
9503
|
-
_context.next =
|
|
9508
|
+
_context.next = 33;
|
|
9504
9509
|
break;
|
|
9505
9510
|
}
|
|
9506
9511
|
throw new UnableToComputeError("Unable to compute fee for the destination asset. Destination dry run error: ".concat(destDryRunError));
|
|
9507
|
-
case
|
|
9512
|
+
case 33:
|
|
9508
9513
|
if (!(normalizeSymbol(asset.symbol) !== normalizeSymbol(destFeeCurrency))) {
|
|
9509
|
-
_context.next =
|
|
9514
|
+
_context.next = 35;
|
|
9510
9515
|
break;
|
|
9511
9516
|
}
|
|
9512
9517
|
throw new UnableToComputeError("The XCM fee could not be calculated because the origin or destination chain does not support DryRun.\n As a result, fee estimation is only available through PaymentInfo, which provides the cost in the native asset.\n This limitation restricts support to transfers involving the native asset of the Destination chain only.");
|
|
9513
|
-
case
|
|
9518
|
+
case 35:
|
|
9514
9519
|
totalFee = calculateTotalXcmFee(xcmFeeResult);
|
|
9515
9520
|
method = api.getMethod(tx);
|
|
9516
9521
|
if (method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen') {
|
|
@@ -9519,7 +9524,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
9519
9524
|
feeToSubtract = destFee;
|
|
9520
9525
|
}
|
|
9521
9526
|
return _context.abrupt("return", BigInt(currency.amount) - feeToSubtract > (balance < edBN ? edBN : 0));
|
|
9522
|
-
case
|
|
9527
|
+
case 39:
|
|
9523
9528
|
case "end":
|
|
9524
9529
|
return _context.stop();
|
|
9525
9530
|
}
|
|
@@ -10301,4 +10306,4 @@ var Builder = function Builder(api) {
|
|
|
10301
10306
|
return new GeneralBuilder(api, new BatchTransactionManager());
|
|
10302
10307
|
};
|
|
10303
10308
|
|
|
10304
|
-
export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, Version, XTokensError, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, generateAddressMultiLocationV4, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
|
|
10309
|
+
export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, Version, XTokensError, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, generateAddressMultiLocationV4, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, isEthersContract, isEthersSigner, replaceBigInt, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-core",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.1",
|
|
4
4
|
"description": "SDK core for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"@scure/base": "^1.2.5",
|
|
28
28
|
"ethers": "^6.13.7",
|
|
29
29
|
"viem": "^2.28.1",
|
|
30
|
-
"@paraspell/assets": "10.1.
|
|
31
|
-
"@paraspell/
|
|
32
|
-
"@paraspell/
|
|
30
|
+
"@paraspell/assets": "10.1.1",
|
|
31
|
+
"@paraspell/pallets": "10.1.1",
|
|
32
|
+
"@paraspell/sdk-common": "10.1.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@babel/plugin-syntax-import-attributes": "^7.27.1",
|