@paraspell/sdk-core 11.8.2 → 11.8.4
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 +78 -71
- package/dist/index.d.ts +9 -5
- package/dist/index.mjs +78 -71
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -838,8 +838,8 @@ var computeOverridenAmount = function computeOverridenAmount(options, increaseAm
|
|
|
838
838
|
api = options.api;
|
|
839
839
|
var amount = options.currency.amount;
|
|
840
840
|
var config = api.getConfig();
|
|
841
|
-
if (isConfig(config) && config.abstractDecimals) {
|
|
842
|
-
return
|
|
841
|
+
if (isConfig(config) && config.abstractDecimals && typeof amount !== 'bigint') {
|
|
842
|
+
return Number(increaseAmount) + Number(amount);
|
|
843
843
|
} else {
|
|
844
844
|
assertToIsString(to);
|
|
845
845
|
var asset = assets.findAssetInfoOrThrow(from, currency, to);
|
|
@@ -4481,13 +4481,15 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4481
4481
|
case 1:
|
|
4482
4482
|
_fee = _context3.v;
|
|
4483
4483
|
_context3.n = 2;
|
|
4484
|
-
return isSufficientDestination(api, destination, address,
|
|
4484
|
+
return isSufficientDestination(api, destination, address, currency.amount, asset, _fee);
|
|
4485
4485
|
case 2:
|
|
4486
4486
|
sufficient = _context3.v;
|
|
4487
4487
|
return _context3.a(2, {
|
|
4488
4488
|
fee: _fee,
|
|
4489
4489
|
feeType: 'paymentInfo',
|
|
4490
|
-
sufficient:
|
|
4490
|
+
sufficient: sufficient,
|
|
4491
|
+
asset: asset,
|
|
4492
|
+
currency: asset.symbol
|
|
4491
4493
|
});
|
|
4492
4494
|
case 3:
|
|
4493
4495
|
_context3.n = 4;
|
|
@@ -4500,7 +4502,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4500
4502
|
asset: asset,
|
|
4501
4503
|
originFee: originFee,
|
|
4502
4504
|
feeAsset: resolvedFeeAsset,
|
|
4503
|
-
amount:
|
|
4505
|
+
amount: currency.amount < 2n ? 2n : currency.amount
|
|
4504
4506
|
});
|
|
4505
4507
|
case 4:
|
|
4506
4508
|
dryRunResult = _context3.v;
|
|
@@ -4524,7 +4526,9 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4524
4526
|
fee: _fee2,
|
|
4525
4527
|
feeType: 'paymentInfo',
|
|
4526
4528
|
dryRunError: dryRunResult.failureReason,
|
|
4527
|
-
sufficient: false
|
|
4529
|
+
sufficient: false,
|
|
4530
|
+
asset: asset,
|
|
4531
|
+
currency: asset.symbol
|
|
4528
4532
|
});
|
|
4529
4533
|
case 7:
|
|
4530
4534
|
fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
|
|
@@ -4533,7 +4537,9 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4533
4537
|
feeType: 'dryRun',
|
|
4534
4538
|
sufficient: true,
|
|
4535
4539
|
forwardedXcms: newForwardedXcms,
|
|
4536
|
-
destParaId: destParaId
|
|
4540
|
+
destParaId: destParaId,
|
|
4541
|
+
asset: asset,
|
|
4542
|
+
currency: asset.symbol
|
|
4537
4543
|
});
|
|
4538
4544
|
}
|
|
4539
4545
|
}, _callee3);
|
|
@@ -5125,14 +5131,11 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
|
5125
5131
|
};
|
|
5126
5132
|
}();
|
|
5127
5133
|
|
|
5128
|
-
function
|
|
5129
|
-
|
|
5130
|
-
}
|
|
5131
|
-
function _traverseXcmHops() {
|
|
5132
|
-
_traverseXcmHops = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(config) {
|
|
5134
|
+
var traverseXcmHops = /*#__PURE__*/function () {
|
|
5135
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config) {
|
|
5133
5136
|
var api, origin, destination, currency, initialForwardedXcms, initialDestParaId, swapConfig, processHop, shouldContinue, extractNextHopData, assetHubChain, bridgeHubChain, currentOrigin, forwardedXcms, nextParaId, asset, currentAsset, hasPassedExchange, hops, intermediateResults, destinationResult, nextChain, hopApi, isDestination, isAssetHub, isBridgeHub, hopResult, _extractNextHopData, newXcms, destParaId;
|
|
5134
|
-
return _regenerator().w(function (
|
|
5135
|
-
while (1) switch (
|
|
5137
|
+
return _regenerator().w(function (_context) {
|
|
5138
|
+
while (1) switch (_context.p = _context.n) {
|
|
5136
5139
|
case 0:
|
|
5137
5140
|
api = config.api, origin = config.origin, destination = config.destination, currency = config.currency, initialForwardedXcms = config.initialForwardedXcms, initialDestParaId = config.initialDestParaId, swapConfig = config.swapConfig, processHop = config.processHop, shouldContinue = config.shouldContinue, extractNextHopData = config.extractNextHopData;
|
|
5138
5141
|
assetHubChain = "AssetHub".concat(getRelayChainOf(origin));
|
|
@@ -5147,19 +5150,19 @@ function _traverseXcmHops() {
|
|
|
5147
5150
|
intermediateResults = {};
|
|
5148
5151
|
case 1:
|
|
5149
5152
|
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)) {
|
|
5150
|
-
|
|
5153
|
+
_context.n = 10;
|
|
5151
5154
|
break;
|
|
5152
5155
|
}
|
|
5153
5156
|
nextChain = getTChain(nextParaId, getRelayChainOf(origin));
|
|
5154
5157
|
if (nextChain) {
|
|
5155
|
-
|
|
5158
|
+
_context.n = 2;
|
|
5156
5159
|
break;
|
|
5157
5160
|
}
|
|
5158
5161
|
throw new InvalidParameterError("Unable to find TChain for paraId ".concat(nextParaId));
|
|
5159
5162
|
case 2:
|
|
5160
5163
|
hopApi = api.clone();
|
|
5161
|
-
|
|
5162
|
-
|
|
5164
|
+
_context.p = 3;
|
|
5165
|
+
_context.n = 4;
|
|
5163
5166
|
return hopApi.init(nextChain, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
5164
5167
|
case 4:
|
|
5165
5168
|
// true if this hop should be treated as the destination
|
|
@@ -5168,7 +5171,7 @@ function _traverseXcmHops() {
|
|
|
5168
5171
|
isDestination = nextChain === destination && (!swapConfig || hasPassedExchange || nextChain === swapConfig.exchangeChain);
|
|
5169
5172
|
isAssetHub = nextChain === assetHubChain;
|
|
5170
5173
|
isBridgeHub = nextChain === bridgeHubChain;
|
|
5171
|
-
|
|
5174
|
+
_context.n = 5;
|
|
5172
5175
|
return processHop({
|
|
5173
5176
|
api: hopApi,
|
|
5174
5177
|
currentChain: nextChain,
|
|
@@ -5181,7 +5184,7 @@ function _traverseXcmHops() {
|
|
|
5181
5184
|
isBridgeHub: isBridgeHub
|
|
5182
5185
|
});
|
|
5183
5186
|
case 5:
|
|
5184
|
-
hopResult =
|
|
5187
|
+
hopResult = _context.v;
|
|
5185
5188
|
if (!isDestination) {
|
|
5186
5189
|
hops.push({
|
|
5187
5190
|
chain: nextChain,
|
|
@@ -5196,10 +5199,10 @@ function _traverseXcmHops() {
|
|
|
5196
5199
|
intermediateResults.bridgeHub = hopResult;
|
|
5197
5200
|
}
|
|
5198
5201
|
if (shouldContinue(hopResult)) {
|
|
5199
|
-
|
|
5202
|
+
_context.n = 6;
|
|
5200
5203
|
break;
|
|
5201
5204
|
}
|
|
5202
|
-
return
|
|
5205
|
+
return _context.a(3, 10);
|
|
5203
5206
|
case 6:
|
|
5204
5207
|
// Update state for next iteration
|
|
5205
5208
|
if (swapConfig && nextChain === swapConfig.exchangeChain) {
|
|
@@ -5211,16 +5214,16 @@ function _traverseXcmHops() {
|
|
|
5211
5214
|
nextParaId = destParaId;
|
|
5212
5215
|
currentOrigin = nextChain;
|
|
5213
5216
|
case 7:
|
|
5214
|
-
|
|
5215
|
-
|
|
5217
|
+
_context.p = 7;
|
|
5218
|
+
_context.n = 8;
|
|
5216
5219
|
return hopApi.disconnect();
|
|
5217
5220
|
case 8:
|
|
5218
|
-
return
|
|
5221
|
+
return _context.f(7);
|
|
5219
5222
|
case 9:
|
|
5220
|
-
|
|
5223
|
+
_context.n = 1;
|
|
5221
5224
|
break;
|
|
5222
5225
|
case 10:
|
|
5223
|
-
return
|
|
5226
|
+
return _context.a(2, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
5224
5227
|
hops: hops
|
|
5225
5228
|
}, intermediateResults.assetHub && {
|
|
5226
5229
|
assetHub: intermediateResults.assetHub
|
|
@@ -5232,40 +5235,42 @@ function _traverseXcmHops() {
|
|
|
5232
5235
|
lastProcessedChain: currentOrigin
|
|
5233
5236
|
}));
|
|
5234
5237
|
}
|
|
5235
|
-
},
|
|
5238
|
+
}, _callee, null, [[3,, 7, 9]]);
|
|
5236
5239
|
}));
|
|
5237
|
-
return
|
|
5238
|
-
|
|
5240
|
+
return function traverseXcmHops(_x) {
|
|
5241
|
+
return _ref.apply(this, arguments);
|
|
5242
|
+
};
|
|
5243
|
+
}();
|
|
5239
5244
|
var addEthereumBridgeFees = /*#__PURE__*/function () {
|
|
5240
|
-
var
|
|
5245
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, bridgeHubResult, destination, assetHubChain) {
|
|
5241
5246
|
var ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee;
|
|
5242
|
-
return _regenerator().w(function (
|
|
5243
|
-
while (1) switch (
|
|
5247
|
+
return _regenerator().w(function (_context2) {
|
|
5248
|
+
while (1) switch (_context2.n) {
|
|
5244
5249
|
case 0:
|
|
5245
5250
|
if (!(!bridgeHubResult || !('fee' in bridgeHubResult) || destination !== 'Ethereum')) {
|
|
5246
|
-
|
|
5251
|
+
_context2.n = 1;
|
|
5247
5252
|
break;
|
|
5248
5253
|
}
|
|
5249
|
-
return
|
|
5254
|
+
return _context2.a(2, bridgeHubResult);
|
|
5250
5255
|
case 1:
|
|
5251
5256
|
ahApi = api.clone();
|
|
5252
|
-
|
|
5257
|
+
_context2.n = 2;
|
|
5253
5258
|
return ahApi.init(assetHubChain, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
5254
5259
|
case 2:
|
|
5255
|
-
|
|
5260
|
+
_context2.n = 3;
|
|
5256
5261
|
return getParaEthTransferFees(ahApi);
|
|
5257
5262
|
case 3:
|
|
5258
|
-
_yield$getParaEthTran =
|
|
5263
|
+
_yield$getParaEthTran = _context2.v;
|
|
5259
5264
|
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 1);
|
|
5260
5265
|
bridgeFee = _yield$getParaEthTran2[0];
|
|
5261
|
-
return
|
|
5266
|
+
return _context2.a(2, _objectSpread2(_objectSpread2({}, bridgeHubResult), {}, {
|
|
5262
5267
|
fee: bridgeHubResult.fee + bridgeFee
|
|
5263
5268
|
}));
|
|
5264
5269
|
}
|
|
5265
|
-
},
|
|
5270
|
+
}, _callee2);
|
|
5266
5271
|
}));
|
|
5267
5272
|
return function addEthereumBridgeFees(_x2, _x3, _x4, _x5) {
|
|
5268
|
-
return
|
|
5273
|
+
return _ref2.apply(this, arguments);
|
|
5269
5274
|
};
|
|
5270
5275
|
}();
|
|
5271
5276
|
|
|
@@ -5315,6 +5320,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5315
5320
|
return api.getDryRunCall({
|
|
5316
5321
|
tx: tx,
|
|
5317
5322
|
chain: origin,
|
|
5323
|
+
destination: destination,
|
|
5318
5324
|
address: senderAddress,
|
|
5319
5325
|
asset: _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
5320
5326
|
amount: amount
|
|
@@ -5344,8 +5350,8 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5344
5350
|
while (1) switch (_context.n) {
|
|
5345
5351
|
case 0:
|
|
5346
5352
|
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange, isDestination = params.isDestination;
|
|
5347
|
-
if (
|
|
5348
|
-
hopAsset = assets.findNativeAssetInfoOrThrow(currentChain);
|
|
5353
|
+
if (asset.location && asset.location.parents === sdkCommon.Parents.TWO) {
|
|
5354
|
+
hopAsset = assets.findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
|
|
5349
5355
|
} else if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
5350
5356
|
hopAsset = assets.findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
5351
5357
|
} else if (isDestination) {
|
|
@@ -5371,7 +5377,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5371
5377
|
xcm: forwardedXcms[1][0],
|
|
5372
5378
|
chain: currentChain,
|
|
5373
5379
|
origin: currentOrigin,
|
|
5374
|
-
asset:
|
|
5380
|
+
asset: hopAsset,
|
|
5375
5381
|
feeAsset: resolvedFeeAsset,
|
|
5376
5382
|
originFee: originDryRun.fee,
|
|
5377
5383
|
amount: amount
|
|
@@ -5787,6 +5793,10 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
|
|
|
5787
5793
|
// First dry run with dummy fees to extract actual fees
|
|
5788
5794
|
_context3.n = 2;
|
|
5789
5795
|
return createXcmAndCall(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
|
|
5796
|
+
assetInfoTo: _objectSpread2(_objectSpread2({}, assetTo), {}, {
|
|
5797
|
+
// Use half of the amountOut in initial dryRun to prevent NoDeal error in dry run
|
|
5798
|
+
amount: assetTo.amount / 2n
|
|
5799
|
+
}),
|
|
5790
5800
|
fees: fees
|
|
5791
5801
|
}));
|
|
5792
5802
|
case 2:
|
|
@@ -10100,7 +10110,7 @@ var createMintTxs = function createMintTxs(chain, asset, balance, address, api)
|
|
|
10100
10110
|
var nativePallet = pallets.getNativeAssetsPallet(chain);
|
|
10101
10111
|
var otherPallets = pallets.getOtherAssetsPallets(chain);
|
|
10102
10112
|
var isMainNativeAsset = assets.isSymbolMatch(asset.symbol, assets.getNativeAssetSymbol(chain));
|
|
10103
|
-
var pallet = assets.isForeignAsset(asset) || !isMainNativeAsset ? pickOtherPallet(asset, otherPallets) : nativePallet;
|
|
10113
|
+
var pallet = assets.isForeignAsset(asset) && chain !== 'Mythos' || !isMainNativeAsset ? pickOtherPallet(asset, otherPallets) : nativePallet;
|
|
10104
10114
|
var palletInstance = getPalletInstance(pallet);
|
|
10105
10115
|
return palletInstance.mint(address, asset, balance, chain, api);
|
|
10106
10116
|
};
|
|
@@ -10461,6 +10471,7 @@ var getOriginXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10461
10471
|
return api.getDryRunCall({
|
|
10462
10472
|
tx: tx,
|
|
10463
10473
|
chain: origin,
|
|
10474
|
+
destination: destination,
|
|
10464
10475
|
address: senderAddress,
|
|
10465
10476
|
asset: _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
10466
10477
|
amount: amount
|
|
@@ -10897,11 +10908,22 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10897
10908
|
case 7:
|
|
10898
10909
|
processHop = /*#__PURE__*/function () {
|
|
10899
10910
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
10900
|
-
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange,
|
|
10911
|
+
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset, hopResult;
|
|
10901
10912
|
return _regenerator().w(function (_context) {
|
|
10902
10913
|
while (1) switch (_context.n) {
|
|
10903
10914
|
case 0:
|
|
10904
10915
|
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange;
|
|
10916
|
+
if (!(currentAsset.location && currentAsset.location.parents === sdkCommon.Parents.TWO)) {
|
|
10917
|
+
if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
10918
|
+
hopAsset = assets.findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
10919
|
+
} else if (destination === currentChain) {
|
|
10920
|
+
hopAsset = assets.findAssetOnDestOrThrow(origin, currentChain, currency);
|
|
10921
|
+
} else {
|
|
10922
|
+
hopAsset = currentAsset;
|
|
10923
|
+
}
|
|
10924
|
+
} else {
|
|
10925
|
+
hopAsset = assets.findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
|
|
10926
|
+
}
|
|
10905
10927
|
_context.n = 1;
|
|
10906
10928
|
return getDestXcmFee({
|
|
10907
10929
|
api: hopApi,
|
|
@@ -10914,7 +10936,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10914
10936
|
}),
|
|
10915
10937
|
address: address,
|
|
10916
10938
|
senderAddress: senderAddress,
|
|
10917
|
-
asset:
|
|
10939
|
+
asset: hopAsset,
|
|
10918
10940
|
feeAsset: feeAsset,
|
|
10919
10941
|
tx: tx,
|
|
10920
10942
|
originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
|
|
@@ -10924,21 +10946,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10924
10946
|
});
|
|
10925
10947
|
case 1:
|
|
10926
10948
|
hopResult = _context.v;
|
|
10927
|
-
|
|
10928
|
-
if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
10929
|
-
hopAsset = assets.findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
10930
|
-
} else if (destination === currentChain) {
|
|
10931
|
-
hopAsset = assets.findAssetOnDestOrThrow(origin, currentChain, currency);
|
|
10932
|
-
} else {
|
|
10933
|
-
hopAsset = asset;
|
|
10934
|
-
}
|
|
10935
|
-
} else {
|
|
10936
|
-
hopAsset = assets.findNativeAssetInfoOrThrow(currentChain);
|
|
10937
|
-
}
|
|
10938
|
-
return _context.a(2, _objectSpread2(_objectSpread2({}, hopResult), {}, {
|
|
10939
|
-
currency: hopAsset.symbol,
|
|
10940
|
-
asset: hopAsset
|
|
10941
|
-
}));
|
|
10949
|
+
return _context.a(2, hopResult);
|
|
10942
10950
|
}
|
|
10943
10951
|
}, _callee);
|
|
10944
10952
|
}));
|
|
@@ -10992,10 +11000,6 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10992
11000
|
}
|
|
10993
11001
|
// We failed before reaching destination, use fallback
|
|
10994
11002
|
_destApi = api.clone();
|
|
10995
|
-
if (!(destination !== 'Ethereum')) {
|
|
10996
|
-
_context2.n = 10;
|
|
10997
|
-
break;
|
|
10998
|
-
}
|
|
10999
11003
|
_context2.n = 10;
|
|
11000
11004
|
return _destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
11001
11005
|
case 10:
|
|
@@ -11254,7 +11258,7 @@ var getXcmFeeEstimate = /*#__PURE__*/function () {
|
|
|
11254
11258
|
case 3:
|
|
11255
11259
|
originSufficient = _context.v;
|
|
11256
11260
|
_context.n = 4;
|
|
11257
|
-
return isSufficientDestination(destApi, destination, address,
|
|
11261
|
+
return isSufficientDestination(destApi, destination, address, currency.amount, originAsset, fixedDestinationFee);
|
|
11258
11262
|
case 4:
|
|
11259
11263
|
_destinationSufficient = _context.v;
|
|
11260
11264
|
return _context.a(2, {
|
|
@@ -12352,12 +12356,14 @@ var createCustomXcm = function createCustomXcm(_ref, isDotAsset) {
|
|
|
12352
12356
|
return depositInstruction;
|
|
12353
12357
|
};
|
|
12354
12358
|
|
|
12355
|
-
var createRefundInstruction = function createRefundInstruction(api, senderAddress, version) {
|
|
12359
|
+
var createRefundInstruction = function createRefundInstruction(api, senderAddress, version, assetCount) {
|
|
12356
12360
|
return {
|
|
12357
12361
|
SetAppendix: [{
|
|
12358
12362
|
DepositAsset: {
|
|
12359
12363
|
assets: {
|
|
12360
|
-
Wild:
|
|
12364
|
+
Wild: {
|
|
12365
|
+
AllCounted: assetCount
|
|
12366
|
+
}
|
|
12361
12367
|
},
|
|
12362
12368
|
beneficiary: createBeneficiaryLocation({
|
|
12363
12369
|
api: api,
|
|
@@ -12382,7 +12388,7 @@ var buildAssets = function buildAssets(chain, asset, feeAmount, isDotAsset, vers
|
|
|
12382
12388
|
*/
|
|
12383
12389
|
var createTypeAndThenCall = /*#__PURE__*/function () {
|
|
12384
12390
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options) {
|
|
12385
|
-
var api, senderAddress, version, context, assetInfo, isDotAsset, customXcm, refundInstruction, fees, finalCustomXcm, totalFee, assets;
|
|
12391
|
+
var api, senderAddress, version, context, assetInfo, isDotAsset, customXcm, assetCount, refundInstruction, fees, finalCustomXcm, totalFee, assets;
|
|
12386
12392
|
return _regenerator().w(function (_context) {
|
|
12387
12393
|
while (1) switch (_context.n) {
|
|
12388
12394
|
case 0:
|
|
@@ -12403,7 +12409,8 @@ var createTypeAndThenCall = /*#__PURE__*/function () {
|
|
|
12403
12409
|
}
|
|
12404
12410
|
});
|
|
12405
12411
|
customXcm = createCustomXcm(context, isDotAsset);
|
|
12406
|
-
|
|
12412
|
+
assetCount = isDotAsset ? 1 : 2;
|
|
12413
|
+
refundInstruction = senderAddress ? createRefundInstruction(api, senderAddress, version, assetCount) : null;
|
|
12407
12414
|
_context.n = 2;
|
|
12408
12415
|
return computeAllFees(context, customXcm, isDotAsset, refundInstruction);
|
|
12409
12416
|
case 2:
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _paraspell_sdk_common from '@paraspell/sdk-common';
|
|
2
|
-
import { TLocation, TSubstrateChain,
|
|
2
|
+
import { TChain, TLocation, TSubstrateChain, Version, TRelaychain, TParachain, TExternalChain, TJunction, TJunctions } from '@paraspell/sdk-common';
|
|
3
3
|
export * from '@paraspell/sdk-common';
|
|
4
4
|
import * as _paraspell_assets from '@paraspell/assets';
|
|
5
5
|
import { TCurrencyInputWithAmount, TCurrencyInput, WithAmount, TAssetInfo, TAsset, TAssetWithFee, WithComplexAmount, TCurrencyCore, TAmount, TAssetWithLocation, TForeignAssetWithId, TForeignAssetInfo } from '@paraspell/assets';
|
|
@@ -635,7 +635,7 @@ type TXcmFeeHopResult = {
|
|
|
635
635
|
asset: TAssetInfo;
|
|
636
636
|
};
|
|
637
637
|
type TConditionalXcmFeeDetail<TDisableFallback extends boolean> = TDisableFallback extends false ? TXcmFeeDetailWithFallback : TXcmFeeDetail;
|
|
638
|
-
type TDestXcmFeeDetail<TDisableFallback extends boolean> =
|
|
638
|
+
type TDestXcmFeeDetail<TDisableFallback extends boolean> = TConditionalXcmFeeDetail<TDisableFallback> & {
|
|
639
639
|
forwardedXcms?: any;
|
|
640
640
|
destParaId?: number;
|
|
641
641
|
};
|
|
@@ -978,6 +978,10 @@ type TDryRunCallBaseOptions<TRes> = {
|
|
|
978
978
|
* The chain to dry-run on
|
|
979
979
|
*/
|
|
980
980
|
chain: TSubstrateChain;
|
|
981
|
+
/**
|
|
982
|
+
* The destination chain
|
|
983
|
+
*/
|
|
984
|
+
destination: TDestination;
|
|
981
985
|
/**
|
|
982
986
|
* The address to dry-run with
|
|
983
987
|
*/
|
|
@@ -990,7 +994,7 @@ type TDryRunCallBaseOptions<TRes> = {
|
|
|
990
994
|
bypassOptions?: TBypassOptions;
|
|
991
995
|
feeAsset?: TAssetInfo;
|
|
992
996
|
};
|
|
993
|
-
type TDryRunBypassOptions<TApi, TRes> = WithApi<Omit<TDryRunCallBaseOptions<TRes>, 'useRootOrigin'>, TApi, TRes>;
|
|
997
|
+
type TDryRunBypassOptions<TApi, TRes> = WithApi<Omit<TDryRunCallBaseOptions<TRes>, 'useRootOrigin' | 'destination'>, TApi, TRes>;
|
|
994
998
|
type TDryRunCallOptions<TApi, TRes> = WithApi<TDryRunCallBaseOptions<TRes>, TApi, TRes>;
|
|
995
999
|
type TDryRunXcmBaseOptions<TRes> = {
|
|
996
1000
|
originLocation: any;
|
|
@@ -2119,7 +2123,7 @@ declare const dryRunInternal: <TApi, TRes>(options: TDryRunOptions<TApi, TRes>)
|
|
|
2119
2123
|
|
|
2120
2124
|
declare const dryRunOrigin: <TApi, TRes>(options: TDryRunCallOptions<TApi, TRes>) => Promise<TDryRunChainResult>;
|
|
2121
2125
|
|
|
2122
|
-
declare
|
|
2126
|
+
declare const traverseXcmHops: <TApi, TRes, THopResult>(config: HopTraversalConfig<TApi, TRes, THopResult>) => Promise<HopTraversalResult<THopResult>>;
|
|
2123
2127
|
declare const addEthereumBridgeFees: <TApi, TRes, TResult extends {
|
|
2124
2128
|
fee?: bigint;
|
|
2125
2129
|
}>(api: IPolkadotApi<TApi, TRes>, bridgeHubResult: TResult | undefined, destination: TChain, assetHubChain: TSubstrateChain) => Promise<TResult | undefined>;
|
|
@@ -2190,7 +2194,7 @@ declare const maybeOverrideAsset: (version: Version, amount: bigint, asset: TAss
|
|
|
2190
2194
|
|
|
2191
2195
|
declare const sortAssets: (assets: TAsset[]) => TAsset[];
|
|
2192
2196
|
|
|
2193
|
-
declare const computeOverridenAmount: <TApi, TRes>(options: TCreateTxsOptions<TApi, TRes>, increaseAmount: string) => bigint;
|
|
2197
|
+
declare const computeOverridenAmount: <TApi, TRes>(options: TCreateTxsOptions<TApi, TRes>, increaseAmount: string) => number | bigint;
|
|
2194
2198
|
declare const overrideTxAmount: <TApi, TRes>(options: TCreateTxsOptions<TApi, TRes>, builder: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>, amount: string) => Promise<TRes>;
|
|
2195
2199
|
declare const createTx: <TApi, TRes>(options: TCreateTxsOptions<TApi, TRes>, builder: GeneralBuilder<TApi, TRes, TSendBaseOptionsWithSenderAddress>, amount: string | undefined) => Promise<TRes>;
|
|
2196
2200
|
|
package/dist/index.mjs
CHANGED
|
@@ -839,8 +839,8 @@ var computeOverridenAmount = function computeOverridenAmount(options, increaseAm
|
|
|
839
839
|
api = options.api;
|
|
840
840
|
var amount = options.currency.amount;
|
|
841
841
|
var config = api.getConfig();
|
|
842
|
-
if (isConfig(config) && config.abstractDecimals) {
|
|
843
|
-
return
|
|
842
|
+
if (isConfig(config) && config.abstractDecimals && typeof amount !== 'bigint') {
|
|
843
|
+
return Number(increaseAmount) + Number(amount);
|
|
844
844
|
} else {
|
|
845
845
|
assertToIsString(to);
|
|
846
846
|
var asset = findAssetInfoOrThrow(from, currency, to);
|
|
@@ -4482,13 +4482,15 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4482
4482
|
case 1:
|
|
4483
4483
|
_fee = _context3.v;
|
|
4484
4484
|
_context3.n = 2;
|
|
4485
|
-
return isSufficientDestination(api, destination, address,
|
|
4485
|
+
return isSufficientDestination(api, destination, address, currency.amount, asset, _fee);
|
|
4486
4486
|
case 2:
|
|
4487
4487
|
sufficient = _context3.v;
|
|
4488
4488
|
return _context3.a(2, {
|
|
4489
4489
|
fee: _fee,
|
|
4490
4490
|
feeType: 'paymentInfo',
|
|
4491
|
-
sufficient:
|
|
4491
|
+
sufficient: sufficient,
|
|
4492
|
+
asset: asset,
|
|
4493
|
+
currency: asset.symbol
|
|
4492
4494
|
});
|
|
4493
4495
|
case 3:
|
|
4494
4496
|
_context3.n = 4;
|
|
@@ -4501,7 +4503,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4501
4503
|
asset: asset,
|
|
4502
4504
|
originFee: originFee,
|
|
4503
4505
|
feeAsset: resolvedFeeAsset,
|
|
4504
|
-
amount:
|
|
4506
|
+
amount: currency.amount < 2n ? 2n : currency.amount
|
|
4505
4507
|
});
|
|
4506
4508
|
case 4:
|
|
4507
4509
|
dryRunResult = _context3.v;
|
|
@@ -4525,7 +4527,9 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4525
4527
|
fee: _fee2,
|
|
4526
4528
|
feeType: 'paymentInfo',
|
|
4527
4529
|
dryRunError: dryRunResult.failureReason,
|
|
4528
|
-
sufficient: false
|
|
4530
|
+
sufficient: false,
|
|
4531
|
+
asset: asset,
|
|
4532
|
+
currency: asset.symbol
|
|
4529
4533
|
});
|
|
4530
4534
|
case 7:
|
|
4531
4535
|
fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
|
|
@@ -4534,7 +4538,9 @@ var getDestXcmFee = /*#__PURE__*/function () {
|
|
|
4534
4538
|
feeType: 'dryRun',
|
|
4535
4539
|
sufficient: true,
|
|
4536
4540
|
forwardedXcms: newForwardedXcms,
|
|
4537
|
-
destParaId: destParaId
|
|
4541
|
+
destParaId: destParaId,
|
|
4542
|
+
asset: asset,
|
|
4543
|
+
currency: asset.symbol
|
|
4538
4544
|
});
|
|
4539
4545
|
}
|
|
4540
4546
|
}, _callee3);
|
|
@@ -5126,14 +5132,11 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
|
|
|
5126
5132
|
};
|
|
5127
5133
|
}();
|
|
5128
5134
|
|
|
5129
|
-
function
|
|
5130
|
-
|
|
5131
|
-
}
|
|
5132
|
-
function _traverseXcmHops() {
|
|
5133
|
-
_traverseXcmHops = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(config) {
|
|
5135
|
+
var traverseXcmHops = /*#__PURE__*/function () {
|
|
5136
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config) {
|
|
5134
5137
|
var api, origin, destination, currency, initialForwardedXcms, initialDestParaId, swapConfig, processHop, shouldContinue, extractNextHopData, assetHubChain, bridgeHubChain, currentOrigin, forwardedXcms, nextParaId, asset, currentAsset, hasPassedExchange, hops, intermediateResults, destinationResult, nextChain, hopApi, isDestination, isAssetHub, isBridgeHub, hopResult, _extractNextHopData, newXcms, destParaId;
|
|
5135
|
-
return _regenerator().w(function (
|
|
5136
|
-
while (1) switch (
|
|
5138
|
+
return _regenerator().w(function (_context) {
|
|
5139
|
+
while (1) switch (_context.p = _context.n) {
|
|
5137
5140
|
case 0:
|
|
5138
5141
|
api = config.api, origin = config.origin, destination = config.destination, currency = config.currency, initialForwardedXcms = config.initialForwardedXcms, initialDestParaId = config.initialDestParaId, swapConfig = config.swapConfig, processHop = config.processHop, shouldContinue = config.shouldContinue, extractNextHopData = config.extractNextHopData;
|
|
5139
5142
|
assetHubChain = "AssetHub".concat(getRelayChainOf(origin));
|
|
@@ -5148,19 +5151,19 @@ function _traverseXcmHops() {
|
|
|
5148
5151
|
intermediateResults = {};
|
|
5149
5152
|
case 1:
|
|
5150
5153
|
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)) {
|
|
5151
|
-
|
|
5154
|
+
_context.n = 10;
|
|
5152
5155
|
break;
|
|
5153
5156
|
}
|
|
5154
5157
|
nextChain = getTChain(nextParaId, getRelayChainOf(origin));
|
|
5155
5158
|
if (nextChain) {
|
|
5156
|
-
|
|
5159
|
+
_context.n = 2;
|
|
5157
5160
|
break;
|
|
5158
5161
|
}
|
|
5159
5162
|
throw new InvalidParameterError("Unable to find TChain for paraId ".concat(nextParaId));
|
|
5160
5163
|
case 2:
|
|
5161
5164
|
hopApi = api.clone();
|
|
5162
|
-
|
|
5163
|
-
|
|
5165
|
+
_context.p = 3;
|
|
5166
|
+
_context.n = 4;
|
|
5164
5167
|
return hopApi.init(nextChain, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
5165
5168
|
case 4:
|
|
5166
5169
|
// true if this hop should be treated as the destination
|
|
@@ -5169,7 +5172,7 @@ function _traverseXcmHops() {
|
|
|
5169
5172
|
isDestination = nextChain === destination && (!swapConfig || hasPassedExchange || nextChain === swapConfig.exchangeChain);
|
|
5170
5173
|
isAssetHub = nextChain === assetHubChain;
|
|
5171
5174
|
isBridgeHub = nextChain === bridgeHubChain;
|
|
5172
|
-
|
|
5175
|
+
_context.n = 5;
|
|
5173
5176
|
return processHop({
|
|
5174
5177
|
api: hopApi,
|
|
5175
5178
|
currentChain: nextChain,
|
|
@@ -5182,7 +5185,7 @@ function _traverseXcmHops() {
|
|
|
5182
5185
|
isBridgeHub: isBridgeHub
|
|
5183
5186
|
});
|
|
5184
5187
|
case 5:
|
|
5185
|
-
hopResult =
|
|
5188
|
+
hopResult = _context.v;
|
|
5186
5189
|
if (!isDestination) {
|
|
5187
5190
|
hops.push({
|
|
5188
5191
|
chain: nextChain,
|
|
@@ -5197,10 +5200,10 @@ function _traverseXcmHops() {
|
|
|
5197
5200
|
intermediateResults.bridgeHub = hopResult;
|
|
5198
5201
|
}
|
|
5199
5202
|
if (shouldContinue(hopResult)) {
|
|
5200
|
-
|
|
5203
|
+
_context.n = 6;
|
|
5201
5204
|
break;
|
|
5202
5205
|
}
|
|
5203
|
-
return
|
|
5206
|
+
return _context.a(3, 10);
|
|
5204
5207
|
case 6:
|
|
5205
5208
|
// Update state for next iteration
|
|
5206
5209
|
if (swapConfig && nextChain === swapConfig.exchangeChain) {
|
|
@@ -5212,16 +5215,16 @@ function _traverseXcmHops() {
|
|
|
5212
5215
|
nextParaId = destParaId;
|
|
5213
5216
|
currentOrigin = nextChain;
|
|
5214
5217
|
case 7:
|
|
5215
|
-
|
|
5216
|
-
|
|
5218
|
+
_context.p = 7;
|
|
5219
|
+
_context.n = 8;
|
|
5217
5220
|
return hopApi.disconnect();
|
|
5218
5221
|
case 8:
|
|
5219
|
-
return
|
|
5222
|
+
return _context.f(7);
|
|
5220
5223
|
case 9:
|
|
5221
|
-
|
|
5224
|
+
_context.n = 1;
|
|
5222
5225
|
break;
|
|
5223
5226
|
case 10:
|
|
5224
|
-
return
|
|
5227
|
+
return _context.a(2, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({
|
|
5225
5228
|
hops: hops
|
|
5226
5229
|
}, intermediateResults.assetHub && {
|
|
5227
5230
|
assetHub: intermediateResults.assetHub
|
|
@@ -5233,40 +5236,42 @@ function _traverseXcmHops() {
|
|
|
5233
5236
|
lastProcessedChain: currentOrigin
|
|
5234
5237
|
}));
|
|
5235
5238
|
}
|
|
5236
|
-
},
|
|
5239
|
+
}, _callee, null, [[3,, 7, 9]]);
|
|
5237
5240
|
}));
|
|
5238
|
-
return
|
|
5239
|
-
|
|
5241
|
+
return function traverseXcmHops(_x) {
|
|
5242
|
+
return _ref.apply(this, arguments);
|
|
5243
|
+
};
|
|
5244
|
+
}();
|
|
5240
5245
|
var addEthereumBridgeFees = /*#__PURE__*/function () {
|
|
5241
|
-
var
|
|
5246
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(api, bridgeHubResult, destination, assetHubChain) {
|
|
5242
5247
|
var ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee;
|
|
5243
|
-
return _regenerator().w(function (
|
|
5244
|
-
while (1) switch (
|
|
5248
|
+
return _regenerator().w(function (_context2) {
|
|
5249
|
+
while (1) switch (_context2.n) {
|
|
5245
5250
|
case 0:
|
|
5246
5251
|
if (!(!bridgeHubResult || !('fee' in bridgeHubResult) || destination !== 'Ethereum')) {
|
|
5247
|
-
|
|
5252
|
+
_context2.n = 1;
|
|
5248
5253
|
break;
|
|
5249
5254
|
}
|
|
5250
|
-
return
|
|
5255
|
+
return _context2.a(2, bridgeHubResult);
|
|
5251
5256
|
case 1:
|
|
5252
5257
|
ahApi = api.clone();
|
|
5253
|
-
|
|
5258
|
+
_context2.n = 2;
|
|
5254
5259
|
return ahApi.init(assetHubChain, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
5255
5260
|
case 2:
|
|
5256
|
-
|
|
5261
|
+
_context2.n = 3;
|
|
5257
5262
|
return getParaEthTransferFees(ahApi);
|
|
5258
5263
|
case 3:
|
|
5259
|
-
_yield$getParaEthTran =
|
|
5264
|
+
_yield$getParaEthTran = _context2.v;
|
|
5260
5265
|
_yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 1);
|
|
5261
5266
|
bridgeFee = _yield$getParaEthTran2[0];
|
|
5262
|
-
return
|
|
5267
|
+
return _context2.a(2, _objectSpread2(_objectSpread2({}, bridgeHubResult), {}, {
|
|
5263
5268
|
fee: bridgeHubResult.fee + bridgeFee
|
|
5264
5269
|
}));
|
|
5265
5270
|
}
|
|
5266
|
-
},
|
|
5271
|
+
}, _callee2);
|
|
5267
5272
|
}));
|
|
5268
5273
|
return function addEthereumBridgeFees(_x2, _x3, _x4, _x5) {
|
|
5269
|
-
return
|
|
5274
|
+
return _ref2.apply(this, arguments);
|
|
5270
5275
|
};
|
|
5271
5276
|
}();
|
|
5272
5277
|
|
|
@@ -5316,6 +5321,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5316
5321
|
return api.getDryRunCall({
|
|
5317
5322
|
tx: tx,
|
|
5318
5323
|
chain: origin,
|
|
5324
|
+
destination: destination,
|
|
5319
5325
|
address: senderAddress,
|
|
5320
5326
|
asset: _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
5321
5327
|
amount: amount
|
|
@@ -5345,8 +5351,8 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5345
5351
|
while (1) switch (_context.n) {
|
|
5346
5352
|
case 0:
|
|
5347
5353
|
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange, isDestination = params.isDestination;
|
|
5348
|
-
if (
|
|
5349
|
-
hopAsset = findNativeAssetInfoOrThrow(currentChain);
|
|
5354
|
+
if (asset.location && asset.location.parents === Parents.TWO) {
|
|
5355
|
+
hopAsset = findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
|
|
5350
5356
|
} else if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
5351
5357
|
hopAsset = findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
5352
5358
|
} else if (isDestination) {
|
|
@@ -5372,7 +5378,7 @@ var dryRunInternal = /*#__PURE__*/function () {
|
|
|
5372
5378
|
xcm: forwardedXcms[1][0],
|
|
5373
5379
|
chain: currentChain,
|
|
5374
5380
|
origin: currentOrigin,
|
|
5375
|
-
asset:
|
|
5381
|
+
asset: hopAsset,
|
|
5376
5382
|
feeAsset: resolvedFeeAsset,
|
|
5377
5383
|
originFee: originDryRun.fee,
|
|
5378
5384
|
amount: amount
|
|
@@ -5788,6 +5794,10 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
|
|
|
5788
5794
|
// First dry run with dummy fees to extract actual fees
|
|
5789
5795
|
_context3.n = 2;
|
|
5790
5796
|
return createXcmAndCall(_objectSpread2(_objectSpread2({}, internalOptions), {}, {
|
|
5797
|
+
assetInfoTo: _objectSpread2(_objectSpread2({}, assetTo), {}, {
|
|
5798
|
+
// Use half of the amountOut in initial dryRun to prevent NoDeal error in dry run
|
|
5799
|
+
amount: assetTo.amount / 2n
|
|
5800
|
+
}),
|
|
5791
5801
|
fees: fees
|
|
5792
5802
|
}));
|
|
5793
5803
|
case 2:
|
|
@@ -10101,7 +10111,7 @@ var createMintTxs = function createMintTxs(chain, asset, balance, address, api)
|
|
|
10101
10111
|
var nativePallet = getNativeAssetsPallet(chain);
|
|
10102
10112
|
var otherPallets = getOtherAssetsPallets(chain);
|
|
10103
10113
|
var isMainNativeAsset = isSymbolMatch(asset.symbol, getNativeAssetSymbol(chain));
|
|
10104
|
-
var pallet = isForeignAsset(asset) || !isMainNativeAsset ? pickOtherPallet(asset, otherPallets) : nativePallet;
|
|
10114
|
+
var pallet = isForeignAsset(asset) && chain !== 'Mythos' || !isMainNativeAsset ? pickOtherPallet(asset, otherPallets) : nativePallet;
|
|
10105
10115
|
var palletInstance = getPalletInstance(pallet);
|
|
10106
10116
|
return palletInstance.mint(address, asset, balance, chain, api);
|
|
10107
10117
|
};
|
|
@@ -10462,6 +10472,7 @@ var getOriginXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10462
10472
|
return api.getDryRunCall({
|
|
10463
10473
|
tx: tx,
|
|
10464
10474
|
chain: origin,
|
|
10475
|
+
destination: destination,
|
|
10465
10476
|
address: senderAddress,
|
|
10466
10477
|
asset: _objectSpread2(_objectSpread2({}, asset), {}, {
|
|
10467
10478
|
amount: amount
|
|
@@ -10898,11 +10909,22 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10898
10909
|
case 7:
|
|
10899
10910
|
processHop = /*#__PURE__*/function () {
|
|
10900
10911
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
|
|
10901
|
-
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange,
|
|
10912
|
+
var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset, hopResult;
|
|
10902
10913
|
return _regenerator().w(function (_context) {
|
|
10903
10914
|
while (1) switch (_context.n) {
|
|
10904
10915
|
case 0:
|
|
10905
10916
|
hopApi = params.api, currentChain = params.currentChain, currentOrigin = params.currentOrigin, currentAsset = params.currentAsset, forwardedXcms = params.forwardedXcms, hasPassedExchange = params.hasPassedExchange;
|
|
10917
|
+
if (!(currentAsset.location && currentAsset.location.parents === Parents.TWO)) {
|
|
10918
|
+
if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
10919
|
+
hopAsset = findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
10920
|
+
} else if (destination === currentChain) {
|
|
10921
|
+
hopAsset = findAssetOnDestOrThrow(origin, currentChain, currency);
|
|
10922
|
+
} else {
|
|
10923
|
+
hopAsset = currentAsset;
|
|
10924
|
+
}
|
|
10925
|
+
} else {
|
|
10926
|
+
hopAsset = findNativeAssetInfoOrThrow(getRelayChainOf(currentChain));
|
|
10927
|
+
}
|
|
10906
10928
|
_context.n = 1;
|
|
10907
10929
|
return getDestXcmFee({
|
|
10908
10930
|
api: hopApi,
|
|
@@ -10915,7 +10937,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10915
10937
|
}),
|
|
10916
10938
|
address: address,
|
|
10917
10939
|
senderAddress: senderAddress,
|
|
10918
|
-
asset:
|
|
10940
|
+
asset: hopAsset,
|
|
10919
10941
|
feeAsset: feeAsset,
|
|
10920
10942
|
tx: tx,
|
|
10921
10943
|
originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
|
|
@@ -10925,21 +10947,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10925
10947
|
});
|
|
10926
10948
|
case 1:
|
|
10927
10949
|
hopResult = _context.v;
|
|
10928
|
-
|
|
10929
|
-
if (hasPassedExchange && swapConfig && currentChain !== swapConfig.exchangeChain) {
|
|
10930
|
-
hopAsset = findAssetOnDestOrThrow(swapConfig.exchangeChain, currentChain, swapConfig.currencyTo);
|
|
10931
|
-
} else if (destination === currentChain) {
|
|
10932
|
-
hopAsset = findAssetOnDestOrThrow(origin, currentChain, currency);
|
|
10933
|
-
} else {
|
|
10934
|
-
hopAsset = asset;
|
|
10935
|
-
}
|
|
10936
|
-
} else {
|
|
10937
|
-
hopAsset = findNativeAssetInfoOrThrow(currentChain);
|
|
10938
|
-
}
|
|
10939
|
-
return _context.a(2, _objectSpread2(_objectSpread2({}, hopResult), {}, {
|
|
10940
|
-
currency: hopAsset.symbol,
|
|
10941
|
-
asset: hopAsset
|
|
10942
|
-
}));
|
|
10950
|
+
return _context.a(2, hopResult);
|
|
10943
10951
|
}
|
|
10944
10952
|
}, _callee);
|
|
10945
10953
|
}));
|
|
@@ -10993,10 +11001,6 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
|
|
|
10993
11001
|
}
|
|
10994
11002
|
// We failed before reaching destination, use fallback
|
|
10995
11003
|
_destApi = api.clone();
|
|
10996
|
-
if (!(destination !== 'Ethereum')) {
|
|
10997
|
-
_context2.n = 10;
|
|
10998
|
-
break;
|
|
10999
|
-
}
|
|
11000
11004
|
_context2.n = 10;
|
|
11001
11005
|
return _destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
|
|
11002
11006
|
case 10:
|
|
@@ -11255,7 +11259,7 @@ var getXcmFeeEstimate = /*#__PURE__*/function () {
|
|
|
11255
11259
|
case 3:
|
|
11256
11260
|
originSufficient = _context.v;
|
|
11257
11261
|
_context.n = 4;
|
|
11258
|
-
return isSufficientDestination(destApi, destination, address,
|
|
11262
|
+
return isSufficientDestination(destApi, destination, address, currency.amount, originAsset, fixedDestinationFee);
|
|
11259
11263
|
case 4:
|
|
11260
11264
|
_destinationSufficient = _context.v;
|
|
11261
11265
|
return _context.a(2, {
|
|
@@ -12353,12 +12357,14 @@ var createCustomXcm = function createCustomXcm(_ref, isDotAsset) {
|
|
|
12353
12357
|
return depositInstruction;
|
|
12354
12358
|
};
|
|
12355
12359
|
|
|
12356
|
-
var createRefundInstruction = function createRefundInstruction(api, senderAddress, version) {
|
|
12360
|
+
var createRefundInstruction = function createRefundInstruction(api, senderAddress, version, assetCount) {
|
|
12357
12361
|
return {
|
|
12358
12362
|
SetAppendix: [{
|
|
12359
12363
|
DepositAsset: {
|
|
12360
12364
|
assets: {
|
|
12361
|
-
Wild:
|
|
12365
|
+
Wild: {
|
|
12366
|
+
AllCounted: assetCount
|
|
12367
|
+
}
|
|
12362
12368
|
},
|
|
12363
12369
|
beneficiary: createBeneficiaryLocation({
|
|
12364
12370
|
api: api,
|
|
@@ -12383,7 +12389,7 @@ var buildAssets = function buildAssets(chain, asset, feeAmount, isDotAsset, vers
|
|
|
12383
12389
|
*/
|
|
12384
12390
|
var createTypeAndThenCall = /*#__PURE__*/function () {
|
|
12385
12391
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options) {
|
|
12386
|
-
var api, senderAddress, version, context, assetInfo, isDotAsset, customXcm, refundInstruction, fees, finalCustomXcm, totalFee, assets;
|
|
12392
|
+
var api, senderAddress, version, context, assetInfo, isDotAsset, customXcm, assetCount, refundInstruction, fees, finalCustomXcm, totalFee, assets;
|
|
12387
12393
|
return _regenerator().w(function (_context) {
|
|
12388
12394
|
while (1) switch (_context.n) {
|
|
12389
12395
|
case 0:
|
|
@@ -12404,7 +12410,8 @@ var createTypeAndThenCall = /*#__PURE__*/function () {
|
|
|
12404
12410
|
}
|
|
12405
12411
|
});
|
|
12406
12412
|
customXcm = createCustomXcm(context, isDotAsset);
|
|
12407
|
-
|
|
12413
|
+
assetCount = isDotAsset ? 1 : 2;
|
|
12414
|
+
refundInstruction = senderAddress ? createRefundInstruction(api, senderAddress, version, assetCount) : null;
|
|
12408
12415
|
_context.n = 2;
|
|
12409
12416
|
return computeAllFees(context, customXcm, isDotAsset, refundInstruction);
|
|
12410
12417
|
case 2:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraspell/sdk-core",
|
|
3
|
-
"version": "11.8.
|
|
3
|
+
"version": "11.8.4",
|
|
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.36.0",
|
|
29
|
-
"@paraspell/assets": "11.8.
|
|
30
|
-
"@paraspell/
|
|
31
|
-
"@paraspell/
|
|
29
|
+
"@paraspell/assets": "11.8.4",
|
|
30
|
+
"@paraspell/sdk-common": "11.8.4",
|
|
31
|
+
"@paraspell/pallets": "11.8.4"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/plugin-syntax-import-attributes": "^7.27.1",
|