@paraspell/sdk-core 11.8.0 → 11.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -832,48 +832,49 @@ var isConfig = function isConfig(value) {
832
832
  Object.keys(value).length < 3 || 'apiOverrides' in value || 'development' in value || 'abstractDecimals' in value || 'xcmFormatCheck' in value);
833
833
  };
834
834
 
835
- var computeOverridenAmount = function computeOverridenAmount(options) {
835
+ var computeOverridenAmount = function computeOverridenAmount(options, increaseAmount) {
836
836
  var from = options.from,
837
837
  to = options.to,
838
838
  currency = options.currency,
839
839
  api = options.api;
840
+ var amount = options.currency.amount;
840
841
  var config = api.getConfig();
841
842
  if (isConfig(config) && config.abstractDecimals) {
842
- return BYPASS_CURRENCY_AMOUNT;
843
+ return BigInt(increaseAmount) + BigInt(amount);
843
844
  } else {
844
845
  assertToIsString(to);
845
846
  var asset = findAssetInfoOrThrow(from, currency, to);
846
- return parseUnits(BYPASS_CURRENCY_AMOUNT, asset.decimals);
847
+ return parseUnits(increaseAmount, asset.decimals) + BigInt(amount);
847
848
  }
848
849
  };
849
- var overrideTxAmount = function overrideTxAmount(options, builder) {
850
+ var overrideTxAmount = function overrideTxAmount(options, builder, amount) {
850
851
  var modifiedBuilder = builder.currency(_objectSpread2(_objectSpread2({}, options.currency), {}, {
851
- amount: computeOverridenAmount(options)
852
+ amount: computeOverridenAmount(options, amount)
852
853
  }));
853
854
  return modifiedBuilder['buildInternal']();
854
855
  };
855
- var createTxs = /*#__PURE__*/function () {
856
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, builder) {
857
- var tx, txBypass;
856
+ var createTx = /*#__PURE__*/function () {
857
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, builder, amount) {
858
858
  return _regenerator().w(function (_context) {
859
859
  while (1) switch (_context.n) {
860
860
  case 0:
861
+ if (!(amount === undefined)) {
862
+ _context.n = 2;
863
+ break;
864
+ }
861
865
  _context.n = 1;
862
866
  return builder['buildInternal']();
863
867
  case 1:
864
- tx = _context.v;
865
- _context.n = 2;
866
- return overrideTxAmount(options, builder);
868
+ return _context.a(2, _context.v);
867
869
  case 2:
868
- txBypass = _context.v;
869
- return _context.a(2, {
870
- tx: tx,
871
- txBypass: txBypass
872
- });
870
+ _context.n = 3;
871
+ return overrideTxAmount(options, builder, amount);
872
+ case 3:
873
+ return _context.a(2, _context.v);
873
874
  }
874
875
  }, _callee);
875
876
  }));
876
- return function createTxs(_x, _x2) {
877
+ return function createTx(_x, _x2, _x3) {
877
878
  return _ref.apply(this, arguments);
878
879
  };
879
880
  }();
@@ -2720,7 +2721,7 @@ var getLocationTokenId = function getLocationTokenId(location, chain) {
2720
2721
  return null;
2721
2722
  };
2722
2723
 
2723
- var computeFeeFromDryRun = function computeFeeFromDryRun(dryRun, chain, _executionFee) {
2724
+ var computeFeeFromDryRun = function computeFeeFromDryRun(dryRun, chain, executionFee) {
2724
2725
  var isFeeAsset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
2725
2726
  // Extract delivery fees from emitted events
2726
2727
  var deliveryFees = [];
@@ -2772,7 +2773,7 @@ var computeFeeFromDryRun = function computeFeeFromDryRun(dryRun, chain, _executi
2772
2773
  }).reduce(function (acc, df) {
2773
2774
  return acc + df.plancks;
2774
2775
  }, 0n);
2775
- return totalDeliveryFees;
2776
+ return totalDeliveryFees + executionFee;
2776
2777
  }
2777
2778
  };
2778
2779
 
@@ -3376,7 +3377,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
3376
3377
  dest: createDestination(version, reserveChain !== null && reserveChain !== void 0 ? reserveChain : chain, destChain, paraIdTo),
3377
3378
  xcm: [{
3378
3379
  BuyExecution: {
3379
- fees: updateAsset(assetLocalizedToDest, amount - (feeAsset ? reserveFee : originFee + reserveFee)),
3380
+ fees: updateAsset(assetLocalizedToDest, reserveFee === 1000n ? amount / 2n : amount - (feeAsset ? reserveFee : originFee + reserveFee)),
3380
3381
  weight_limit: 'Unlimited'
3381
3382
  }
3382
3383
  }].concat(_toConsumableArray(suffixXcm))
@@ -4372,95 +4373,125 @@ var createOriginLocation = function createOriginLocation(origin, destination) {
4372
4373
  };
4373
4374
  };
4374
4375
  var getDestXcmFee = /*#__PURE__*/function () {
4375
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
4376
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
4376
4377
  var api, origin, hopChain, destination, currency, forwardedXcms, asset, address, feeAsset, originFee, tx, disableFallback, swapConfig, resolvedFeeAsset, calcPaymentInfoFee, _fee, sufficient, dryRunResult, _fee2, fee, newForwardedXcms, destParaId;
4377
- return _regenerator().w(function (_context2) {
4378
- while (1) switch (_context2.n) {
4378
+ return _regenerator().w(function (_context3) {
4379
+ while (1) switch (_context3.n) {
4379
4380
  case 0:
4380
4381
  api = options.api, origin = options.origin, hopChain = options.prevChain, destination = options.destination, currency = options.currency, forwardedXcms = options.forwardedXcms, asset = options.asset, address = options.address, feeAsset = options.feeAsset, originFee = options.originFee, tx = options.tx, disableFallback = options.disableFallback, swapConfig = options.swapConfig;
4381
4382
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
4382
4383
  calcPaymentInfoFee = /*#__PURE__*/function () {
4383
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
4384
- var originAsset, amount, _t;
4385
- return _regenerator().w(function (_context) {
4386
- while (1) switch (_context.p = _context.n) {
4384
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
4385
+ var attempt, _t2;
4386
+ return _regenerator().w(function (_context2) {
4387
+ while (1) switch (_context2.p = _context2.n) {
4387
4388
  case 0:
4388
4389
  if (!(destination === 'Ethereum')) {
4389
- _context.n = 1;
4390
+ _context2.n = 1;
4390
4391
  break;
4391
4392
  }
4392
- return _context.a(2, 0n);
4393
+ return _context2.a(2, 0n);
4393
4394
  case 1:
4394
- originAsset = swapConfig !== null && swapConfig !== void 0 && swapConfig.currencyTo ? findAssetInfoOrThrow(swapConfig.exchangeChain, swapConfig.currencyTo, destination) : findAssetInfoOrThrow(origin, currency, destination);
4395
- amount = swapConfig !== null && swapConfig !== void 0 && swapConfig.currencyTo ? swapConfig.amountOut : currency.amount;
4396
- if (!originAsset.location) {
4397
- _context.n = 7;
4398
- break;
4399
- }
4400
- _context.p = 2;
4401
- _context.n = 3;
4402
- return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
4403
- destination: destination
4404
- }), {
4405
- location: originAsset.location,
4406
- amount: amount
4407
- });
4395
+ attempt = /*#__PURE__*/function () {
4396
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, curr, amt) {
4397
+ var assetInfo, _t;
4398
+ return _regenerator().w(function (_context) {
4399
+ while (1) switch (_context.p = _context.n) {
4400
+ case 0:
4401
+ assetInfo = findAssetInfoOrThrow(chain, curr, destination);
4402
+ if (!assetInfo.location) {
4403
+ _context.n = 6;
4404
+ break;
4405
+ }
4406
+ _context.p = 1;
4407
+ _context.n = 2;
4408
+ return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
4409
+ destination: destination
4410
+ }), {
4411
+ location: assetInfo.location,
4412
+ amount: amt
4413
+ });
4414
+ case 2:
4415
+ return _context.a(2, _context.v);
4416
+ case 3:
4417
+ _context.p = 3;
4418
+ _t = _context.v;
4419
+ if (!(_t instanceof InvalidCurrencyError)) {
4420
+ _context.n = 5;
4421
+ break;
4422
+ }
4423
+ _context.n = 4;
4424
+ return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
4425
+ destination: destination
4426
+ }), {
4427
+ symbol: assetInfo.symbol,
4428
+ amount: amt
4429
+ });
4430
+ case 4:
4431
+ return _context.a(2, _context.v);
4432
+ case 5:
4433
+ throw _t;
4434
+ case 6:
4435
+ _context.n = 7;
4436
+ return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
4437
+ destination: destination
4438
+ }), {
4439
+ symbol: assetInfo.symbol,
4440
+ amount: amt
4441
+ });
4442
+ case 7:
4443
+ return _context.a(2, _context.v);
4444
+ }
4445
+ }, _callee, null, [[1, 3]]);
4446
+ }));
4447
+ return function attempt(_x2, _x3, _x4) {
4448
+ return _ref3.apply(this, arguments);
4449
+ };
4450
+ }();
4451
+ _context2.p = 2;
4452
+ _context2.n = 3;
4453
+ return attempt(origin, currency, currency.amount);
4408
4454
  case 3:
