@paraspell/sdk-core 11.10.0 → 11.12.0
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 +129 -111
- package/dist/index.d.ts +17 -7
- package/dist/index.mjs +120 -105
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -838,6 +838,9 @@ var sortAssets = function sortAssets(assets$1) {
|
|
|
838
838
|
});
|
|
839
839
|
};
|
|
840
840
|
|
|
841
|
+
var parseUnits = viem.parseUnits;
|
|
842
|
+
var formatUnits = viem.formatUnits;
|
|
843
|
+
|
|
841
844
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
842
845
|
var isConfig = function isConfig(value) {
|
|
843
846
|
return _typeof(value) === 'object' && value !== null && !Array.isArray(value) && (
|
|
@@ -857,7 +860,7 @@ var computeOverridenAmount = function computeOverridenAmount(options, increaseAm
|
|
|
857
860
|
} else {
|
|
858
861
|
assertToIsString(to);
|
|
859
862
|
var asset = assets.findAssetInfoOrThrow(from, currency, to);
|
|
860
|
-
return
|
|
863
|
+
return parseUnits(increaseAmount, asset.decimals) + BigInt(amount);
|
|
861
864
|
}
|
|
862
865
|
};
|
|
863
866
|
var overrideTxAmount = /*#__PURE__*/function () {
|
|
@@ -1221,7 +1224,7 @@ var padFee = function padFee(raw, origin, dest, side) {
|
|
|
1221
1224
|
// apply default 30% padding
|
|
1222
1225
|
return mul(raw, 130n, 100n);
|
|
1223
1226
|
};
|
|
1224
|
-
var
|
|
1227
|
+
var padValueBy = function padValueBy(amount, percent) {
|
|
1225
1228
|
return mul(amount, BigInt(100 + percent), 100n);
|
|
1226
1229
|
};
|
|
1227
1230
|
|
|
@@ -3194,7 +3197,7 @@ var applyDecimalAbstraction = function applyDecimalAbstraction(amount, decimals,
|
|
|
3194
3197
|
}
|
|
3195
3198
|
return BigInt(_strAmount);
|
|
3196
3199
|
}
|
|
3197
|
-
return
|
|
3200
|
+
return parseUnits(amount.toString(), decimals);
|
|
3198
3201
|
};
|
|
3199
3202
|
|
|
3200
3203
|
var createAssetsFilter = function createAssetsFilter(asset) {
|
|
@@ -3667,7 +3670,7 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
|
3667
3670
|
paraIdTo: paraIdTo
|
|
3668
3671
|
}; // We mint 1000 units of feeAsset and use 100
|
|
3669
3672
|
FEE_ASSET_AMOUNT = 100;
|
|
3670
|
-
feeAssetAmount = feeAssetInfo ?
|
|
3673
|
+
feeAssetAmount = feeAssetInfo ? parseUnits(FEE_ASSET_AMOUNT.toString(), feeAssetInfo.decimals) : MIN_FEE;
|
|
3671
3674
|
call = createExecuteCall(chain, createDirectExecuteXcm(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
|
|
3672
3675
|
fees: {
|
|
3673
3676
|
originFee: feeAssetAmount,
|
|
@@ -3695,9 +3698,9 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
|
3695
3698
|
throw new DryRunFailedError(dryRunResult.failureReason);
|
|
3696
3699
|
case 2:
|
|
3697
3700
|
originFeeEstimate = dryRunResult.origin.fee;
|
|
3698
|
-
originFee =
|
|
3701
|
+
originFee = padValueBy(originFeeEstimate, FEE_PADDING_PERCENTAGE$2);
|
|
3699
3702
|
reserveFeeEstimate = getReserveFeeFromHops(dryRunResult.hops);
|
|
3700
|
-
reserveFee =
|
|
3703
|
+
reserveFee = padValueBy(reserveFeeEstimate, FEE_PADDING_PERCENTAGE$2);
|
|
3701
3704
|
checkAmount(feeAssetInfo && !assets.isAssetEqual(assetInfo, feeAssetInfo) ? reserveFee : originFee + reserveFee);
|
|
3702
3705
|
xcm = createDirectExecuteXcm(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
|
|
3703
3706
|
fees: {
|
|
@@ -3747,7 +3750,7 @@ var getMythosOriginFee = /*#__PURE__*/function () {
|
|
|
3747
3750
|
}
|
|
3748
3751
|
throw new InvalidParameterError("Pool DOT -> ".concat(nativeAsset.symbol, " not found."));
|
|
3749
3752
|
case 4:
|
|
3750
|
-
return _context.a(2,
|
|
3753
|
+
return _context.a(2, padValueBy(feeConverted, 10));
|
|
3751
3754
|
}
|
|
3752
3755
|
}, _callee);
|
|
3753
3756
|
}));
|
|
@@ -4497,6 +4500,50 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4497
4500
|
};
|
|
4498
4501
|
}();
|
|
4499
4502
|
|
|
4503
|
+
var getFailureInfo$1 = function getFailureInfo(result) {
|
|
4504
|
+
var orderedChecks = [{
|
|
4505
|
+
chain: 'origin',
|
|
4506
|
+
chainResult: result.origin
|
|
4507
|
+
}, {
|
|
4508
|
+
chain: 'destination',
|
|
4509
|
+
chainResult: result.destination
|
|
4510
|
+
}, {
|
|
4511
|
+
chain: 'assetHub',
|
|
4512
|
+
chainResult: result.assetHub
|
|
4513
|
+
}, {
|
|
4514
|
+
chain: 'bridgeHub',
|
|
4515
|
+
chainResult: result.bridgeHub
|
|
4516
|
+
}].concat(_toConsumableArray(result.hops.map(function (hop) {
|
|
4517
|
+
return {
|
|
4518
|
+
chain: hop.chain,
|
|
4519
|
+
chainResult: hop.result
|
|
4520
|
+
};
|
|
4521
|
+
})));
|
|
4522
|
+
var _iterator = _createForOfIteratorHelper(orderedChecks),
|
|
4523
|
+
_step;
|
|
4524
|
+
try {
|
|
4525
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
4526
|
+
var _step$value = _step.value,
|
|
4527
|
+
chain = _step$value.chain,
|
|
4528
|
+
chainResult = _step$value.chainResult;
|
|
4529
|
+
if (chainResult && chainResult.success === false && chainResult.failureReason) {
|
|
4530
|
+
return {
|
|
4531
|
+
failureChain: chain,
|
|
4532
|
+
failureReason: chainResult.failureReason
|
|
4533
|
+
};
|
|
4534
|
+
}
|
|
4535
|
+
}
|
|
4536
|
+
} catch (err) {
|
|
4537
|
+
_iterator.e(err);
|
|
4538
|
+
} finally {
|
|
4539
|
+
_iterator.f();
|
|
4540
|
+
}
|
|
4541
|
+
return {
|
|
4542
|
+
failureChain: result.failureChain,
|
|
4543
|
+
failureReason: result.failureReason
|
|
4544
|
+
};
|
|
4545
|
+
};
|
|
4546
|
+
|
|
4500
4547
|
var getParaEthTransferFees = /*#__PURE__*/function () {
|
|
4501
4548
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(ahApi) {
|
|
4502
4549
|
var DEFAULT_FEE, feeStorageItem, leFeeHex, bytes, reversedHex, validReversedHex, leFee, transferBridgeFee, finalBridgeFee, finalAssethubExecutionFee;
|
|
@@ -5222,41 +5269,10 @@ var addEthereumBridgeFees = /*#__PURE__*/function () {
|
|
|
5222
5269
|
};
|
|
5223
5270
|
}();
|
|
5224
5271
|
|
|
5225
|
-
var getFailureInfo$1 = function getFailureInfo(results, hops) {
|
|
5226
|
-
// Check standard chains first for backwards compatibility
|
|
5227
|
-
for (var _i = 0, _arr = ['destination', 'assetHub', 'bridgeHub']; _i < _arr.length; _i++) {
|
|
5228
|
-
var chain = _arr[_i];
|
|
5229
|
-
var res = results[chain];
|
|
5230
|
-
if (res && !res.success && res.failureReason) {
|
|
5231
|
-
return {
|
|
5232
|
-
failureReason: res.failureReason,
|
|
5233
|
-
failureChain: chain
|
|
5234
|
-
};
|
|
5235
|
-
}
|
|
5236
|
-
}
|
|
5237
|
-
var _iterator = _createForOfIteratorHelper(hops),
|
|
5238
|
-
_step;
|
|
5239
|
-
try {
|
|
5240
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
5241
|
-
var hop = _step.value;
|
|
5242
|
-
if (!hop.result.success && hop.result.failureReason) {
|
|
5243
|
-
return {
|
|
5244
|
-
failureReason: hop.result.failureReason,
|
|
5245
|
-
failureChain: hop.chain
|
|
5246
|
-
};
|
|
5247
|
-
}
|
|
5248
|
-
}
|
|
5249
|
-
} catch (err) {
|
|
5250
|
-
_iterator.e(err);
|
|
5251
|
-
} finally {
|
|
5252
|
-
_iterator.f();
|
|
5253
|
-
}
|
|
5254
|
-
return {};
|
|
5255
|
-
};
|
|
5256
5272
|
var dryRunInternal = /*#__PURE__*/function () {
|
|
5257
5273
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
5258
5274
|
var _traversalResult$brid;
|
|
5259
|
-
var api, origin, destination, currency, tx, senderAddress, feeAsset, swapConfig, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, asset, amount, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, assetHubChain, bridgeHubChain, processedBridgeHub, bridgeHubHopIndex, bridgeHubWithCurrency,
|
|
5275
|
+
var api, origin, destination, currency, tx, senderAddress, feeAsset, swapConfig, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, asset, amount, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, assetHubChain, bridgeHubChain, processedBridgeHub, bridgeHubHopIndex, bridgeHubWithCurrency, result, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
|
|
5260
5276
|
return _regenerator().w(function (_context2) {
|
|
5261
5277
|
while (1) switch (_context2.n) {
|
|
5262
5278
|
case 0:
|
|
@@ -5316,19 +5332,18 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5316
5332
|
initialForwardedXcms = originDryModified.forwardedXcms, initialDestParaId = originDryModified.destParaId;
|
|
5317
5333
|
processHop = /*#__PURE__*/function () {
|
|
5318
5334
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
5319
|
-
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange,
|
|
5335
|
+
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset, _findAssetInfoOnDest, hopDryRun;
|
|
5320
5336
|
return _regenerator().w(function (_context) {
|
|
5321
5337
|
while (1) switch (_context.n) {
|
|
5322
5338
|
case 0:
|
|
5323
|
-
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange
|
|
5339
|
+
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange;
|
|
5324
5340
|
if (asset.location && asset.location.parents === sdkCommon.Parents.TWO) {
|
|
5325
5341
|
hopAsset = assets.findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
|
|
5326
5342
|
} else if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
5327
5343
|
hopAsset = assets.findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
5328
|
-
} else if (isDestination) {
|
|
5329
|
-
hopAsset = assets.findAssetOnDestOrThrow(origin, currentChain, currency);
|
|
5330
5344
|
} else {
|
|
5331
5345
|
hopAsset = asset;
|
|
5346
|
+
hopAsset = (_findAssetInfoOnDest = assets.findAssetInfoOnDest(origin, currentChain, currency)) !== null && _findAssetInfoOnDest !== void 0 ? _findAssetInfoOnDest : asset;
|
|
5332
5347
|
}
|
|
5333
5348
|
if (assets.hasDryRunSupport(currentChain)) {
|
|
5334
5349
|
_context.n = 1;
|
|
@@ -5430,20 +5445,14 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5430
5445
|
currency: assets.getNativeAssetSymbol(bridgeHubChain),
|
|
5431
5446
|
asset: assets.findNativeAssetInfoOrThrow(bridgeHubChain)
|
|
5432
5447
|
}) : processedBridgeHub;
|
|
5433
|
-
|
|
5434
|
-
destination: traversalResult.destination,
|
|
5435
|
-
assetHub: traversalResult.assetHub,
|
|
5436
|
-
bridgeHub: bridgeHubWithCurrency
|
|
5437
|
-
}, traversalResult.hops), failureReason = _getFailureInfo.failureReason, failureChain = _getFailureInfo.failureChain;
|
|
5438
|
-
return _context2.a(2, {
|
|
5439
|
-
failureReason: failureReason,
|
|
5440
|
-
failureChain: failureChain,
|
|
5448
|
+
result = {
|
|
5441
5449
|
origin: originDryModified,
|
|
5442
5450
|
assetHub: traversalResult.assetHub,
|
|
5443
5451
|
bridgeHub: bridgeHubWithCurrency,
|
|
5444
5452
|
destination: traversalResult.destination,
|
|
5445
5453
|
hops: traversalResult.hops
|
|
5446
|
-
}
|
|
5454
|
+
};
|
|
5455
|
+
return _context2.a(2, _objectSpread2(_objectSpread2({}, getFailureInfo$1(result)), result));
|
|
5447
5456
|
}
|
|
5448
5457
|
}, _callee2);
|
|
5449
5458
|
}));
|
|
@@ -5640,7 +5649,7 @@ var extractFeesFromDryRun = function extractFeesFromDryRun(chain, dryRunResult,
|
|
|
5640
5649
|
throw new DryRunFailedError("Exchange (destination) failed: ".concat(dryRunResult.destination.failureReason || 'Unknown reason'));
|
|
5641
5650
|
}
|
|
5642
5651
|
if (dryRunResult.destination && dryRunResult.destination.success) {
|
|
5643
|
-
fees.exchangeFee =
|
|
5652
|
+
fees.exchangeFee = padValueBy(dryRunResult.destination.fee, FEE_PADDING_PERCENTAGE$1);
|
|
5644
5653
|
}
|
|
5645
5654
|
} else {
|
|
5646
5655
|
// Normal case: exchange is an intermediate hop
|
|
@@ -5649,7 +5658,7 @@ var extractFeesFromDryRun = function extractFeesFromDryRun(chain, dryRunResult,
|
|
|
5649
5658
|
throw new DryRunFailedError("Exchange hop failed: ".concat(exchangeHop.result.failureReason || 'Unknown reason'));
|
|
5650
5659
|
}
|
|
5651
5660
|
if (exchangeHop.result.success) {
|
|
5652
|
-
fees.exchangeFee =
|
|
5661
|
+
fees.exchangeFee = padValueBy(exchangeHop.result.fee, FEE_PADDING_PERCENTAGE$1);
|
|
5653
5662
|
}
|
|
5654
5663
|
}
|
|
5655
5664
|
} else {
|
|
@@ -5666,7 +5675,7 @@ var extractFeesFromDryRun = function extractFeesFromDryRun(chain, dryRunResult,
|
|
|
5666
5675
|
throw new DryRunFailedError("Hop before exchange failed: ".concat(hopBeforeExchange.result.failureReason || 'Unknown reason'));
|
|
5667
5676
|
}
|
|
5668
5677
|
if (hopBeforeExchange.result.success) {
|
|
5669
|
-
fees.originReserveFee =
|
|
5678
|
+
fees.originReserveFee = padValueBy(hopBeforeExchange.result.fee, FEE_PADDING_PERCENTAGE$1);
|
|
5670
5679
|
}
|
|
5671
5680
|
} else if (!destChain && hops.length > 0) {
|
|
5672
5681
|
// Special case: when destChain is undefined and we have hops,
|
|
@@ -5676,7 +5685,7 @@ var extractFeesFromDryRun = function extractFeesFromDryRun(chain, dryRunResult,
|
|
|
5676
5685
|
throw new DryRunFailedError("Origin reserve hop failed: ".concat(lastHop.result.failureReason || 'Unknown reason'));
|
|
5677
5686
|
}
|
|
5678
5687
|
if (lastHop.result.success) {
|
|
5679
|
-
fees.originReserveFee =
|
|
5688
|
+
fees.originReserveFee = padValueBy(lastHop.result.fee, FEE_PADDING_PERCENTAGE$1);
|
|
5680
5689
|
}
|
|
5681
5690
|
}
|
|
5682
5691
|
// Handle destination reserve fee (hop after exchange)
|
|
@@ -5687,7 +5696,7 @@ var extractFeesFromDryRun = function extractFeesFromDryRun(chain, dryRunResult,
|
|
|
5687
5696
|
throw new DryRunFailedError("Hop after exchange failed: ".concat(hopAfterExchange.result.failureReason || 'Unknown reason'));
|
|
5688
5697
|
}
|
|
5689
5698
|
if (hopAfterExchange.result.success) {
|
|
5690
|
-
fees.destReserveFee =
|
|
5699
|
+
fees.destReserveFee = padValueBy(hopAfterExchange.result.fee, FEE_PADDING_PERCENTAGE$1);
|
|
5691
5700
|
}
|
|
5692
5701
|
}
|
|
5693
5702
|
return fees;
|
|
@@ -5886,8 +5895,8 @@ var handleToAhTeleport = /*#__PURE__*/function () {
|
|
|
5886
5895
|
});
|
|
5887
5896
|
case 4:
|
|
5888
5897
|
feeResult = _context.v;
|
|
5889
|
-
originExecutionFee =
|
|
5890
|
-
destinationExecutionFee =
|
|
5898
|
+
originExecutionFee = padValueBy(feeResult.origin.fee, 20); // Pad by 20%
|
|
5899
|
+
destinationExecutionFee = padValueBy(
|
|
5891
5900
|
// Pad by 20%
|
|
5892
5901
|
feeResult.destination.feeType === 'paymentInfo' ? feeResult.origin.fee : feeResult.destination.fee, 20);
|
|
5893
5902
|
return _context.a(2, createExecuteExchangeXcm(input, origin, (_feeResult$origin$wei = feeResult.origin.weight) !== null && _feeResult$origin$wei !== void 0 ? _feeResult$origin$wei : MAX_WEIGHT, originExecutionFee, destinationExecutionFee));
|
|
@@ -10655,7 +10664,7 @@ var createMintTxs = function createMintTxs(chain, asset, balance, address, api)
|
|
|
10655
10664
|
return palletInstance.mint(address, asset, balance, chain, api);
|
|
10656
10665
|
};
|
|
10657
10666
|
var createRequiredMintTxs = function createRequiredMintTxs(chain, asset, amountHuman, balance, address, api) {
|
|
10658
|
-
var amount =
|
|
10667
|
+
var amount = parseUnits(amountHuman, asset.decimals);
|
|
10659
10668
|
return createMintTxs(chain, _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
10660
10669
|
amount: amount
|
|
10661
10670
|
}), balance, address, api);
|
|
@@ -10663,7 +10672,7 @@ var createRequiredMintTxs = function createRequiredMintTxs(chain, asset, amountH
|
|
|
10663
10672
|
var createOptionalMintTxs = function createOptionalMintTxs(chain, currency, amountHuman, balance, address, api) {
|
|
10664
10673
|
var asset = assets.findAssetInfo(chain, currency, null);
|
|
10665
10674
|
if (!asset) return null;
|
|
10666
|
-
var amount =
|
|
10675
|
+
var amount = parseUnits(amountHuman, asset.decimals);
|
|
10667
10676
|
return createMintTxs(chain, _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
10668
10677
|
amount: amount
|
|
10669
10678
|
}), balance, address, api);
|
|
@@ -10704,7 +10713,7 @@ var mintBonusForSent = function mintBonusForSent(chain, sent, feeAsset, mintFeeA
|
|
|
10704
10713
|
});
|
|
10705
10714
|
return preminted.some(function (a) {
|
|
10706
10715
|
return assets.isAssetXcEqual(a, sent);
|
|
10707
|
-
}) ?
|
|
10716
|
+
}) ? parseUnits(BYPASS_MINT_AMOUNT, sent.decimals) : 0n;
|
|
10708
10717
|
};
|
|
10709
10718
|
var wrapTxBypass = /*#__PURE__*/function () {
|
|
10710
10719
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dryRunOptions) {
|
|
@@ -10787,7 +10796,7 @@ var wrapTxBypass = /*#__PURE__*/function () {
|
|
|
10787
10796
|
_context.n = 8;
|
|
10788
10797
|
break;
|
|
10789
10798
|
}
|
|
10790
|
-
amount =
|
|
10799
|
+
amount = parseUnits(BYPASS_MINT_AMOUNT, feeAsset.decimals);
|
|
10791
10800
|
_context.n = 7;
|
|
10792
10801
|
return createMintTxs(chain, _objectSpread2(_objectSpread2({}, feeAsset), {}, {
|
|
10793
10802
|
amount: amount
|
|
@@ -10806,7 +10815,7 @@ var wrapTxBypass = /*#__PURE__*/function () {
|
|
|
10806
10815
|
balance = _context.v;
|
|
10807
10816
|
bonus = mintBonusForSent(chain, asset, feeAsset, !!mintFeeAssets);
|
|
10808
10817
|
if ((options === null || options === void 0 ? void 0 : options.sentAssetMintMode) === 'bypass') {
|
|
10809
|
-
mintAmount =
|
|
10818
|
+
mintAmount = parseUnits(BYPASS_MINT_AMOUNT, asset.decimals) + asset.amount;
|
|
10810
10819
|
} else {
|
|
10811
10820
|
missing = (_calcPreviewMintAmoun = calcPreviewMintAmount(balance, asset.amount)) !== null && _calcPreviewMintAmoun !== void 0 ? _calcPreviewMintAmoun : 0n;
|
|
10812
10821
|
total = missing + bonus;
|
|
@@ -11468,7 +11477,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
11468
11477
|
case 10:
|
|
11469
11478
|
processHop = /*#__PURE__*/function () {
|
|
11470
11479
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
11471
|
-
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset, hopResult;
|
|
11480
|
+
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset, _findAssetInfoOnDest, hopResult;
|
|
11472
11481
|
return _regenerator().w(function (_context) {
|
|
11473
11482
|
while (1) switch (_context.n) {
|
|
11474
11483
|
case 0:
|
|
@@ -11476,10 +11485,8 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
11476
11485
|
if (!(currentAsset.location && currentAsset.location.parents === sdkCommon.Parents.TWO)) {
|
|
11477
11486
|
if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
11478
11487
|
hopAsset = assets.findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
11479
|
-
} else if (destination === currentChain) {
|
|
11480
|
-
hopAsset = assets.findAssetOnDestOrThrow(origin, currentChain, currency);
|
|
11481
11488
|
} else {
|
|
11482
|
-
hopAsset = currentAsset;
|
|
11489
|
+
hopAsset = (_findAssetInfoOnDest = assets.findAssetInfoOnDest(origin, currentChain, currency)) !== null && _findAssetInfoOnDest !== void 0 ? _findAssetInfoOnDest : currentAsset;
|
|
11483
11490
|
}
|
|
11484
11491
|
} else {
|
|
11485
11492
|
hopAsset = assets.findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
|
|
@@ -12161,83 +12168,56 @@ var buildDestInfo = /*#__PURE__*/function () {
|
|
|
12161
12168
|
|
|
12162
12169
|
var buildHopInfo = /*#__PURE__*/function () {
|
|
12163
12170
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
12164
|
-
var api, chain, feeData, originChain, asset, currency,
|
|
12171
|
+
var api, chain, feeData, originChain, asset, currency, hopApi, xcmFeeDetails, isBridgeHub, hopAsset, hopCurrencyPayload, ed;
|
|
12165
12172
|
return _regenerator().w(function (_context) {
|
|
12166
12173
|
while (1) switch (_context.p = _context.n) {
|
|
12167
12174
|
case 0:
|
|
12168
|
-
api = _ref.api, chain = _ref.chain, feeData = _ref.feeData, originChain = _ref.originChain, asset = _ref.asset, currency = _ref.currency
|
|
12175
|
+
api = _ref.api, chain = _ref.chain, feeData = _ref.feeData, originChain = _ref.originChain, asset = _ref.asset, currency = _ref.currency;
|
|
12169
12176
|
hopApi = api.clone();
|
|
12170
12177
|
_context.n = 1;
|
|
12171
12178
|
return hopApi.init(chain);
|
|
12172
12179
|
case 1:
|
|
12173
12180
|
hopApi.setDisconnectAllowed(false);
|
|
12174
12181
|
_context.p = 2;
|
|
12175
|
-
resolvedAddress = assets.isChainEvm(originChain) && ahAddress ? ahAddress : senderAddress;
|
|
12176
|
-
_context.n = 3;
|
|
12177
|
-
return getBalanceNativeInternal({
|
|
12178
|
-
api: hopApi,
|
|
12179
|
-
address: resolvedAddress,
|
|
12180
|
-
chain: chain
|
|
12181
|
-
});
|
|
12182
|
-
case 3:
|
|
12183
|
-
nativeBalanceOnHop = _context.v;
|
|
12184
|
-
nativeAssetSymbolOnHop = assets.getNativeAssetSymbol(chain);
|
|
12185
12182
|
xcmFeeDetails = {
|
|
12186
12183
|
fee: feeData.fee,
|
|
12187
|
-
|
|
12188
|
-
currencySymbol: nativeAssetSymbolOnHop,
|
|
12184
|
+
currencySymbol: asset.symbol,
|
|
12189
12185
|
asset: asset
|
|
12190
12186
|
};
|
|
12191
12187
|
isBridgeHub = chain.includes('BridgeHub');
|
|
12192
12188
|
if (!isBridgeHub) {
|
|
12193
|
-
_context.n =
|
|
12189
|
+
_context.n = 3;
|
|
12194
12190
|
break;
|
|
12195
12191
|
}
|
|
12196
12192
|
return _context.a(2, {
|
|
12197
12193
|
currencySymbol: assets.getNativeAssetSymbol(chain),
|
|
12198
12194
|
xcmFee: xcmFeeDetails
|
|
12199
12195
|
});
|
|
12200
|
-
case
|
|
12196
|
+
case 3:
|
|
12201
12197
|
hopAsset = assets.findAssetOnDestOrThrow(originChain, chain, currency);
|
|
12202
12198
|
hopCurrencyPayload = hopAsset.location ? {
|
|
12203
12199
|
location: hopAsset.location
|
|
12204
12200
|
} : {
|
|
12205
12201
|
symbol: hopAsset.symbol
|
|
12206
12202
|
};
|
|
12207
|
-
|
|
12208
|
-
return getAssetBalanceInternal({
|
|
12209
|
-
api: hopApi,
|
|
12210
|
-
address: resolvedAddress,
|
|
12211
|
-
chain: chain,
|
|
12212
|
-
currency: hopCurrencyPayload
|
|
12213
|
-
});
|
|
12214
|
-
case 5:
|
|
12215
|
-
balance = _context.v;
|
|
12216
|
-
ed = assets.getExistentialDeposit(chain, hopCurrencyPayload);
|
|
12217
|
-
if (ed) {
|
|
12218
|
-
_context.n = 6;
|
|
12219
|
-
break;
|
|
12220
|
-
}
|
|
12221
|
-
throw new InvalidParameterError("Existential deposit not found for chain ".concat(chain, " with currency ").concat(JSON.stringify(hopCurrencyPayload)));
|
|
12222
|
-
case 6:
|
|
12203
|
+
ed = assets.getExistentialDepositOrThrow(chain, hopCurrencyPayload);
|
|
12223
12204
|
return _context.a(2, {
|
|
12224
|
-
balance: balance,
|
|
12225
12205
|
currencySymbol: hopAsset.symbol,
|
|
12226
12206
|
asset: hopAsset,
|
|
12227
|
-
existentialDeposit:
|
|
12207
|
+
existentialDeposit: ed,
|
|
12228
12208
|
xcmFee: xcmFeeDetails
|
|
12229
12209
|
});
|
|
12230
|
-
case
|
|
12231
|
-
_context.p =
|
|
12210
|
+
case 4:
|
|
12211
|
+
_context.p = 4;
|
|
12232
12212
|
hopApi.setDisconnectAllowed(true);
|
|
12233
|
-
_context.n =
|
|
12213
|
+
_context.n = 5;
|
|
12234
12214
|
return hopApi.disconnect();
|
|
12235
|
-
case
|
|
12236
|
-
return _context.f(
|
|
12237
|
-
case
|
|
12215
|
+
case 5:
|
|
12216
|
+
return _context.f(4);
|
|
12217
|
+
case 6:
|
|
12238
12218
|
return _context.a(2);
|
|
12239
12219
|
}
|
|
12240
|
-
}, _callee, null, [[2,,
|
|
12220
|
+
}, _callee, null, [[2,, 4, 6]]);
|
|
12241
12221
|
}));
|
|
12242
12222
|
return function buildHopInfo(_x) {
|
|
12243
12223
|
return _ref2.apply(this, arguments);
|
|
@@ -12722,7 +12702,7 @@ var computeInstructionFee = /*#__PURE__*/function () {
|
|
|
12722
12702
|
while (1) switch (_context.n) {
|
|
12723
12703
|
case 0:
|
|
12724
12704
|
chain = _ref.chain, api = _ref.api;
|
|
12725
|
-
_t =
|
|
12705
|
+
_t = padValueBy;
|
|
12726
12706
|
_context.n = 1;
|
|
12727
12707
|
return api.getXcmPaymentApiFee(chain, addXcmVersionHeader(xcm, version), [], {
|
|
12728
12708
|
location: DOT_LOCATION
|
|
@@ -14378,6 +14358,41 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
14378
14358
|
}
|
|
14379
14359
|
return getTransferInfo$1;
|
|
14380
14360
|
}()
|
|
14361
|
+
/**
|
|
14362
|
+
* Returns the receivable amount on the destination after the transfer
|
|
14363
|
+
*
|
|
14364
|
+
* @returns The computed receivable amount.
|
|
14365
|
+
* @throws \{UnableToComputeError\} Thrown when the receivable amount cannot be determined.
|
|
14366
|
+
*/
|
|
14367
|
+
)
|
|
14368
|
+
}, {
|
|
14369
|
+
key: "getReceivableAmount",
|
|
14370
|
+
value: (function () {
|
|
14371
|
+
var _getReceivableAmount = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
14372
|
+
var _yield$this$getTransf, receivedAmount;
|
|
14373
|
+
return _regenerator().w(function (_context14) {
|
|
14374
|
+
while (1) switch (_context14.n) {
|
|
14375
|
+
case 0:
|
|
14376
|
+
_context14.n = 1;
|
|
14377
|
+
return this.getTransferInfo();
|
|
14378
|
+
case 1:
|
|
14379
|
+
_yield$this$getTransf = _context14.v;
|
|
14380
|
+
receivedAmount = _yield$this$getTransf.destination.receivedCurrency.receivedAmount;
|
|
14381
|
+
if (!(receivedAmount instanceof UnableToComputeError)) {
|
|
14382
|
+
_context14.n = 2;
|
|
14383
|
+
break;
|
|
14384
|
+
}
|
|
14385
|
+
throw receivedAmount;
|
|
14386
|
+
case 2:
|
|
14387
|
+
return _context14.a(2, receivedAmount);
|
|
14388
|
+
}
|
|
14389
|
+
}, _callee14, this);
|
|
14390
|
+
}));
|
|
14391
|
+
function getReceivableAmount() {
|
|
14392
|
+
return _getReceivableAmount.apply(this, arguments);
|
|
14393
|
+
}
|
|
14394
|
+
return getReceivableAmount;
|
|
14395
|
+
}()
|
|
14381
14396
|
/**
|
|
14382
14397
|
* Returns the API instance used by the builder.
|
|
14383
14398
|
*
|
|
@@ -14468,6 +14483,7 @@ exports.dryRun = dryRun;
|
|
|
14468
14483
|
exports.dryRunInternal = dryRunInternal;
|
|
14469
14484
|
exports.dryRunOrigin = dryRunOrigin;
|
|
14470
14485
|
exports.encodeSs58 = encodeSs58;
|
|
14486
|
+
exports.formatUnits = formatUnits;
|
|
14471
14487
|
exports.getAssetBalance = getAssetBalance;
|
|
14472
14488
|
exports.getAssetBalanceInternal = getAssetBalanceInternal;
|
|
14473
14489
|
exports.getAssetReserveChain = getAssetReserveChain;
|
|
@@ -14482,6 +14498,7 @@ exports.getChainLocation = getChainLocation;
|
|
|
14482
14498
|
exports.getChainProviders = getChainProviders;
|
|
14483
14499
|
exports.getChainVersion = getChainVersion;
|
|
14484
14500
|
exports.getCurrencySelection = getCurrencySelection;
|
|
14501
|
+
exports.getFailureInfo = getFailureInfo$1;
|
|
14485
14502
|
exports.getMinTransferableAmount = getMinTransferableAmount;
|
|
14486
14503
|
exports.getMinTransferableAmountInternal = getMinTransferableAmountInternal;
|
|
14487
14504
|
exports.getOriginFeeDetails = getOriginFeeDetails;
|
|
@@ -14508,7 +14525,8 @@ exports.maybeOverrideAsset = maybeOverrideAsset;
|
|
|
14508
14525
|
exports.maybeOverrideAssets = maybeOverrideAssets;
|
|
14509
14526
|
exports.overrideTxAmount = overrideTxAmount;
|
|
14510
14527
|
exports.padFee = padFee;
|
|
14511
|
-
exports.
|
|
14528
|
+
exports.padValueBy = padValueBy;
|
|
14529
|
+
exports.parseUnits = parseUnits;
|
|
14512
14530
|
exports.resolveDestChain = resolveDestChain;
|
|
14513
14531
|
exports.resolveModuleError = resolveModuleError;
|
|
14514
14532
|
exports.resolveParaId = resolveParaId;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { TCurrencyInputWithAmount, TCurrencyInput, WithAmount, TAssetInfo, TAsse
|
|
|
6
6
|
export * from '@paraspell/assets';
|
|
7
7
|
import { TPallet } from '@paraspell/pallets';
|
|
8
8
|
export * from '@paraspell/pallets';
|
|
9
|
-
import { WalletClient } from 'viem';
|
|
9
|
+
import { WalletClient, parseUnits as parseUnits$1, formatUnits as formatUnits$1 } from 'viem';
|
|
10
10
|
|
|
11
11
|
type WithApi<TBase, TApi, TRes> = TBase & {
|
|
12
12
|
api: IPolkadotApi<TApi, TRes>;
|
|
@@ -518,6 +518,13 @@ declare class GeneralBuilder<TApi, TRes, T extends Partial<TSendBaseOptions> = o
|
|
|
518
518
|
* @returns The transfer info.
|
|
519
519
|
*/
|
|
520
520
|
getTransferInfo(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>): Promise<TTransferInfo>;
|
|
521
|
+
/**
|
|
522
|
+
* Returns the receivable amount on the destination after the transfer
|
|
523
|
+
*
|
|
524
|
+
* @returns The computed receivable amount.
|
|
525
|
+
* @throws \{UnableToComputeError\} Thrown when the receivable amount cannot be determined.
|
|
526
|
+
*/
|
|
527
|
+
getReceivableAmount(this: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>): Promise<bigint>;
|
|
521
528
|
/**
|
|
522
529
|
* Returns the API instance used by the builder.
|
|
523
530
|
*
|
|
@@ -1305,8 +1312,7 @@ type THopTransferInfo = {
|
|
|
1305
1312
|
chain: TChain;
|
|
1306
1313
|
result: {
|
|
1307
1314
|
xcmFee: TXcmFeeBase;
|
|
1308
|
-
|
|
1309
|
-
existentialDeposit?: bigint;
|
|
1315
|
+
existentialDeposit: bigint;
|
|
1310
1316
|
/** @deprecated use `asset` property instead */
|
|
1311
1317
|
currencySymbol: string;
|
|
1312
1318
|
asset: TAssetInfo;
|
|
@@ -1314,7 +1320,6 @@ type THopTransferInfo = {
|
|
|
1314
1320
|
};
|
|
1315
1321
|
type TXcmFeeBase = {
|
|
1316
1322
|
fee: bigint;
|
|
1317
|
-
balance: bigint;
|
|
1318
1323
|
/** @deprecated use `asset` property instead */
|
|
1319
1324
|
currencySymbol: string;
|
|
1320
1325
|
asset: TAssetInfo;
|
|
@@ -1337,11 +1342,11 @@ type TTransferInfo = {
|
|
|
1337
1342
|
};
|
|
1338
1343
|
xcmFee: TXcmFeeBase & {
|
|
1339
1344
|
sufficient: boolean;
|
|
1345
|
+
balance: bigint;
|
|
1340
1346
|
balanceAfter: bigint;
|
|
1341
1347
|
};
|
|
1342
1348
|
};
|
|
1343
1349
|
assetHub?: {
|
|
1344
|
-
balance: bigint;
|
|
1345
1350
|
/** @deprecated use `asset` property instead */
|
|
1346
1351
|
currencySymbol: string;
|
|
1347
1352
|
asset: TAssetInfo;
|
|
@@ -2159,6 +2164,8 @@ declare const dryRunInternal: <TApi, TRes>(options: TDryRunOptions<TApi, TRes>)
|
|
|
2159
2164
|
|
|
2160
2165
|
declare const dryRunOrigin: <TApi, TRes>(options: TDryRunCallOptions<TApi, TRes>) => Promise<TDryRunChainResult>;
|
|
2161
2166
|
|
|
2167
|
+
declare const getFailureInfo: (result: TDryRunResult) => Pick<TDryRunResult, "failureReason" | "failureChain">;
|
|
2168
|
+
|
|
2162
2169
|
declare const traverseXcmHops: <TApi, TRes, THopResult>(config: HopTraversalConfig<TApi, TRes, THopResult>) => Promise<HopTraversalResult<THopResult>>;
|
|
2163
2170
|
declare const addEthereumBridgeFees: <TApi, TRes, TResult extends {
|
|
2164
2171
|
fee?: bigint;
|
|
@@ -2263,7 +2270,7 @@ declare const computeFeeFromDryRunPjs: (dryRun: any, chain: TSubstrateChain, exe
|
|
|
2263
2270
|
declare const resolveModuleError: (chain: TSubstrateChain, error: TModuleError) => XTokensError | PolkadotXcmError;
|
|
2264
2271
|
|
|
2265
2272
|
declare const padFee: (raw: bigint, origin: TSubstrateChain, dest: TChain, side: "origin" | "destination") => bigint;
|
|
2266
|
-
declare const
|
|
2273
|
+
declare const padValueBy: (amount: bigint, percent: number) => bigint;
|
|
2267
2274
|
|
|
2268
2275
|
/**
|
|
2269
2276
|
* Retrieves the chain instance for a given chain.
|
|
@@ -2327,7 +2334,10 @@ declare const handleSwapExecuteTransfer: <TApi, TRes>(options: TCreateSwapXcmOpt
|
|
|
2327
2334
|
|
|
2328
2335
|
declare const handleToAhTeleport: <TApi, TRes>(origin: TParachain, input: TPolkadotXCMTransferOptions<TApi, TRes>, defaultTx: TRes) => Promise<TRes>;
|
|
2329
2336
|
|
|
2337
|
+
declare const parseUnits: typeof parseUnits$1;
|
|
2338
|
+
declare const formatUnits: typeof formatUnits$1;
|
|
2339
|
+
|
|
2330
2340
|
declare const validateAddress: (address: TAddress, chain: TChain, isDestination?: boolean) => void;
|
|
2331
2341
|
|
|
2332
|
-
export { AmountTooLowError, AssetClaimBuilder, AssetsPallet, BatchMode, BridgeHaltedError, Builder, ChainNotSupportedError, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleChainsError, InvalidAddressError, InvalidParameterError, MissingChainApiError, NoXCMSupportImplementedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertHasLocation, assertIsForeign, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createTx, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, getAssetBalance, getAssetBalanceInternal, getAssetReserveChain, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getCurrencySelection, getMinTransferableAmount, getMinTransferableAmountInternal, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, overrideTxAmount, padFee,
|
|
2342
|
+
export { AmountTooLowError, AssetClaimBuilder, AssetsPallet, BatchMode, BridgeHaltedError, Builder, ChainNotSupportedError, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleChainsError, InvalidAddressError, InvalidParameterError, MissingChainApiError, NoXCMSupportImplementedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertHasLocation, assertIsForeign, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createTx, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, formatUnits, getAssetBalance, getAssetBalanceInternal, getAssetReserveChain, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getCurrencySelection, getFailureInfo, getMinTransferableAmount, getMinTransferableAmountInternal, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, overrideTxAmount, padFee, padValueBy, parseUnits, resolveDestChain, resolveModuleError, resolveParaId, reverseTransformLocation, send, sortAssets, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, verifyEdOnDestination, wrapTxBypass };
|
|
2333
2343
|
export type { BuildHopInfoOptions, HopProcessParams, HopTraversalConfig, HopTraversalResult, IPolkadotApi, IPolkadotXCMTransfer, IXTokensTransfer, IXTransferTransfer, OneKey, TAddress, TApiOrUrl, TAssetClaimInternalOptions, TAssetClaimOptions, TAssetClaimOptionsBase, TBatchOptions, TBatchedSendOptions, TBifrostToken, TBridgeStatus, TBuildDestInfoOptions, TBuildInternalRes, TBuilderConfig, TBuilderOptions, TBypassOptions, TChainConfig, TChainConfigMap, TChainWithApi, TConditionalXcmFeeDetail, TConditionalXcmFeeHopInfo, TCreateBaseSwapXcmOptions, TCreateBaseTransferXcmOptions, TCreateBeneficiaryOptions, TCreateBeneficiaryXTokensOptions, TCreateSwapXcmInternalOptions, TCreateSwapXcmOptions, TCreateTransferXcmOptions, TCreateTxsOptions, TDestWeight, TDestXcmFeeDetail, TDestination, TDryRunBaseOptions, TDryRunBypassOptions, TDryRunCallBaseOptions, TDryRunCallOptions, TDryRunChain, TDryRunChainFailure, TDryRunChainResult, TDryRunChainSuccess, TDryRunOptions, TDryRunPreviewOptions, TDryRunResBase, TDryRunResult, TDryRunXcmBaseOptions, TDryRunXcmOptions, TEvmBuilderOptions, TEvmBuilderOptionsBase, TEvmChainFrom, TFeeType, TForeignAssetId, TForeignOrNativeAsset, TForeignOrTokenAsset, TGetAssetBalanceOptions, TGetAssetBalanceOptionsBase, TGetBalanceForeignByAssetOptions, TGetBalanceForeignOptions, TGetBalanceForeignOptionsBase, TGetBalanceNativeOptions, TGetBalanceNativeOptionsBase, TGetFeeForDestChainBaseOptions, TGetFeeForDestChainOptions, TGetMinTransferableAmountOptions, TGetOriginFeeDetailsOptions, TGetOriginFeeDetailsOptionsBase, TGetOriginXcmFeeBaseOptions, TGetOriginXcmFeeEstimateOptions, TGetOriginXcmFeeInternalOptions, TGetOriginXcmFeeOptions, TGetReverseTxFeeOptions, TGetTransferInfoOptions, TGetTransferInfoOptionsBase, TGetTransferableAmountOptions, TGetTransferableAmountOptionsBase, TGetXcmFeeBaseOptions, TGetXcmFeeBuilderOptions, TGetXcmFeeEstimateDetail, TGetXcmFeeEstimateOptions, TGetXcmFeeEstimateResult, TGetXcmFeeInternalOptions, TGetXcmFeeOptions, TGetXcmFeeResult, THopInfo, THopTransferInfo, THubKey, TMantaAsset, TModuleError, TNativeTokenAsset, TNodleAsset, TOriginFeeDetails, TOtherReserveAsset, TPolkadotXCMTransferOptions, TPolkadotXcmMethod, TProviderEntry, TRelayToParaDestination, TRelayToParaOptions, TRelayToParaOverrides, TReserveAsset, TScenario, TSelfReserveAsset, TSendBaseOptions, TSendBaseOptionsWithSenderAddress, TSendInternalOptions, TSendOptions, TSerializeEthTransferOptions, TSerializedApiCall, TSerializedEthTransfer, TSwapConfig, TSwapFeeEstimates, TTransferFeeEstimates, TTransferInfo, TTransferLocalOptions, TTxFactory, TTypeAndThenCallContext, TTypeAndThenFees, TUrl, TVerifyEdOnDestinationOptions, TVerifyEdOnDestinationOptionsBase, TWeight, TXTokensCurrencySelection, TXTokensMethod, TXTokensTransferOptions, TXTransferMethod, TXTransferTransferOptions, TXcmAsset, TXcmFeeBase, TXcmFeeChain, TXcmFeeDetail, TXcmFeeDetailError, TXcmFeeDetailSuccess, TXcmFeeDetailWithFallback, TXcmFeeHopInfo, TXcmFeeHopResult, TXcmForeignAsset, TXcmPalletMethod, TXcmVersioned, TZeitgeistAsset, WithApi, WithRequiredSenderAddress };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { blake2b } from '@noble/hashes/blake2';
|
|
2
|
-
import { isChainEvm, getAssetsObject, InvalidCurrencyError, isForeignAsset, extractAssetLocation, findAssetInfoOrThrow, getNativeAssetSymbol, getOtherAssets, isAssetEqual, findNativeAssetInfoOrThrow, findAssetInfo, isTAsset, getExistentialDepositOrThrow, isSymbolMatch, hasDryRunSupport, isOverrideLocationSpecifier, findAssetInfoByLoc, findAssetOnDestOrThrow, Native, hasXcmPaymentApiSupport, getExistentialDeposit, getRelayChainSymbol, findNativeAssetInfo, isAssetXcEqual, hasSupportForAsset, isSymbolSpecifier, normalizeLocation, getEdFromAssetOrThrow, normalizeSymbol } from '@paraspell/assets';
|
|
2
|
+
import { isChainEvm, getAssetsObject, InvalidCurrencyError, isForeignAsset, extractAssetLocation, findAssetInfoOrThrow, getNativeAssetSymbol, getOtherAssets, isAssetEqual, findNativeAssetInfoOrThrow, findAssetInfo, isTAsset, getExistentialDepositOrThrow, isSymbolMatch, hasDryRunSupport, isOverrideLocationSpecifier, findAssetInfoByLoc, findAssetOnDestOrThrow, findAssetInfoOnDest, Native, hasXcmPaymentApiSupport, getExistentialDeposit, getRelayChainSymbol, findNativeAssetInfo, isAssetXcEqual, hasSupportForAsset, isSymbolSpecifier, normalizeLocation, getEdFromAssetOrThrow, normalizeSymbol } from '@paraspell/assets';
|
|
3
3
|
export * from '@paraspell/assets';
|
|
4
4
|
import { base58 } from '@scure/base';
|
|
5
|
-
import { isAddress, parseUnits, createPublicClient, http, getContract, pad, toHex, getAddress, concat, keccak256 } from 'viem';
|
|
5
|
+
import { isAddress, parseUnits as parseUnits$1, formatUnits as formatUnits$1, createPublicClient, http, getContract, pad, toHex, getAddress, concat, keccak256 } from 'viem';
|
|
6
6
|
import { getSupportedPalletsDetails, getDefaultPallet, getSupportedPallets, getNativeAssetsPallet, getOtherAssetsPallets } from '@paraspell/pallets';
|
|
7
7
|
export * from '@paraspell/pallets';
|
|
8
8
|
import { replaceBigInt, isTLocation, Version, hasJunction, getJunctionValue, isRelayChain, Parents, PARACHAINS, deepEqual, isTrustedChain, isExternalChain, isDotKsmBridge, isSystemChain } from '@paraspell/sdk-common';
|
|
@@ -839,6 +839,9 @@ var sortAssets = function sortAssets(assets) {
|
|
|
839
839
|
});
|
|
840
840
|
};
|
|
841
841
|
|
|
842
|
+
var parseUnits = parseUnits$1;
|
|
843
|
+
var formatUnits = formatUnits$1;
|
|
844
|
+
|
|
842
845
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
843
846
|
var isConfig = function isConfig(value) {
|
|
844
847
|
return _typeof(value) === 'object' && value !== null && !Array.isArray(value) && (
|
|
@@ -1222,7 +1225,7 @@ var padFee = function padFee(raw, origin, dest, side) {
|
|
|
1222
1225
|
// apply default 30% padding
|
|
1223
1226
|
return mul(raw, 130n, 100n);
|
|
1224
1227
|
};
|
|
1225
|
-
var
|
|
1228
|
+
var padValueBy = function padValueBy(amount, percent) {
|
|
1226
1229
|
return mul(amount, BigInt(100 + percent), 100n);
|
|
1227
1230
|
};
|
|
1228
1231
|
|
|
@@ -3696,9 +3699,9 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
|
|
|
3696
3699
|
throw new DryRunFailedError(dryRunResult.failureReason);
|
|
3697
3700
|
case 2:
|
|
3698
3701
|
originFeeEstimate = dryRunResult.origin.fee;
|
|
3699
|
-
originFee =
|
|
3702
|
+
originFee = padValueBy(originFeeEstimate, FEE_PADDING_PERCENTAGE$2);
|
|
3700
3703
|
reserveFeeEstimate = getReserveFeeFromHops(dryRunResult.hops);
|
|
3701
|
-
reserveFee =
|
|
3704
|
+
reserveFee = padValueBy(reserveFeeEstimate, FEE_PADDING_PERCENTAGE$2);
|
|
3702
3705
|
checkAmount(feeAssetInfo && !isAssetEqual(assetInfo, feeAssetInfo) ? reserveFee : originFee + reserveFee);
|
|
3703
3706
|
xcm = createDirectExecuteXcm(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
|
|
3704
3707
|
fees: {
|
|
@@ -3748,7 +3751,7 @@ var getMythosOriginFee = /*#__PURE__*/function () {
|
|
|
3748
3751
|
}
|
|
3749
3752
|
throw new InvalidParameterError("Pool DOT -> ".concat(nativeAsset.symbol, " not found."));
|
|
3750
3753
|
case 4:
|
|
3751
|
-
return _context.a(2,
|
|
3754
|
+
return _context.a(2, padValueBy(feeConverted, 10));
|
|
3752
3755
|
}
|
|
3753
3756
|
}, _callee);
|
|
3754
3757
|
}));
|
|
@@ -4498,6 +4501,50 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4498
4501
|
};
|
|
4499
4502
|
}();
|
|
4500
4503
|
|
|
4504
|
+
var getFailureInfo$1 = function getFailureInfo(result) {
|
|
4505
|
+
var orderedChecks = [{
|
|
4506
|
+
chain: 'origin',
|
|
4507
|
+
chainResult: result.origin
|
|
4508
|
+
}, {
|
|
4509
|
+
chain: 'destination',
|
|
4510
|
+
chainResult: result.destination
|
|
4511
|
+
}, {
|
|
4512
|
+
chain: 'assetHub',
|
|
4513
|
+
chainResult: result.assetHub
|
|
4514
|
+
}, {
|
|
4515
|
+
chain: 'bridgeHub',
|
|
4516
|
+
chainResult: result.bridgeHub
|
|
4517
|
+
}].concat(_toConsumableArray(result.hops.map(function (hop) {
|
|
4518
|
+
return {
|
|
4519
|
+
chain: hop.chain,
|
|
4520
|
+
chainResult: hop.result
|
|
4521
|
+
};
|
|
4522
|
+
})));
|
|
4523
|
+
var _iterator = _createForOfIteratorHelper(orderedChecks),
|
|
4524
|
+
_step;
|
|
4525
|
+
try {
|
|
4526
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
4527
|
+
var _step$value = _step.value,
|
|
4528
|
+
chain = _step$value.chain,
|
|
4529
|
+
chainResult = _step$value.chainResult;
|
|
4530
|
+
if (chainResult && chainResult.success === false && chainResult.failureReason) {
|
|
4531
|
+
return {
|
|
4532
|
+
failureChain: chain,
|
|
4533
|
+
failureReason: chainResult.failureReason
|
|
4534
|
+
};
|
|
4535
|
+
}
|
|
4536
|
+
}
|
|
4537
|
+
} catch (err) {
|
|
4538
|
+
_iterator.e(err);
|
|
4539
|
+
} finally {
|
|
4540
|
+
_iterator.f();
|
|
4541
|
+
}
|
|
4542
|
+
return {
|
|
4543
|
+
failureChain: result.failureChain,
|
|
4544
|
+
failureReason: result.failureReason
|
|
4545
|
+
};
|
|
4546
|
+
};
|
|
4547
|
+
|
|
4501
4548
|
var getParaEthTransferFees = /*#__PURE__*/function () {
|
|
4502
4549
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(ahApi) {
|
|
4503
4550
|
var DEFAULT_FEE, feeStorageItem, leFeeHex, bytes, reversedHex, validReversedHex, leFee, transferBridgeFee, finalBridgeFee, finalAssethubExecutionFee;
|
|
@@ -5223,41 +5270,10 @@ var addEthereumBridgeFees = /*#__PURE__*/function () {
|
|
|
5223
5270
|
};
|
|
5224
5271
|
}();
|
|
5225
5272
|
|
|
5226
|
-
var getFailureInfo$1 = function getFailureInfo(results, hops) {
|
|
5227
|
-
// Check standard chains first for backwards compatibility
|
|
5228
|
-
for (var _i = 0, _arr = ['destination', 'assetHub', 'bridgeHub']; _i < _arr.length; _i++) {
|
|
5229
|
-
var chain = _arr[_i];
|
|
5230
|
-
var res = results[chain];
|
|
5231
|
-
if (res && !res.success && res.failureReason) {
|
|
5232
|
-
return {
|
|
5233
|
-
failureReason: res.failureReason,
|
|
5234
|
-
failureChain: chain
|
|
5235
|
-
};
|
|
5236
|
-
}
|
|
5237
|
-
}
|
|
5238
|
-
var _iterator = _createForOfIteratorHelper(hops),
|
|
5239
|
-
_step;
|
|
5240
|
-
try {
|
|
5241
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
5242
|
-
var hop = _step.value;
|
|
5243
|
-
if (!hop.result.success && hop.result.failureReason) {
|
|
5244
|
-
return {
|
|
5245
|
-
failureReason: hop.result.failureReason,
|
|
5246
|
-
failureChain: hop.chain
|
|
5247
|
-
};
|
|
5248
|
-
}
|
|
5249
|
-
}
|
|
5250
|
-
} catch (err) {
|
|
5251
|
-
_iterator.e(err);
|
|
5252
|
-
} finally {
|
|
5253
|
-
_iterator.f();
|
|
5254
|
-
}
|
|
5255
|
-
return {};
|
|
5256
|
-
};
|
|
5257
5273
|
var dryRunInternal = /*#__PURE__*/function () {
|
|
5258
5274
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
5259
5275
|
var _traversalResult$brid;
|
|
5260
|
-
var api, origin, destination, currency, tx, senderAddress, feeAsset, swapConfig, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, asset, amount, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, assetHubChain, bridgeHubChain, processedBridgeHub, bridgeHubHopIndex, bridgeHubWithCurrency,
|
|
5276
|
+
var api, origin, destination, currency, tx, senderAddress, feeAsset, swapConfig, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, asset, amount, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, assetHubChain, bridgeHubChain, processedBridgeHub, bridgeHubHopIndex, bridgeHubWithCurrency, result, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
|
|
5261
5277
|
return _regenerator().w(function (_context2) {
|
|
5262
5278
|
while (1) switch (_context2.n) {
|
|
5263
5279
|
case 0:
|
|
@@ -5317,19 +5333,18 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5317
5333
|
initialForwardedXcms = originDryModified.forwardedXcms, initialDestParaId = originDryModified.destParaId;
|
|
5318
5334
|
processHop = /*#__PURE__*/function () {
|
|
5319
5335
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
5320
|
-
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange,
|
|
5336
|
+
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset, _findAssetInfoOnDest, hopDryRun;
|
|
5321
5337
|
return _regenerator().w(function (_context) {
|
|
5322
5338
|
while (1) switch (_context.n) {
|
|
5323
5339
|
case 0:
|
|
5324
|
-
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange
|
|
5340
|
+
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange;
|
|
5325
5341
|
if (asset.location && asset.location.parents === Parents.TWO) {
|
|
5326
5342
|
hopAsset = findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
|
|
5327
5343
|
} else if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
5328
5344
|
hopAsset = findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
5329
|
-
} else if (isDestination) {
|
|
5330
|
-
hopAsset = findAssetOnDestOrThrow(origin, currentChain, currency);
|
|
5331
5345
|
} else {
|
|
5332
5346
|
hopAsset = asset;
|
|
5347
|
+
hopAsset = (_findAssetInfoOnDest = findAssetInfoOnDest(origin, currentChain, currency)) !== null && _findAssetInfoOnDest !== void 0 ? _findAssetInfoOnDest : asset;
|
|
5333
5348
|
}
|
|
5334
5349
|
if (hasDryRunSupport(currentChain)) {
|
|
5335
5350
|
_context.n = 1;
|
|
@@ -5431,20 +5446,14 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5431
5446
|
currency: getNativeAssetSymbol(bridgeHubChain),
|
|
5432
5447
|
asset: findNativeAssetInfoOrThrow(bridgeHubChain)
|
|
5433
5448
|
}) : processedBridgeHub;
|
|
5434
|
-
|
|
5435
|
-
destination: traversalResult.destination,
|
|
5436
|
-
assetHub: traversalResult.assetHub,
|
|
5437
|
-
bridgeHub: bridgeHubWithCurrency
|
|
5438
|
-
}, traversalResult.hops), failureReason = _getFailureInfo.failureReason, failureChain = _getFailureInfo.failureChain;
|
|
5439
|
-
return _context2.a(2, {
|
|
5440
|
-
failureReason: failureReason,
|
|
5441
|
-
failureChain: failureChain,
|
|
5449
|
+
result = {
|
|
5442
5450
|
origin: originDryModified,
|
|
5443
5451
|
assetHub: traversalResult.assetHub,
|
|
5444
5452
|
bridgeHub: bridgeHubWithCurrency,
|
|
5445
5453
|
destination: traversalResult.destination,
|
|
5446
5454
|
hops: traversalResult.hops
|
|
5447
|
-
}
|
|
5455
|
+
};
|
|
5456
|
+
return _context2.a(2, _objectSpread2(_objectSpread2({}, getFailureInfo$1(result)), result));
|
|
5448
5457
|
}
|
|
5449
5458
|
}, _callee2);
|
|
5450
5459
|
}));
|
|
@@ -5641,7 +5650,7 @@ var extractFeesFromDryRun = function extractFeesFromDryRun(chain, dryRunResult,
|
|
|
5641
5650
|
throw new DryRunFailedError("Exchange (destination) failed: ".concat(dryRunResult.destination.failureReason || 'Unknown reason'));
|
|
5642
5651
|
}
|
|
5643
5652
|
if (dryRunResult.destination && dryRunResult.destination.success) {
|
|
5644
|
-
fees.exchangeFee =
|
|
5653
|
+
fees.exchangeFee = padValueBy(dryRunResult.destination.fee, FEE_PADDING_PERCENTAGE$1);
|
|
5645
5654
|
}
|
|
5646
5655
|
} else {
|
|
5647
5656
|
// Normal case: exchange is an intermediate hop
|
|
@@ -5650,7 +5659,7 @@ var extractFeesFromDryRun = function extractFeesFromDryRun(chain, dryRunResult,
|
|
|
5650
5659
|
throw new DryRunFailedError("Exchange hop failed: ".concat(exchangeHop.result.failureReason || 'Unknown reason'));
|
|
5651
5660
|
}
|
|
5652
5661
|
if (exchangeHop.result.success) {
|
|
5653
|
-
fees.exchangeFee =
|
|
5662
|
+
fees.exchangeFee = padValueBy(exchangeHop.result.fee, FEE_PADDING_PERCENTAGE$1);
|
|
5654
5663
|
}
|
|
5655
5664
|
}
|
|
5656
5665
|
} else {
|
|
@@ -5667,7 +5676,7 @@ var extractFeesFromDryRun = function extractFeesFromDryRun(chain, dryRunResult,
|
|
|
5667
5676
|
throw new DryRunFailedError("Hop before exchange failed: ".concat(hopBeforeExchange.result.failureReason || 'Unknown reason'));
|
|
5668
5677
|
}
|
|
5669
5678
|
if (hopBeforeExchange.result.success) {
|
|
5670
|
-
fees.originReserveFee =
|
|
5679
|
+
fees.originReserveFee = padValueBy(hopBeforeExchange.result.fee, FEE_PADDING_PERCENTAGE$1);
|
|
5671
5680
|
}
|
|
5672
5681
|
} else if (!destChain && hops.length > 0) {
|
|
5673
5682
|
// Special case: when destChain is undefined and we have hops,
|
|
@@ -5677,7 +5686,7 @@ var extractFeesFromDryRun = function extractFeesFromDryRun(chain, dryRunResult,
|
|
|
5677
5686
|
throw new DryRunFailedError("Origin reserve hop failed: ".concat(lastHop.result.failureReason || 'Unknown reason'));
|
|
5678
5687
|
}
|
|
5679
5688
|
if (lastHop.result.success) {
|
|
5680
|
-
fees.originReserveFee =
|
|
5689
|
+
fees.originReserveFee = padValueBy(lastHop.result.fee, FEE_PADDING_PERCENTAGE$1);
|
|
5681
5690
|
}
|
|
5682
5691
|
}
|
|
5683
5692
|
// Handle destination reserve fee (hop after exchange)
|
|
@@ -5688,7 +5697,7 @@ var extractFeesFromDryRun = function extractFeesFromDryRun(chain, dryRunResult,
|
|
|
5688
5697
|
throw new DryRunFailedError("Hop after exchange failed: ".concat(hopAfterExchange.result.failureReason || 'Unknown reason'));
|
|
5689
5698
|
}
|
|
5690
5699
|
if (hopAfterExchange.result.success) {
|
|
5691
|
-
fees.destReserveFee =
|
|
5700
|
+
fees.destReserveFee = padValueBy(hopAfterExchange.result.fee, FEE_PADDING_PERCENTAGE$1);
|
|
5692
5701
|
}
|
|
5693
5702
|
}
|
|
5694
5703
|
return fees;
|
|
@@ -5887,8 +5896,8 @@ var handleToAhTeleport = /*#__PURE__*/function () {
|
|
|
5887
5896
|
});
|
|
5888
5897
|
case 4:
|
|
5889
5898
|
feeResult = _context.v;
|
|
5890
|
-
originExecutionFee =
|
|
5891
|
-
destinationExecutionFee =
|
|
5899
|
+
originExecutionFee = padValueBy(feeResult.origin.fee, 20); // Pad by 20%
|
|
5900
|
+
destinationExecutionFee = padValueBy(
|
|
5892
5901
|
// Pad by 20%
|
|
5893
5902
|
feeResult.destination.feeType === 'paymentInfo' ? feeResult.origin.fee : feeResult.destination.fee, 20);
|
|
5894
5903
|
return _context.a(2, createExecuteExchangeXcm(input, origin, (_feeResult$origin$wei = feeResult.origin.weight) !== null && _feeResult$origin$wei !== void 0 ? _feeResult$origin$wei : MAX_WEIGHT, originExecutionFee, destinationExecutionFee));
|
|
@@ -11469,7 +11478,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
11469
11478
|
case 10:
|
|
11470
11479
|
processHop = /*#__PURE__*/function () {
|
|
11471
11480
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
11472
|
-
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset, hopResult;
|
|
11481
|
+
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset, _findAssetInfoOnDest, hopResult;
|
|
11473
11482
|
return _regenerator().w(function (_context) {
|
|
11474
11483
|
while (1) switch (_context.n) {
|
|
11475
11484
|
case 0:
|
|
@@ -11477,10 +11486,8 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
11477
11486
|
if (!(currentAsset.location && currentAsset.location.parents === Parents.TWO)) {
|
|
11478
11487
|
if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
11479
11488
|
hopAsset = findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
11480
|
-
} else if (destination === currentChain) {
|
|
11481
|
-
hopAsset = findAssetOnDestOrThrow(origin, currentChain, currency);
|
|
11482
11489
|
} else {
|
|
11483
|
-
hopAsset = currentAsset;
|
|
11490
|
+
hopAsset = (_findAssetInfoOnDest = findAssetInfoOnDest(origin, currentChain, currency)) !== null && _findAssetInfoOnDest !== void 0 ? _findAssetInfoOnDest : currentAsset;
|
|
11484
11491
|
}
|
|
11485
11492
|
} else {
|
|
11486
11493
|
hopAsset = findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
|
|
@@ -12162,83 +12169,56 @@ var buildDestInfo = /*#__PURE__*/function () {
|
|
|
12162
12169
|
|
|
12163
12170
|
var buildHopInfo = /*#__PURE__*/function () {
|
|
12164
12171
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
|
|
12165
|
-
var api, chain, feeData, originChain, asset, currency,
|
|
12172
|
+
var api, chain, feeData, originChain, asset, currency, hopApi, xcmFeeDetails, isBridgeHub, hopAsset, hopCurrencyPayload, ed;
|
|
12166
12173
|
return _regenerator().w(function (_context) {
|
|
12167
12174
|
while (1) switch (_context.p = _context.n) {
|
|
12168
12175
|
case 0:
|
|
12169
|
-
api = _ref.api, chain = _ref.chain, feeData = _ref.feeData, originChain = _ref.originChain, asset = _ref.asset, currency = _ref.currency
|
|
12176
|
+
api = _ref.api, chain = _ref.chain, feeData = _ref.feeData, originChain = _ref.originChain, asset = _ref.asset, currency = _ref.currency;
|
|
12170
12177
|
hopApi = api.clone();
|
|
12171
12178
|
_context.n = 1;
|
|
12172
12179
|
return hopApi.init(chain);
|
|
12173
12180
|
case 1:
|
|
12174
12181
|
hopApi.setDisconnectAllowed(false);
|
|
12175
12182
|
_context.p = 2;
|
|
12176
|
-
resolvedAddress = isChainEvm(originChain) && ahAddress ? ahAddress : senderAddress;
|
|
12177
|
-
_context.n = 3;
|
|
12178
|
-
return getBalanceNativeInternal({
|
|
12179
|
-
api: hopApi,
|
|
12180
|
-
address: resolvedAddress,
|
|
12181
|
-
chain: chain
|
|
12182
|
-
});
|
|
12183
|
-
case 3:
|
|
12184
|
-
nativeBalanceOnHop = _context.v;
|
|
12185
|
-
nativeAssetSymbolOnHop = getNativeAssetSymbol(chain);
|
|
12186
12183
|
xcmFeeDetails = {
|
|
12187
12184
|
fee: feeData.fee,
|
|
12188
|
-
|
|
12189
|
-
currencySymbol: nativeAssetSymbolOnHop,
|
|
12185
|
+
currencySymbol: asset.symbol,
|
|
12190
12186
|
asset: asset
|
|
12191
12187
|
};
|
|
12192
12188
|
isBridgeHub = chain.includes('BridgeHub');
|
|
12193
12189
|
if (!isBridgeHub) {
|
|
12194
|
-
_context.n =
|
|
12190
|
+
_context.n = 3;
|
|
12195
12191
|
break;
|
|
12196
12192
|
}
|
|
12197
12193
|
return _context.a(2, {
|
|
12198
12194
|
currencySymbol: getNativeAssetSymbol(chain),
|
|
12199
12195
|
xcmFee: xcmFeeDetails
|
|
12200
12196
|
});
|
|
12201
|
-
case
|
|
12197
|
+
case 3:
|
|
12202
12198
|
hopAsset = findAssetOnDestOrThrow(originChain, chain, currency);
|
|
12203
12199
|
hopCurrencyPayload = hopAsset.location ? {
|
|
12204
12200
|
location: hopAsset.location
|
|
12205
12201
|
} : {
|
|
12206
12202
|
symbol: hopAsset.symbol
|
|
12207
12203
|
};
|
|
12208
|
-
|
|
12209
|
-
return getAssetBalanceInternal({
|
|
12210
|
-
api: hopApi,
|
|
12211
|
-
address: resolvedAddress,
|
|
12212
|
-
chain: chain,
|
|
12213
|
-
currency: hopCurrencyPayload
|
|
12214
|
-
});
|
|
12215
|
-
case 5:
|
|
12216
|
-
balance = _context.v;
|
|
12217
|
-
ed = getExistentialDeposit(chain, hopCurrencyPayload);
|
|
12218
|
-
if (ed) {
|
|
12219
|
-
_context.n = 6;
|
|
12220
|
-
break;
|
|
12221
|
-
}
|
|
12222
|
-
throw new InvalidParameterError("Existential deposit not found for chain ".concat(chain, " with currency ").concat(JSON.stringify(hopCurrencyPayload)));
|
|
12223
|
-
case 6:
|
|
12204
|
+
ed = getExistentialDepositOrThrow(chain, hopCurrencyPayload);
|
|
12224
12205
|
return _context.a(2, {
|
|
12225
|
-
balance: balance,
|
|
12226
12206
|
currencySymbol: hopAsset.symbol,
|
|
12227
12207
|
asset: hopAsset,
|
|
12228
|
-
existentialDeposit:
|
|
12208
|
+
existentialDeposit: ed,
|
|
12229
12209
|
xcmFee: xcmFeeDetails
|
|
12230
12210
|
});
|
|
12231
|
-
case
|
|
12232
|
-
_context.p =
|
|
12211
|
+
case 4:
|
|
12212
|
+
_context.p = 4;
|
|
12233
12213
|
hopApi.setDisconnectAllowed(true);
|
|
12234
|
-
_context.n =
|
|
12214
|
+
_context.n = 5;
|
|
12235
12215
|
return hopApi.disconnect();
|
|
12236
|
-
case
|
|
12237
|
-
return _context.f(
|
|
12238
|
-
case
|
|
12216
|
+
case 5:
|
|
12217
|
+
return _context.f(4);
|
|
12218
|
+
case 6:
|
|
12239
12219
|
return _context.a(2);
|
|
12240
12220
|
}
|
|
12241
|
-
}, _callee, null, [[2,,
|
|
12221
|
+
}, _callee, null, [[2,, 4, 6]]);
|
|
12242
12222
|
}));
|
|
12243
12223
|
return function buildHopInfo(_x) {
|
|
12244
12224
|
return _ref2.apply(this, arguments);
|
|
@@ -12723,7 +12703,7 @@ var computeInstructionFee = /*#__PURE__*/function () {
|
|
|
12723
12703
|
while (1) switch (_context.n) {
|
|
12724
12704
|
case 0:
|
|
12725
12705
|
chain = _ref.chain, api = _ref.api;
|
|
12726
|
-
_t =
|
|
12706
|
+
_t = padValueBy;
|
|
12727
12707
|
_context.n = 1;
|
|
12728
12708
|
return api.getXcmPaymentApiFee(chain, addXcmVersionHeader(xcm, version), [], {
|
|
12729
12709
|
location: DOT_LOCATION
|
|
@@ -14379,6 +14359,41 @@ var GeneralBuilder = /*#__PURE__*/function () {
|
|
|
14379
14359
|
}
|
|
14380
14360
|
return getTransferInfo$1;
|
|
14381
14361
|
}()
|
|
14362
|
+
/**
|
|
14363
|
+
* Returns the receivable amount on the destination after the transfer
|
|
14364
|
+
*
|
|
14365
|
+
* @returns The computed receivable amount.
|
|
14366
|
+
* @throws \{UnableToComputeError\} Thrown when the receivable amount cannot be determined.
|
|
14367
|
+
*/
|
|
14368
|
+
)
|
|
14369
|
+
}, {
|
|
14370
|
+
key: "getReceivableAmount",
|
|
14371
|
+
value: (function () {
|
|
14372
|
+
var _getReceivableAmount = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
|
|
14373
|
+
var _yield$this$getTransf, receivedAmount;
|
|
14374
|
+
return _regenerator().w(function (_context14) {
|
|
14375
|
+
while (1) switch (_context14.n) {
|
|
14376
|
+
case 0:
|
|
14377
|
+
_context14.n = 1;
|
|
14378
|
+
return this.getTransferInfo();
|
|
14379
|
+
case 1:
|
|
14380
|
+
_yield$this$getTransf = _context14.v;
|
|
14381
|
+
receivedAmount = _yield$this$getTransf.destination.receivedCurrency.receivedAmount;
|
|
14382
|
+
if (!(receivedAmount instanceof UnableToComputeError)) {
|
|
14383
|
+
_context14.n = 2;
|
|
14384
|
+
break;
|
|
14385
|
+
}
|
|
14386
|
+
throw receivedAmount;
|
|
14387
|
+
case 2:
|
|
14388
|
+
return _context14.a(2, receivedAmount);
|
|
14389
|
+
}
|
|
14390
|
+
}, _callee14, this);
|
|
14391
|
+
}));
|
|
14392
|
+
function getReceivableAmount() {
|
|
14393
|
+
return _getReceivableAmount.apply(this, arguments);
|
|
14394
|
+
}
|
|
14395
|
+
return getReceivableAmount;
|
|
14396
|
+
}()
|
|
14382
14397
|
/**
|
|
14383
14398
|
* Returns the API instance used by the builder.
|
|
14384
14399
|
*
|
|
@@ -14412,4 +14427,4 @@ var Builder = function Builder(api) {
|
|
|
14412
14427
|
return new GeneralBuilder(api, new BatchTransactionManager());
|
|
14413
14428
|
};
|
|
14414
14429
|
|
|
14415
|
-
export { AmountTooLowError, AssetClaimBuilder, AssetsPallet, BatchMode, BridgeHaltedError, Builder, ChainNotSupportedError, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleChainsError, InvalidAddressError, InvalidParameterError, MissingChainApiError, NoXCMSupportImplementedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertHasLocation, assertIsForeign, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createTx, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, getAssetBalance, getAssetBalanceInternal, getAssetReserveChain, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getCurrencySelection, getMinTransferableAmount, getMinTransferableAmountInternal, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, overrideTxAmount, padFee,
|
|
14430
|
+
export { AmountTooLowError, AssetClaimBuilder, AssetsPallet, BatchMode, BridgeHaltedError, Builder, ChainNotSupportedError, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleChainsError, InvalidAddressError, InvalidParameterError, MissingChainApiError, NoXCMSupportImplementedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertHasId, assertHasLocation, assertIsForeign, assertSenderAddress, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, computeOverridenAmount, convertSs58, createAsset, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createTx, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, formatUnits, getAssetBalance, getAssetBalanceInternal, getAssetReserveChain, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getCurrencySelection, getFailureInfo$1 as getFailureInfo, getMinTransferableAmount, getMinTransferableAmountInternal, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, getXcmFeeInternal, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, overrideTxAmount, padFee, padValueBy, parseUnits, resolveDestChain, resolveModuleError, resolveParaId, reverseTransformLocation, send, sortAssets, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, verifyEdOnDestination, wrapTxBypass };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-core",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.12.0",
|
|
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.37.9",
|
|
29
|
-
"@paraspell/
|
|
30
|
-
"@paraspell/
|
|
31
|
-
"@paraspell/
|
|
29
|
+
"@paraspell/assets": "11.12.0",
|
|
30
|
+
"@paraspell/sdk-common": "11.12.0",
|
|
31
|
+
"@paraspell/pallets": "11.12.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/plugin-syntax-import-attributes": "^7.27.1",
|