@paraspell/sdk-core 11.8.4 → 11.8.6

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 CHANGED
@@ -771,6 +771,20 @@ var createVersionedAssets = function createVersionedAssets(version, amount, loca
771
771
  return addXcmVersionHeader([asset], version);
772
772
  };
773
773
 
774
+ var getCurrencySelection = function getCurrencySelection(asset) {
775
+ if (asset.location) return {
776
+ location: asset.location
777
+ };
778
+ if (assets.isForeignAsset(asset) && asset.assetId) {
779
+ return {
780
+ id: asset.assetId
781
+ };
782
+ }
783
+ return {
784
+ symbol: asset.symbol
785
+ };
786
+ };
787
+
774
788
  var maybeOverrideAssets = function maybeOverrideAssets(version, amount, assets, overriddenCurrency) {
775
789
  if (!overriddenCurrency) {
776
790
  return assets;
@@ -908,7 +922,7 @@ var getRelayChainOf = function getRelayChainOf(chain) {
908
922
  };
909
923
 
910
924
  var AssetHubPolkadot$1 = {
911
- name: "AssetHub",
925
+ name: "Asset Hub",
912
926
  info: "PolkadotAssetHub",
913
927
  paraId: 1000,
914
928
  providers: [
@@ -1009,10 +1023,6 @@ var Astar$1 = {
1009
1023
  name: "Astar",
1010
1024
  endpoint: "wss://rpc.astar.network"
1011
1025
  },
1012
- {
1013
- name: "Automata 1RPC",
1014
- endpoint: "wss://1rpc.io/astr"
1015
- },
1016
1026
  {
1017
1027
  name: "Blast",
1018
1028
  endpoint: "wss://astar.public.blastapi.io"
@@ -1051,15 +1061,11 @@ var BifrostPolkadot$1 = {
1051
1061
  {
1052
1062
  name: "LiebiEU",
1053
1063
  endpoint: "wss://eu.bifrost-polkadot-rpc.liebi.com/ws"
1054
- },
1055
- {
1056
- name: "RadiumBlock",
1057
- endpoint: "wss://bifrost.public.curie.radiumblock.co/ws"
1058
1064
  }
1059
1065
  ]
1060
1066
  };
1061
1067
  var BridgeHubPolkadot$1 = {
1062
- name: "BridgeHub",
1068
+ name: "Bridge Hub",
1063
1069
  info: "polkadotBridgeHub",
1064
1070
  paraId: 1002,
1065
1071
  providers: [
@@ -1208,16 +1214,16 @@ var Interlay$1 = {
1208
1214
  };
1209
1215
  var Heima$1 = {
1210
1216
  name: "Heima",
1211
- info: "litentry",
1217
+ info: "heima",
1212
1218
  paraId: 2013,
1213
1219
  providers: [
1214
1220
  {
1215
1221
  name: "Dwellir",
1216
- endpoint: "wss://litentry-rpc.dwellir.com"
1222
+ endpoint: "wss://heima-rpc.n.dwellir.com"
1217
1223
  },
1218
1224
  {
1219
- name: "Litentry",
1220
- endpoint: "wss://rpc.litentry-parachain.litentry.io"
1225
+ name: "Heima",
1226
+ endpoint: "wss://rpc.heima-parachain.heima.network"
1221
1227
  }
1222
1228
  ]
1223
1229
  };
@@ -1642,7 +1648,7 @@ var Xode$1 = {
1642
1648
  ]
1643
1649
  };
1644
1650
  var AssetHubKusama$1 = {
1645
- name: "AssetHub",
1651
+ name: "Asset Hub",
1646
1652
  info: "KusamaAssetHub",
1647
1653
  paraId: 1000,
1648
1654
  providers: [
@@ -1685,7 +1691,7 @@ var AssetHubKusama$1 = {
1685
1691
  ]
1686
1692
  };
1687
1693
  var BridgeHubKusama$1 = {
1688
- name: "BridgeHub",
1694
+ name: "Bridge Hub",
1689
1695
  info: "kusamaBridgeHub",
1690
1696
  paraId: 1002,
1691
1697
  providers: [
@@ -1987,10 +1993,6 @@ var Quartz$1 = {
1987
1993
  name: "Geo Load Balancer",
1988
1994
  endpoint: "wss://ws-quartz.unique.network"
1989
1995
  },
1990
- {
1991
- name: "Unique Asia",
1992
- endpoint: "wss://asia-ws-quartz.unique.network"
1993
- },
1994
1996
  {
1995
1997
  name: "Unique Europe",
1996
1998
  endpoint: "wss://eu-ws-quartz.unique.network"
@@ -2082,7 +2084,7 @@ var Zeitgeist$1 = {
2082
2084
  ]
2083
2085
  };
2084
2086
  var AssetHubWestend$1 = {
2085
- name: "AssetHub",
2087
+ name: "Asset Hub",
2086
2088
  info: "WestendAssetHub",
2087
2089
  paraId: 1000,
2088
2090
  providers: [
@@ -2105,7 +2107,7 @@ var AssetHubWestend$1 = {
2105
2107
  ]
2106
2108
  };
2107
2109
  var BridgeHubWestend$1 = {
2108
- name: "BridgeHub",
2110
+ name: "Bridge Hub",
2109
2111
  info: "westendBridgeHub",
2110
2112
  paraId: 1002,
2111
2113
  providers: [
@@ -2195,7 +2197,7 @@ var AjunaPaseo$1 = {
2195
2197
  ]
2196
2198
  };
2197
2199
  var AssetHubPaseo$1 = {
2198
- name: "AssetHub",
2200
+ name: "Asset Hub",
2199
2201
  info: "PaseoAssetHub",
2200
2202
  paraId: 1000,
2201
2203
  providers: [
@@ -2233,7 +2235,7 @@ var BifrostPaseo$1 = {
2233
2235
  ]
2234
2236
  };
2235
2237
  var BridgeHubPaseo$1 = {
2236
- name: "BridgeHub",
2238
+ name: "Bridge Hub",
2237
2239
  info: "PaseoBridgeHub",
2238
2240
  paraId: 1002,
2239
2241
  providers: [
@@ -2400,7 +2402,7 @@ var ZeitgeistPaseo$1 = {
2400
2402
  ]
2401
2403
  };
2402
2404
  var Polkadot = {
2403
- name: "Polkadot",
2405
+ name: "Polkadot Relay",
2404
2406
  info: "polkadot",
2405
2407
  paraId: 0,
2406
2408
  providers: [
@@ -2463,7 +2465,7 @@ var Polkadot = {
2463
2465
  ]
2464
2466
  };
2465
2467
  var Kusama = {
2466
- name: "Kusama",
2468
+ name: "Kusama Relay",
2467
2469
  info: "kusama",
2468
2470
  paraId: 0,
2469
2471
  providers: [
@@ -2514,7 +2516,7 @@ var Kusama = {
2514
2516
  ]
2515
2517
  };
2516
2518
  var Westend = {
2517
- name: "Westend",
2519
+ name: "Westend Relay",
2518
2520
  info: "westend",
2519
2521
  paraId: 0,
2520
2522
  providers: [
@@ -2541,7 +2543,7 @@ var Westend = {
2541
2543
  ]
2542
2544
  };
2543
2545
  var Paseo = {
2544
- name: "Paseo",
2546
+ name: "Paseo Relay",
2545
2547
  info: "paseo",
2546
2548
  paraId: 0,
2547
2549
  providers: [
@@ -3291,6 +3293,7 @@ var getAssetReserveChain = function getAssetReserveChain(chain, destChain, asset
3291
3293
  Here: null
3292
3294
  }
3293
3295
  })) {
3296
+ if (relaychain === 'Paseo') return ahChain;
3294
3297
  return CHAINS_DOT_RESERVE_AH.has(destChain) ? ahChain : relaychain;
3295
3298
  }
3296
3299
  return chain;
@@ -3695,6 +3698,44 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
3695
3698
  };
3696
3699
  }();
3697
3700
 
3701
+ var getMythosOriginFee = /*#__PURE__*/function () {
3702
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api) {
3703
+ var ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, ahExecutionFee, nativeAsset, feeConverted;
3704
+ return _regenerator().w(function (_context) {
3705
+ while (1) switch (_context.n) {
3706
+ case 0:
3707
+ ahApi = api.clone();
3708
+ _context.n = 1;
3709
+ return ahApi.init('AssetHubPolkadot');
3710
+ case 1:
3711
+ _context.n = 2;
3712
+ return getParaEthTransferFees(ahApi);
3713
+ case 2:
3714
+ _yield$getParaEthTran = _context.v;
3715
+ _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
3716
+ bridgeFee = _yield$getParaEthTran2[0];
3717
+ ahExecutionFee = _yield$getParaEthTran2[1];
3718
+ nativeAsset = assets.findNativeAssetInfoOrThrow('Mythos');
3719
+ assertHasLocation(nativeAsset);
3720
+ _context.n = 3;
3721
+ return ahApi.quoteAhPrice(DOT_LOCATION, nativeAsset.location, bridgeFee + ahExecutionFee);
3722
+ case 3:
3723
+ feeConverted = _context.v;
3724
+ if (feeConverted) {
3725
+ _context.n = 4;
3726
+ break;
3727
+ }
3728
+ throw new InvalidParameterError("Pool DOT -> ".concat(nativeAsset.symbol, " not found."));
3729
+ case 4:
3730
+ return _context.a(2, padFeeBy(feeConverted, 10));
3731
+ }
3732
+ }, _callee);
3733
+ }));
3734
+ return function getMythosOriginFee(_x) {
3735
+ return _ref.apply(this, arguments);
3736
+ };
3737
+ }();
3738
+
3698
3739
  var resolveFeeAsset = function resolveFeeAsset(feeAsset, origin, destination, currency) {
3699
3740
  var asset = assets.findAssetInfo(origin, feeAsset, !sdkCommon.isTLocation(destination) ? destination : null);
3700
3741
  var usesRawOverriddenMultiAssets = Array.isArray(currency) && currency.every(assets.isTAsset);
@@ -3736,49 +3777,6 @@ var getReverseTxFee = /*#__PURE__*/function () {
3736
3777
  };
3737
3778
  }();
3738
3779
 
3739
- var AssetsPallet = /*#__PURE__*/function () {
3740
- function AssetsPallet() {
3741
- _classCallCheck(this, AssetsPallet);
3742
- }
3743
- return _createClass(AssetsPallet, [{
3744
- key: "mint",
3745
- value: function mint(address, asset, _balance, chain) {
3746
- assertHasId(asset);
3747
- var assetId = asset.assetId,
3748
- amount = asset.amount;
3749
- var id = chain === 'Astar' || chain === 'Shiden' || chain === 'Moonbeam' ? BigInt(assetId) : Number(assetId);
3750
- var addr = assets.isChainEvm(chain) ? address : {
3751
- Id: address
3752
- };
3753
- return Promise.resolve({
3754
- assetStatusTx: {
3755
- module: 'Assets',
3756
- method: 'force_asset_status',
3757
- parameters: {
3758
- id: id,
3759
- owner: addr,
3760
- issuer: addr,
3761
- admin: addr,
3762
- freezer: addr,
3763
- min_balance: 0n,
3764
- is_sufficient: true,
3765
- is_frozen: false
3766
- }
3767
- },
3768
- balanceTx: {
3769
- module: 'Assets',
3770
- method: 'mint',
3771
- parameters: {
3772
- id: id,
3773
- beneficiary: addr,
3774
- amount: amount
3775
- }
3776
- }
3777
- });
3778
- }
3779
- }]);
3780
- }();
3781
-
3782
3780
  // Inspired by Moonbeam XCM-SDK
3783
3781
  // https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/utils/src/format/asset.ts#L1
3784
3782
  var formatAssetIdToERC20 = function formatAssetIdToERC20(id) {
@@ -3859,7 +3857,7 @@ var getBalanceForeignPolkadotXcm = /*#__PURE__*/function () {
3859
3857
  assertHasLocation(asset);
3860
3858
  return _context.a(2, api.getBalanceForeignAssetsPallet(address, asset.location));
3861
3859
  case 3:
3862
- if (!(chain === 'AssetHubPolkadot')) {
3860
+ if (!chain.startsWith('AssetHub')) {
3863
3861
  _context.n = 5;
3864
3862
  break;
3865
3863
  }
@@ -3873,7 +3871,7 @@ var getBalanceForeignPolkadotXcm = /*#__PURE__*/function () {
3873
3871
  case 4:
3874
3872
  return _context.a(2, api.getBalanceForeignAssetsPallet(address, asset.location));
3875
3873
  case 5:
3876
- return _context.a(2, api.getBalanceForeignPolkadotXcm(address, asset.assetId));
3874
+ return _context.a(2, api.getBalanceForeignPolkadotXcm(chain, address, asset));
3877
3875
  }
3878
3876
  }, _callee);
3879
3877
  }));
@@ -4201,77 +4199,6 @@ var getAssetBalance = /*#__PURE__*/function () {
4201
4199
  };
4202
4200
  }();
4203
4201
 
4204
- var getOriginFeeDetailsInternal = /*#__PURE__*/function () {
4205
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
4206
- var _getExistentialDeposi;
4207
- var api, account, accountDestination, ahAddress, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
4208
- return _regenerator().w(function (_context) {
4209
- while (1) switch (_context.n) {
4210
- case 0:
4211
- api = _ref.api, account = _ref.account, accountDestination = _ref.accountDestination, ahAddress = _ref.ahAddress, currency = _ref.currency, origin = _ref.origin, destination = _ref.destination, _ref$feeMarginPercent = _ref.feeMarginPercentage, feeMarginPercentage = _ref$feeMarginPercent === void 0 ? 10 : _ref$feeMarginPercent;
4212
- _context.n = 1;
4213
- return api.init(origin);
4214
- case 1:
4215
- _context.n = 2;
4216
- return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination).senderAddress(account).ahAddress(ahAddress)['buildInternal']();
4217
- case 2:
4218
- tx = _context.v;
4219
- _context.n = 3;
4220
- return api.calculateTransactionFee(tx, account);
4221
- case 3:
4222
- xcmFee = _context.v;
4223
- xcmFeeWithMargin = xcmFee + xcmFee / BigInt(feeMarginPercentage);
4224
- _context.n = 4;
4225
- return getBalanceNativeInternal({
4226
- address: account,
4227
- chain: origin,
4228
- api: api
4229
- });
4230
- case 4:
4231
- nativeBalance = _context.v;
4232
- existentialDeposit = BigInt((_getExistentialDeposi = assets.getExistentialDeposit(origin)) !== null && _getExistentialDeposi !== void 0 ? _getExistentialDeposi : '0');
4233
- sufficientForXCM = nativeBalance - existentialDeposit - xcmFeeWithMargin > 0;
4234
- return _context.a(2, {
4235
- sufficientForXCM: sufficientForXCM,
4236
- xcmFee: xcmFee
4237
- });
4238
- }
4239
- }, _callee);
4240
- }));
4241
- return function getOriginFeeDetailsInternal(_x) {
4242
- return _ref2.apply(this, arguments);
4243
- };
4244
- }();
4245
- var getOriginFeeDetails = /*#__PURE__*/function () {
4246
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
4247
- var api;
4248
- return _regenerator().w(function (_context2) {
4249
- while (1) switch (_context2.p = _context2.n) {
4250
- case 0:
4251
- api = options.api;
4252
- api.setDisconnectAllowed(false);
4253
- _context2.p = 1;
4254
- _context2.n = 2;
4255
- return getOriginFeeDetailsInternal(options);
4256
- case 2:
4257
- return _context2.a(2, _context2.v);
4258
- case 3:
4259
- _context2.p = 3;
4260
- api.setDisconnectAllowed(true);
4261
- _context2.n = 4;
4262
- return api.disconnect();
4263
- case 4:
4264
- return _context2.f(3);
4265
- case 5:
4266
- return _context2.a(2);
4267
- }
4268
- }, _callee2, null, [[1,, 3, 5]]);
4269
- }));
4270
- return function getOriginFeeDetails(_x2) {
4271
- return _ref3.apply(this, arguments);
4272
- };
4273
- }();
4274
-
4275
4202
  var isSufficientOrigin = /*#__PURE__*/function () {
4276
4203
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, origin, destination, senderAddress, feeNative, currency, asset, feeAsset) {
4277
4204
  var edNative, balanceNative, isNativeAssetToOrigin, isNativeAssetToDest, isSufficientNative, balanceAsset, edAsset, isSufficientAsset;
@@ -4459,7 +4386,7 @@ var getDestXcmFee = /*#__PURE__*/function () {
4459
4386
  _context2.n = 5;
4460
4387
  break;
4461
4388
  }
4462
- throw _t2;
4389
+ return _context2.a(2, 0n);
4463
4390
  case 5:
4464
4391
  _context2.n = 6;
4465
4392
  return attempt(swapConfig.exchangeChain, swapConfig.currencyTo, swapConfig.amountOut);
@@ -5308,7 +5235,7 @@ var getFailureInfo$1 = function getFailureInfo(results, hops) {
5308
5235
  var dryRunInternal = /*#__PURE__*/function () {
5309
5236
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
5310
5237
  var _traversalResult$brid;
5311
- 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;
5238
+ var api, origin, destination, currency, tx, senderAddress, feeAsset, swapConfig, bypassOptions, _options$useRootOrigi, useRootOrigin, resolvedFeeAsset, asset, amount, originDryRun, isMythosToEthereum, originDryModified, initialForwardedXcms, initialDestParaId, processHop, traversalResult, assetHubChain, bridgeHubChain, processedBridgeHub, bridgeHubHopIndex, bridgeHubWithCurrency, _getFailureInfo, failureReason, failureChain, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9;
5312
5239
  return _regenerator().w(function (_context2) {
5313
5240
  while (1) switch (_context2.n) {
5314
5241
  case 0:
@@ -5342,7 +5269,30 @@ var dryRunInternal = /*#__PURE__*/function () {
5342
5269
  hops: []
5343
5270
  });
5344
5271
  case 2:
5345
- initialForwardedXcms = originDryRun.forwardedXcms, initialDestParaId = originDryRun.destParaId;
5272
+ isMythosToEthereum = origin === 'Mythos' && destination === 'Ethereum';
5273
+ if (!isMythosToEthereum) {
5274
+ _context2.n = 4;
5275
+ break;
5276
+ }
5277
+ _t2 = _objectSpread2;
5278
+ _t3 = _objectSpread2({}, originDryRun);
5279
+ _t4 = {};
5280
+ _t5 = originDryRun.fee;
5281
+ _context2.n = 3;
5282
+ return getMythosOriginFee(api);
5283
+ case 3:
5284
+ _t6 = _context2.v;
5285
+ _t7 = _t5 + _t6;
5286
+ _t = _t2(_t3, _t4, {
5287
+ fee: _t7
5288
+ });
5289
+ _context2.n = 5;
5290
+ break;
5291
+ case 4:
5292
+ _t = originDryRun;
5293
+ case 5:
5294
+ originDryModified = _t;
5295
+ initialForwardedXcms = originDryModified.forwardedXcms, initialDestParaId = originDryModified.destParaId;
5346
5296
  processHop = /*#__PURE__*/function () {
5347
5297
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
5348
5298
  var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, isDestination, hopAsset, hopDryRun;
@@ -5379,7 +5329,7 @@ var dryRunInternal = /*#__PURE__*/function () {
5379
5329
  origin: currentOrigin,
5380
5330
  asset: hopAsset,
5381
5331
  feeAsset: resolvedFeeAsset,
5382
- originFee: originDryRun.fee,
5332
+ originFee: originDryModified.fee,
5383
5333
  amount: amount
5384
5334
  });
5385
5335
  case 2:
@@ -5395,7 +5345,7 @@ var dryRunInternal = /*#__PURE__*/function () {
5395
5345
  return _ref2.apply(this, arguments);
5396
5346
  };
5397
5347
  }();
5398
- _context2.n = 3;
5348
+ _context2.n = 6;
5399
5349
  return traverseXcmHops({
5400
5350
  api: api,
5401
5351
  origin: origin,
@@ -5415,25 +5365,35 @@ var dryRunInternal = /*#__PURE__*/function () {
5415
5365
  };
5416
5366
  }
5417
5367
  });
5418
- case 3:
5368
+ case 6:
5419
5369
  traversalResult = _context2.v;
5420
5370
  // Process Ethereum bridge fees
5421
5371
  assetHubChain = "AssetHub".concat(getRelayChainOf(origin));
5422
- bridgeHubChain = "BridgeHub".concat(getRelayChainOf(origin));
5372
+ bridgeHubChain = "BridgeHub".concat(getRelayChainOf(origin)); // For Mythos → Ethereum, we skip additional Ethereum bridge fees (aligns with getXcmFeeInternal)
5373
+ if (!isMythosToEthereum) {
5374
+ _context2.n = 7;
5375
+ break;
5376
+ }
5377
+ _t8 = traversalResult.bridgeHub;
5378
+ _context2.n = 11;
5379
+ break;
5380
+ case 7:
5423
5381
  if (!((_traversalResult$brid = traversalResult.bridgeHub) !== null && _traversalResult$brid !== void 0 && _traversalResult$brid.success)) {
5424
- _context2.n = 5;
5382
+ _context2.n = 9;
5425
5383
  break;
5426
5384
  }
5427
- _context2.n = 4;
5385
+ _context2.n = 8;
5428
5386
  return addEthereumBridgeFees(api, traversalResult.bridgeHub, destination, assetHubChain);
5429
- case 4:
5430
- _t = _context2.v;
5431
- _context2.n = 6;
5387
+ case 8:
5388
+ _t9 = _context2.v;
5389
+ _context2.n = 10;
5432
5390
  break;
5433
- case 5:
5434
- _t = traversalResult.bridgeHub;
5435
- case 6:
5436
- processedBridgeHub = _t;
5391
+ case 9:
5392
+ _t9 = traversalResult.bridgeHub;
5393
+ case 10:
5394
+ _t8 = _t9;
5395
+ case 11:
5396
+ processedBridgeHub = _t8;
5437
5397
  // Update bridge hub in hops if needed
5438
5398
  if (processedBridgeHub && processedBridgeHub.success && traversalResult.bridgeHub && traversalResult.bridgeHub.success && processedBridgeHub.fee !== traversalResult.bridgeHub.fee) {
5439
5399
  bridgeHubHopIndex = traversalResult.hops.findIndex(function (hop) {
@@ -5457,7 +5417,7 @@ var dryRunInternal = /*#__PURE__*/function () {
5457
5417
  return _context2.a(2, {
5458
5418
  failureReason: failureReason,
5459
5419
  failureChain: failureChain,
5460
- origin: originDryRun,
5420
+ origin: originDryModified,
5461
5421
  assetHub: traversalResult.assetHub,
5462
5422
  bridgeHub: bridgeHubWithCurrency,
5463
5423
  destination: traversalResult.destination,
@@ -5861,20 +5821,15 @@ var handleToAhTeleport = /*#__PURE__*/function () {
5861
5821
  while (1) switch (_context.n) {
5862
5822
  case 0:
5863
5823
  api = input.api, destination = input.destination, address = input.address, senderAddress = input.senderAddress, asset = input.assetInfo, currency = input.currency;
5864
- if (!sdkCommon.isTLocation(destination)) {
5865
- _context.n = 1;
5866
- break;
5867
- }
5868
- throw new InvalidParameterError('Location destination is not supported for this scenario');
5869
- case 1:
5824
+ assertToIsString(destination, 'Location destination is not supported for AH teleport.');
5870
5825
  if (!sdkCommon.isTLocation(address)) {
5871
- _context.n = 2;
5826
+ _context.n = 1;
5872
5827
  break;
5873
5828
  }
5874
5829
  throw new InvalidParameterError('Location address is not supported for this scenario');
5875
- case 2:
5830
+ case 1:
5876
5831
  assertSenderAddress(senderAddress);
5877
- _context.n = 3;
5832
+ _context.n = 2;
5878
5833
  return dryRunInternal({
5879
5834
  api: api,
5880
5835
  tx: defaultTx,
@@ -5884,19 +5839,19 @@ var handleToAhTeleport = /*#__PURE__*/function () {
5884
5839
  address: address,
5885
5840
  currency: currency
5886
5841
  });
5887
- case 3:
5842
+ case 2:
5888
5843
  dryRunResult = _context.v;
5889
5844
  if (!((_dryRunResult$destina = dryRunResult.destination) !== null && _dryRunResult$destina !== void 0 && _dryRunResult$destina.success)) {
5890
- _context.n = 4;
5845
+ _context.n = 3;
5891
5846
  break;
5892
5847
  }
5893
5848
  return _context.a(2, defaultTx);
5894
- case 4:
5849
+ case 3:
5895
5850
  // If the default tx dry run failed, we need to create execute transaction
5896
5851
  dummyTx = createExecuteExchangeXcm(input, origin, MAX_WEIGHT,
5897
5852
  // Enter dummy fee values just to get the dry run to pass
5898
5853
  asset.amount, asset.amount / 2n);
5899
- _context.n = 5;
5854
+ _context.n = 4;
5900
5855
  return getXcmFeeInternal({
5901
5856
  api: api,
5902
5857
  tx: dummyTx,
@@ -5908,7 +5863,7 @@ var handleToAhTeleport = /*#__PURE__*/function () {
5908
5863
  disableFallback: false,
5909
5864
  useRootOrigin: true
5910
5865
  });
5911
- case 5:
5866
+ case 4:
5912
5867
  feeResult = _context.v;
5913
5868
  originExecutionFee = padFeeBy(feeResult.origin.fee, 20); // Pad by 20%
5914
5869
  destinationExecutionFee = padFeeBy(
@@ -6131,7 +6086,7 @@ var Parachain = /*#__PURE__*/function () {
6131
6086
  key: "transfer",
6132
6087
  value: function () {
6133
6088
  var _transfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(sendOptions) {
6134
- var api, asset, currency, feeAsset, feeCurrency, address, destination, paraIdTo, overriddenAsset, version, senderAddress, ahAddress, pallet, method, scenario, paraId, destChain, isLocalTransfer, isRelayAsset, supportsTypeThen, useTypeAndThen, isBifrostOrigin, isJamtonOrigin, isAssetHubDest, useMultiAssets, input, options, shouldUseTeleport, isAhToOtherPara, isOtherParaToAh, isAllowedAhTransfer, isAHPOrigin, isAHPDest, isExternalAsset, isEthDest, isExternalAssetViaAh, isExternalAssetToAh, call;
6089
+ var api, asset, currency, feeAsset, feeCurrency, address, destination, paraIdTo, overriddenAsset, version, senderAddress, ahAddress, pallet, method, scenario, paraId, destChain, isLocalTransfer, isRelayAsset, supportsTypeThen, useTypeAndThen, isBifrostOrigin, isJamtonOrigin, isAssetHubDest, useMultiAssets, input, options, shouldUseTeleport, isAhToOtherPara, isOtherParaToAh, isAllowedAhTransfer, isAHPOrigin, isAHPDest, isExternalAsset, isEthDest, isExternalAssetViaAh, isExternalAssetToAh, call, _t;
6135
6090
  return _regenerator().w(function (_context) {
6136
6091
  while (1) switch (_context.n) {
6137
6092
  case 0:
@@ -6154,7 +6109,7 @@ var Parachain = /*#__PURE__*/function () {
6154
6109
  case 2:
6155
6110
  this.throwIfTempDisabled(sendOptions, destChain);
6156
6111
  this.throwIfCantReceive(destChain);
6157
- isRelayAsset = sdkCommon.deepEqual(asset.location, RELAY_LOCATION);
6112
+ isRelayAsset = sdkCommon.deepEqual(asset.location, RELAY_LOCATION) && assets.isSymbolMatch(assets.getRelayChainSymbol(this.chain), asset.symbol);
6158
6113
  _context.n = 3;
6159
6114
  return api.hasMethod('PolkadotXcm', 'transfer_assets_using_type_and_then');
6160
6115
  case 3:
@@ -6165,7 +6120,7 @@ var Parachain = /*#__PURE__*/function () {
6165
6120
  }
6166
6121
  throw new InvalidParameterError('Relaychain assets can only be transferred using the type-and-then method which is not supported by this chain');
6167
6122
  case 4:
6168
- useTypeAndThen = isRelayAsset && supportsTypeThen && destChain && (!sdkCommon.isTrustedChain(this.chain) || !sdkCommon.isTrustedChain(destChain));
6123
+ useTypeAndThen = isRelayAsset && supportsTypeThen && destChain && !feeAsset && (!sdkCommon.isTrustedChain(this.chain) || !sdkCommon.isTrustedChain(destChain));
6169
6124
  if (!(supportsXTokens(this) && this.canUseXTokens(sendOptions) && !useTypeAndThen)) {
6170
6125
  _context.n = 6;
6171
6126
  break;
@@ -6212,7 +6167,7 @@ var Parachain = /*#__PURE__*/function () {
6212
6167
  }));
6213
6168
  case 7:
6214
6169
  if (!(supportsPolkadotXCM(this) || useTypeAndThen)) {
6215
- _context.n = 13;
6170
+ _context.n = 16;
6216
6171
  break;
6217
6172
  }
6218
6173
  options = {
@@ -6265,7 +6220,7 @@ var Parachain = /*#__PURE__*/function () {
6265
6220
  isExternalAssetViaAh = isExternalAsset && !isAHPOrigin && !isAHPDest && !isEthDest && !feeAsset; // External asset - Any origin to AHP - DestinationReserve - one DepositAsset instruction
6266
6221
  isExternalAssetToAh = isExternalAsset && isAHPDest && !isAHPOrigin && !isEthDest && !feeAsset;
6267
6222
  if (!(isExternalAssetViaAh || isExternalAssetToAh || useTypeAndThen)) {
6268
- _context.n = 12;
6223
+ _context.n = 15;
6269
6224
  break;
6270
6225
  }
6271
6226
  if (!(useTypeAndThen && supportsPolkadotXCM(this))) {
@@ -6275,20 +6230,33 @@ var Parachain = /*#__PURE__*/function () {
6275
6230
  _context.n = 10;
6276
6231
  return this.transferPolkadotXCM(options);
6277
6232
  case 10:
6233
+ if (!isRelayAsset) {
6234
+ _context.n = 12;
6235
+ break;
6236
+ }
6278
6237
  _context.n = 11;
6279
- return createTypeAndThenCall(this.chain, options);
6238
+ return createTypeThenAutoReserve(this.chain, options);
6280
6239
  case 11:
6281
- call = _context.v;
6282
- return _context.a(2, api.callTxMethod(call));
6240
+ _t = _context.v;
6241
+ _context.n = 14;
6242
+ break;
6283
6243
  case 12:
6244
+ _context.n = 13;
6245
+ return createTypeAndThenCall(this.chain, options);
6246
+ case 13:
6247
+ _t = _context.v;
6248
+ case 14:
6249
+ call = _t;
6250
+ return _context.a(2, api.callTxMethod(call));
6251
+ case 15:
6284
6252
  if (!supportsPolkadotXCM(this)) {
6285
- _context.n = 13;
6253
+ _context.n = 16;
6286
6254
  break;
6287
6255
  }
6288
6256
  return _context.a(2, this.transferPolkadotXCM(options));
6289
- case 13:
6257
+ case 16:
6290
6258
  throw new NoXCMSupportImplementedError(this._chain);
6291
- case 14:
6259
+ case 17:
6292
6260
  return _context.a(2);
6293
6261
  }
6294
6262
  }, _callee, this);
@@ -6315,7 +6283,8 @@ var Parachain = /*#__PURE__*/function () {
6315
6283
  if (isSendingDisabled) {
6316
6284
  throw new InvalidParameterError("Sending from ".concat(this.chain, " is temporarily disabled"));
6317
6285
  }
6318
- var isReceivingDisabled = destChain && !sdkCommon.isRelayChain(destChain) && !sdkCommon.isExternalChain(destChain) && getChain(destChain).isReceivingTempDisabled(options);
6286
+ var scenario = resolveScenario(this.chain, options.to);
6287
+ var isReceivingDisabled = destChain && !sdkCommon.isRelayChain(destChain) && !sdkCommon.isExternalChain(destChain) && getChain(destChain).isReceivingTempDisabled(scenario);
6319
6288
  if (isReceivingDisabled) {
6320
6289
  throw new InvalidParameterError("Receiving on ".concat(destChain, " is temporarily disabled"));
6321
6290
  }
@@ -6327,7 +6296,7 @@ var Parachain = /*#__PURE__*/function () {
6327
6296
  }
6328
6297
  }, {
6329
6298
  key: "isReceivingTempDisabled",
6330
- value: function isReceivingTempDisabled(_options) {
6299
+ value: function isReceivingTempDisabled(_scenario) {
6331
6300
  return false;
6332
6301
  }
6333
6302
  }, {
@@ -6363,39 +6332,46 @@ var Parachain = /*#__PURE__*/function () {
6363
6332
  key: "transferRelayToPara",
6364
6333
  value: function () {
6365
6334
  var _transferRelayToPara = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
6366
- var api, version, pallet, assetInfo, address, destination, paraIdTo, methodOverride, _this$getRelayToParaO, method, includeFee, customMethod, paraId, destChain, scenario;
6335
+ var api, version, pallet, assetInfo, address, senderAddress, destination, paraIdTo, methodOverride, _this$getRelayToParaO, method, includeFee, customMethod, paraId, destChain, scenario;
6367
6336
  return _regenerator().w(function (_context2) {
6368
6337
  while (1) switch (_context2.n) {
6369
6338
  case 0:
6370
- api = options.api, version = options.version, pallet = options.pallet, assetInfo = options.assetInfo, address = options.address, destination = options.destination, paraIdTo = options.paraIdTo, methodOverride = options.method;
6339
+ api = options.api, version = options.version, pallet = options.pallet, assetInfo = options.assetInfo, address = options.address, senderAddress = options.senderAddress, destination = options.destination, paraIdTo = options.paraIdTo, methodOverride = options.method;
6371
6340
  _this$getRelayToParaO = this.getRelayToParaOverrides(), method = _this$getRelayToParaO.method, includeFee = _this$getRelayToParaO.includeFee;
6341
+ if (!this.isReceivingTempDisabled('RelayToPara')) {
6342
+ _context2.n = 1;
6343
+ break;
6344
+ }
6345
+ throw new InvalidParameterError("Receiving on ".concat(this.chain, " is temporarily disabled"));
6346
+ case 1:
6372
6347
  customMethod = methodOverride !== null && methodOverride !== void 0 ? methodOverride : method;
6373
6348
  if (!(customMethod === 'transfer_assets_using_type_and_then')) {
6374
- _context2.n = 2;
6349
+ _context2.n = 3;
6375
6350
  break;
6376
6351
  }
6377
6352
  paraId = resolveParaId(paraIdTo, destination);
6378
6353
  destChain = resolveDestChain(this.chain, paraId);
6379
6354
  scenario = 'RelayToPara';
6380
6355
  if (destChain) {
6381
- _context2.n = 1;
6356
+ _context2.n = 2;
6382
6357
  break;
6383
6358
  }
6384
6359
  throw new InvalidParameterError('Cannot override destination when using type and then transfer.');
6385
- case 1:
6386
- return _context2.a(2, createTypeAndThenCall(getRelayChainOf(destChain), _objectSpread2(_objectSpread2({}, options), {}, {
6360
+ case 2:
6361
+ return _context2.a(2, createTypeThenAutoReserve(getRelayChainOf(destChain), _objectSpread2(_objectSpread2({}, options), {}, {
6387
6362
  beneficiaryLocation: createBeneficiaryLocation({
6388
6363
  api: api,
6389
6364
  address: address,
6390
6365
  version: version
6391
6366
  }),
6367
+ senderAddress: senderAddress,
6392
6368
  asset: this.createCurrencySpec(assetInfo.amount, scenario, version, assetInfo, false),
6393
6369
  destLocation: createDestination(version, this.chain, destination, paraId),
6394
6370
  scenario: scenario,
6395
6371
  destChain: destChain,
6396
6372
  paraIdTo: paraId
6397
6373
  })));
6398
- case 2:
6374
+ case 3:
6399
6375
  return _context2.a(2, {
6400
6376
  module: pallet !== null && pallet !== void 0 ? pallet : 'XcmPallet',
6401
6377
  method: customMethod,
@@ -7659,11 +7635,21 @@ var ComposableFinance = /*#__PURE__*/function (_Parachain) {
7659
7635
  assertHasId(asset);
7660
7636
  return transferXTokens(input, BigInt(asset.assetId));
7661
7637
  }
7662
- }]);
7663
- }(Parachain);
7664
-
7665
- var CoretimeKusama = /*#__PURE__*/function (_Parachain) {
7666
- function CoretimeKusama() {
7638
+ }, {
7639
+ key: "isSendingTempDisabled",
7640
+ value: function isSendingTempDisabled(_options) {
7641
+ return true;
7642
+ }
7643
+ }, {
7644
+ key: "isReceivingTempDisabled",
7645
+ value: function isReceivingTempDisabled(_scenario) {
7646
+ return true;
7647
+ }
7648
+ }]);
7649
+ }(Parachain);
7650
+
7651
+ var CoretimeKusama = /*#__PURE__*/function (_Parachain) {
7652
+ function CoretimeKusama() {
7667
7653
  _classCallCheck(this, CoretimeKusama);
7668
7654
  return _callSuper(this, CoretimeKusama, ['CoretimeKusama', 'kusamaCoretime', 'Kusama', sdkCommon.Version.V5]);
7669
7655
  }
@@ -7671,10 +7657,11 @@ var CoretimeKusama = /*#__PURE__*/function (_Parachain) {
7671
7657
  return _createClass(CoretimeKusama, [{
7672
7658
  key: "transferPolkadotXCM",
7673
7659
  value: function transferPolkadotXCM(input) {
7674
- // TESTED block hash on Rococo: 0x78ace0f1bf7cac9a42e56143321b617d98327e2750f795efb0abb833025c9082
7675
7660
  var scenario = input.scenario;
7676
- var method = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
7677
- return transferPolkadotXcm(input, method, 'Unlimited');
7661
+ if (scenario === 'ParaToPara') {
7662
+ throw new ScenarioNotSupportedError(this.chain, scenario);
7663
+ }
7664
+ return transferPolkadotXcm(input, 'limited_teleport_assets', 'Unlimited');
7678
7665
  }
7679
7666
  }, {
7680
7667
  key: "getRelayToParaOverrides",
@@ -7706,6 +7693,11 @@ var CoretimePolkadot = /*#__PURE__*/function (_Parachain) {
7706
7693
  }
7707
7694
  return transferPolkadotXcm(input, 'limited_teleport_assets', 'Unlimited');
7708
7695
  }
7696
+ }, {
7697
+ key: "canReceiveFrom",
7698
+ value: function canReceiveFrom(origin) {
7699
+ return origin !== 'Hydration' && origin !== 'Moonbeam';
7700
+ }
7709
7701
  }, {
7710
7702
  key: "getRelayToParaOverrides",
7711
7703
  value: function getRelayToParaOverrides() {
@@ -7873,6 +7865,16 @@ var Curio = /*#__PURE__*/function (_Parachain) {
7873
7865
  };
7874
7866
  return transferXTokens(input, currencySelection);
7875
7867
  }
7868
+ }, {
7869
+ key: "isSendingTempDisabled",
7870
+ value: function isSendingTempDisabled(_options) {
7871
+ return true;
7872
+ }
7873
+ }, {
7874
+ key: "isReceivingTempDisabled",
7875
+ value: function isReceivingTempDisabled(_scenario) {
7876
+ return true;
7877
+ }
7876
7878
  }]);
7877
7879
  }(Parachain);
7878
7880
 
@@ -7995,7 +7997,7 @@ var EnergyWebXPaseo = /*#__PURE__*/function (_EnergyWebX) {
7995
7997
  var Heima = /*#__PURE__*/function (_Parachain) {
7996
7998
  function Heima() {
7997
7999
  var chain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Heima';
7998
- var info = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'litentry';
8000
+ var info = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'heima';
7999
8001
  var ecosystem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Polkadot';
8000
8002
  var version = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : sdkCommon.Version.V5;
8001
8003
  _classCallCheck(this, Heima);
@@ -8167,6 +8169,12 @@ var Polimec = /*#__PURE__*/function (_Parachain) {
8167
8169
  }
8168
8170
  return transferPolkadotXCM;
8169
8171
  }()
8172
+ }, {
8173
+ key: "isSendingTempDisabled",
8174
+ value: function isSendingTempDisabled(_ref3) {
8175
+ var assetInfo = _ref3.assetInfo;
8176
+ return assets.isSymbolMatch(assetInfo.symbol, this.getNativeAssetSymbol());
8177
+ }
8170
8178
  }, {
8171
8179
  key: "transferRelayToPara",
8172
8180
  value: function transferRelayToPara(options) {
@@ -8884,7 +8892,7 @@ var Moonriver = /*#__PURE__*/function (_Parachain) {
8884
8892
 
8885
8893
  var createTypeAndThenTransfer = /*#__PURE__*/function () {
8886
8894
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, chain, version) {
8887
- var api, asset, senderAddress, address, destination, messageId, ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, ahExecutionFee, feeConverted, nativeMythAmount;
8895
+ var api, asset, senderAddress, address, destination, messageId, nativeMythAmount;
8888
8896
  return _regenerator().w(function (_context) {
8889
8897
  while (1) switch (_context.n) {
8890
8898
  case 0:
@@ -8902,28 +8910,10 @@ var createTypeAndThenTransfer = /*#__PURE__*/function () {
8902
8910
  return generateMessageId(api, senderAddress, getParaId(chain), asset.assetId, address, asset.amount);
8903
8911
  case 2:
8904
8912
  messageId = _context.v;
8905
- ahApi = api.clone();
8906
8913
  _context.n = 3;
8907
- return ahApi.init('AssetHubPolkadot');
8914
+ return getMythosOriginFee(api);
8908
8915
  case 3:
8909
- _context.n = 4;
8910
- return getParaEthTransferFees(ahApi);
8911
- case 4:
8912
- _yield$getParaEthTran = _context.v;
8913
- _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
8914
- bridgeFee = _yield$getParaEthTran2[0];
8915
- ahExecutionFee = _yield$getParaEthTran2[1];
8916
- _context.n = 5;
8917
- return ahApi.quoteAhPrice(DOT_LOCATION, assets.getNativeAssets(chain)[0].location, bridgeFee + ahExecutionFee);
8918
- case 5:
8919
- feeConverted = _context.v;
8920
- if (feeConverted) {
8921
- _context.n = 6;
8922
- break;
8923
- }
8924
- throw new InvalidParameterError("Pool DOT -> ".concat(asset.symbol, " not found."));
8925
- case 6:
8926
- nativeMythAmount = padFeeBy(feeConverted, 10);
8916
+ nativeMythAmount = _context.v;
8927
8917
  return _context.a(2, {
8928
8918
  module: 'PolkadotXcm',
8929
8919
  method: 'transfer_assets_using_type_and_then',
@@ -9121,7 +9111,17 @@ var PAssetHub = /*#__PURE__*/function (_PeoplePolkadot) {
9121
9111
  return _callSuper(this, PAssetHub, ['PAssetHub', 'PAssetHub - Contracts', 'Paseo', sdkCommon.Version.V5]);
9122
9112
  }
9123
9113
  _inherits(PAssetHub, _PeoplePolkadot);
9124
- return _createClass(PAssetHub);
9114
+ return _createClass(PAssetHub, [{
9115
+ key: "isSendingTempDisabled",
9116
+ value: function isSendingTempDisabled(_options) {
9117
+ return true;
9118
+ }
9119
+ }, {
9120
+ key: "isReceivingTempDisabled",
9121
+ value: function isReceivingTempDisabled(_scenario) {
9122
+ return true;
9123
+ }
9124
+ }]);
9125
9125
  }(PeoplePolkadot);
9126
9126
 
9127
9127
  var Peaq = /*#__PURE__*/function (_Parachain) {
@@ -9146,6 +9146,16 @@ var Peaq = /*#__PURE__*/function (_Parachain) {
9146
9146
  value: function transferRelayToPara() {
9147
9147
  throw new ChainNotSupportedError();
9148
9148
  }
9149
+ }, {
9150
+ key: "isSendingTempDisabled",
9151
+ value: function isSendingTempDisabled(_options) {
9152
+ return true;
9153
+ }
9154
+ }, {
9155
+ key: "isReceivingTempDisabled",
9156
+ value: function isReceivingTempDisabled(_scenario) {
9157
+ return true;
9158
+ }
9149
9159
  }, {
9150
9160
  key: "transferLocalNonNativeAsset",
9151
9161
  value: function transferLocalNonNativeAsset(options) {
@@ -9397,8 +9407,17 @@ var RobonomicsPolkadot = /*#__PURE__*/function (_Parachain) {
9397
9407
  return _createClass(RobonomicsPolkadot, [{
9398
9408
  key: "transferPolkadotXCM",
9399
9409
  value: function transferPolkadotXCM(input) {
9410
+ var scenario = input.scenario;
9411
+ if (scenario === 'ParaToPara') {
9412
+ throw new ScenarioNotSupportedError(this.chain, scenario);
9413
+ }
9400
9414
  return transferPolkadotXcm(input, 'limited_reserve_transfer_assets', 'Unlimited');
9401
9415
  }
9416
+ }, {
9417
+ key: "isReceivingTempDisabled",
9418
+ value: function isReceivingTempDisabled(scenario) {
9419
+ return scenario !== 'RelayToPara';
9420
+ }
9402
9421
  }, {
9403
9422
  key: "transferLocalNonNativeAsset",
9404
9423
  value: function transferLocalNonNativeAsset(options) {
@@ -9472,6 +9491,16 @@ var Subsocial = /*#__PURE__*/function (_Parachain) {
9472
9491
  }
9473
9492
  return transferPolkadotXcm(input, 'limited_reserve_transfer_assets', 'Unlimited');
9474
9493
  }
9494
+ }, {
9495
+ key: "isSendingTempDisabled",
9496
+ value: function isSendingTempDisabled(_options) {
9497
+ return true;
9498
+ }
9499
+ }, {
9500
+ key: "isReceivingTempDisabled",
9501
+ value: function isReceivingTempDisabled(_scenario) {
9502
+ return true;
9503
+ }
9475
9504
  }]);
9476
9505
  }(Parachain);
9477
9506
 
@@ -9554,6 +9583,11 @@ var Zeitgeist = /*#__PURE__*/function (_Parachain) {
9554
9583
  var currencySelection = this.getCurrencySelection(asset);
9555
9584
  return transferXTokens(input, currencySelection);
9556
9585
  }
9586
+ }, {
9587
+ key: "canReceiveFrom",
9588
+ value: function canReceiveFrom(origin) {
9589
+ return origin !== 'Astar';
9590
+ }
9557
9591
  }, {
9558
9592
  key: "transferLocalNonNativeAsset",
9559
9593
  value: function transferLocalNonNativeAsset(options) {
@@ -9857,10 +9891,17 @@ var dryRunOrigin = /*#__PURE__*/function () {
9857
9891
  };
9858
9892
  }();
9859
9893
 
9860
- var AssetManagerPallet = /*#__PURE__*/function () {
9894
+ var BaseAssetsPallet = /*#__PURE__*/_createClass(function BaseAssetsPallet(palletName) {
9895
+ _classCallCheck(this, BaseAssetsPallet);
9896
+ this.palletName = palletName;
9897
+ });
9898
+
9899
+ var AssetManagerPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
9861
9900
  function AssetManagerPallet() {
9862
9901
  _classCallCheck(this, AssetManagerPallet);
9902
+ return _callSuper(this, AssetManagerPallet, arguments);
9863
9903
  }
9904
+ _inherits(AssetManagerPallet, _BaseAssetsPallet);
9864
9905
  return _createClass(AssetManagerPallet, [{
9865
9906
  key: "mint",
9866
9907
  value: function mint(address, asset, balance) {
@@ -9869,7 +9910,7 @@ var AssetManagerPallet = /*#__PURE__*/function () {
9869
9910
  amount = asset.amount;
9870
9911
  return Promise.resolve({
9871
9912
  balanceTx: {
9872
- module: 'AssetManager',
9913
+ module: this.palletName,
9873
9914
  method: 'updateBalance',
9874
9915
  parameters: {
9875
9916
  who: {
@@ -9884,12 +9925,59 @@ var AssetManagerPallet = /*#__PURE__*/function () {
9884
9925
  });
9885
9926
  }
9886
9927
  }]);
9887
- }();
9928
+ }(BaseAssetsPallet);
9888
9929
 
9889
- var BalancesPallet = /*#__PURE__*/function () {
9930
+ var AssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
9931
+ function AssetsPallet() {
9932
+ _classCallCheck(this, AssetsPallet);
9933
+ return _callSuper(this, AssetsPallet, arguments);
9934
+ }
9935
+ _inherits(AssetsPallet, _BaseAssetsPallet);
9936
+ return _createClass(AssetsPallet, [{
9937
+ key: "mint",
9938
+ value: function mint(address, asset, _balance, chain) {
9939
+ assertHasId(asset);
9940
+ var assetId = asset.assetId,
9941
+ amount = asset.amount;
9942
+ var id = chain === 'Astar' || chain === 'Shiden' || chain === 'Moonbeam' ? BigInt(assetId) : Number(assetId);
9943
+ var addr = assets.isChainEvm(chain) ? address : {
9944
+ Id: address
9945
+ };
9946
+ return Promise.resolve({
9947
+ assetStatusTx: {
9948
+ module: this.palletName,
9949
+ method: 'force_asset_status',
9950
+ parameters: {
9951
+ id: id,
9952
+ owner: addr,
9953
+ issuer: addr,
9954
+ admin: addr,
9955
+ freezer: addr,
9956
+ min_balance: 0n,
9957
+ is_sufficient: true,
9958
+ is_frozen: false
9959
+ }
9960
+ },
9961
+ balanceTx: {
9962
+ module: this.palletName,
9963
+ method: 'mint',
9964
+ parameters: {
9965
+ id: id,
9966
+ beneficiary: addr,
9967
+ amount: amount
9968
+ }
9969
+ }
9970
+ });
9971
+ }
9972
+ }]);
9973
+ }(BaseAssetsPallet);
9974
+
9975
+ var BalancesPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
9890
9976
  function BalancesPallet() {
9891
9977
  _classCallCheck(this, BalancesPallet);
9978
+ return _callSuper(this, BalancesPallet, arguments);
9892
9979
  }
9980
+ _inherits(BalancesPallet, _BaseAssetsPallet);
9893
9981
  return _createClass(BalancesPallet, [{
9894
9982
  key: "mint",
9895
9983
  value: function mint(address, assetInfo, balance, chain) {
@@ -9897,7 +9985,7 @@ var BalancesPallet = /*#__PURE__*/function () {
9897
9985
  var notUseId = chain.startsWith('Hydration') || chain === 'Basilisk' || assets.isChainEvm(chain);
9898
9986
  return Promise.resolve({
9899
9987
  balanceTx: {
9900
- module: 'Balances',
9988
+ module: this.palletName,
9901
9989
  method: 'force_set_balance',
9902
9990
  parameters: {
9903
9991
  who: notUseId ? address : {
@@ -9909,12 +9997,14 @@ var BalancesPallet = /*#__PURE__*/function () {
9909
9997
  });
9910
9998
  }
9911
9999
  }]);
9912
- }();
10000
+ }(BaseAssetsPallet);
9913
10001
 
9914
- var CurrenciesPallet = /*#__PURE__*/function () {
10002
+ var CurrenciesPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
9915
10003
  function CurrenciesPallet() {
9916
10004
  _classCallCheck(this, CurrenciesPallet);
10005
+ return _callSuper(this, CurrenciesPallet, arguments);
9917
10006
  }
10007
+ _inherits(CurrenciesPallet, _BaseAssetsPallet);
9918
10008
  return _createClass(CurrenciesPallet, [{
9919
10009
  key: "mint",
9920
10010
  value: function mint(address, assetInfo, balance) {
@@ -9923,7 +10013,7 @@ var CurrenciesPallet = /*#__PURE__*/function () {
9923
10013
  amount = assetInfo.amount;
9924
10014
  return Promise.resolve({
9925
10015
  balanceTx: {
9926
- module: 'Currencies',
10016
+ module: this.palletName,
9927
10017
  method: 'update_balance',
9928
10018
  parameters: {
9929
10019
  who: address,
@@ -9934,12 +10024,14 @@ var CurrenciesPallet = /*#__PURE__*/function () {
9934
10024
  });
9935
10025
  }
9936
10026
  }]);
9937
- }();
10027
+ }(BaseAssetsPallet);
9938
10028
 
9939
- var ForeignAssetsPallet = /*#__PURE__*/function () {
10029
+ var ForeignAssetsPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
9940
10030
  function ForeignAssetsPallet() {
9941
10031
  _classCallCheck(this, ForeignAssetsPallet);
10032
+ return _callSuper(this, ForeignAssetsPallet, arguments);
9942
10033
  }
10034
+ _inherits(ForeignAssetsPallet, _BaseAssetsPallet);
9943
10035
  return _createClass(ForeignAssetsPallet, [{
9944
10036
  key: "mint",
9945
10037
  value: function mint(address, asset) {
@@ -9948,7 +10040,7 @@ var ForeignAssetsPallet = /*#__PURE__*/function () {
9948
10040
  amount = asset.amount;
9949
10041
  return Promise.resolve({
9950
10042
  assetStatusTx: {
9951
- module: 'ForeignAssets',
10043
+ module: this.palletName,
9952
10044
  method: 'force_asset_status',
9953
10045
  parameters: {
9954
10046
  id: location,
@@ -9970,7 +10062,7 @@ var ForeignAssetsPallet = /*#__PURE__*/function () {
9970
10062
  }
9971
10063
  },
9972
10064
  balanceTx: {
9973
- module: 'ForeignAssets',
10065
+ module: this.palletName,
9974
10066
  method: 'mint',
9975
10067
  parameters: {
9976
10068
  id: location,
@@ -9983,7 +10075,7 @@ var ForeignAssetsPallet = /*#__PURE__*/function () {
9983
10075
  });
9984
10076
  }
9985
10077
  }]);
9986
- }();
10078
+ }(BaseAssetsPallet);
9987
10079
 
9988
10080
  var SIZE = 32;
9989
10081
  var BALANCE_SLOT = 0;
@@ -9998,10 +10090,12 @@ var calculateMappingSlot = function calculateMappingSlot(key) {
9998
10090
  var encoded = viem.concat([keyPadded, slotHex]);
9999
10091
  return viem.keccak256(encoded);
10000
10092
  };
10001
- var SystemPallet = /*#__PURE__*/function () {
10093
+ var SystemPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
10002
10094
  function SystemPallet() {
10003
10095
  _classCallCheck(this, SystemPallet);
10096
+ return _callSuper(this, SystemPallet, arguments);
10004
10097
  }
10098
+ _inherits(SystemPallet, _BaseAssetsPallet);
10005
10099
  return _createClass(SystemPallet, [{
10006
10100
  key: "mint",
10007
10101
  value: function () {
@@ -10022,7 +10116,7 @@ var SystemPallet = /*#__PURE__*/function () {
10022
10116
  storageKey = _context.v;
10023
10117
  return _context.a(2, {
10024
10118
  balanceTx: {
10025
- module: 'System',
10119
+ module: this.palletName,
10026
10120
  method: 'set_storage',
10027
10121
  parameters: {
10028
10122
  items: [[storageKey, amountEncoded]]
@@ -10030,7 +10124,7 @@ var SystemPallet = /*#__PURE__*/function () {
10030
10124
  }
10031
10125
  });
10032
10126
  }
10033
- }, _callee);
10127
+ }, _callee, this);
10034
10128
  }));
10035
10129
  function mint(_x, _x2, _x3, _x4, _x5) {
10036
10130
  return _mint.apply(this, arguments);
@@ -10038,12 +10132,14 @@ var SystemPallet = /*#__PURE__*/function () {
10038
10132
  return mint;
10039
10133
  }()
10040
10134
  }]);
10041
- }();
10135
+ }(BaseAssetsPallet);
10042
10136
 
10043
- var TokensPallet = /*#__PURE__*/function () {
10137
+ var TokensPallet = /*#__PURE__*/function (_BaseAssetsPallet) {
10044
10138
  function TokensPallet() {
10045
10139
  _classCallCheck(this, TokensPallet);
10140
+ return _callSuper(this, TokensPallet, arguments);
10046
10141
  }
10142
+ _inherits(TokensPallet, _BaseAssetsPallet);
10047
10143
  return _createClass(TokensPallet, [{
10048
10144
  key: "mint",
10049
10145
  value: function mint(address, asset, balance, chain) {
@@ -10053,7 +10149,7 @@ var TokensPallet = /*#__PURE__*/function () {
10053
10149
  var amount = asset.amount;
10054
10150
  return Promise.resolve({
10055
10151
  balanceTx: {
10056
- module: 'Tokens',
10152
+ module: this.palletName,
10057
10153
  method: 'set_balance',
10058
10154
  parameters: {
10059
10155
  who: {
@@ -10067,35 +10163,93 @@ var TokensPallet = /*#__PURE__*/function () {
10067
10163
  });
10068
10164
  }
10069
10165
  }]);
10070
- }();
10166
+ }(BaseAssetsPallet);
10071
10167
 
10072
10168
  var palletRegistry = {
10073
- Balances: BalancesPallet,
10074
- Tokens: TokensPallet,
10075
- Currencies: CurrenciesPallet,
10076
- Assets: AssetsPallet,
10077
- ForeignAssets: ForeignAssetsPallet,
10078
- AssetManager: AssetManagerPallet,
10079
- System: SystemPallet
10169
+ Balances: new BalancesPallet('Balances'),
10170
+ Tokens: new TokensPallet('Tokens'),
10171
+ Currencies: new CurrenciesPallet('Currencies'),
10172
+ Assets: new AssetsPallet('Assets'),
10173
+ ForeignAssets: new ForeignAssetsPallet('ForeignAssets'),
10174
+ AssetManager: new AssetManagerPallet('AssetManager'),
10175
+ System: new SystemPallet('System'),
10176
+ Fungibles: new AssetsPallet('Fungibles')
10080
10177
  };
10081
10178
  var getPalletInstance = function getPalletInstance(type) {
10082
- var HandlerClass = palletRegistry[type];
10083
- return new HandlerClass();
10179
+ return palletRegistry[type];
10084
10180
  };
10085
10181
 
10086
- var getCurrencySelection = function getCurrencySelection(asset) {
10087
- if (asset.location) return {
10088
- location: asset.location
10182
+ var getOriginFeeDetailsInternal = /*#__PURE__*/function () {
10183
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
10184
+ var _getExistentialDeposi;
10185
+ var api, account, accountDestination, ahAddress, currency, origin, destination, _ref$feeMarginPercent, feeMarginPercentage, tx, xcmFee, xcmFeeWithMargin, nativeBalance, existentialDeposit, sufficientForXCM;
10186
+ return _regenerator().w(function (_context) {
10187
+ while (1) switch (_context.n) {
10188
+ case 0:
10189
+ api = _ref.api, account = _ref.account, accountDestination = _ref.accountDestination, ahAddress = _ref.ahAddress, currency = _ref.currency, origin = _ref.origin, destination = _ref.destination, _ref$feeMarginPercent = _ref.feeMarginPercentage, feeMarginPercentage = _ref$feeMarginPercent === void 0 ? 10 : _ref$feeMarginPercent;
10190
+ _context.n = 1;
10191
+ return api.init(origin);
10192
+ case 1:
10193
+ _context.n = 2;
10194
+ return Builder(api).from(origin).to(destination).currency(currency).address(accountDestination).senderAddress(account).ahAddress(ahAddress)['buildInternal']();
10195
+ case 2:
10196
+ tx = _context.v;
10197
+ _context.n = 3;
10198
+ return api.calculateTransactionFee(tx, account);
10199
+ case 3:
10200
+ xcmFee = _context.v;
10201
+ xcmFeeWithMargin = xcmFee + xcmFee / BigInt(feeMarginPercentage);
10202
+ _context.n = 4;
10203
+ return getBalanceNativeInternal({
10204
+ address: account,
10205
+ chain: origin,
10206
+ api: api
10207
+ });
10208
+ case 4:
10209
+ nativeBalance = _context.v;
10210
+ existentialDeposit = BigInt((_getExistentialDeposi = assets.getExistentialDeposit(origin)) !== null && _getExistentialDeposi !== void 0 ? _getExistentialDeposi : '0');
10211
+ sufficientForXCM = nativeBalance - existentialDeposit - xcmFeeWithMargin > 0;
10212
+ return _context.a(2, {
10213
+ sufficientForXCM: sufficientForXCM,
10214
+ xcmFee: xcmFee
10215
+ });
10216
+ }
10217
+ }, _callee);
10218
+ }));
10219
+ return function getOriginFeeDetailsInternal(_x) {
10220
+ return _ref2.apply(this, arguments);
10089
10221
  };
10090
- if (assets.isForeignAsset(asset) && asset.assetId) {
10091
- return {
10092
- id: asset.assetId
10093
- };
10094
- }
10095
- return {
10096
- symbol: asset.symbol
10222
+ }();
10223
+ var getOriginFeeDetails = /*#__PURE__*/function () {
10224
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
10225
+ var api;
10226
+ return _regenerator().w(function (_context2) {
10227
+ while (1) switch (_context2.p = _context2.n) {
10228
+ case 0:
10229
+ api = options.api;
10230
+ api.setDisconnectAllowed(false);
10231
+ _context2.p = 1;
10232
+ _context2.n = 2;
10233
+ return getOriginFeeDetailsInternal(options);
10234
+ case 2:
10235
+ return _context2.a(2, _context2.v);
10236
+ case 3:
10237
+ _context2.p = 3;
10238
+ api.setDisconnectAllowed(true);
10239
+ _context2.n = 4;
10240
+ return api.disconnect();
10241
+ case 4:
10242
+ return _context2.f(3);
10243
+ case 5:
10244
+ return _context2.a(2);
10245
+ }
10246
+ }, _callee2, null, [[1,, 3, 5]]);
10247
+ }));
10248
+ return function getOriginFeeDetails(_x2) {
10249
+ return _ref3.apply(this, arguments);
10097
10250
  };
10098
- };
10251
+ }();
10252
+
10099
10253
  var pickOtherPallet = function pickOtherPallet(asset, pallets) {
10100
10254
  if (assets.isForeignAsset(asset) && (!asset.assetId || asset.assetId.startsWith('0x'))) {
10101
10255
  var _pallets$find;
@@ -10803,7 +10957,7 @@ var getFailureInfo = function getFailureInfo(chains, hops) {
10803
10957
  };
10804
10958
  var getXcmFeeInternal = /*#__PURE__*/function () {
10805
10959
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
10806
- var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, swapConfig, useRootOrigin, asset, amount, _yield$getOriginXcmFe, originFee, originCurrency, originAsset, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, processHop, traversalResult, destFee, destCurrency, destAsset, destFeeType, destDryRunError, destSufficient, destResult, _destApi, destFallback, assetHubChain, processedBridgeHub, bridgeHubChain, bridgeHubHopIndex, convertToFeeDetail, result, _getFailureInfo2, failureChain, failureReason;
10960
+ var api, tx, origin, destination, senderAddress, address, currency, feeAsset, disableFallback, swapConfig, useRootOrigin, asset, amount, _yield$getOriginXcmFe, originFeeRaw, originCurrency, originAsset, originFeeType, originDryRunError, initialForwardedXcm, initialDestParaId, originWeight, sufficientOriginFee, isMythosToEthereum, originFee, destApi, destFeeRes, _result, _getFailureInfo, _failureChain, _failureReason, processHop, traversalResult, destFee, destCurrency, destAsset, destFeeType, destDryRunError, destSufficient, destResult, _destApi, destFallback, assetHubChain, processedBridgeHub, bridgeHubChain, bridgeHubHopIndex, convertToFeeDetail, result, _getFailureInfo2, failureChain, failureReason, _t, _t2, _t3, _t4;
10807
10961
  return _regenerator().w(function (_context2) {
10808
10962
  while (1) switch (_context2.p = _context2.n) {
10809
10963
  case 0:
@@ -10824,7 +10978,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10824
10978
  });
10825
10979
  case 1:
10826
10980
  _yield$getOriginXcmFe = _context2.v;
10827
- originFee = _yield$getOriginXcmFe.fee;
10981
+ originFeeRaw = _yield$getOriginXcmFe.fee;
10828
10982
  originCurrency = _yield$getOriginXcmFe.currency;
10829
10983
  originAsset = _yield$getOriginXcmFe.asset;
10830
10984
  originFeeType = _yield$getOriginXcmFe.feeType;
@@ -10833,17 +10987,34 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10833
10987
  initialDestParaId = _yield$getOriginXcmFe.destParaId;
10834
10988
  originWeight = _yield$getOriginXcmFe.weight;
10835
10989
  sufficientOriginFee = _yield$getOriginXcmFe.sufficient;
10990
+ isMythosToEthereum = origin === 'Mythos' && destination === 'Ethereum';
10991
+ if (!isMythosToEthereum) {
10992
+ _context2.n = 3;
10993
+ break;
10994
+ }
10995
+ _context2.n = 2;
10996
+ return getMythosOriginFee(api);
10997
+ case 2:
10998
+ _t2 = _context2.v;
10999
+ _t3 = originFeeRaw !== null && originFeeRaw !== void 0 ? originFeeRaw : 0n;
11000
+ _t = _t2 + _t3;
11001
+ _context2.n = 4;
11002
+ break;
11003
+ case 3:
11004
+ _t = originFeeRaw;
11005
+ case 4:
11006
+ originFee = _t;
10836
11007
  if (!(originDryRunError || originFeeType === 'paymentInfo')) {
10837
- _context2.n = 7;
11008
+ _context2.n = 10;
10838
11009
  break;
10839
11010
  }
10840
11011
  destApi = api.clone();
10841
- _context2.p = 2;
10842
- _context2.n = 3;
11012
+ _context2.p = 5;
11013
+ _context2.n = 6;
10843
11014
  return destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
10844
- case 3:
11015
+ case 6:
10845
11016
  destApi.setDisconnectAllowed(false);
10846
- _context2.n = 4;
11017
+ _context2.n = 7;
10847
11018
  return getDestXcmFee({
10848
11019
  api: destApi,
10849
11020
  forwardedXcms: undefined,
@@ -10862,7 +11033,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10862
11033
  disableFallback: disableFallback,
10863
11034
  swapConfig: swapConfig
10864
11035
  });
10865
- case 4:
11036
+ case 7:
10866
11037
  destFeeRes = _context2.v;
10867
11038
  _result = {
10868
11039
  origin: _objectSpread2(_objectSpread2(_objectSpread2({}, originFee && {
@@ -10898,14 +11069,14 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10898
11069
  failureChain: _failureChain,
10899
11070
  failureReason: _failureReason
10900
11071
  }));
10901
- case 5:
10902
- _context2.p = 5;
11072
+ case 8:
11073
+ _context2.p = 8;
10903
11074
  destApi.setDisconnectAllowed(true);
10904
- _context2.n = 6;
11075
+ _context2.n = 9;
10905
11076
  return destApi.disconnect();
10906
- case 6:
10907
- return _context2.f(5);
10908
- case 7:
11077
+ case 9:
11078
+ return _context2.f(8);
11079
+ case 10:
10909
11080
  processHop = /*#__PURE__*/function () {
10910
11081
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
10911
11082
  var hopApi, currentChain, currentOrigin, currentAsset, forwardedXcms, hasPassedExchange, hopAsset, hopResult;
@@ -10954,7 +11125,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10954
11125
  return _ref3.apply(this, arguments);
10955
11126
  };
10956
11127
  }();
10957
- _context2.n = 8;
11128
+ _context2.n = 11;
10958
11129
  return traverseXcmHops({
10959
11130
  api: api,
10960
11131
  origin: origin,
@@ -10974,14 +11145,14 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10974
11145
  };
10975
11146
  }
10976
11147
  });
10977
- case 8:
11148
+ case 11:
10978
11149
  traversalResult = _context2.v;
10979
11150
  // Handle case where we failed before reaching destination
10980
11151
  destFee = 0n;
10981
11152
  destFeeType = destination === 'Ethereum' ? 'noFeeRequired' : 'paymentInfo';
10982
11153
  destSufficient = undefined;
10983
11154
  if (!traversalResult.destination) {
10984
- _context2.n = 9;
11155
+ _context2.n = 12;
10985
11156
  break;
10986
11157
  }
10987
11158
  destResult = traversalResult.destination;
@@ -10991,19 +11162,19 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
10991
11162
  destSufficient = destResult.sufficient;
10992
11163
  destCurrency = destResult.currency;
10993
11164
  destAsset = destResult.asset;
10994
- _context2.n = 13;
11165
+ _context2.n = 16;
10995
11166
  break;
10996
- case 9:
11167
+ case 12:
10997
11168
  if (!(traversalResult.hops.length > 0 && traversalResult.hops[traversalResult.hops.length - 1].result.dryRunError)) {
10998
- _context2.n = 12;
11169
+ _context2.n = 15;
10999
11170
  break;
11000
11171
  }
11001
11172
  // We failed before reaching destination, use fallback
11002
11173
  _destApi = api.clone();
11003
- _context2.n = 10;
11174
+ _context2.n = 13;
11004
11175
  return _destApi.init(destination, DRY_RUN_CLIENT_TIMEOUT_MS);
11005
- case 10:
11006
- _context2.n = 11;
11176
+ case 13:
11177
+ _context2.n = 14;
11007
11178
  return getDestXcmFee({
11008
11179
  api: _destApi,
11009
11180
  forwardedXcms: undefined,
@@ -11021,28 +11192,38 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
11021
11192
  disableFallback: disableFallback,
11022
11193
  swapConfig: swapConfig
11023
11194
  });
11024
- case 11:
11195
+ case 14:
11025
11196
  destFallback = _context2.v;
11026
11197
  destFee = destFallback.fee;
11027
11198
  destFeeType = destFallback.feeType;
11028
11199
  destSufficient = destFallback.sufficient;
11029
11200
  destCurrency = assets.getNativeAssetSymbol(destination);
11030
11201
  destAsset = assets.findNativeAssetInfoOrThrow(destination);
11031
- _context2.n = 13;
11202
+ _context2.n = 16;
11032
11203
  break;
11033
- case 12:
11204
+ case 15:
11034
11205
  destFee = 0n;
11035
11206
  destFeeType = 'noFeeRequired';
11036
11207
  destSufficient = true;
11037
11208
  destCurrency = assets.getNativeAssetSymbol(destination);
11038
11209
  destAsset = assets.findNativeAssetInfoOrThrow(destination);
11039
- case 13:
11210
+ case 16:
11040
11211
  // Process Ethereum bridge fees
11041
11212
  assetHubChain = "AssetHub".concat(getRelayChainOf(origin));
11042
- _context2.n = 14;
11213
+ if (!isMythosToEthereum) {
11214
+ _context2.n = 17;
11215
+ break;
11216
+ }
11217
+ _t4 = traversalResult.bridgeHub;
11218
+ _context2.n = 19;
11219
+ break;
11220
+ case 17:
11221
+ _context2.n = 18;
11043
11222
  return addEthereumBridgeFees(api, traversalResult.bridgeHub, destination, assetHubChain);
11044
- case 14:
11045
- processedBridgeHub = _context2.v;
11223
+ case 18:
11224
+ _t4 = _context2.v;
11225
+ case 19:
11226
+ processedBridgeHub = _t4;
11046
11227
  // Update bridge hub fee in hops if needed
11047
11228
  if (processedBridgeHub && traversalResult.bridgeHub && processedBridgeHub.fee !== traversalResult.bridgeHub.fee) {
11048
11229
  bridgeHubChain = "BridgeHub".concat(getRelayChainOf(origin));
@@ -11118,7 +11299,7 @@ var getXcmFeeInternal = /*#__PURE__*/function () {
11118
11299
  failureReason: failureReason
11119
11300
  }));
11120
11301
  }
11121
- }, _callee2, null, [[2,, 5, 7]]);
11302
+ }, _callee2, null, [[5,, 8, 10]]);
11122
11303
  }));
11123
11304
  return function getXcmFeeInternal(_x) {
11124
11305
  return _ref2.apply(this, arguments);
@@ -11424,6 +11605,7 @@ var send = /*#__PURE__*/function () {
11424
11605
  origin: origin,
11425
11606
  destination: destination,
11426
11607
  address: address,
11608
+ senderAddress: senderAddress,
11427
11609
  assetInfo: _objectSpread2(_objectSpread2({}, asset), {}, {
11428
11610
  amount: finalAmount
11429
11611
  }),
@@ -12164,12 +12346,13 @@ var computeInstructionFee = /*#__PURE__*/function () {
12164
12346
  }();
12165
12347
  var computeAllFees = /*#__PURE__*/function () {
12166
12348
  var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref3, customXcm, isDotAsset, refundInstruction) {
12349
+ var _customXcm$DepositRes;
12167
12350
  var reserve, dest, version, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0;
12168
12351
  return _regenerator().w(function (_context2) {
12169
12352
  while (1) switch (_context2.n) {
12170
12353
  case 0:
12171
12354
  reserve = _ref3.reserve, dest = _ref3.dest, version = _ref3.options.version;
12172
- if (!('DepositReserveAsset' in customXcm)) {
12355
+ if (!('DepositReserveAsset' in customXcm || 'InitiateTeleport' in customXcm)) {
12173
12356
  _context2.n = 6;
12174
12357
  break;
12175
12358
  }
@@ -12192,7 +12375,7 @@ var computeAllFees = /*#__PURE__*/function () {
12192
12375
  case 4:
12193
12376
  _t5 = _t4;
12194
12377
  _context2.n = 5;
12195
- return computeInstructionFee(assets.hasXcmPaymentApiSupport(dest.chain) ? dest : reserve, version, customXcm.DepositReserveAsset.xcm);
12378
+ return computeInstructionFee(assets.hasXcmPaymentApiSupport(dest.chain) ? dest : reserve, version, ((_customXcm$DepositRes = customXcm === null || customXcm === void 0 ? void 0 : customXcm.DepositReserveAsset) !== null && _customXcm$DepositRes !== void 0 ? _customXcm$DepositRes : customXcm.InitiateTeleport).xcm);
12196
12379
  case 5:
12197
12380
  _t6 = _context2.v;
12198
12381
  _t2 = {
@@ -12247,7 +12430,7 @@ var computeAllFees = /*#__PURE__*/function () {
12247
12430
  }();
12248
12431
 
12249
12432
  var createTypeAndThenCallContext = /*#__PURE__*/function () {
12250
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options) {
12433
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options, overrideReserve) {
12251
12434
  var api, destChain, assetInfo, reserveChain, destApi, reserveApi;
12252
12435
  return _regenerator().w(function (_context) {
12253
12436
  while (1) switch (_context.n) {
@@ -12260,12 +12443,14 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
12260
12443
  }
12261
12444
  throw new InvalidParameterError('Cannot override destination when using type and then transfer.');
12262
12445
  case 1:
12263
- reserveChain = sdkCommon.isRelayChain(destChain) ? destChain : getAssetReserveChain(chain, chain, assetInfo.location);
12446
+ reserveChain = overrideReserve !== undefined ? overrideReserve :
12447
+ // Paseo ecosystem migrated reserves to AssetHub
12448
+ getRelayChainOf(chain) === 'Paseo' ? getAssetReserveChain(chain, chain, assetInfo.location) : sdkCommon.isRelayChain(destChain) ? destChain : getAssetReserveChain(chain, chain, assetInfo.location);
12264
12449
  destApi = api.clone();
12265
12450
  _context.n = 2;
12266
12451
  return destApi.init(destChain);
12267
12452
  case 2:
12268
- reserveApi = reserveChain !== chain ? api.clone() : destApi;
12453
+ reserveApi = reserveChain === chain ? api : reserveChain === destChain ? destApi : api.clone();
12269
12454
  _context.n = 3;
12270
12455
  return reserveApi.init(reserveChain);
12271
12456
  case 3:
@@ -12288,7 +12473,7 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
12288
12473
  }
12289
12474
  }, _callee);
12290
12475
  }));
12291
- return function createTypeAndThenCallContext(_x, _x2) {
12476
+ return function createTypeAndThenCallContext(_x, _x2, _x3) {
12292
12477
  return _ref.apply(this, arguments);
12293
12478
  };
12294
12479
  }();
@@ -12336,20 +12521,33 @@ var createCustomXcm = function createCustomXcm(_ref, isDotAsset) {
12336
12521
  if (origin.chain !== reserve.chain && dest.chain !== reserve.chain) {
12337
12522
  var buyExecutionAmount = !isDotAsset ? destFee : assetInfo.amount - reserveFee - refundFee;
12338
12523
  if (buyExecutionAmount < 0n) throw new AmountTooLowError();
12524
+ var filter = fees.destFee === MIN_FEE ? {
12525
+ Wild: 'All'
12526
+ } : {
12527
+ Definite: assetsFilter
12528
+ };
12529
+ var buyExecution = {
12530
+ BuyExecution: {
12531
+ fees: createAsset(version, buyExecutionAmount, feeAssetLocation),
12532
+ weight_limit: 'Unlimited'
12533
+ }
12534
+ };
12535
+ var destLoc = createDestination(version, origin.chain, destination, paraIdTo);
12536
+ // If destination is a system chain, use teleport instead of reserve deposit
12537
+ if (sdkCommon.isSystemChain(dest.chain)) {
12538
+ return {
12539
+ InitiateTeleport: {
12540
+ assets: filter,
12541
+ dest: destLoc,
12542
+ xcm: [buyExecution, depositInstruction]
12543
+ }
12544
+ };
12545
+ }
12339
12546
  return {
12340
12547
  DepositReserveAsset: {
12341
- assets: fees.destFee === MIN_FEE ? {
12342
- Wild: 'All'
12343
- } : {
12344
- Definite: assetsFilter
12345
- },
12346
- dest: createDestination(version, origin.chain, destination, paraIdTo),
12347
- xcm: [{
12348
- BuyExecution: {
12349
- fees: createAsset(version, buyExecutionAmount, feeAssetLocation),
12350
- weight_limit: 'Unlimited'
12351
- }
12352
- }, depositInstruction]
12548
+ assets: filter,
12549
+ dest: destLoc,
12550
+ xcm: [buyExecution, depositInstruction]
12353
12551
  }
12354
12552
  };
12355
12553
  }
@@ -12387,14 +12585,14 @@ var buildAssets = function buildAssets(chain, asset, feeAmount, isDotAsset, vers
12387
12585
  * Creates a type and then call for transferring assets using XCM. Works only for DOT and snowbridge assets so far.
12388
12586
  */
12389
12587
  var createTypeAndThenCall = /*#__PURE__*/function () {
12390
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options) {
12588
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options, overrideReserve) {
12391
12589
  var api, senderAddress, version, context, assetInfo, isDotAsset, customXcm, assetCount, refundInstruction, fees, finalCustomXcm, totalFee, assets;
12392
12590
  return _regenerator().w(function (_context) {
12393
12591
  while (1) switch (_context.n) {
12394
12592
  case 0:
12395
12593
  api = options.api, senderAddress = options.senderAddress, version = options.version;
12396
12594
  _context.n = 1;
12397
- return createTypeAndThenCallContext(chain, options);
12595
+ return createTypeAndThenCallContext(chain, options, overrideReserve);
12398
12596
  case 1:
12399
12597
  context = _context.v;
12400
12598
  assetInfo = context.assetInfo;
@@ -12424,11 +12622,184 @@ var createTypeAndThenCall = /*#__PURE__*/function () {
12424
12622
  }
12425
12623
  }, _callee);
12426
12624
  }));
12427
- return function createTypeAndThenCall(_x, _x2) {
12625
+ return function createTypeAndThenCall(_x, _x2, _x3) {
12428
12626
  return _ref.apply(this, arguments);
12429
12627
  };
12430
12628
  }();
12431
12629
 
12630
+ /**
12631
+ * Choose a reserve (AssetHub or Relay) by checking the beneficiary’s balance on each.
12632
+ * We resolve the beneficiary account on every candidate and return the first with
12633
+ * balance \>= amount, or undefined if none qualify.
12634
+ */
12635
+ var selectReserveByBalance = /*#__PURE__*/function () {
12636
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options) {
12637
+ var api, assetInfo, destination, version, paraIdTo, relay, candidates, _i, _candidates, reserve, reserveApi, location, resolvedAddress, balance;
12638
+ return _regenerator().w(function (_context) {
12639
+ while (1) switch (_context.n) {
12640
+ case 0:
12641
+ api = options.api, assetInfo = options.assetInfo, destination = options.destination, version = options.version, paraIdTo = options.paraIdTo;
12642
+ relay = getRelayChainOf(chain);
12643
+ candidates = ["AssetHub".concat(relay), relay];
12644
+ _i = 0, _candidates = candidates;
12645
+ case 1:
12646
+ if (!(_i < _candidates.length)) {
12647
+ _context.n = 7;
12648
+ break;
12649
+ }
12650
+ reserve = _candidates[_i];
12651
+ reserveApi = api.clone();
12652
+ _context.n = 2;
12653
+ return reserveApi.init(reserve);
12654
+ case 2:
12655
+ location = createDestination(version, chain, destination, paraIdTo);
12656
+ _context.n = 3;
12657
+ return reserveApi.convertLocationToAccount(location);
12658
+ case 3:
12659
+ resolvedAddress = _context.v;
12660
+ if (resolvedAddress) {
12661
+ _context.n = 4;
12662
+ break;
12663
+ }
12664
+ return _context.a(3, 6);
12665
+ case 4:
12666
+ assertAddressIsString(resolvedAddress);
12667
+ _context.n = 5;
12668
+ return getAssetBalanceInternal({
12669
+ api: reserveApi,
12670
+ chain: reserve,
12671
+ address: resolvedAddress,
12672
+ currency: getCurrencySelection(assetInfo)
12673
+ });
12674
+ case 5:
12675
+ balance = _context.v;
12676
+ if (!(balance >= assetInfo.amount)) {
12677
+ _context.n = 6;
12678
+ break;
12679
+ }
12680
+ return _context.a(2, reserve);
12681
+ case 6:
12682
+ _i++;
12683
+ _context.n = 1;
12684
+ break;
12685
+ case 7:
12686
+ return _context.a(2, undefined);
12687
+ }
12688
+ }, _callee);
12689
+ }));
12690
+ return function selectReserveByBalance(_x, _x2) {
12691
+ return _ref.apply(this, arguments);
12692
+ };
12693
+ }();
12694
+
12695
+ var createCallForReserve = /*#__PURE__*/function () {
12696
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, reserveChain, options) {
12697
+ var api, destination, address, senderAddress, currency, feeCurrency, serialized, tx, dryRunResult, success;
12698
+ return _regenerator().w(function (_context) {
12699
+ while (1) switch (_context.n) {
12700
+ case 0:
12701
+ api = options.api, destination = options.destination, address = options.address, senderAddress = options.senderAddress, currency = options.currency, feeCurrency = options.feeCurrency;
12702
+ _context.n = 1;
12703
+ return createTypeAndThenCall(chain, options, reserveChain);
12704
+ case 1:
12705
+ serialized = _context.v;
12706
+ assertAddressIsString(address);
12707
+ assertToIsString(destination, 'Location destination is not supported for reserve auto-selection.');
12708
+ assertSenderAddress(senderAddress);
12709
+ tx = api.callTxMethod(serialized);
12710
+ _context.n = 2;
12711
+ return dryRunInternal({
12712
+ api: api,
12713
+ tx: tx,
12714
+ origin: chain,
12715
+ destination: destination,
12716
+ address: address,
12717
+ senderAddress: senderAddress,
12718
+ currency: currency,
12719
+ feeAsset: feeCurrency,
12720
+ useRootOrigin: true
12721
+ });
12722
+ case 2:
12723
+ dryRunResult = _context.v;
12724
+ success = !dryRunResult.failureReason;
12725
+ return _context.a(2, {
12726
+ call: serialized,
12727
+ success: success
12728
+ });
12729
+ }
12730
+ }, _callee);
12731
+ }));
12732
+ return function createCallForReserve(_x, _x2, _x3) {
12733
+ return _ref.apply(this, arguments);
12734
+ };
12735
+ }();
12736
+ /**
12737
+ * Creates a type-and-then call but auto-selects the asset reserve between AssetHub and the Relay chain
12738
+ * by dry-running both variants and preferring the one that succeeds. If both fail, returns the
12739
+ * AssetHub variant. Supports only relaychain assets.
12740
+ */
12741
+ var createTypeThenAutoReserve = /*#__PURE__*/function () {
12742
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(chain, options) {
12743
+ var originSupports, destSupports, reserve, relay, assetHubReserve, ahResult, relayResult;
12744
+ return _regenerator().w(function (_context2) {
12745
+ while (1) switch (_context2.n) {
12746
+ case 0:
12747
+ // Use dry-run path only when BOTH origin and destination support it
12748
+ originSupports = assets.hasDryRunSupport(chain);
12749
+ destSupports = options.destChain ? assets.hasDryRunSupport(options.destChain) : false;
12750
+ if (originSupports && destSupports) {
12751
+ _context2.n = 5;
12752
+ break;
12753
+ }
12754
+ _context2.n = 1;
12755
+ return selectReserveByBalance(chain, options);
12756
+ case 1:
12757
+ reserve = _context2.v;
12758
+ if (!reserve) {
12759
+ _context2.n = 3;
12760
+ break;
12761
+ }
12762
+ _context2.n = 2;
12763
+ return createTypeAndThenCall(chain, options, reserve);
12764
+ case 2:
12765
+ return _context2.a(2, _context2.v);
12766
+ case 3:
12767
+ _context2.n = 4;
12768
+ return createTypeAndThenCall(chain, options);
12769
+ case 4:
12770
+ return _context2.a(2, _context2.v);
12771
+ case 5:
12772
+ relay = getRelayChainOf(chain);
12773
+ assetHubReserve = "AssetHub".concat(relay);
12774
+ _context2.n = 6;
12775
+ return createCallForReserve(chain, assetHubReserve, options);
12776
+ case 6:
12777
+ ahResult = _context2.v;
12778
+ if (!ahResult.success) {
12779
+ _context2.n = 7;
12780
+ break;
12781
+ }
12782
+ return _context2.a(2, ahResult.call);
12783
+ case 7:
12784
+ _context2.n = 8;
12785
+ return createCallForReserve(chain, relay, options);
12786
+ case 8:
12787
+ relayResult = _context2.v;
12788
+ if (!relayResult.success) {
12789
+ _context2.n = 9;
12790
+ break;
12791
+ }
12792
+ return _context2.a(2, relayResult.call);
12793
+ case 9:
12794
+ return _context2.a(2, ahResult.call);
12795
+ }
12796
+ }, _callee2);
12797
+ }));
12798
+ return function createTypeThenAutoReserve(_x4, _x5) {
12799
+ return _ref2.apply(this, arguments);
12800
+ };
12801
+ }();
12802
+
12432
12803
  var calculateTotalXcmFee = function calculateTotalXcmFee(feeResult) {
12433
12804
  var _feeResult$assetHub;
12434
12805
  var totalFee = 0n;
@@ -13535,6 +13906,7 @@ exports.createExecuteCall = createExecuteCall;
13535
13906
  exports.createExecuteExchangeXcm = createExecuteExchangeXcm;
13536
13907
  exports.createTx = createTx;
13537
13908
  exports.createTypeAndThenCall = createTypeAndThenCall;
13909
+ exports.createTypeThenAutoReserve = createTypeThenAutoReserve;
13538
13910
  exports.createVersionedAssets = createVersionedAssets;
13539
13911
  exports.createX1Payload = createX1Payload;
13540
13912
  exports.deriveAccountId = deriveAccountId;