4409
- return _context.a(2, _context.v);
4455
+ return _context2.a(2, _context2.v);
4410
4456
  case 4:
4411
- _context.p = 4;
4412
- _t = _context.v;
4413
- if (!(_t instanceof InvalidCurrencyError)) {
4414
- _context.n = 6;
4457
+ _context2.p = 4;
4458
+ _t2 = _context2.v;
4459
+ if (!(!(_t2 instanceof InvalidCurrencyError) || !swapConfig)) {
4460
+ _context2.n = 5;
4415
4461
  break;
4416
4462
  }
4417
- _context.n = 5;
4418
- return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
4419
- destination: destination
4420
- }), {
4421
- symbol: originAsset.symbol,
4422
- amount: amount
4423
- });
4463
+ throw _t2;
4424
4464
  case 5:
4425
- return _context.a(2, _context.v);
4465
+ _context2.n = 6;
4466
+ return attempt(swapConfig.exchangeChain, swapConfig.currencyTo, swapConfig.amountOut);
4426
4467
  case 6:
4427
- throw _t;
4428
- case 7:
4429
- _context.n = 8;
4430
- return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
4431
- destination: destination
4432
- }), {
4433
- symbol: originAsset.symbol,
4434
- amount: amount
4435
- });
4436
- case 8:
4437
- return _context.a(2, _context.v);
4468
+ return _context2.a(2, _context2.v);
4438
4469
  }
4439
- }, _callee, null, [[2, 4]]);
4470
+ }, _callee2, null, [[2, 4]]);
4440
4471
  }));
4441
4472
  return function calcPaymentInfoFee() {
4442
4473
  return _ref2.apply(this, arguments);
4443
4474
  };
4444
4475
  }();
4445
4476
  if (!(!hasDryRunSupport(destination) || !forwardedXcms || destination === 'Ethereum')) {
4446
- _context2.n = 3;
4477
+ _context3.n = 3;
4447
4478
  break;
4448
4479
  }
4449
- _context2.n = 1;
4480
+ _context3.n = 1;
4450
4481
  return calcPaymentInfoFee();
4451
4482
  case 1:
4452
- _fee = _context2.v;
4453
- _context2.n = 2;
4483
+ _fee = _context3.v;
4484
+ _context3.n = 2;
4454
4485
  return isSufficientDestination(api, destination, address, BigInt(currency.amount), asset, _fee);
4455
4486
  case 2:
