@paraspell/sdk-core 11.14.7 → 11.14.8
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 +30 -24
- package/dist/index.mjs +30 -24
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -7470,7 +7470,7 @@ var send = /*#__PURE__*/function () {
|
|
|
7470
7470
|
|
|
7471
7471
|
var buildDestInfo = /*#__PURE__*/function () {
|
|
7472
7472
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
7473
|
-
var api, origin, destination, address, currency, originFee, isFeeAssetAh, destFeeDetail, totalHopFee, bridgeFee, destApi, destAsset, edDest, destBalance, destAmount, effectiveAmountForBalance, destBalanceSufficient,
|
|
7473
|
+
var api, origin, destination, address, currency, originFee, isFeeAssetAh, destFeeDetail, totalHopFee, bridgeFee, destApi, destAsset, edDest, destBalance, destAmount, destFeeAssetEqual, effectiveDestFee, effectiveAmountForBalance, destBalanceSufficient, destBalanceAfter, createUnableToComputeError, isUnableToCompute, destbalanceAfterResult, destBalanceSufficientResult, receivedAmount, isSubBridge, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
|
|
7474
7474
|
return _regenerator().w(function (_context) {
|
|
7475
7475
|
while (1) switch (_context.n) {
|
|
7476
7476
|
case 0:
|
|
@@ -7491,11 +7491,17 @@ var buildDestInfo = /*#__PURE__*/function () {
|
|
|
7491
7491
|
case 2:
|
|
7492
7492
|
destBalance = _context.v;
|
|
7493
7493
|
destAmount = isFeeAssetAh ? currency.amount - originFee : currency.amount;
|
|
7494
|
+
destFeeAssetEqual = assets.isSymbolMatch(destFeeDetail.asset.symbol, destAsset.symbol);
|
|
7495
|
+
effectiveDestFee = destFeeAssetEqual ? destFeeDetail.fee : 0n;
|
|
7494
7496
|
effectiveAmountForBalance = destAmount - totalHopFee;
|
|
7495
|
-
destBalanceSufficient = effectiveAmountForBalance -
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
|
|
7497
|
+
destBalanceSufficient = effectiveAmountForBalance - effectiveDestFee > (destBalance < edDest ? edDest : 0n);
|
|
7498
|
+
destBalanceAfter = destBalance - effectiveDestFee + effectiveAmountForBalance;
|
|
7499
|
+
createUnableToComputeError = function createUnableToComputeError() {
|
|
7500
|
+
return new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same');
|
|
7501
|
+
};
|
|
7502
|
+
isUnableToCompute = destFeeDetail.feeType === 'paymentInfo' && !destFeeAssetEqual;
|
|
7503
|
+
destbalanceAfterResult = isUnableToCompute ? createUnableToComputeError() : destBalanceAfter;
|
|
7504
|
+
destBalanceSufficientResult = isUnableToCompute ? createUnableToComputeError() : destBalanceSufficient;
|
|
7499
7505
|
isSubBridge = sdkCommon.isSubstrateBridge(origin, destination);
|
|
7500
7506
|
if (isSubBridge) {
|
|
7501
7507
|
nativeAssetOfOriginSymbol = assets.getNativeAssetSymbol(origin);
|
|
@@ -7538,7 +7544,7 @@ var buildDestInfo = /*#__PURE__*/function () {
|
|
|
7538
7544
|
case 4:
|
|
7539
7545
|
destXcmFeeBalance = destBalance;
|
|
7540
7546
|
case 5:
|
|
7541
|
-
destXcmFeeBalanceAfter = isFeeAssetAh ? destBalanceAfter : destXcmFeeBalance - destFeeDetail.fee + (
|
|
7547
|
+
destXcmFeeBalanceAfter = isFeeAssetAh ? destBalanceAfter : destXcmFeeBalance - destFeeDetail.fee + (destFeeAssetEqual ? effectiveAmountForBalance : 0n);
|
|
7542
7548
|
return _context.a(2, {
|
|
7543
7549
|
receivedCurrency: {
|
|
7544
7550
|
sufficient: destBalanceSufficientResult,
|
|
@@ -7553,7 +7559,7 @@ var buildDestInfo = /*#__PURE__*/function () {
|
|
|
7553
7559
|
fee: destFeeDetail.fee,
|
|
7554
7560
|
balance: destXcmFeeBalance,
|
|
7555
7561
|
balanceAfter: destXcmFeeBalanceAfter,
|
|
7556
|
-
currencySymbol: destFeeDetail.
|
|
7562
|
+
currencySymbol: destFeeDetail.asset.symbol,
|
|
7557
7563
|
asset: destFeeDetail.asset
|
|
7558
7564
|
}
|
|
7559
7565
|
});
|
|
@@ -8568,20 +8574,16 @@ var createTypeThenAutoReserve = /*#__PURE__*/function () {
|
|
|
8568
8574
|
};
|
|
8569
8575
|
}();
|
|
8570
8576
|
|
|
8571
|
-
var calculateTotalXcmFee = function calculateTotalXcmFee(feeResult) {
|
|
8572
|
-
var
|
|
8573
|
-
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
|
|
8577
|
-
if (feeResult.destination.fee !== undefined) {
|
|
8578
|
-
totalFee += feeResult.destination.fee;
|
|
8579
|
-
}
|
|
8580
|
-
return totalFee;
|
|
8577
|
+
var calculateTotalXcmFee = function calculateTotalXcmFee(asset, feeResult) {
|
|
8578
|
+
var totalHopFee = feeResult.hops.reduce(function (acc, hop) {
|
|
8579
|
+
return assets.isAssetXcEqual(hop.result.asset, asset) ? acc + hop.result.fee : acc;
|
|
8580
|
+
}, 0n);
|
|
8581
|
+
var destFee = assets.isAssetXcEqual(feeResult.destination.asset, asset) ? feeResult.destination.fee : 0n;
|
|
8582
|
+
return totalHopFee + destFee;
|
|
8581
8583
|
};
|
|
8582
8584
|
var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
8583
8585
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
8584
|
-
var api, buildTx, origin, destination, currency, address, senderAddress, feeAsset, isSubBridge, destApi, asset, amount, destAsset, ed, balance, xcmFeeResult, dryRunError,
|
|
8586
|
+
var api, buildTx, origin, destination, currency, address, senderAddress, feeAsset, isSubBridge, destApi, asset, amount, destAsset, ed, balance, xcmFeeResult, dryRunError, hops, _xcmFeeResult$destina, destFee, destFeeType, destFeeAsset, destDryRunError, erroredHop, hopError, isUnableToCompute, tx, totalFee, method, feeToSubtract;
|
|
8585
8587
|
return _regenerator().w(function (_context) {
|
|
8586
8588
|
while (1) switch (_context.n) {
|
|
8587
8589
|
case 0:
|
|
@@ -8633,19 +8635,22 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
8633
8635
|
});
|
|
8634
8636
|
case 5:
|
|
8635
8637
|
xcmFeeResult = _context.v;
|
|
8636
|
-
dryRunError = xcmFeeResult.origin.dryRunError,
|
|
8638
|
+
dryRunError = xcmFeeResult.origin.dryRunError, hops = xcmFeeResult.hops, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeType = _xcmFeeResult$destina.feeType, destFeeAsset = _xcmFeeResult$destina.asset, destDryRunError = _xcmFeeResult$destina.dryRunError;
|
|
8637
8639
|
if (!dryRunError) {
|
|
8638
8640
|
_context.n = 6;
|
|
8639
8641
|
break;
|
|
8640
8642
|
}
|
|
8641
8643
|
throw new DryRunFailedError(dryRunError, 'origin');
|
|
8642
8644
|
case 6:
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
+
erroredHop = hops.find(function (hop) {
|
|
8646
|
+
return hop.result.dryRunError;
|
|
8647
|
+
});
|
|
8648
|
+
hopError = erroredHop === null || erroredHop === void 0 ? void 0 : erroredHop.result.dryRunError;
|
|
8649
|
+
if (!hopError) {
|
|
8645
8650
|
_context.n = 7;
|
|
8646
8651
|
break;
|
|
8647
8652
|
}
|
|
8648
|
-
throw new DryRunFailedError(
|
|
8653
|
+
throw new DryRunFailedError(hopError, erroredHop.chain);
|
|
8649
8654
|
case 7:
|
|
8650
8655
|
if (!destDryRunError) {
|
|
8651
8656
|
_context.n = 8;
|
|
@@ -8653,7 +8658,8 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
8653
8658
|
}
|
|
8654
8659
|
throw new UnableToComputeError("Unable to compute fee for the destination asset. Destination dry run error: ".concat(destDryRunError));
|
|
8655
8660
|
case 8:
|
|
8656
|
-
|
|
8661
|
+
isUnableToCompute = !assets.isSymbolMatch(assets.normalizeSymbol(destAsset.symbol), assets.normalizeSymbol(destFeeAsset.symbol)) && destFeeType === 'paymentInfo';
|
|
8662
|
+
if (!isUnableToCompute) {
|
|
8657
8663
|
_context.n = 9;
|
|
8658
8664
|
break;
|
|
8659
8665
|
}
|
|
@@ -8663,7 +8669,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
8663
8669
|
return buildTx();
|
|
8664
8670
|
case 10:
|
|
8665
8671
|
tx = _context.v;
|
|
8666
|
-
totalFee = calculateTotalXcmFee(xcmFeeResult);
|
|
8672
|
+
totalFee = calculateTotalXcmFee(asset, xcmFeeResult);
|
|
8667
8673
|
method = api.getMethod(tx);
|
|
8668
8674
|
if (method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen') {
|
|
8669
8675
|
feeToSubtract = totalFee;
|
package/dist/index.mjs
CHANGED
|
@@ -7471,7 +7471,7 @@ var send = /*#__PURE__*/function () {
|
|
|
7471
7471
|
|
|
7472
7472
|
var buildDestInfo = /*#__PURE__*/function () {
|
|
7473
7473
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
7474
|
-
var api, origin, destination, address, currency, originFee, isFeeAssetAh, destFeeDetail, totalHopFee, bridgeFee, destApi, destAsset, edDest, destBalance, destAmount, effectiveAmountForBalance, destBalanceSufficient,
|
|
7474
|
+
var api, origin, destination, address, currency, originFee, isFeeAssetAh, destFeeDetail, totalHopFee, bridgeFee, destApi, destAsset, edDest, destBalance, destAmount, destFeeAssetEqual, effectiveDestFee, effectiveAmountForBalance, destBalanceSufficient, destBalanceAfter, createUnableToComputeError, isUnableToCompute, destbalanceAfterResult, destBalanceSufficientResult, receivedAmount, isSubBridge, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
|
|
7475
7475
|
return _regenerator().w(function (_context) {
|
|
7476
7476
|
while (1) switch (_context.n) {
|
|
7477
7477
|
case 0:
|
|
@@ -7492,11 +7492,17 @@ var buildDestInfo = /*#__PURE__*/function () {
|
|
|
7492
7492
|
case 2:
|
|
7493
7493
|
destBalance = _context.v;
|
|
7494
7494
|
destAmount = isFeeAssetAh ? currency.amount - originFee : currency.amount;
|
|
7495
|
+
destFeeAssetEqual = isSymbolMatch(destFeeDetail.asset.symbol, destAsset.symbol);
|
|
7496
|
+
effectiveDestFee = destFeeAssetEqual ? destFeeDetail.fee : 0n;
|
|
7495
7497
|
effectiveAmountForBalance = destAmount - totalHopFee;
|
|
7496
|
-
destBalanceSufficient = effectiveAmountForBalance -
|
|
7497
|
-
|
|
7498
|
-
|
|
7499
|
-
|
|
7498
|
+
destBalanceSufficient = effectiveAmountForBalance - effectiveDestFee > (destBalance < edDest ? edDest : 0n);
|
|
7499
|
+
destBalanceAfter = destBalance - effectiveDestFee + effectiveAmountForBalance;
|
|
7500
|
+
createUnableToComputeError = function createUnableToComputeError() {
|
|
7501
|
+
return new UnableToComputeError('Unable to compute if dest balance will be sufficient. Fee currency is not the same');
|
|
7502
|
+
};
|
|
7503
|
+
isUnableToCompute = destFeeDetail.feeType === 'paymentInfo' && !destFeeAssetEqual;
|
|
7504
|
+
destbalanceAfterResult = isUnableToCompute ? createUnableToComputeError() : destBalanceAfter;
|
|
7505
|
+
destBalanceSufficientResult = isUnableToCompute ? createUnableToComputeError() : destBalanceSufficient;
|
|
7500
7506
|
isSubBridge = isSubstrateBridge(origin, destination);
|
|
7501
7507
|
if (isSubBridge) {
|
|
7502
7508
|
nativeAssetOfOriginSymbol = getNativeAssetSymbol(origin);
|
|
@@ -7539,7 +7545,7 @@ var buildDestInfo = /*#__PURE__*/function () {
|
|
|
7539
7545
|
case 4:
|
|
7540
7546
|
destXcmFeeBalance = destBalance;
|
|
7541
7547
|
case 5:
|
|
7542
|
-
destXcmFeeBalanceAfter = isFeeAssetAh ? destBalanceAfter : destXcmFeeBalance - destFeeDetail.fee + (
|
|
7548
|
+
destXcmFeeBalanceAfter = isFeeAssetAh ? destBalanceAfter : destXcmFeeBalance - destFeeDetail.fee + (destFeeAssetEqual ? effectiveAmountForBalance : 0n);
|
|
7543
7549
|
return _context.a(2, {
|
|
7544
7550
|
receivedCurrency: {
|
|
7545
7551
|
sufficient: destBalanceSufficientResult,
|
|
@@ -7554,7 +7560,7 @@ var buildDestInfo = /*#__PURE__*/function () {
|
|
|
7554
7560
|
fee: destFeeDetail.fee,
|
|
7555
7561
|
balance: destXcmFeeBalance,
|
|
7556
7562
|
balanceAfter: destXcmFeeBalanceAfter,
|
|
7557
|
-
currencySymbol: destFeeDetail.
|
|
7563
|
+
currencySymbol: destFeeDetail.asset.symbol,
|
|
7558
7564
|
asset: destFeeDetail.asset
|
|
7559
7565
|
}
|
|
7560
7566
|
});
|
|
@@ -8569,20 +8575,16 @@ var createTypeThenAutoReserve = /*#__PURE__*/function () {
|
|
|
8569
8575
|
};
|
|
8570
8576
|
}();
|
|
8571
8577
|
|
|
8572
|
-
var calculateTotalXcmFee = function calculateTotalXcmFee(feeResult) {
|
|
8573
|
-
var
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
|
|
8577
|
-
|
|
8578
|
-
if (feeResult.destination.fee !== undefined) {
|
|
8579
|
-
totalFee += feeResult.destination.fee;
|
|
8580
|
-
}
|
|
8581
|
-
return totalFee;
|
|
8578
|
+
var calculateTotalXcmFee = function calculateTotalXcmFee(asset, feeResult) {
|
|
8579
|
+
var totalHopFee = feeResult.hops.reduce(function (acc, hop) {
|
|
8580
|
+
return isAssetXcEqual(hop.result.asset, asset) ? acc + hop.result.fee : acc;
|
|
8581
|
+
}, 0n);
|
|
8582
|
+
var destFee = isAssetXcEqual(feeResult.destination.asset, asset) ? feeResult.destination.fee : 0n;
|
|
8583
|
+
return totalHopFee + destFee;
|
|
8582
8584
|
};
|
|
8583
8585
|
var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
8584
8586
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
8585
|
-
var api, buildTx, origin, destination, currency, address, senderAddress, feeAsset, isSubBridge, destApi, asset, amount, destAsset, ed, balance, xcmFeeResult, dryRunError,
|
|
8587
|
+
var api, buildTx, origin, destination, currency, address, senderAddress, feeAsset, isSubBridge, destApi, asset, amount, destAsset, ed, balance, xcmFeeResult, dryRunError, hops, _xcmFeeResult$destina, destFee, destFeeType, destFeeAsset, destDryRunError, erroredHop, hopError, isUnableToCompute, tx, totalFee, method, feeToSubtract;
|
|
8586
8588
|
return _regenerator().w(function (_context) {
|
|
8587
8589
|
while (1) switch (_context.n) {
|
|
8588
8590
|
case 0:
|
|
@@ -8634,19 +8636,22 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
8634
8636
|
});
|
|
8635
8637
|
case 5:
|
|
8636
8638
|
xcmFeeResult = _context.v;
|
|
8637
|
-
dryRunError = xcmFeeResult.origin.dryRunError,
|
|
8639
|
+
dryRunError = xcmFeeResult.origin.dryRunError, hops = xcmFeeResult.hops, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeType = _xcmFeeResult$destina.feeType, destFeeAsset = _xcmFeeResult$destina.asset, destDryRunError = _xcmFeeResult$destina.dryRunError;
|
|
8638
8640
|
if (!dryRunError) {
|
|
8639
8641
|
_context.n = 6;
|
|
8640
8642
|
break;
|
|
8641
8643
|
}
|
|
8642
8644
|
throw new DryRunFailedError(dryRunError, 'origin');
|
|
8643
8645
|
case 6:
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
+
erroredHop = hops.find(function (hop) {
|
|
8647
|
+
return hop.result.dryRunError;
|
|
8648
|
+
});
|
|
8649
|
+
hopError = erroredHop === null || erroredHop === void 0 ? void 0 : erroredHop.result.dryRunError;
|
|
8650
|
+
if (!hopError) {
|
|
8646
8651
|
_context.n = 7;
|
|
8647
8652
|
break;
|
|
8648
8653
|
}
|
|
8649
|
-
throw new DryRunFailedError(
|
|
8654
|
+
throw new DryRunFailedError(hopError, erroredHop.chain);
|
|
8650
8655
|
case 7:
|
|
8651
8656
|
if (!destDryRunError) {
|
|
8652
8657
|
_context.n = 8;
|
|
@@ -8654,7 +8659,8 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
8654
8659
|
}
|
|
8655
8660
|
throw new UnableToComputeError("Unable to compute fee for the destination asset. Destination dry run error: ".concat(destDryRunError));
|
|
8656
8661
|
case 8:
|
|
8657
|
-
|
|
8662
|
+
isUnableToCompute = !isSymbolMatch(normalizeSymbol(destAsset.symbol), normalizeSymbol(destFeeAsset.symbol)) && destFeeType === 'paymentInfo';
|
|
8663
|
+
if (!isUnableToCompute) {
|
|
8658
8664
|
_context.n = 9;
|
|
8659
8665
|
break;
|
|
8660
8666
|
}
|
|
@@ -8664,7 +8670,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
|
|
|
8664
8670
|
return buildTx();
|
|
8665
8671
|
case 10:
|
|
8666
8672
|
tx = _context.v;
|
|
8667
|
-
totalFee = calculateTotalXcmFee(xcmFeeResult);
|
|
8673
|
+
totalFee = calculateTotalXcmFee(asset, xcmFeeResult);
|
|
8668
8674
|
method = api.getMethod(tx);
|
|
8669
8675
|
if (method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen') {
|
|
8670
8676
|
feeToSubtract = totalFee;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-core",
|
|
3
|
-
"version": "11.14.
|
|
3
|
+
"version": "11.14.8",
|
|
4
4
|
"description": "SDK core for ParaSpell XCM/XCMP tool for developers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"@noble/hashes": "^1.8.0",
|
|
27
27
|
"@scure/base": "^2.0.0",
|
|
28
28
|
"viem": "^2.40.3",
|
|
29
|
-
"@paraspell/
|
|
30
|
-
"@paraspell/
|
|
31
|
-
"@paraspell/pallets": "11.14.
|
|
29
|
+
"@paraspell/assets": "11.14.8",
|
|
30
|
+
"@paraspell/sdk-common": "11.14.8",
|
|
31
|
+
"@paraspell/pallets": "11.14.8"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/plugin-syntax-import-attributes": "^7.27.1",
|