4456
- sufficient = _context2.v;
4457
- return _context2.a(2, {
4487
+ sufficient = _context3.v;
4488
+ return _context3.a(2, {
4458
4489
  fee: _fee,
4459
4490
  feeType: 'paymentInfo',
4460
4491
  sufficient: !hasDryRunSupport(destination) ? sufficient : false
4461
4492
  });
4462
4493
  case 3:
4463
- _context2.n = 4;
4494
+ _context3.n = 4;
4464
4495
  return api.getDryRunXcm({
4465
4496
  originLocation: addXcmVersionHeader(createOriginLocation(hopChain, destination), Version.V4),
4466
4497
  tx: tx,
@@ -4473,24 +4504,24 @@ var getDestXcmFee = /*#__PURE__*/function () {
4473
4504
  amount: BigInt(currency.amount) < 2n ? 2n : BigInt(currency.amount)
4474
4505
  });
4475
4506
  case 4:
4476
- dryRunResult = _context2.v;
4507
+ dryRunResult = _context3.v;
4477
4508
  if (dryRunResult.success) {
4478
- _context2.n = 7;
4509
+ _context3.n = 7;
4479
4510
  break;
4480
4511
  }
4481
4512
  if (!disableFallback) {
4482
- _context2.n = 5;
4513
+ _context3.n = 5;
4483
4514
  break;
4484
4515
  }
4485
- return _context2.a(2, {
4516
+ return _context3.a(2, {
4486
4517
  dryRunError: dryRunResult.failureReason
4487
4518
  });
4488
4519
  case 5:
4489
- _context2.n = 6;
4520
+ _context3.n = 6;
4490
4521
  return calcPaymentInfoFee();
4491
4522
  case 6:
4492
- _fee2 = _context2.v;
4493
- return _context2.a(2, {
4523
+ _fee2 = _context3.v;
4524
+ return _context3.a(2, {
4494
4525
  fee: _fee2,
4495
4526
  feeType: 'paymentInfo',
4496
4527
  dryRunError: dryRunResult.failureReason,
@@ -4498,7 +4529,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
4498
4529
  });
4499
4530
  case 7:
4500
4531
  fee = dryRunResult.fee, newForwardedXcms = dryRunResult.forwardedXcms, destParaId = dryRunResult.destParaId;
4501
- return _context2.a(2, {
4532
+ return _context3.a(2, {
4502
4533
  fee: fee,
4503
4534
  feeType: 'dryRun',
4504
4535
  sufficient: true,
@@ -4506,7 +4537,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
4506
4537
  destParaId: destParaId
4507
4538
  });
4508
4539
  }
4509
- }, _callee2);
4540
+ }, _callee3);
4510
4541
  }));
4511
4542
  return function getDestXcmFee(_x) {
4512
4543
  return _ref.apply(this, arguments);
@@ -5134,7 +5165,7 @@ function _traverseXcmHops() {
5134
5165
  case 4:
5135
5166
  // true if this hop should be treated as the destination
5136
5167
  // - normally when nextChain === destination
5137
- // - but if swap is required, only after (or on) the exchange hop const isDestination =
5168
+ // - but if swap is required, only after (or on) the exchange hop
5138
5169
  isDestination = nextChain === destination && (!swapConfig || hasPassedExchange || nextChain === swapConfig.exchangeChain);
5139
5170
  isAssetHub = nextChain === assetHubChain;
5140
5171
  isBridgeHub = nextChain === bridgeHubChain;
@@ -5272,8 +5303,8 @@ var getFailureInfo$1 = function getFailureInfo(results, hops) {
5272
5303
  };
5273
5304
  var dryRunInternal = /*#__PURE__*/function () {
5274
5305
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
5275
- var _traversalResult$brid, _traversalResult$asse;
5276
- var api, origin, destination, currency, tx, senderAddress, feeAsset, swapConfig, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, asset, amount, originDryRun, initialForwardedXcms, initialDestParaId, processHop, traversalResult, assetHubChain, bridgeHubChain, processedBridgeHub, bridgeHubHopIndex, assetHubWithCurrency, bridgeHubWithCurrency, _getFailureInfo, failureReason, failureChain, _t;
5306
+ var _traversalResult$brid;
5307
+ var api, origin, destination, currency, tx, senderAddress, feeAsset, swapConfig, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, asset, amount, originDryRun, initialForwardedXcms, initialDestParaId, processHop, traversalResult, assetHubChain, bridgeHubChain, processedBridgeHub, bridgeHubHopIndex, bridgeHubWithCurrency, _getFailureInfo, failureReason, failureChain, _t;
5277
5308
  return _regenerator().w(function (_context2) {
5278
5309
  while (1) switch (_context2.n) {
5279
5310
  case 0:
@@ -5409,24 +5440,20 @@ var dryRunInternal = /*#__PURE__*/function () {
5409
5440
  });
5410
5441
  }
5411
5442
  }
5412
- assetHubWithCurrency = (_traversalResult$asse = traversalResult.assetHub) !== null && _traversalResult$asse !== void 0 && _traversalResult$asse.success ? _objectSpread2(_objectSpread2({}, traversalResult.assetHub), {}, {
5413
- currency: resolvedFeeAsset ? resolvedFeeAsset.symbol : getNativeAssetSymbol(assetHubChain),
5414
- asset: resolvedFeeAsset !== null && resolvedFeeAsset !== void 0 ? resolvedFeeAsset : findNativeAssetInfoOrThrow(assetHubChain)
5415
- }) : traversalResult.assetHub;
5416
5443
  bridgeHubWithCurrency = processedBridgeHub !== null && processedBridgeHub !== void 0 && processedBridgeHub.success ? _objectSpread2(_objectSpread2({}, processedBridgeHub), {}, {
5417
5444
  currency: getNativeAssetSymbol(bridgeHubChain),
5418
5445
  asset: findNativeAssetInfoOrThrow(bridgeHubChain)
5419
5446
  }) : processedBridgeHub;
5420
5447
  _getFailureInfo = getFailureInfo$1({
5421
5448
  destination: traversalResult.destination,
5422
- assetHub: assetHubWithCurrency,
5449
+ assetHub: traversalResult.assetHub,
5423
5450
  bridgeHub: bridgeHubWithCurrency
5424
5451
  }, traversalResult.hops), failureReason = _getFailureInfo.failureReason, failureChain = _getFailureInfo.failureChain;
5425
5452
  return _context2.a(2, {
5426
5453
  failureReason: failureReason,
5427
5454
  failureChain: failureChain,
5428
5455
  origin: originDryRun,
5429
- assetHub: assetHubWithCurrency,
5456
+ assetHub: traversalResult.assetHub,
5430
5457
  bridgeHub: bridgeHubWithCurrency,
5431
5458
  destination: traversalResult.destination,
5432
5459
  hops: traversalResult.hops
@@ -5447,7 +5474,7 @@ var isMultiHopSwap = function isMultiHopSwap(exchangeChain, assetFrom, assetTo)
5447
5474
 
5448
5475
  var createExchangeInstructions = /*#__PURE__*/function () {
5449
5476
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, assetFrom, assetTo) {
5450
- var chain, exchangeChain, assetInfoFrom, assetInfoTo, version, calculateMinAmountOut, _options$fees, originReserveFee, exchangeFee, nativeSymbol, needsMultiHop, nativeAsset, shouldUseMaximal, nativeAmountOut, assetNative;
5477
+ var chain, exchangeChain, assetInfoFrom, assetInfoTo, version, calculateMinAmountOut, _options$fees, originReserveFee, exchangeFee, nativeSymbol, needsMultiHop, nativeAsset, nativeAmountOut, assetNative;
5451
5478
  return _regenerator().w(function (_context) {
5452
5479
  while (1) switch (_context.n) {
5453
5480
  case 0:
@@ -5458,7 +5485,6 @@ var createExchangeInstructions = /*#__PURE__*/function () {
5458
5485
  symbol: Native(nativeSymbol)
5459
5486
  }, null);
5460
5487
  assertHasLocation(nativeAsset);
5461
- shouldUseMaximal = !chain || exchangeChain === 'Hydration' && exchangeFee === 0n;
5462
5488
  if (needsMultiHop) {
5463
5489
  _context.n = 1;
5464
5490
  break;
@@ -5467,7 +5493,7 @@ var createExchangeInstructions = /*#__PURE__*/function () {
5467
5493
  ExchangeAsset: {
5468
5494
  give: createAssetsFilter(assetFrom),
5469
5495
  want: [assetTo],
5470
- maximal: shouldUseMaximal
5496
+ maximal: false
5471
5497
  }
5472
5498
  }]);
5473
5499
  case 1:
@@ -5480,7 +5506,7 @@ var createExchangeInstructions = /*#__PURE__*/function () {
5480
5506
  ExchangeAsset: {
5481
5507
  give: createAssetsFilter(assetFrom),
5482
5508
  want: [assetNative],
5483
- maximal: shouldUseMaximal
5509
+ maximal: false
5484
5510
  }
5485
5511
  }, {
5486
5512
  ExchangeAsset: {
@@ -5498,17 +5524,15 @@ var createExchangeInstructions = /*#__PURE__*/function () {
5498
5524
  }();
5499
5525
  var createSwapExecuteXcm = /*#__PURE__*/function () {
5500
5526
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
5501
- var api, chain, exchangeChain, destChain, assetInfoFrom, assetInfoTo, _options$fees2, originReserveFee, exchangeFee, destReserveFee, recipientAddress, version, paraIdTo, assetFrom, MIN_FEE, amountOut, assetTo, assetToLocalizedToDest, _prepareCommonExecute, prefix, depositInstruction, exchangeInstructions, exchangeToDestXcm, finalXcm, fullXcm;
5527
+ var api, chain, exchangeChain, destChain, assetInfoFrom, assetInfoTo, _options$fees2, originReserveFee, destReserveFee, recipientAddress, version, paraIdTo, assetFrom, amountOut, assetTo, assetToLocalizedToDest, _prepareCommonExecute, prefix, depositInstruction, exchangeInstructions, exchangeToDestXcm, finalXcm, fullXcm;
5502
5528
  return _regenerator().w(function (_context2) {
5503
5529
  while (1) switch (_context2.n) {
5504
5530
  case 0:
5505
- api = options.api, chain = options.chain, exchangeChain = options.exchangeChain, destChain = options.destChain, assetInfoFrom = options.assetInfoFrom, assetInfoTo = options.assetInfoTo, _options$fees2 = options.fees, originReserveFee = _options$fees2.originReserveFee, exchangeFee = _options$fees2.exchangeFee, destReserveFee = _options$fees2.destReserveFee, recipientAddress = options.recipientAddress, version = options.version, paraIdTo = options.paraIdTo;
5531
+ api = options.api, chain = options.chain, exchangeChain = options.exchangeChain, destChain = options.destChain, assetInfoFrom = options.assetInfoFrom, assetInfoTo = options.assetInfoTo, _options$fees2 = options.fees, originReserveFee = _options$fees2.originReserveFee, destReserveFee = _options$fees2.destReserveFee, recipientAddress = options.recipientAddress, version = options.version, paraIdTo = options.paraIdTo;
5506
5532
  assertHasLocation(assetInfoFrom);
5507
5533
  assertHasLocation(assetInfoTo);
5508
5534
  assetFrom = createAsset(version, assetInfoFrom.amount, localizeLocation(exchangeChain, assetInfoFrom.location));
5509
- MIN_FEE = 1000n; // Exchange fee 0n means we are creating a dummy tx
5510
- // Set want to 1000n to prevent NoDeal
5511
- amountOut = chain && exchangeFee === 0n ? MIN_FEE : assetInfoTo.amount;
5535
+ amountOut = assetInfoTo.amount;
5512
5536
  assetTo = createAsset(version, amountOut, localizeLocation(exchangeChain, assetInfoTo.location));
5513
5537
  assetToLocalizedToDest = createAsset(version, amountOut, localizeLocation(destChain !== null && destChain !== void 0 ? destChain : exchangeChain, assetInfoTo.location));
5514
5538
  _prepareCommonExecute = prepareCommonExecuteXcm({
@@ -5528,12 +5552,6 @@ var createSwapExecuteXcm = /*#__PURE__*/function () {
5528
5552
  return createExchangeInstructions(options, assetFrom, assetTo);
5529
5553
  case 1:
5530
5554
  exchangeInstructions = _context2.v;
5531
- if (!(assetInfoTo.amount < MIN_FEE)) {
5532
- _context2.n = 2;
5533
- break;
5534
- }
5535
- throw new AmountTooLowError('Amount to receive after swap is too low, Increase Currency From amount.');
5536
- case 2:
5537
5555
  exchangeToDestXcm = destChain ? createBaseExecuteXcm({
5538
5556
  chain: exchangeChain,
5539
5557
  destChain: destChain,
@@ -9675,7 +9693,6 @@ var MAX_WEIGHT = {
9675
9693
  refTime: MAX_U64
9676
9694
  };
9677
9695
  var BYPASS_MINT_AMOUNT = '1000';
9678
- var BYPASS_CURRENCY_AMOUNT = '800';
9679
9696
 
9680
9697
  var buildClaimAssetsParams = function buildClaimAssetsParams(options) {
9681
9698
  var assets = options.assets,
@@ -10274,6 +10291,136 @@ var wrapTxBypass = /*#__PURE__*/function () {
10274
10291
  };
10275
10292
  }();
10276
10293
 
10294
+ var getBypassResultWithRetries = /*#__PURE__*/function () {
10295
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, internalFn, initialTx) {
10296
+ var maxRetries,
10297
+ bumpStep,
10298
+ hasError,
10299
+ first,
10300
+ result,
10301
+ i,
10302
+ amount,
10303
+ bumpedTx,
10304
+ _args = arguments,
10305
+ _t,
10306
+ _t2,
10307
+ _t3;
10308
+ return _regenerator().w(function (_context) {
10309
+ while (1) switch (_context.p = _context.n) {
10310
+ case 0:
10311
+ maxRetries = _args.length > 3 && _args[3] !== undefined ? _args[3] : 5;
10312
+ bumpStep = _args.length > 4 && _args[4] !== undefined ? _args[4] : 100;
10313
+ hasError = function hasError(res) {
10314
+ return 'failureReason' in res ? !!res.failureReason : 'dryRunError' in res ? !!res.dryRunError : false;
10315
+ };
10316
+ if (!initialTx) {
10317
+ _context.n = 5;
10318
+ break;
10319
+ }
10320
+ _context.p = 1;
10321
+ _context.n = 2;
10322
+ return internalFn(_objectSpread2(_objectSpread2({}, options), {}, {
10323
+ tx: initialTx,
10324
+ useRootOrigin: true
10325
+ }));
10326
+ case 2:
10327
+ first = _context.v;
10328
+ if (hasError(first)) {
10329
+ _context.n = 3;
10330
+ break;
10331
+ }
10332
+ return _context.a(2, first);
10333
+ case 3:
10334
+ _context.n = 5;
10335
+ break;
10336
+ case 4:
10337
+ _context.p = 4;
10338
+ _t = _context.v;
10339
+ if (_t instanceof AmountTooLowError) {
10340
+ _context.n = 5;
10341
+ break;
10342
+ }
10343
+ throw _t;
10344
+ case 5:
10345
+ result = null;
10346
+ i = 1;
10347
+ case 6:
10348
+ if (!(i <= maxRetries)) {
10349
+ _context.n = 19;
10350
+ break;
10351
+ }
10352
+ amount = (bumpStep * i).toString();
10353
+ bumpedTx = void 0;
10354
+ _context.p = 7;
10355
+ _context.n = 8;
10356
+ return options.buildTx(amount);
10357
+ case 8:
10358
+ bumpedTx = _context.v;
10359
+ _context.n = 12;
10360
+ break;
10361
+ case 9:
10362
+ _context.p = 9;
10363
+ _t2 = _context.v;
10364
+ if (!(_t2 instanceof AmountTooLowError)) {
10365
+ _context.n = 11;
10366
+ break;
10367
+ }
10368
+ if (!(i === maxRetries)) {
10369
+ _context.n = 10;
10370
+ break;
10371
+ }
10372
+ throw _t2;
10373
+ case 10:
10374
+ return _context.a(3, 18);
10375
+ case 11:
10376
+ throw _t2;
10377
+ case 12:
10378
+ _context.p = 12;
10379
+ _context.n = 13;
10380
+ return internalFn(_objectSpread2(_objectSpread2({}, options), {}, {
10381
+ tx: bumpedTx,
10382
+ useRootOrigin: true
10383
+ }));
10384
+ case 13:
10385
+ result = _context.v;
10386
+ if (hasError(result)) {
10387
+ _context.n = 14;
10388
+ break;
10389
+ }
10390
+ return _context.a(2, result);
10391
+ case 14:
10392
+ _context.n = 18;
10393
+ break;
10394
+ case 15:
10395
+ _context.p = 15;
10396
+ _t3 = _context.v;
10397
+ if (!(_t3 instanceof AmountTooLowError)) {
10398
+ _context.n = 17;
10399
+ break;
10400
+ }
10401
+ if (!(i === maxRetries)) {
10402
+ _context.n = 16;
10403
+ break;
10404
+ }
10405
+ throw _t3;
10406
+ case 16:
10407
+ return _context.a(3, 18);
10408
+ case 17:
10409
+ throw _t3;
10410
+ case 18:
10411
+ i++;
10412
+ _context.n = 6;
10413
+ break;
10414
+ case 19:
10415
+ return _context.a(2, result);
10416
+ }
10417
+ }, _callee, null, [[12, 15], [7, 9], [1, 4]]);
10418
+ }));
10419
+ return function getBypassResultWithRetries(_x, _x2, _x3) {
10420
+ return _ref.apply(this, arguments);
10421
+ };
10422
+ }();
10423
+
10277
10424
  var getOriginXcmFeeInternal = /*#__PURE__*/function () {
10278
10425
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
10279
10426
  var api, tx, origin, destination, senderAddress, disableFallback, feeAsset, currency, _ref$useRootOrigin, useRootOrigin, asset, amount, resolvedFeeAsset, nativeAssetSymbol, rawFee, paddedFee, sufficient, dryRunResult, _rawFee, _paddedFee, fee, forwardedXcms, destParaId, weight;
@@ -10374,30 +10521,48 @@ var getOriginXcmFeeInternal = /*#__PURE__*/function () {
10374
10521
 
10375
10522
  var getOriginXcmFee = /*#__PURE__*/function () {
10376
10523
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
10377
- var _options$txs, tx, txBypass, forced, real;
10524
+ var buildTx, tx, real, forced, _forced, _t;
10378
10525
  return _regenerator().w(function (_context) {
10379
- while (1) switch (_context.n) {
10526
+ while (1) switch (_context.p = _context.n) {
10380
10527
  case 0:
10381
- _options$txs = options.txs, tx = _options$txs.tx, txBypass = _options$txs.txBypass;
10382
- _context.n = 1;
10383
- return getOriginXcmFeeInternal(_objectSpread2(_objectSpread2({}, options), {}, {
10384
- tx: txBypass,
10385
- useRootOrigin: true
10386
- }));
10387
- case 1:
10388
- forced = _context.v;
10528
+ buildTx = options.buildTx;
10529
+ _context.p = 1;
10389
10530
  _context.n = 2;
10531
+ return buildTx();
10532
+ case 2:
10533
+ tx = _context.v;
10534
+ _context.n = 3;
10390
10535
  return getOriginXcmFeeInternal(_objectSpread2(_objectSpread2({}, options), {}, {
10391
10536
  tx: tx,
10392
10537
  useRootOrigin: false
10393
10538
  }));
10394
- case 2:
10539
+ case 3:
10395
10540
  real = _context.v;
10541
+ _context.n = 4;
10542
+ return getBypassResultWithRetries(options, getOriginXcmFeeInternal, tx);
10543
+ case 4:
10544
+ forced = _context.v;
10396
10545
  return _context.a(2, _objectSpread2(_objectSpread2({}, forced), {}, {
10397
10546
  sufficient: real.sufficient
10398
10547
  }));
10548
+ case 5:
10549
+ _context.p = 5;
10550
+ _t = _context.v;
10551
+ if (_t instanceof AmountTooLowError) {
10552
+ _context.n = 6;
10553
+ break;
10554
+ }
10555
+ throw _t;
10556
+ case 6:
10557
+ _context.n = 7;
10558
+ return getBypassResultWithRetries(options, getOriginXcmFeeInternal);
10559
+ case 7:
10560
+ _forced = _context.v;
10561
+ return _context.a(2, _objectSpread2(_objectSpread2({}, _forced), {}, {
10562
+ sufficient: false
10563
+ }));
10399
10564
  }
10400
- }, _callee);
10565
+ }, _callee, null, [[1, 5]]);
10401
10566
  }));
10402
10567
  return function getOriginXcmFee(_x) {
10403
10568
  return _ref.apply(this, arguments);
@@ -10754,7 +10919,9 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10754
10919
  feeAsset: feeAsset,
10755
10920
  tx: tx,
10756
10921
  originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
10757
- disableFallback: disableFallback
10922
+ disableFallback: disableFallback,
10923
+ hasPassedExchange: hasPassedExchange,
10924
+ swapConfig: swapConfig
10758
10925
  });
10759
10926
  case 1:
10760
10927
  hopResult = _context.v;
@@ -10848,7 +11015,8 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10848
11015
  tx: tx,
10849
11016
  originFee: originFee !== null && originFee !== void 0 ? originFee : 0n,
10850
11017
  senderAddress: senderAddress,
10851
- disableFallback: disableFallback
11018
+ disableFallback: disableFallback,
11019
+ swapConfig: swapConfig
10852
11020
  });
10853
11021
  case 11:
10854
11022
  destFallback = _context2.v;
@@ -10956,30 +11124,27 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10956
11124
 
10957
11125
  var getXcmFee = /*#__PURE__*/function () {
10958
11126
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
10959
- var _real$assetHub, _real$bridgeHub;
10960
- var _options$txs, tx, txBypass, forced, real, api;
11127
+ var buildTx, api, _real$assetHub, _real$bridgeHub, tx, real, forced, _forced, _t;
10961
11128
  return _regenerator().w(function (_context) {
10962
- while (1) switch (_context.n) {
11129
+ while (1) switch (_context.p = _context.n) {
10963
11130
  case 0:
10964
- _options$txs = options.txs, tx = _options$txs.tx, txBypass = _options$txs.txBypass;
10965
- _context.n = 1;
10966
- return getXcmFeeInternal(_objectSpread2(_objectSpread2({}, options), {}, {
10967
- tx: txBypass,
10968
- useRootOrigin: true
10969
- }));
10970
- case 1:
10971
- forced = _context.v;
11131
+ buildTx = options.buildTx, api = options.api;
11132
+ _context.p = 1;
10972
11133
  _context.n = 2;
11134
+ return buildTx();
11135
+ case 2:
11136
+ tx = _context.v;
11137
+ _context.n = 3;
10973
11138
  return getXcmFeeInternal(_objectSpread2(_objectSpread2({}, options), {}, {
10974
11139
  tx: tx,
10975
11140
  useRootOrigin: false
10976
11141
  }));
10977
- case 2:
10978
- real = _context.v;
10979
- api = options.api;
10980
- _context.n = 3;
10981
- return api.disconnect();
10982
11142
  case 3:
11143
+ real = _context.v;
11144
+ _context.n = 4;
11145
+ return getBypassResultWithRetries(options, getXcmFeeInternal, tx);
11146
+ case 4:
11147
+ forced = _context.v;
10983
11148
  return _context.a(2, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, forced), {}, {
10984
11149
  origin: _objectSpread2(_objectSpread2({}, forced.origin), {}, {
10985
11150
  sufficient: real.origin.sufficient
@@ -10996,17 +11161,62 @@ var getXcmFee = /*#__PURE__*/function () {
10996
11161
  sufficient: (_real$bridgeHub = real.bridgeHub) === null || _real$bridgeHub === void 0 ? void 0 : _real$bridgeHub.sufficient
10997
11162
  })
10998
11163
  } : {}), {}, {
10999
- hops: forced.hops.map(function (hop, index) {
11000
- var _real$hops$index;
11164
+ hops: forced.hops.map(function (hop, i) {
11165
+ var _real$hops$i;
11001
11166
  return _objectSpread2(_objectSpread2({}, hop), {}, {
11002
11167
  result: _objectSpread2(_objectSpread2({}, hop.result), {}, {
11003
- sufficient: (_real$hops$index = real.hops[index]) === null || _real$hops$index === void 0 ? void 0 : _real$hops$index.result.sufficient
11168
+ sufficient: (_real$hops$i = real.hops[i]) === null || _real$hops$i === void 0 || (_real$hops$i = _real$hops$i.result) === null || _real$hops$i === void 0 ? void 0 : _real$hops$i.sufficient
11004
11169
  })
11005
11170
  });
11006
11171
  })
11007
11172
  }));
11173
+ case 5:
11174
+ _context.p = 5;
11175
+ _t = _context.v;
11176
+ if (_t instanceof AmountTooLowError) {
11177
+ _context.n = 6;
11178
+ break;
11179
+ }
11180
+ throw _t;
11181
+ case 6:
11182
+ _context.n = 7;
11183
+ return getBypassResultWithRetries(options, getXcmFeeInternal);
11184
+ case 7:
11185
+ _forced = _context.v;
11186
+ return _context.a(2, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, _forced), {}, {
11187
+ origin: _objectSpread2(_objectSpread2({}, _forced.origin), {}, {
11188
+ sufficient: false
11189
+ }),
11190
+ destination: _objectSpread2(_objectSpread2({}, _forced.destination), {}, {
11191
+ sufficient: false
11192
+ })
11193
+ }, _forced.assetHub ? {
11194
+ assetHub: _objectSpread2(_objectSpread2({}, _forced.assetHub), {}, {
11195
+ sufficient: false
11196
+ })
11197
+ } : {}), _forced.bridgeHub ? {
11198
+ bridgeHub: _objectSpread2(_objectSpread2({}, _forced.bridgeHub), {}, {
11199
+ sufficient: false
11200
+ })
11201
+ } : {}), {}, {
11202
+ hops: _forced.hops.map(function (hop) {
11203
+ return _objectSpread2(_objectSpread2({}, hop), {}, {
11204
+ result: _objectSpread2(_objectSpread2({}, hop.result), {}, {
11205
+ sufficient: false
11206
+ })
11207
+ });
11208
+ })
11209
+ }));
11210
+ case 8:
11211
+ _context.p = 8;
11212
+ _context.n = 9;
11213
+ return api.disconnect();
11214
+ case 9:
11215
+ return _context.f(8);
11216
+ case 10:
11217
+ return _context.a(2);
11008
11218
  }
11009
- }, _callee);
11219
+ }, _callee, null, [[1, 5, 8, 10]]);
11010
11220
  }));
11011
11221
  return function getXcmFee(_x) {
11012
11222
  return _ref.apply(this, arguments);
@@ -11452,11 +11662,11 @@ var buildHopInfo = /*#__PURE__*/function () {
11452
11662
 
11453
11663
  var getTransferInfo = /*#__PURE__*/function () {
11454
11664
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
11455
- var api, txs, origin, destination, senderAddress, ahAddress, address, currency, feeAsset, resolvedFeeAsset, originAsset, amount, originBalanceFee, originBalance, edOrigin, _yield$getXcmFee, _yield$getXcmFee$orig, originFee, originFeeCurrency, originFeeAsset, assetHubFeeResult, bridgeHubFeeResult, destFeeDetail, hops, isFeeAssetAh, originBalanceAfter, originBalanceFeeAfter, originBalanceNativeSufficient, originBalanceSufficient, assetHub, bridgeHub, bridgeHubChain, builtHops, totalHopFee, destinationInfo, _t;
11665
+ var api, buildTx, origin, destination, senderAddress, ahAddress, address, currency, feeAsset, resolvedFeeAsset, originAsset, amount, originBalanceFee, originBalance, edOrigin, _yield$getXcmFee, _yield$getXcmFee$orig, originFee, originFeeCurrency, originFeeAsset, assetHubFeeResult, bridgeHubFeeResult, destFeeDetail, hops, isFeeAssetAh, originBalanceAfter, originBalanceFeeAfter, originBalanceNativeSufficient, originBalanceSufficient, assetHub, bridgeHub, bridgeHubChain, builtHops, totalHopFee, destinationInfo, _t;
11456
11666
  return _regenerator().w(function (_context2) {
11457
11667
  while (1) switch (_context2.p = _context2.n) {
11458
11668
  case 0:
11459
- api = _ref.api, txs = _ref.txs, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, ahAddress = _ref.ahAddress, address = _ref.address, currency = _ref.currency, feeAsset = _ref.feeAsset;
11669
+ api = _ref.api, buildTx = _ref.buildTx, origin = _ref.origin, destination = _ref.destination, senderAddress = _ref.senderAddress, ahAddress = _ref.ahAddress, address = _ref.address, currency = _ref.currency, feeAsset = _ref.feeAsset;
11460
11670
  if (!(isChainEvm(origin) && !ahAddress)) {
11461
11671
  _context2.n = 1;
11462
11672
  break;
@@ -11510,7 +11720,7 @@ var getTransferInfo = /*#__PURE__*/function () {
11510
11720
  _context2.n = 9;
11511
11721
  return getXcmFee({
11512
11722
  api: api,
11513
- txs: txs,
11723
+ buildTx: buildTx,
11514
11724
  origin: origin,
11515
11725
  destination: destination,
11516
11726
  senderAddress: senderAddress,
@@ -11678,11 +11888,11 @@ var getTransferInfo = /*#__PURE__*/function () {
11678
11888
 
11679
11889
  var getMinTransferableAmountInternal = /*#__PURE__*/function () {
11680
11890
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
11681
- var api, origin, senderAddress, address, chain, destination, currency, feeAsset, txs, builder, resolvedFeeAsset, asset, destAsset, destCurrency, destApi, destBalance, destEd, nativeAssetInfo, isNativeAsset, paysOriginInSendingAsset, amount, result, originFee, hopFeeTotal, destinationFee, edComponent, minAmount, modifiedBuilder, dryRunResult, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
11891
+ var api, origin, senderAddress, address, chain, destination, currency, feeAsset, buildTx, builder, resolvedFeeAsset, asset, destAsset, destCurrency, destApi, destBalance, destEd, nativeAssetInfo, isNativeAsset, paysOriginInSendingAsset, amount, result, originFee, hopFeeTotal, destinationFee, edComponent, minAmount, modifiedBuilder, dryRunResult, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
11682
11892
  return _regenerator().w(function (_context) {
11683
11893
  while (1) switch (_context.n) {
11684
11894
  case 0:
11685
- api = _ref.api, origin = _ref.origin, senderAddress = _ref.senderAddress, address = _ref.address, chain = _ref.origin, destination = _ref.destination, currency = _ref.currency, feeAsset = _ref.feeAsset, txs = _ref.txs, builder = _ref.builder;
11895
+ api = _ref.api, origin = _ref.origin, senderAddress = _ref.senderAddress, address = _ref.address, chain = _ref.origin, destination = _ref.destination, currency = _ref.currency, feeAsset = _ref.feeAsset, buildTx = _ref.buildTx, builder = _ref.builder;
11686
11896
  validateAddress(senderAddress, chain, false);
11687
11897
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, chain, destination, currency) : undefined;
11688
11898
  asset = findAssetInfoOrThrow(chain, currency, null);
@@ -11715,7 +11925,7 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
11715
11925
  api: api,
11716
11926
  origin: origin,
11717
11927
  destination: destination,
11718
- txs: txs,
11928
+ buildTx: buildTx,
11719
11929
  senderAddress: senderAddress,
11720
11930
  address: address,
11721
11931
  currency: _objectSpread2(_objectSpread2({}, currency), {}, {
@@ -11810,11 +12020,11 @@ var getMinTransferableAmount = /*#__PURE__*/function () {
11810
12020
 
11811
12021
  var getTransferableAmountInternal = /*#__PURE__*/function () {
11812
12022
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
11813
- var api, senderAddress, chain, destination, currency, txs, feeAsset, resolvedFeeAsset, asset, amount, balance, ed, nativeAssetInfo, isNativeAsset, paysOriginInSendingAsset, feeToSubtract, _yield$getOriginXcmFe, fee, transferable;
12023
+ var api, senderAddress, chain, destination, currency, buildTx, feeAsset, resolvedFeeAsset, asset, amount, balance, ed, nativeAssetInfo, isNativeAsset, paysOriginInSendingAsset, feeToSubtract, _yield$getOriginXcmFe, fee, transferable;
11814
12024
  return _regenerator().w(function (_context) {
11815
12025
  while (1) switch (_context.n) {
11816
12026
  case 0:
11817
- api = _ref.api, senderAddress = _ref.senderAddress, chain = _ref.origin, destination = _ref.destination, currency = _ref.currency, txs = _ref.txs, feeAsset = _ref.feeAsset;
12027
+ api = _ref.api, senderAddress = _ref.senderAddress, chain = _ref.origin, destination = _ref.destination, currency = _ref.currency, buildTx = _ref.buildTx, feeAsset = _ref.feeAsset;
11818
12028
  validateAddress(senderAddress, chain, false);
11819
12029
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, chain, destination, currency) : undefined;
11820
12030
  asset = findAssetInfoOrThrow(chain, currency, null);
@@ -11840,7 +12050,7 @@ var getTransferableAmountInternal = /*#__PURE__*/function () {
11840
12050
  _context.n = 2;
11841
12051
  return getOriginXcmFee({
11842
12052
  api: api,
11843
- txs: txs,
12053
+ buildTx: buildTx,
11844
12054
  origin: chain,
11845
12055
  destination: chain,
11846
12056
  senderAddress: senderAddress,
@@ -11937,7 +12147,7 @@ var computeInstructionFee = /*#__PURE__*/function () {
11937
12147
  chain = _ref.chain, api = _ref.api;
11938
12148
  _t = padFeeBy;
11939
12149
  _context.n = 1;
11940
- return api.getXcmPaymentApiFee(chain, addXcmVersionHeader(xcm, version), {
12150
+ return api.getXcmPaymentApiFee(chain, addXcmVersionHeader(xcm, version), [], {
11941
12151
  location: DOT_LOCATION
11942
12152
  }, true);
11943
12153
  case 1:
@@ -12226,11 +12436,11 @@ var calculateTotalXcmFee = function calculateTotalXcmFee(feeResult) {
12226
12436
  };
12227
12437
  var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
12228
12438
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
12229
- var api, txs, origin, destination, currency, address, senderAddress, feeAsset, destApi, asset, amount, destCurrency, ed, balance, tx, txBypass, xcmFeeResult, dryRunError, assetHubFeeResult, bridgeHubFeeResult, _xcmFeeResult$destina, destFee, destFeeCurrency, destDryRunError, hopDryRunError, totalFee, method, feeToSubtract;
12439
+ var api, buildTx, origin, destination, currency, address, senderAddress, feeAsset, destApi, asset, amount, destCurrency, ed, balance, xcmFeeResult, dryRunError, assetHubFeeResult, bridgeHubFeeResult, _xcmFeeResult$destina, destFee, destFeeCurrency, destDryRunError, hopDryRunError, tx, totalFee, method, feeToSubtract;
12230
12440
  return _regenerator().w(function (_context) {
12231
12441
  while (1) switch (_context.n) {
12232
12442
  case 0:
12233
- api = options.api, txs = options.txs, origin = options.origin, destination = options.destination, currency = options.currency, address = options.address, senderAddress = options.senderAddress, feeAsset = options.feeAsset;
12443
+ api = options.api, buildTx = options.buildTx, origin = options.origin, destination = options.destination, currency = options.currency, address = options.address, senderAddress = options.senderAddress, feeAsset = options.feeAsset;
12234
12444
  if (!(destination === 'Ethereum')) {
12235
12445
  _context.n = 1;
12236
12446
  break;
@@ -12271,11 +12481,10 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
12271
12481
  });
12272
12482
  case 5:
12273
12483
  balance = _context.v;
12274
- tx = txs.tx, txBypass = txs.txBypass;
12275
12484
  _context.n = 6;
12276
- return getXcmFeeInternal({
12485
+ return getXcmFee({
12277
12486
  api: api,
12278
- tx: txBypass,
12487
+ buildTx: buildTx,
12279
12488
  origin: origin,
12280
12489
  destination: destination,
12281
12490
  senderAddress: senderAddress,
@@ -12284,8 +12493,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
12284
12493
  amount: amount
12285
12494
  }),
12286
12495
  feeAsset: feeAsset,
12287
- disableFallback: false,
12288
- useRootOrigin: true
12496
+ disableFallback: false
12289
12497
  });
12290
12498
  case 6:
12291
12499
  xcmFeeResult = _context.v;
@@ -12315,6 +12523,10 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
12315
12523
  }
12316
12524
  throw new UnableToComputeError("The XCM fee could not be calculated because the origin or destination chain does not support DryRun.\n As a result, fee estimation is only available through PaymentInfo, which provides the cost in the native asset.\n This limitation restricts support to transfers involving the native asset of the Destination chain only.");
12317
12525
  case 10:
12526
+ _context.n = 11;
12527
+ return buildTx();
12528
+ case 11:
12529
+ tx = _context.v;
12318
12530
  totalFee = calculateTotalXcmFee(xcmFeeResult);
12319
12531
  method = api.getMethod(tx);
12320
12532
  if (method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen') {
@@ -12878,11 +13090,14 @@ var GeneralBuilder = /*#__PURE__*/function () {
12878
13090
  return dryRunPreview;
12879
13091
  }()
12880
13092
  }, {
12881
- key: "createTxs",
12882
- value: function createTxs$1() {
12883
- return createTxs(_objectSpread2(_objectSpread2({}, this._options), {}, {
12884
- api: this.api
12885
- }), this);
13093
+ key: "createTxFactory",
13094
+ value: function createTxFactory() {
13095
+ var _this = this;
13096
+ return function (amount) {
13097
+ return createTx(_objectSpread2(_objectSpread2({}, _this._options), {}, {
13098
+ api: _this.api
13099
+ }), _this, amount);
13100
+ };
12886
13101
  }
12887
13102
  /**
12888
13103
  * Returns the XCM fee for the transfer using dryRun or paymentInfo function.
@@ -12894,7 +13109,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
12894
13109
  value: (function () {
12895
13110
  var _getXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(options) {
12896
13111
  var _options$disableFallb;
12897
- var _this$_options2, from, to, address, senderAddress, feeAsset, currency, disableFallback, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0;
13112
+ var _this$_options2, from, to, address, senderAddress, feeAsset, currency, disableFallback;
12898
13113
  return _regenerator().w(function (_context7) {
12899
13114
  while (1) switch (_context7.p = _context7.n) {
12900
13115
  case 0:
@@ -12903,43 +13118,30 @@ var GeneralBuilder = /*#__PURE__*/function () {
12903
13118
  assertAddressIsString(address);
12904
13119
  disableFallback = (_options$disableFallb = options === null || options === void 0 ? void 0 : options.disableFallback) !== null && _options$disableFallb !== void 0 ? _options$disableFallb : false;
12905
13120
  _context7.p = 1;
12906
- _t = getXcmFee;
12907
- _t2 = this.api;
12908
13121
  _context7.n = 2;
12909
- return this.createTxs();
12910
- case 2:
12911
- _t3 = _context7.v;
12912
- _t4 = from;
12913
- _t5 = to;
12914
- _t6 = senderAddress;
12915
- _t7 = address;
12916
- _t8 = currency;
12917
- _t9 = feeAsset;
12918
- _t0 = disableFallback;
12919
- _context7.n = 3;
12920
- return _t({
12921
- api: _t2,
12922
- txs: _t3,
12923
- origin: _t4,
12924
- destination: _t5,
12925
- senderAddress: _t6,
12926
- address: _t7,
12927
- currency: _t8,
12928
- feeAsset: _t9,
12929
- disableFallback: _t0
13122
+ return getXcmFee({
13123
+ api: this.api,
13124
+ buildTx: this.createTxFactory(),
13125
+ origin: from,
13126
+ destination: to,
13127
+ senderAddress: senderAddress,
13128
+ address: address,
13129
+ currency: currency,
13130
+ feeAsset: feeAsset,
13131
+ disableFallback: disableFallback
12930
13132
  });
12931
- case 3:
13133
+ case 2:
12932
13134
  return _context7.a(2, _context7.v);
12933
- case 4:
12934
- _context7.p = 4;
12935
- _context7.n = 5;
13135
+ case 3:
13136
+ _context7.p = 3;
13137
+ _context7.n = 4;
12936
13138
  return this.api.disconnect();
13139
+ case 4:
13140
+ return _context7.f(3);
12937
13141
  case 5:
12938
- return _context7.f(4);
12939
- case 6:
12940
13142
  return _context7.a(2);
12941
13143
  }
12942
- }, _callee7, this, [[1,, 4, 6]]);
13144
+ }, _callee7, this, [[1,, 3, 5]]);
12943
13145
  }));
12944
13146
  function getXcmFee$1(_x6) {
12945
13147
  return _getXcmFee2.apply(this, arguments);
@@ -12965,16 +13167,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
12965
13167
  currency,
12966
13168
  feeAsset,
12967
13169
  api,
12968
- _args8 = arguments,
12969
- _t1,
12970
- _t10,
12971
- _t11,
12972
- _t12,
12973
- _t13,
12974
- _t14,
12975
- _t15,
12976
- _t16,
12977
- _t17;
13170
+ _args8 = arguments;
12978
13171
  return _regenerator().w(function (_context8) {
12979
13172
  while (1) switch (_context8.p = _context8.n) {
12980
13173
  case 0:
@@ -12985,41 +13178,29 @@ var GeneralBuilder = /*#__PURE__*/function () {
12985
13178
  assertToIsString(to);
12986
13179
  api = this.api;
12987
13180
  _context8.p = 1;
12988
- _t1 = getOriginXcmFee;
12989
- _t10 = api;
12990
13181
  _context8.n = 2;
12991
- return this.createTxs();
12992
- case 2:
12993
- _t11 = _context8.v;
12994
- _t12 = from;
12995
- _t13 = to;
12996
- _t14 = senderAddress;
12997
- _t15 = currency;
12998
- _t16 = feeAsset;
12999
- _t17 = disableFallback;
13000
- _context8.n = 3;
13001
- return _t1({
13002
- api: _t10,
13003
- txs: _t11,
13004
- origin: _t12,
13005
- destination: _t13,
13006
- senderAddress: _t14,
13007
- currency: _t15,
13008
- feeAsset: _t16,
13009
- disableFallback: _t17
13182
+ return getOriginXcmFee({
13183
+ api: api,
13184
+ buildTx: this.createTxFactory(),
13185
+ origin: from,
13186
+ destination: to,
13187
+ senderAddress: senderAddress,
13188
+ currency: currency,
13189
+ feeAsset: feeAsset,
13190
+ disableFallback: disableFallback
13010
13191
  });
13011
- case 3:
13192
+ case 2:
13012
13193
  return _context8.a(2, _context8.v);
13013
- case 4:
13014
- _context8.p = 4;
13015
- _context8.n = 5;
13194
+ case 3:
13195
+ _context8.p = 3;
13196
+ _context8.n = 4;
13016
13197
  return this.api.disconnect();
13198
+ case 4:
13199
+ return _context8.f(3);
13017
13200
  case 5:
13018
- return _context8.f(4);
13019
- case 6:
13020
13201
  return _context8.a(2);
13021
13202
  }
13022
- }, _callee8, this, [[1,, 4, 6]]);
13203
+ }, _callee8, this, [[1,, 3, 5]]);
13023
13204
  }));
13024
13205
  function getOriginXcmFee$1() {
13025
13206
  return _getOriginXcmFee2.apply(this, arguments);
@@ -13134,32 +13315,21 @@ var GeneralBuilder = /*#__PURE__*/function () {
13134
13315
  key: "getTransferableAmount",
13135
13316
  value: (function () {
13136
13317
  var _getTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
13137
- var _this$_options6, from, to, senderAddress, currency, feeAsset, api, _t18, _t19, _t20, _t21, _t22, _t23, _t24, _t25;
13318
+ var _this$_options6, from, to, senderAddress, currency, feeAsset, api;
13138
13319
  return _regenerator().w(function (_context1) {
13139
13320
  while (1) switch (_context1.n) {
13140
13321
  case 0:
13141
13322
  _this$_options6 = this._options, from = _this$_options6.from, to = _this$_options6.to, senderAddress = _this$_options6.senderAddress, currency = _this$_options6.currency, feeAsset = _this$_options6.feeAsset;
13142
13323
  assertToIsString(to);
13143
13324
  api = this.api;
13144
- _t18 = getTransferableAmount;
13145
- _t19 = api;
13146
- _context1.n = 1;
13147
- return this.createTxs();
13148
- case 1:
13149
- _t20 = _context1.v;
13150
- _t21 = from;
13151
- _t22 = to;
13152
- _t23 = senderAddress;
13153
- _t24 = feeAsset;
13154
- _t25 = currency;
13155
- return _context1.a(2, _t18({
13156
- api: _t19,
13157
- txs: _t20,
13158
- origin: _t21,
13159
- destination: _t22,
13160
- senderAddress: _t23,
13161
- feeAsset: _t24,
13162
- currency: _t25
13325
+ return _context1.a(2, getTransferableAmount({
13326
+ api: api,
13327
+ buildTx: this.createTxFactory(),
13328
+ origin: from,
13329
+ destination: to,
13330
+ senderAddress: senderAddress,
13331
+ feeAsset: feeAsset,
13332
+ currency: currency
13163
13333
  }));
13164
13334
  }
13165
13335
  }, _callee1, this);
@@ -13179,7 +13349,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
13179
13349
  key: "getMinTransferableAmount",
13180
13350
  value: (function () {
13181
13351
  var _getMinTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
13182
- var _this$_options7, from, to, senderAddress, address, currency, feeAsset, api, _t26, _t27, _t28, _t29, _t30, _t31, _t32, _t33, _t34, _t35;
13352
+ var _this$_options7, from, to, senderAddress, address, currency, feeAsset, api;
13183
13353
  return _regenerator().w(function (_context10) {
13184
13354
  while (1) switch (_context10.n) {
13185
13355
  case 0:
@@ -13187,29 +13357,16 @@ var GeneralBuilder = /*#__PURE__*/function () {
13187
13357
  assertToIsString(to);
13188
13358
  assertAddressIsString(address);
13189
13359
  api = this.api;
13190
- _t26 = getMinTransferableAmount;
13191
- _t27 = api;
13192
- _context10.n = 1;
13193
- return this.createTxs();
13194
- case 1:
13195
- _t28 = _context10.v;
13196
- _t29 = from;
13197
- _t30 = to;
13198
- _t31 = senderAddress;
13199
- _t32 = address;
13200
- _t33 = feeAsset;
13201
- _t34 = currency;
13202
- _t35 = this;
13203
- return _context10.a(2, _t26({
13204
- api: _t27,
13205
- txs: _t28,
13206
- origin: _t29,
13207
- destination: _t30,
13208
- senderAddress: _t31,
13209
- address: _t32,
13210
- feeAsset: _t33,
13211
- currency: _t34,
13212
- builder: _t35
13360
+ return _context10.a(2, getMinTransferableAmount({
13361
+ api: api,
13362
+ buildTx: this.createTxFactory(),
13363
+ origin: from,
13364
+ destination: to,
13365
+ senderAddress: senderAddress,
13366
+ address: address,
13367
+ feeAsset: feeAsset,
13368
+ currency: currency,
13369
+ builder: this
13213
13370
  }));
13214
13371
  }
13215
13372
  }, _callee10, this);
@@ -13229,34 +13386,22 @@ var GeneralBuilder = /*#__PURE__*/function () {
13229
13386
  key: "verifyEdOnDestination",
13230
13387
  value: (function () {
13231
13388
  var _verifyEdOnDestination2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
13232
- var _this$_options8, from, to, address, currency, senderAddress, feeAsset, _t36, _t37, _t38, _t39, _t40, _t41, _t42, _t43, _t44;
13389
+ var _this$_options8, from, to, address, currency, senderAddress, feeAsset;
13233
13390
  return _regenerator().w(function (_context11) {
13234
13391
  while (1) switch (_context11.n) {
13235
13392
  case 0:
13236
13393
  _this$_options8 = this._options, from = _this$_options8.from, to = _this$_options8.to, address = _this$_options8.address, currency = _this$_options8.currency, senderAddress = _this$_options8.senderAddress, feeAsset = _this$_options8.feeAsset;
13237
13394
  assertToIsString(to);
13238
13395
  assertAddressIsString(address);
13239
- _t36 = verifyEdOnDestination;
13240
- _t37 = this.api;
13241
- _context11.n = 1;
13242
- return this.createTxs();
13243
- case 1:
13244
- _t38 = _context11.v;
13245
- _t39 = from;
13246
- _t40 = to;
13247
- _t41 = address;
13248
- _t42 = senderAddress;
13249
- _t43 = feeAsset;
13250
- _t44 = currency;
13251
- return _context11.a(2, _t36({
13252
- api: _t37,
13253
- txs: _t38,
13254
- origin: _t39,
13255
- destination: _t40,
13256
- address: _t41,
13257
- senderAddress: _t42,
13258
- feeAsset: _t43,
13259
- currency: _t44
13396
+ return _context11.a(2, verifyEdOnDestination({
13397
+ api: this.api,
13398
+ buildTx: this.createTxFactory(),
13399
+ origin: from,
13400
+ destination: to,
13401
+ address: address,
13402
+ senderAddress: senderAddress,
13403
+ feeAsset: feeAsset,
13404
+ currency: currency
13260
13405
  }));
13261
13406
  }
13262
13407
  }, _callee11, this);
@@ -13276,36 +13421,23 @@ var GeneralBuilder = /*#__PURE__*/function () {
13276
13421
  key: "getTransferInfo",
13277
13422
  value: (function () {
13278
13423
  var _getTransferInfo2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
13279
- var _this$_options9, from, to, address, currency, ahAddress, senderAddress, feeAsset, _t45, _t46, _t47, _t48, _t49, _t50, _t51, _t52, _t53, _t54;
13424
+ var _this$_options9, from, to, address, currency, ahAddress, senderAddress, feeAsset;
13280
13425
  return _regenerator().w(function (_context12) {
13281
13426
  while (1) switch (_context12.n) {
13282
13427
  case 0:
13283
13428
  _this$_options9 = this._options, from = _this$_options9.from, to = _this$_options9.to, address = _this$_options9.address, currency = _this$_options9.currency, ahAddress = _this$_options9.ahAddress, senderAddress = _this$_options9.senderAddress, feeAsset = _this$_options9.feeAsset;
13284
13429
  assertToIsString(to);
13285
13430
  assertAddressIsString(address);
13286
- _t45 = getTransferInfo;
13287
- _t46 = this.api;
13288
- _context12.n = 1;
13289
- return this.createTxs();
13290
- case 1:
13291
- _t47 = _context12.v;
13292
- _t48 = from;
13293
- _t49 = to;
13294
- _t50 = address;
13295
- _t51 = senderAddress;
13296
- _t52 = ahAddress;
13297
- _t53 = currency;
13298
- _t54 = feeAsset;
13299
- return _context12.a(2, _t45({
13300
- api: _t46,
13301
- txs: _t47,
13302
- origin: _t48,
13303
- destination: _t49,
13304
- address: _t50,
13305
- senderAddress: _t51,
13306
- ahAddress: _t52,
13307
- currency: _t53,
13308
- feeAsset: _t54
13431
+ return _context12.a(2, getTransferInfo({
13432
+ api: this.api,
13433
+ buildTx: this.createTxFactory(),
13434
+ origin: from,
13435
+ destination: to,
13436
+ address: address,
13437
+ senderAddress: senderAddress,
13438
+ ahAddress: ahAddress,
13439
+ currency: currency,
13440
+ feeAsset: feeAsset
13309
13441
  }));
13310
13442
  }
13311
13443
  }, _callee12, this);
@@ -13348,4 +13480,4 @@ var Builder = function Builder(api) {
13348
13480
  return new GeneralBuilder(api, new BatchTransactionManager());
13349
13481
  };
13350
13482
 
13351
- 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, createTxs, createTypeAndThenCall, 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, padFeeBy, resolveDestChain, resolveModuleError, resolveParaId, reverseTransformLocation, send, sortAssets, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, verifyEdOnDestination, wrapTxBypass };
13483
+ 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, 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, padFeeBy, resolveDestChain, resolveModuleError, resolveParaId, reverseTransformLocation, send, sortAssets, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, traverseXcmHops, validateAddress, verifyEdOnDestination, wrapTxBypass };