@paraspell/sdk-core 11.14.1 → 11.14.3

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
@@ -789,7 +789,7 @@ var maybeOverrideAssets = function maybeOverrideAssets(version, amount, assets,
789
789
  if (!overriddenCurrency) {
790
790
  return assets;
791
791
  }
792
- return sdkCommon.isTLocation(overriddenCurrency) ? [createAsset(version, amount, overriddenCurrency)] : overriddenCurrency;
792
+ return sdkCommon.isTLocation(overriddenCurrency) ? createAsset(version, amount, overriddenCurrency) : overriddenCurrency;
793
793
  };
794
794
  var maybeOverrideAsset = function maybeOverrideAsset(version, amount, asset, overriddenCurrency) {
795
795
  if (!overriddenCurrency) {
@@ -3256,27 +3256,22 @@ var constructRelayToParaParameters = function constructRelayToParaParameters(_re
3256
3256
  asset = _ref.assetInfo,
3257
3257
  address = _ref.address,
3258
3258
  paraIdTo = _ref.paraIdTo;
3259
- var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
3260
- includeFee: false
3261
- },
3262
- includeFee = _ref2.includeFee;
3263
3259
  var paraId = resolveParaId(paraIdTo, destination);
3264
3260
  var beneficiaryLocation = createBeneficiaryLocation({
3265
3261
  api: api,
3266
3262
  address: address,
3267
3263
  version: version
3268
3264
  });
3269
- return _objectSpread2({
3265
+ return {
3270
3266
  dest: createVersionedDestination(version, origin, destination, paraId),
3271
3267
  beneficiary: addXcmVersionHeader(beneficiaryLocation, version),
3272
3268
  assets: createVersionedAssets(version, asset.amount, {
3273
3269
  parents: sdkCommon.Parents.ZERO,
3274
3270
  interior: 'Here'
3275
3271
  }),
3276
- fee_asset_item: DEFAULT_FEE_ASSET
3277
- }, includeFee && {
3272
+ fee_asset_item: DEFAULT_FEE_ASSET,
3278
3273
  weight_limit: 'Unlimited'
3279
- });
3274
+ };
3280
3275
  };
3281
3276
 
3282
3277
  var createDestination = function createDestination(version, origin, destination, chainId, junction, parents) {
@@ -3652,18 +3647,23 @@ var getReserveFeeFromHops = function getReserveFeeFromHops(hops) {
3652
3647
  var FEE_PADDING_PERCENTAGE$1 = 40;
3653
3648
  var handleExecuteTransfer = /*#__PURE__*/function () {
3654
3649
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options) {
3655
- var api, senderAddress, paraIdTo, assetInfo, currency, feeCurrency, address, feeAssetInfo, version, checkAmount, destChain, internalOptions, FEE_ASSET_AMOUNT, feeAssetAmount, call, dryRunResult, originFeeEstimate, originFee, reserveFeeEstimate, reserveFee, xcm, weight;
3650
+ var api, senderAddress, paraIdTo, destChain, assetInfo, currency, feeCurrency, address, feeAssetInfo, version, checkAmount, internalOptions, FEE_ASSET_AMOUNT, feeAssetAmount, call, dryRunResult, originFeeEstimate, originFee, reserveFeeEstimate, reserveFee, xcm, weight;
3656
3651
  return _regenerator().w(function (_context) {
3657
3652
  while (1) switch (_context.n) {
3658
3653
  case 0:
3659
- api = options.api, senderAddress = options.senderAddress, paraIdTo = options.paraIdTo, assetInfo = options.assetInfo, currency = options.currency, feeCurrency = options.feeCurrency, address = options.address, feeAssetInfo = options.feeAssetInfo, version = options.version;
3654
+ api = options.api, senderAddress = options.senderAddress, paraIdTo = options.paraIdTo, destChain = options.destChain, assetInfo = options.assetInfo, currency = options.currency, feeCurrency = options.feeCurrency, address = options.address, feeAssetInfo = options.feeAssetInfo, version = options.version;
3660
3655
  assertSenderAddress(senderAddress);
3661
3656
  assertAddressIsString(address);
3662
3657
  checkAmount = function checkAmount(fee) {
3663
3658
  if (assetInfo.amount <= fee) throw new AmountTooLowError();
3664
3659
  };
3665
3660
  checkAmount(MIN_FEE);
3666
- destChain = getTChain(paraIdTo, getRelayChainOf(chain));
3661
+ if (!(destChain === undefined)) {
3662
+ _context.n = 1;
3663
+ break;
3664
+ }
3665
+ throw new InvalidParameterError('Could not determine destination chain for execute transfer');
3666
+ case 1:
3667
3667
  internalOptions = {
3668
3668
  api: api,
3669
3669
  chain: chain,
@@ -3686,7 +3686,7 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
3686
3686
  reserveFee: MIN_FEE
3687
3687
  }
3688
3688
  })), MAX_WEIGHT);
3689
- _context.n = 1;
3689
+ _context.n = 2;
3690
3690
  return dryRunInternal({
3691
3691
  api: api,
3692
3692
  tx: api.callTxMethod(call),
@@ -3698,14 +3698,14 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
3698
3698
  feeAsset: feeCurrency,
3699
3699
  useRootOrigin: true
3700
3700
  });
3701
- case 1:
3701
+ case 2:
3702
3702
  dryRunResult = _context.v;
3703
3703
  if (dryRunResult.origin.success) {
3704
- _context.n = 2;
3704
+ _context.n = 3;
3705
3705
  break;
3706
3706
  }
3707
3707
  throw new DryRunFailedError(dryRunResult.failureReason);
3708
- case 2:
3708
+ case 3:
3709
3709
  originFeeEstimate = dryRunResult.origin.fee;
3710
3710
  originFee = padValueBy(originFeeEstimate, FEE_PADDING_PERCENTAGE$1);
3711
3711
  reserveFeeEstimate = getReserveFeeFromHops(dryRunResult.hops);
@@ -3717,9 +3717,9 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
3717
3717
  reserveFee: reserveFee
3718
3718
  }
3719
3719
  }));
3720
- _context.n = 3;
3720
+ _context.n = 4;
3721
3721
  return api.getXcmWeight(xcm);
3722
- case 3:
3722
+ case 4:
3723
3723
  weight = _context.v;
3724
3724
  return _context.a(2, createExecuteCall(chain, xcm, weight));
3725
3725
  }
@@ -6669,28 +6669,26 @@ var Parachain = /*#__PURE__*/function () {
6669
6669
  key: "getRelayToParaOverrides",
6670
6670
  value: function getRelayToParaOverrides() {
6671
6671
  return {
6672
- method: 'transfer_assets_using_type_and_then',
6673
- includeFee: true
6672
+ transferType: 'typeAndThen'
6674
6673
  };
6675
6674
  }
6676
6675
  }, {
6677
6676
  key: "transferRelayToPara",
6678
6677
  value: function () {
6679
6678
  var _transferRelayToPara = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
6680
- var api, version, pallet, assetInfo, address, senderAddress, destination, paraIdTo, methodOverride, _this$getRelayToParaO, method, includeFee, customMethod, paraId, destChain, scenario;
6679
+ var api, version, pallet, assetInfo, address, senderAddress, destination, paraIdTo, method, _this$getRelayToParaO, transferType, paraId, destChain, scenario;
6681
6680
  return _regenerator().w(function (_context2) {
6682
6681
  while (1) switch (_context2.n) {
6683
6682
  case 0:
6684
- 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;
6685
- _this$getRelayToParaO = this.getRelayToParaOverrides(), method = _this$getRelayToParaO.method, includeFee = _this$getRelayToParaO.includeFee;
6683
+ api = options.api, version = options.version, pallet = options.pallet, assetInfo = options.assetInfo, address = options.address, senderAddress = options.senderAddress, destination = options.destination, paraIdTo = options.paraIdTo, method = options.method;
6684
+ _this$getRelayToParaO = this.getRelayToParaOverrides(), transferType = _this$getRelayToParaO.transferType;
6686
6685
  if (!this.isReceivingTempDisabled('RelayToPara')) {
6687
6686
  _context2.n = 1;
6688
6687
  break;
6689
6688
  }
6690
6689
  throw new InvalidParameterError("Receiving on ".concat(this.chain, " is temporarily disabled"));
6691
6690
  case 1:
6692
- customMethod = methodOverride !== null && methodOverride !== void 0 ? methodOverride : method;
6693
- if (!(customMethod === 'transfer_assets_using_type_and_then')) {
6691
+ if (!(transferType === 'typeAndThen')) {
6694
6692
  _context2.n = 3;
6695
6693
  break;
6696
6694
  }
@@ -6719,10 +6717,8 @@ var Parachain = /*#__PURE__*/function () {
6719
6717
  case 3:
6720
6718
  return _context2.a(2, {
6721
6719
  module: pallet !== null && pallet !== void 0 ? pallet : 'XcmPallet',
6722
- method: customMethod,
6723
- parameters: constructRelayToParaParameters(options, version, {
6724
- includeFee: includeFee
6725
- })
6720
+ method: method !== null && method !== void 0 ? method : 'limited_teleport_assets',
6721
+ parameters: constructRelayToParaParameters(options, version)
6726
6722
  });
6727
6723
  }
6728
6724
  }, _callee2, this);
@@ -7322,8 +7318,7 @@ var AssetHubKusama = /*#__PURE__*/function (_Parachain) {
7322
7318
  key: "getRelayToParaOverrides",
7323
7319
  value: function getRelayToParaOverrides() {
7324
7320
  return {
7325
- method: 'limited_teleport_assets',
7326
- includeFee: true
7321
+ transferType: 'teleport'
7327
7322
  };
7328
7323
  }
7329
7324
  }, {
@@ -7573,23 +7568,17 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
7573
7568
  _call = _context3.v;
7574
7569
  return _context3.a(2, api.callTxMethod(_call));
7575
7570
  case 9:
7576
- if (!(scenario === 'ParaToPara' && assetInfo.symbol === 'KSM' && !assets.isForeignAsset(assetInfo))) {
7577
- _context3.n = 10;
7578
- break;
7579
- }
7580
- throw new ScenarioNotSupportedError(this.chain, scenario, 'Bridged KSM cannot currently be transfered from AssetHubPolkadot, if you are sending different KSM asset, please specify {id: <KSMID>}.');
7581
- case 10:
7582
7571
  method = this.getMethod(scenario, destination); // Patch transfer_assets to use type_and_then transfer
7583
7572
  if (!(method === 'transfer_assets' && assets.isSymbolMatch(assetInfo.symbol, assets.getRelayChainSymbol(this.chain)))) {
7584
- _context3.n = 12;
7573
+ _context3.n = 11;
7585
7574
  break;
7586
7575
  }
7587
7576
  _t2 = api;
7588
- _context3.n = 11;
7577
+ _context3.n = 10;
7589
7578
  return createTypeAndThenCall(this.chain, options);
7590
- case 11:
7579
+ case 10:
7591
7580
  return _context3.a(2, _t2.callTxMethod.call(_t2, _context3.v));
7592
- case 12:
7581
+ case 11:
7593
7582
  modifiedInput = this.patchInput(options);
7594
7583
  return _context3.a(2, transferPolkadotXcm(modifiedInput, method, 'Unlimited'));
7595
7584
  }
@@ -7604,8 +7593,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
7604
7593
  key: "getRelayToParaOverrides",
7605
7594
  value: function getRelayToParaOverrides() {
7606
7595
  return {
7607
- method: 'limited_teleport_assets',
7608
- includeFee: true
7596
+ transferType: 'teleport'
7609
7597
  };
7610
7598
  }
7611
7599
  }, {
@@ -7920,8 +7908,7 @@ var BridgeHubKusama = /*#__PURE__*/function (_Parachain) {
7920
7908
  key: "getRelayToParaOverrides",
7921
7909
  value: function getRelayToParaOverrides() {
7922
7910
  return {
7923
- method: 'limited_teleport_assets',
7924
- includeFee: true
7911
+ transferType: 'teleport'
7925
7912
  };
7926
7913
  }
7927
7914
  }]);
@@ -7951,8 +7938,7 @@ var BridgeHubPolkadot = /*#__PURE__*/function (_Parachain) {
7951
7938
  key: "getRelayToParaOverrides",
7952
7939
  value: function getRelayToParaOverrides() {
7953
7940
  return {
7954
- method: 'limited_teleport_assets',
7955
- includeFee: true
7941
+ transferType: 'teleport'
7956
7942
  };
7957
7943
  }
7958
7944
  }]);
@@ -8057,8 +8043,7 @@ var Collectives = /*#__PURE__*/function (_Parachain) {
8057
8043
  key: "getRelayToParaOverrides",
8058
8044
  value: function getRelayToParaOverrides() {
8059
8045
  return {
8060
- method: 'limited_teleport_assets',
8061
- includeFee: true
8046
+ transferType: 'teleport'
8062
8047
  };
8063
8048
  }
8064
8049
  }]);
@@ -8092,8 +8077,7 @@ var CoretimeKusama = /*#__PURE__*/function (_Parachain) {
8092
8077
  key: "getRelayToParaOverrides",
8093
8078
  value: function getRelayToParaOverrides() {
8094
8079
  return {
8095
- method: 'limited_teleport_assets',
8096
- includeFee: true
8080
+ transferType: 'teleport'
8097
8081
  };
8098
8082
  }
8099
8083
  }]);
@@ -8127,8 +8111,7 @@ var CoretimePolkadot = /*#__PURE__*/function (_Parachain) {
8127
8111
  key: "getRelayToParaOverrides",
8128
8112
  value: function getRelayToParaOverrides() {
8129
8113
  return {
8130
- method: 'limited_teleport_assets',
8131
- includeFee: true
8114
+ transferType: 'teleport'
8132
8115
  };
8133
8116
  }
8134
8117
  }]);
@@ -8373,8 +8356,7 @@ var Encointer = /*#__PURE__*/function (_Parachain) {
8373
8356
  key: "getRelayToParaOverrides",
8374
8357
  value: function getRelayToParaOverrides() {
8375
8358
  return {
8376
- method: 'limited_teleport_assets',
8377
- includeFee: true
8359
+ transferType: 'teleport'
8378
8360
  };
8379
8361
  }
8380
8362
  }]);
@@ -9378,8 +9360,7 @@ var PeoplePolkadot = /*#__PURE__*/function (_Parachain) {
9378
9360
  key: "getRelayToParaOverrides",
9379
9361
  value: function getRelayToParaOverrides() {
9380
9362
  return {
9381
- method: 'limited_teleport_assets',
9382
- includeFee: true
9363
+ transferType: 'teleport'
9383
9364
  };
9384
9365
  }
9385
9366
  }]);
@@ -9534,8 +9515,7 @@ var PeopleKusama = /*#__PURE__*/function (_Parachain) {
9534
9515
  key: "getRelayToParaOverrides",
9535
9516
  value: function getRelayToParaOverrides() {
9536
9517
  return {
9537
- method: 'limited_teleport_assets',
9538
- includeFee: true
9518
+ transferType: 'teleport'
9539
9519
  };
9540
9520
  }
9541
9521
  }]);
@@ -11790,9 +11770,18 @@ var send = /*#__PURE__*/function () {
11790
11770
  resolvedAsset = asset !== null && asset !== void 0 ? asset : {
11791
11771
  symbol: 'symbol' in currency ? currency.symbol : undefined
11792
11772
  };
11793
- finalAsset = Array.isArray(currency) ? _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
11773
+ finalAsset = Array.isArray(currency) ? // TODO: Refactor this
11774
+ // We use a dummy values when overriding with multi-assets
11775
+ // since these values won't be used but need to pass checks
11776
+ _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
11794
11777
  amount: 0n,
11795
- assetId: '1'
11778
+ assetId: '1',
11779
+ location: {
11780
+ parents: sdkCommon.Parents.ZERO,
11781
+ interior: {
11782
+ Here: null
11783
+ }
11784
+ }
11796
11785
  }) : _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
11797
11786
  amount: finalAmount
11798
11787
  });
@@ -12211,11 +12200,62 @@ var getTransferInfo = /*#__PURE__*/function () {
12211
12200
  };
12212
12201
  }();
12213
12202
 
12214
- var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12215
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
12216
- 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, _yield$modifiedBuilde, tx, dryRunResult;
12203
+ var FEE_PADDING = 30;
12204
+ var sumHopFees = function sumHopFees(result, asset) {
12205
+ return result.hops.reduce(function (acc, hop) {
12206
+ // only add if asset is equal
12207
+ return assets.isAssetEqual(hop.result.asset, asset) ? acc + hop.result.fee : acc;
12208
+ }, 0n);
12209
+ };
12210
+ var computeAllFees = /*#__PURE__*/function () {
12211
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, buildTx) {
12212
+ var origin, dest, assetInfo, _context$options, senderAddress, address, currency, feeCurrency, result, hopFees, destFee;
12217
12213
  return _regenerator().w(function (_context) {
12218
12214
  while (1) switch (_context.n) {
12215
+ case 0:
12216
+ origin = context.origin, dest = context.dest, assetInfo = context.assetInfo, _context$options = context.options, senderAddress = _context$options.senderAddress, address = _context$options.address, currency = _context$options.currency, feeCurrency = _context$options.feeCurrency;
12217
+ assertSenderAddress(senderAddress);
12218
+ assertAddressIsString(address);
12219
+ if (assets.hasDryRunSupport(context.origin.chain)) {
12220
+ _context.n = 1;
12221
+ break;
12222
+ }
12223
+ return _context.a(2, null);
12224
+ case 1:
12225
+ _context.n = 2;
12226
+ return getXcmFeeInternal({
12227
+ api: origin.api,
12228
+ buildTx: buildTx,
12229
+ origin: origin.chain,
12230
+ destination: dest.chain,
12231
+ senderAddress: senderAddress,
12232
+ address: address,
12233
+ currency: currency,
12234
+ feeAsset: feeCurrency,
12235
+ disableFallback: false,
12236
+ skipReverseFeeCalculation: true
12237
+ });
12238
+ case 2:
12239
+ result = _context.v;
12240
+ hopFees = sumHopFees(result, assetInfo);
12241
+ destFee = result.destination.fee;
12242
+ return _context.a(2, {
12243
+ hopFees: padValueBy(hopFees, FEE_PADDING),
12244
+ destFee: padValueBy(destFee, FEE_PADDING)
12245
+ });
12246
+ }
12247
+ }, _callee);
12248
+ }));
12249
+ return function computeAllFees(_x, _x2) {
12250
+ return _ref.apply(this, arguments);
12251
+ };
12252
+ }();
12253
+
12254
+ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12255
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
12256
+ 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, createTx, tx, dryRunResult, _t;
12257
+ return _regenerator().w(function (_context2) {
12258
+ while (1) switch (_context2.p = _context2.n) {
12219
12259
  case 0:
12220
12260
  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;
12221
12261
  validateAddress(senderAddress, chain, false);
@@ -12228,10 +12268,10 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12228
12268
  symbol: destAsset.symbol
12229
12269
  };
12230
12270
  destApi = api.clone();
12231
- _context.n = 1;
12271
+ _context2.n = 1;
12232
12272
  return destApi.init(destination);
12233
12273
  case 1:
12234
- _context.n = 2;
12274
+ _context2.n = 2;
12235
12275
  return getAssetBalanceInternal({
12236
12276
  api: destApi,
12237
12277
  address: address,
@@ -12239,13 +12279,13 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12239
12279
  currency: destCurrency
12240
12280
  });
12241
12281
  case 2:
12242
- destBalance = _context.v;
12282
+ destBalance = _context2.v;
12243
12283
  destEd = assets.getEdFromAssetOrThrow(destAsset);
12244
12284
  nativeAssetInfo = assets.findNativeAssetInfoOrThrow(chain);
12245
12285
  isNativeAsset = assets.isAssetEqual(nativeAssetInfo, asset);
12246
12286
  paysOriginInSendingAsset = !resolvedFeeAsset && isNativeAsset || resolvedFeeAsset && assets.isAssetEqual(resolvedFeeAsset, asset);
12247
12287
  amount = abstractDecimals(currency.amount, asset.decimals, api);
12248
- _context.n = 3;
12288
+ _context2.n = 3;
12249
12289
  return getXcmFee({
12250
12290
  api: api,
12251
12291
  origin: origin,
@@ -12260,7 +12300,7 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12260
12300
  disableFallback: false
12261
12301
  });
12262
12302
  case 3:
12263
- result = _context.v;
12303
+ result = _context2.v;
12264
12304
  originFee = result.origin && paysOriginInSendingAsset && assets.isAssetEqual(result.origin.asset, asset) ? result.origin.fee : 0n;
12265
12305
  hopFeeTotal = result.hops.reduce(function (acc, hop) {
12266
12306
  // only add if asset is equal
@@ -12269,15 +12309,59 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12269
12309
  destinationFee = result.destination && assets.isAssetEqual(result.destination.asset, asset) ? result.destination.fee : 0n;
12270
12310
  edComponent = destBalance === 0n ? destEd : 0n;
12271
12311
  minAmount = hopFeeTotal + destinationFee + originFee + edComponent + 1n;
12272
- modifiedBuilder = builder.currency(_objectSpread2(_objectSpread2({}, currency), {}, {
12273
- amount: minAmount
12274
- }));
12275
- _context.n = 4;
12276
- return modifiedBuilder['buildInternal']();
12277
- case 4:
12278
- _yield$modifiedBuilde = _context.v;
12279
- tx = _yield$modifiedBuilde.tx;
12280
- _context.n = 5;
12312
+ createTx = /*#__PURE__*/function () {
12313
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(amount) {
12314
+ var _yield$builder$curren, tx;
12315
+ return _regenerator().w(function (_context) {
12316
+ while (1) switch (_context.n) {
12317
+ case 0:
12318
+ _context.n = 1;
12319
+ return builder.currency(_objectSpread2(_objectSpread2({}, currency), {}, {
12320
+ amount: amount
12321
+ }))['buildInternal']();
12322
+ case 1:
12323
+ _yield$builder$curren = _context.v;
12324
+ tx = _yield$builder$curren.tx;
12325
+ return _context.a(2, tx);
12326
+ }
12327
+ }, _callee);
12328
+ }));
12329
+ return function createTx(_x2) {
12330
+ return _ref3.apply(this, arguments);
12331
+ };
12332
+ }();
12333
+ _context2.p = 4;
12334
+ _context2.n = 5;
12335
+ return createTx(minAmount);
12336
+ case 5:
12337
+ tx = _context2.v;
12338
+ _context2.n = 10;
12339
+ break;
12340
+ case 6:
12341
+ _context2.p = 6;
12342
+ _t = _context2.v;
12343
+ if (!(_t instanceof AmountTooLowError)) {
12344
+ _context2.n = 10;
12345
+ break;
12346
+ }
12347
+ minAmount = padValueBy(minAmount, FEE_PADDING);
12348
+ _context2.p = 7;
12349
+ _context2.n = 8;
12350
+ return createTx(minAmount);
12351
+ case 8:
12352
+ tx = _context2.v;
12353
+ _context2.n = 10;
12354
+ break;
12355
+ case 9:
12356
+ _context2.p = 9;
12357
+ _context2.v;
12358
+ if (!(_t instanceof AmountTooLowError)) {
12359
+ _context2.n = 10;
12360
+ break;
12361
+ }
12362
+ return _context2.a(2, 0n);
12363
+ case 10:
12364
+ _context2.n = 11;
12281
12365
  return dryRunInternal({
12282
12366
  api: api,
12283
12367
  tx: tx,
@@ -12290,49 +12374,49 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12290
12374
  }),
12291
12375
  feeAsset: feeAsset
12292
12376
  });
12293
- case 5:
12294
- dryRunResult = _context.v;
12377
+ case 11:
12378
+ dryRunResult = _context2.v;
12295
12379
  if (!dryRunResult.failureReason) {
12296
- _context.n = 6;
12380
+ _context2.n = 12;
12297
12381
  break;
12298
12382
  }
12299
- return _context.a(2, 0n);
12300
- case 6:
12301
- return _context.a(2, minAmount);
12383
+ return _context2.a(2, 0n);
12384
+ case 12:
12385
+ return _context2.a(2, minAmount);
12302
12386
  }
12303
- }, _callee);
12387
+ }, _callee2, null, [[7, 9], [4, 6]]);
12304
12388
  }));
12305
12389
  return function getMinTransferableAmountInternal(_x) {
12306
12390
  return _ref2.apply(this, arguments);
12307
12391
  };
12308
12392
  }();
12309
12393
  var getMinTransferableAmount = /*#__PURE__*/function () {
12310
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
12394
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
12311
12395
  var api;
12312
- return _regenerator().w(function (_context2) {
12313
- while (1) switch (_context2.p = _context2.n) {
12396
+ return _regenerator().w(function (_context3) {
12397
+ while (1) switch (_context3.p = _context3.n) {
12314
12398
  case 0:
12315
12399
  api = options.api;
12316
12400
  api.setDisconnectAllowed(false);
12317
- _context2.p = 1;
12318
- _context2.n = 2;
12401
+ _context3.p = 1;
12402
+ _context3.n = 2;
12319
12403
  return getMinTransferableAmountInternal(options);
12320
12404
  case 2:
12321
- return _context2.a(2, _context2.v);
12405
+ return _context3.a(2, _context3.v);
12322
12406
  case 3:
12323
- _context2.p = 3;
12407
+ _context3.p = 3;
12324
12408
  api.setDisconnectAllowed(true);
12325
- _context2.n = 4;
12409
+ _context3.n = 4;
12326
12410
  return api.disconnect();
12327
12411
  case 4:
12328
- return _context2.f(3);
12412
+ return _context3.f(3);
12329
12413
  case 5:
12330
- return _context2.a(2);
12414
+ return _context3.a(2);
12331
12415
  }
12332
- }, _callee2, null, [[1,, 3, 5]]);
12416
+ }, _callee3, null, [[1,, 3, 5]]);
12333
12417
  }));
12334
- return function getMinTransferableAmount(_x2) {
12335
- return _ref3.apply(this, arguments);
12418
+ return function getMinTransferableAmount(_x3) {
12419
+ return _ref4.apply(this, arguments);
12336
12420
  };
12337
12421
  }();
12338
12422
 
@@ -12459,57 +12543,6 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(_ref, isDotAsset, custo
12459
12543
  };
12460
12544
  };
12461
12545
 
12462
- var FEE_PADDING = 30;
12463
- var sumHopFees = function sumHopFees(result, asset) {
12464
- return result.hops.reduce(function (acc, hop) {
12465
- // only add if asset is equal
12466
- return assets.isAssetEqual(hop.result.asset, asset) ? acc + hop.result.fee : acc;
12467
- }, 0n);
12468
- };
12469
- var computeAllFees = /*#__PURE__*/function () {
12470
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, buildTx) {
12471
- var origin, dest, assetInfo, _context$options, senderAddress, address, currency, feeCurrency, result, hopFees, destFee;
12472
- return _regenerator().w(function (_context) {
12473
- while (1) switch (_context.n) {
12474
- case 0:
12475
- origin = context.origin, dest = context.dest, assetInfo = context.assetInfo, _context$options = context.options, senderAddress = _context$options.senderAddress, address = _context$options.address, currency = _context$options.currency, feeCurrency = _context$options.feeCurrency;
12476
- assertSenderAddress(senderAddress);
12477
- assertAddressIsString(address);
12478
- if (assets.hasDryRunSupport(context.origin.chain)) {
12479
- _context.n = 1;
12480
- break;
12481
- }
12482
- return _context.a(2, null);
12483
- case 1:
12484
- _context.n = 2;
12485
- return getXcmFeeInternal({
12486
- api: origin.api,
12487
- buildTx: buildTx,
12488
- origin: origin.chain,
12489
- destination: dest.chain,
12490
- senderAddress: senderAddress,
12491
- address: address,
12492
- currency: currency,
12493
- feeAsset: feeCurrency,
12494
- disableFallback: false,
12495
- skipReverseFeeCalculation: true
12496
- });
12497
- case 2:
12498
- result = _context.v;
12499
- hopFees = sumHopFees(result, assetInfo);
12500
- destFee = result.destination.fee;
12501
- return _context.a(2, {
12502
- hopFees: padValueBy(hopFees, FEE_PADDING),
12503
- destFee: padValueBy(destFee, FEE_PADDING)
12504
- });
12505
- }
12506
- }, _callee);
12507
- }));
12508
- return function computeAllFees(_x, _x2) {
12509
- return _ref.apply(this, arguments);
12510
- };
12511
- }();
12512
-
12513
12546
  var RELAY_ASSET_LOCATIONS = [RELAY_LOCATION, {
12514
12547
  parents: 2,
12515
12548
  interior: {
@@ -12649,9 +12682,7 @@ var createCustomXcm = function createCustomXcm(context, assetCount, isForFeeCalc
12649
12682
  if (isSubBridge || origin.chain !== reserve.chain && dest.chain !== reserve.chain) {
12650
12683
  var buyExecutionAmount = resolveBuyExecutionAmount(context, isForFeeCalc, fees, systemAssetAmount);
12651
12684
  if (buyExecutionAmount < 0n && !isForFeeCalc) throw new AmountTooLowError();
12652
- var filter = isForFeeCalc ? {
12653
- Wild: 'All'
12654
- } : {
12685
+ var filter = {
12655
12686
  Definite: assetsFilter
12656
12687
  };
12657
12688
  var buyExecution = {
package/dist/index.d.ts CHANGED
@@ -183,8 +183,7 @@ type TRelayToParaBaseOptions = {
183
183
  method?: string;
184
184
  };
185
185
  type TRelayToParaOverrides = {
186
- method: TXcmPalletMethod;
187
- includeFee: boolean;
186
+ transferType: 'typeAndThen' | 'teleport';
188
187
  };
189
188
  /**
190
189
  * Options for transferring from a relay chain to a parachain
@@ -2279,7 +2278,7 @@ declare const createVersionedAssets: (version: Version, amount: bigint, location
2279
2278
 
2280
2279
  declare const getCurrencySelection: (chain: TSubstrateChain, asset: TAssetInfo) => TCurrencyCore;
2281
2280
 
2282
- declare const maybeOverrideAssets: (version: Version, amount: bigint, assets: TAsset[], overriddenCurrency?: TLocation | TAsset[]) => TAsset[];
2281
+ declare const maybeOverrideAssets: (version: Version, amount: bigint, assets: TAsset[], overriddenCurrency?: TLocation | TAsset[]) => TAsset | TAsset[];
2283
2282
  declare const maybeOverrideAsset: (version: Version, amount: bigint, asset: TAsset, overriddenCurrency?: TLocation | TAsset[]) => TAsset;
2284
2283
 
2285
2284
  declare const sortAssets: (assets: TAsset[]) => TAsset[];
package/dist/index.mjs CHANGED
@@ -790,7 +790,7 @@ var maybeOverrideAssets = function maybeOverrideAssets(version, amount, assets,
790
790
  if (!overriddenCurrency) {
791
791
  return assets;
792
792
  }
793
- return isTLocation(overriddenCurrency) ? [createAsset(version, amount, overriddenCurrency)] : overriddenCurrency;
793
+ return isTLocation(overriddenCurrency) ? createAsset(version, amount, overriddenCurrency) : overriddenCurrency;
794
794
  };
795
795
  var maybeOverrideAsset = function maybeOverrideAsset(version, amount, asset, overriddenCurrency) {
796
796
  if (!overriddenCurrency) {
@@ -3257,27 +3257,22 @@ var constructRelayToParaParameters = function constructRelayToParaParameters(_re
3257
3257
  asset = _ref.assetInfo,
3258
3258
  address = _ref.address,
3259
3259
  paraIdTo = _ref.paraIdTo;
3260
- var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
3261
- includeFee: false
3262
- },
3263
- includeFee = _ref2.includeFee;
3264
3260
  var paraId = resolveParaId(paraIdTo, destination);
3265
3261
  var beneficiaryLocation = createBeneficiaryLocation({
3266
3262
  api: api,
3267
3263
  address: address,
3268
3264
  version: version
3269
3265
  });
3270
- return _objectSpread2({
3266
+ return {
3271
3267
  dest: createVersionedDestination(version, origin, destination, paraId),
3272
3268
  beneficiary: addXcmVersionHeader(beneficiaryLocation, version),
3273
3269
  assets: createVersionedAssets(version, asset.amount, {
3274
3270
  parents: Parents.ZERO,
3275
3271
  interior: 'Here'
3276
3272
  }),
3277
- fee_asset_item: DEFAULT_FEE_ASSET
3278
- }, includeFee && {
3273
+ fee_asset_item: DEFAULT_FEE_ASSET,
3279
3274
  weight_limit: 'Unlimited'
3280
- });
3275
+ };
3281
3276
  };
3282
3277
 
3283
3278
  var createDestination = function createDestination(version, origin, destination, chainId, junction, parents) {
@@ -3653,18 +3648,23 @@ var getReserveFeeFromHops = function getReserveFeeFromHops(hops) {
3653
3648
  var FEE_PADDING_PERCENTAGE$1 = 40;
3654
3649
  var handleExecuteTransfer = /*#__PURE__*/function () {
3655
3650
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain, options) {
3656
- var api, senderAddress, paraIdTo, assetInfo, currency, feeCurrency, address, feeAssetInfo, version, checkAmount, destChain, internalOptions, FEE_ASSET_AMOUNT, feeAssetAmount, call, dryRunResult, originFeeEstimate, originFee, reserveFeeEstimate, reserveFee, xcm, weight;
3651
+ var api, senderAddress, paraIdTo, destChain, assetInfo, currency, feeCurrency, address, feeAssetInfo, version, checkAmount, internalOptions, FEE_ASSET_AMOUNT, feeAssetAmount, call, dryRunResult, originFeeEstimate, originFee, reserveFeeEstimate, reserveFee, xcm, weight;
3657
3652
  return _regenerator().w(function (_context) {
3658
3653
  while (1) switch (_context.n) {
3659
3654
  case 0:
3660
- api = options.api, senderAddress = options.senderAddress, paraIdTo = options.paraIdTo, assetInfo = options.assetInfo, currency = options.currency, feeCurrency = options.feeCurrency, address = options.address, feeAssetInfo = options.feeAssetInfo, version = options.version;
3655
+ api = options.api, senderAddress = options.senderAddress, paraIdTo = options.paraIdTo, destChain = options.destChain, assetInfo = options.assetInfo, currency = options.currency, feeCurrency = options.feeCurrency, address = options.address, feeAssetInfo = options.feeAssetInfo, version = options.version;
3661
3656
  assertSenderAddress(senderAddress);
3662
3657
  assertAddressIsString(address);
3663
3658
  checkAmount = function checkAmount(fee) {
3664
3659
  if (assetInfo.amount <= fee) throw new AmountTooLowError();
3665
3660
  };
3666
3661
  checkAmount(MIN_FEE);
3667
- destChain = getTChain(paraIdTo, getRelayChainOf(chain));
3662
+ if (!(destChain === undefined)) {
3663
+ _context.n = 1;
3664
+ break;
3665
+ }
3666
+ throw new InvalidParameterError('Could not determine destination chain for execute transfer');
3667
+ case 1:
3668
3668
  internalOptions = {
3669
3669
  api: api,
3670
3670
  chain: chain,
@@ -3687,7 +3687,7 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
3687
3687
  reserveFee: MIN_FEE
3688
3688
  }
3689
3689
  })), MAX_WEIGHT);
3690
- _context.n = 1;
3690
+ _context.n = 2;
3691
3691
  return dryRunInternal({
3692
3692
  api: api,
3693
3693
  tx: api.callTxMethod(call),
@@ -3699,14 +3699,14 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
3699
3699
  feeAsset: feeCurrency,
3700
3700
  useRootOrigin: true
3701
3701
  });
3702
- case 1:
3702
+ case 2:
3703
3703
  dryRunResult = _context.v;
3704
3704
  if (dryRunResult.origin.success) {
3705
- _context.n = 2;
3705
+ _context.n = 3;
3706
3706
  break;
3707
3707
  }
3708
3708
  throw new DryRunFailedError(dryRunResult.failureReason);
3709
- case 2:
3709
+ case 3:
3710
3710
  originFeeEstimate = dryRunResult.origin.fee;
3711
3711
  originFee = padValueBy(originFeeEstimate, FEE_PADDING_PERCENTAGE$1);
3712
3712
  reserveFeeEstimate = getReserveFeeFromHops(dryRunResult.hops);
@@ -3718,9 +3718,9 @@ var handleExecuteTransfer = /*#__PURE__*/function () {
3718
3718
  reserveFee: reserveFee
3719
3719
  }
3720
3720
  }));
3721
- _context.n = 3;
3721
+ _context.n = 4;
3722
3722
  return api.getXcmWeight(xcm);
3723
- case 3:
3723
+ case 4:
3724
3724
  weight = _context.v;
3725
3725
  return _context.a(2, createExecuteCall(chain, xcm, weight));
3726
3726
  }
@@ -6670,28 +6670,26 @@ var Parachain = /*#__PURE__*/function () {
6670
6670
  key: "getRelayToParaOverrides",
6671
6671
  value: function getRelayToParaOverrides() {
6672
6672
  return {
6673
- method: 'transfer_assets_using_type_and_then',
6674
- includeFee: true
6673
+ transferType: 'typeAndThen'
6675
6674
  };
6676
6675
  }
6677
6676
  }, {
6678
6677
  key: "transferRelayToPara",
6679
6678
  value: function () {
6680
6679
  var _transferRelayToPara = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
6681
- var api, version, pallet, assetInfo, address, senderAddress, destination, paraIdTo, methodOverride, _this$getRelayToParaO, method, includeFee, customMethod, paraId, destChain, scenario;
6680
+ var api, version, pallet, assetInfo, address, senderAddress, destination, paraIdTo, method, _this$getRelayToParaO, transferType, paraId, destChain, scenario;
6682
6681
  return _regenerator().w(function (_context2) {
6683
6682
  while (1) switch (_context2.n) {
6684
6683
  case 0:
6685
- 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;
6686
- _this$getRelayToParaO = this.getRelayToParaOverrides(), method = _this$getRelayToParaO.method, includeFee = _this$getRelayToParaO.includeFee;
6684
+ api = options.api, version = options.version, pallet = options.pallet, assetInfo = options.assetInfo, address = options.address, senderAddress = options.senderAddress, destination = options.destination, paraIdTo = options.paraIdTo, method = options.method;
6685
+ _this$getRelayToParaO = this.getRelayToParaOverrides(), transferType = _this$getRelayToParaO.transferType;
6687
6686
  if (!this.isReceivingTempDisabled('RelayToPara')) {
6688
6687
  _context2.n = 1;
6689
6688
  break;
6690
6689
  }
6691
6690
  throw new InvalidParameterError("Receiving on ".concat(this.chain, " is temporarily disabled"));
6692
6691
  case 1:
6693
- customMethod = methodOverride !== null && methodOverride !== void 0 ? methodOverride : method;
6694
- if (!(customMethod === 'transfer_assets_using_type_and_then')) {
6692
+ if (!(transferType === 'typeAndThen')) {
6695
6693
  _context2.n = 3;
6696
6694
  break;
6697
6695
  }
@@ -6720,10 +6718,8 @@ var Parachain = /*#__PURE__*/function () {
6720
6718
  case 3:
6721
6719
  return _context2.a(2, {
6722
6720
  module: pallet !== null && pallet !== void 0 ? pallet : 'XcmPallet',
6723
- method: customMethod,
6724
- parameters: constructRelayToParaParameters(options, version, {
6725
- includeFee: includeFee
6726
- })
6721
+ method: method !== null && method !== void 0 ? method : 'limited_teleport_assets',
6722
+ parameters: constructRelayToParaParameters(options, version)
6727
6723
  });
6728
6724
  }
6729
6725
  }, _callee2, this);
@@ -7323,8 +7319,7 @@ var AssetHubKusama = /*#__PURE__*/function (_Parachain) {
7323
7319
  key: "getRelayToParaOverrides",
7324
7320
  value: function getRelayToParaOverrides() {
7325
7321
  return {
7326
- method: 'limited_teleport_assets',
7327
- includeFee: true
7322
+ transferType: 'teleport'
7328
7323
  };
7329
7324
  }
7330
7325
  }, {
@@ -7574,23 +7569,17 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
7574
7569
  _call = _context3.v;
7575
7570
  return _context3.a(2, api.callTxMethod(_call));
7576
7571
  case 9:
7577
- if (!(scenario === 'ParaToPara' && assetInfo.symbol === 'KSM' && !isForeignAsset(assetInfo))) {
7578
- _context3.n = 10;
7579
- break;
7580
- }
7581
- throw new ScenarioNotSupportedError(this.chain, scenario, 'Bridged KSM cannot currently be transfered from AssetHubPolkadot, if you are sending different KSM asset, please specify {id: <KSMID>}.');
7582
- case 10:
7583
7572
  method = this.getMethod(scenario, destination); // Patch transfer_assets to use type_and_then transfer
7584
7573
  if (!(method === 'transfer_assets' && isSymbolMatch(assetInfo.symbol, getRelayChainSymbol(this.chain)))) {
7585
- _context3.n = 12;
7574
+ _context3.n = 11;
7586
7575
  break;
7587
7576
  }
7588
7577
  _t2 = api;
7589
- _context3.n = 11;
7578
+ _context3.n = 10;
7590
7579
  return createTypeAndThenCall(this.chain, options);
7591
- case 11:
7580
+ case 10:
7592
7581
  return _context3.a(2, _t2.callTxMethod.call(_t2, _context3.v));
7593
- case 12:
7582
+ case 11:
7594
7583
  modifiedInput = this.patchInput(options);
7595
7584
  return _context3.a(2, transferPolkadotXcm(modifiedInput, method, 'Unlimited'));
7596
7585
  }
@@ -7605,8 +7594,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Parachain) {
7605
7594
  key: "getRelayToParaOverrides",
7606
7595
  value: function getRelayToParaOverrides() {
7607
7596
  return {
7608
- method: 'limited_teleport_assets',
7609
- includeFee: true
7597
+ transferType: 'teleport'
7610
7598
  };
7611
7599
  }
7612
7600
  }, {
@@ -7921,8 +7909,7 @@ var BridgeHubKusama = /*#__PURE__*/function (_Parachain) {
7921
7909
  key: "getRelayToParaOverrides",
7922
7910
  value: function getRelayToParaOverrides() {
7923
7911
  return {
7924
- method: 'limited_teleport_assets',
7925
- includeFee: true
7912
+ transferType: 'teleport'
7926
7913
  };
7927
7914
  }
7928
7915
  }]);
@@ -7952,8 +7939,7 @@ var BridgeHubPolkadot = /*#__PURE__*/function (_Parachain) {
7952
7939
  key: "getRelayToParaOverrides",
7953
7940
  value: function getRelayToParaOverrides() {
7954
7941
  return {
7955
- method: 'limited_teleport_assets',
7956
- includeFee: true
7942
+ transferType: 'teleport'
7957
7943
  };
7958
7944
  }
7959
7945
  }]);
@@ -8058,8 +8044,7 @@ var Collectives = /*#__PURE__*/function (_Parachain) {
8058
8044
  key: "getRelayToParaOverrides",
8059
8045
  value: function getRelayToParaOverrides() {
8060
8046
  return {
8061
- method: 'limited_teleport_assets',
8062
- includeFee: true
8047
+ transferType: 'teleport'
8063
8048
  };
8064
8049
  }
8065
8050
  }]);
@@ -8093,8 +8078,7 @@ var CoretimeKusama = /*#__PURE__*/function (_Parachain) {
8093
8078
  key: "getRelayToParaOverrides",
8094
8079
  value: function getRelayToParaOverrides() {
8095
8080
  return {
8096
- method: 'limited_teleport_assets',
8097
- includeFee: true
8081
+ transferType: 'teleport'
8098
8082
  };
8099
8083
  }
8100
8084
  }]);
@@ -8128,8 +8112,7 @@ var CoretimePolkadot = /*#__PURE__*/function (_Parachain) {
8128
8112
  key: "getRelayToParaOverrides",
8129
8113
  value: function getRelayToParaOverrides() {
8130
8114
  return {
8131
- method: 'limited_teleport_assets',
8132
- includeFee: true
8115
+ transferType: 'teleport'
8133
8116
  };
8134
8117
  }
8135
8118
  }]);
@@ -8374,8 +8357,7 @@ var Encointer = /*#__PURE__*/function (_Parachain) {
8374
8357
  key: "getRelayToParaOverrides",
8375
8358
  value: function getRelayToParaOverrides() {
8376
8359
  return {
8377
- method: 'limited_teleport_assets',
8378
- includeFee: true
8360
+ transferType: 'teleport'
8379
8361
  };
8380
8362
  }
8381
8363
  }]);
@@ -9379,8 +9361,7 @@ var PeoplePolkadot = /*#__PURE__*/function (_Parachain) {
9379
9361
  key: "getRelayToParaOverrides",
9380
9362
  value: function getRelayToParaOverrides() {
9381
9363
  return {
9382
- method: 'limited_teleport_assets',
9383
- includeFee: true
9364
+ transferType: 'teleport'
9384
9365
  };
9385
9366
  }
9386
9367
  }]);
@@ -9535,8 +9516,7 @@ var PeopleKusama = /*#__PURE__*/function (_Parachain) {
9535
9516
  key: "getRelayToParaOverrides",
9536
9517
  value: function getRelayToParaOverrides() {
9537
9518
  return {
9538
- method: 'limited_teleport_assets',
9539
- includeFee: true
9519
+ transferType: 'teleport'
9540
9520
  };
9541
9521
  }
9542
9522
  }]);
@@ -11791,9 +11771,18 @@ var send = /*#__PURE__*/function () {
11791
11771
  resolvedAsset = asset !== null && asset !== void 0 ? asset : {
11792
11772
  symbol: 'symbol' in currency ? currency.symbol : undefined
11793
11773
  };
11794
- finalAsset = Array.isArray(currency) ? _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
11774
+ finalAsset = Array.isArray(currency) ? // TODO: Refactor this
11775
+ // We use a dummy values when overriding with multi-assets
11776
+ // since these values won't be used but need to pass checks
11777
+ _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
11795
11778
  amount: 0n,
11796
- assetId: '1'
11779
+ assetId: '1',
11780
+ location: {
11781
+ parents: Parents.ZERO,
11782
+ interior: {
11783
+ Here: null
11784
+ }
11785
+ }
11797
11786
  }) : _objectSpread2(_objectSpread2({}, resolvedAsset), {}, {
11798
11787
  amount: finalAmount
11799
11788
  });
@@ -12212,11 +12201,62 @@ var getTransferInfo = /*#__PURE__*/function () {
12212
12201
  };
12213
12202
  }();
12214
12203
 
12215
- var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12216
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
12217
- 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, _yield$modifiedBuilde, tx, dryRunResult;
12204
+ var FEE_PADDING = 30;
12205
+ var sumHopFees = function sumHopFees(result, asset) {
12206
+ return result.hops.reduce(function (acc, hop) {
12207
+ // only add if asset is equal
12208
+ return isAssetEqual(hop.result.asset, asset) ? acc + hop.result.fee : acc;
12209
+ }, 0n);
12210
+ };
12211
+ var computeAllFees = /*#__PURE__*/function () {
12212
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, buildTx) {
12213
+ var origin, dest, assetInfo, _context$options, senderAddress, address, currency, feeCurrency, result, hopFees, destFee;
12218
12214
  return _regenerator().w(function (_context) {
12219
12215
  while (1) switch (_context.n) {
12216
+ case 0:
12217
+ origin = context.origin, dest = context.dest, assetInfo = context.assetInfo, _context$options = context.options, senderAddress = _context$options.senderAddress, address = _context$options.address, currency = _context$options.currency, feeCurrency = _context$options.feeCurrency;
12218
+ assertSenderAddress(senderAddress);
12219
+ assertAddressIsString(address);
12220
+ if (hasDryRunSupport(context.origin.chain)) {
12221
+ _context.n = 1;
12222
+ break;
12223
+ }
12224
+ return _context.a(2, null);
12225
+ case 1:
12226
+ _context.n = 2;
12227
+ return getXcmFeeInternal({
12228
+ api: origin.api,
12229
+ buildTx: buildTx,
12230
+ origin: origin.chain,
12231
+ destination: dest.chain,
12232
+ senderAddress: senderAddress,
12233
+ address: address,
12234
+ currency: currency,
12235
+ feeAsset: feeCurrency,
12236
+ disableFallback: false,
12237
+ skipReverseFeeCalculation: true
12238
+ });
12239
+ case 2:
12240
+ result = _context.v;
12241
+ hopFees = sumHopFees(result, assetInfo);
12242
+ destFee = result.destination.fee;
12243
+ return _context.a(2, {
12244
+ hopFees: padValueBy(hopFees, FEE_PADDING),
12245
+ destFee: padValueBy(destFee, FEE_PADDING)
12246
+ });
12247
+ }
12248
+ }, _callee);
12249
+ }));
12250
+ return function computeAllFees(_x, _x2) {
12251
+ return _ref.apply(this, arguments);
12252
+ };
12253
+ }();
12254
+
12255
+ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12256
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
12257
+ 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, createTx, tx, dryRunResult, _t;
12258
+ return _regenerator().w(function (_context2) {
12259
+ while (1) switch (_context2.p = _context2.n) {
12220
12260
  case 0:
12221
12261
  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;
12222
12262
  validateAddress(senderAddress, chain, false);
@@ -12229,10 +12269,10 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12229
12269
  symbol: destAsset.symbol
12230
12270
  };
12231
12271
  destApi = api.clone();
12232
- _context.n = 1;
12272
+ _context2.n = 1;
12233
12273
  return destApi.init(destination);
12234
12274
  case 1:
12235
- _context.n = 2;
12275
+ _context2.n = 2;
12236
12276
  return getAssetBalanceInternal({
12237
12277
  api: destApi,
12238
12278
  address: address,
@@ -12240,13 +12280,13 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12240
12280
  currency: destCurrency
12241
12281
  });
12242
12282
  case 2:
12243
- destBalance = _context.v;
12283
+ destBalance = _context2.v;
12244
12284
  destEd = getEdFromAssetOrThrow(destAsset);
12245
12285
  nativeAssetInfo = findNativeAssetInfoOrThrow(chain);
12246
12286
  isNativeAsset = isAssetEqual(nativeAssetInfo, asset);
12247
12287
  paysOriginInSendingAsset = !resolvedFeeAsset && isNativeAsset || resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
12248
12288
  amount = abstractDecimals(currency.amount, asset.decimals, api);
12249
- _context.n = 3;
12289
+ _context2.n = 3;
12250
12290
  return getXcmFee({
12251
12291
  api: api,
12252
12292
  origin: origin,
@@ -12261,7 +12301,7 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12261
12301
  disableFallback: false
12262
12302
  });
12263
12303
  case 3:
12264
- result = _context.v;
12304
+ result = _context2.v;
12265
12305
  originFee = result.origin && paysOriginInSendingAsset && isAssetEqual(result.origin.asset, asset) ? result.origin.fee : 0n;
12266
12306
  hopFeeTotal = result.hops.reduce(function (acc, hop) {
12267
12307
  // only add if asset is equal
@@ -12270,15 +12310,59 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12270
12310
  destinationFee = result.destination && isAssetEqual(result.destination.asset, asset) ? result.destination.fee : 0n;
12271
12311
  edComponent = destBalance === 0n ? destEd : 0n;
12272
12312
  minAmount = hopFeeTotal + destinationFee + originFee + edComponent + 1n;
12273
- modifiedBuilder = builder.currency(_objectSpread2(_objectSpread2({}, currency), {}, {
12274
- amount: minAmount
12275
- }));
12276
- _context.n = 4;
12277
- return modifiedBuilder['buildInternal']();
12278
- case 4:
12279
- _yield$modifiedBuilde = _context.v;
12280
- tx = _yield$modifiedBuilde.tx;
12281
- _context.n = 5;
12313
+ createTx = /*#__PURE__*/function () {
12314
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(amount) {
12315
+ var _yield$builder$curren, tx;
12316
+ return _regenerator().w(function (_context) {
12317
+ while (1) switch (_context.n) {
12318
+ case 0:
12319
+ _context.n = 1;
12320
+ return builder.currency(_objectSpread2(_objectSpread2({}, currency), {}, {
12321
+ amount: amount
12322
+ }))['buildInternal']();
12323
+ case 1:
12324
+ _yield$builder$curren = _context.v;
12325
+ tx = _yield$builder$curren.tx;
12326
+ return _context.a(2, tx);
12327
+ }
12328
+ }, _callee);
12329
+ }));
12330
+ return function createTx(_x2) {
12331
+ return _ref3.apply(this, arguments);
12332
+ };
12333
+ }();
12334
+ _context2.p = 4;
12335
+ _context2.n = 5;
12336
+ return createTx(minAmount);
12337
+ case 5:
12338
+ tx = _context2.v;
12339
+ _context2.n = 10;
12340
+ break;
12341
+ case 6:
12342
+ _context2.p = 6;
12343
+ _t = _context2.v;
12344
+ if (!(_t instanceof AmountTooLowError)) {
12345
+ _context2.n = 10;
12346
+ break;
12347
+ }
12348
+ minAmount = padValueBy(minAmount, FEE_PADDING);
12349
+ _context2.p = 7;
12350
+ _context2.n = 8;
12351
+ return createTx(minAmount);
12352
+ case 8:
12353
+ tx = _context2.v;
12354
+ _context2.n = 10;
12355
+ break;
12356
+ case 9:
12357
+ _context2.p = 9;
12358
+ _context2.v;
12359
+ if (!(_t instanceof AmountTooLowError)) {
12360
+ _context2.n = 10;
12361
+ break;
12362
+ }
12363
+ return _context2.a(2, 0n);
12364
+ case 10:
12365
+ _context2.n = 11;
12282
12366
  return dryRunInternal({
12283
12367
  api: api,
12284
12368
  tx: tx,
@@ -12291,49 +12375,49 @@ var getMinTransferableAmountInternal = /*#__PURE__*/function () {
12291
12375
  }),
12292
12376
  feeAsset: feeAsset
12293
12377
  });
12294
- case 5:
12295
- dryRunResult = _context.v;
12378
+ case 11:
12379
+ dryRunResult = _context2.v;
12296
12380
  if (!dryRunResult.failureReason) {
12297
- _context.n = 6;
12381
+ _context2.n = 12;
12298
12382
  break;
12299
12383
  }
12300
- return _context.a(2, 0n);
12301
- case 6:
12302
- return _context.a(2, minAmount);
12384
+ return _context2.a(2, 0n);
12385
+ case 12:
12386
+ return _context2.a(2, minAmount);
12303
12387
  }
12304
- }, _callee);
12388
+ }, _callee2, null, [[7, 9], [4, 6]]);
12305
12389
  }));
12306
12390
  return function getMinTransferableAmountInternal(_x) {
12307
12391
  return _ref2.apply(this, arguments);
12308
12392
  };
12309
12393
  }();
12310
12394
  var getMinTransferableAmount = /*#__PURE__*/function () {
12311
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
12395
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
12312
12396
  var api;
12313
- return _regenerator().w(function (_context2) {
12314
- while (1) switch (_context2.p = _context2.n) {
12397
+ return _regenerator().w(function (_context3) {
12398
+ while (1) switch (_context3.p = _context3.n) {
12315
12399
  case 0:
12316
12400
  api = options.api;
12317
12401
  api.setDisconnectAllowed(false);
12318
- _context2.p = 1;
12319
- _context2.n = 2;
12402
+ _context3.p = 1;
12403
+ _context3.n = 2;
12320
12404
  return getMinTransferableAmountInternal(options);
12321
12405
  case 2:
12322
- return _context2.a(2, _context2.v);
12406
+ return _context3.a(2, _context3.v);
12323
12407
  case 3:
12324
- _context2.p = 3;
12408
+ _context3.p = 3;
12325
12409
  api.setDisconnectAllowed(true);
12326
- _context2.n = 4;
12410
+ _context3.n = 4;
12327
12411
  return api.disconnect();
12328
12412
  case 4:
12329
- return _context2.f(3);
12413
+ return _context3.f(3);
12330
12414
  case 5:
12331
- return _context2.a(2);
12415
+ return _context3.a(2);
12332
12416
  }
12333
- }, _callee2, null, [[1,, 3, 5]]);
12417
+ }, _callee3, null, [[1,, 3, 5]]);
12334
12418
  }));
12335
- return function getMinTransferableAmount(_x2) {
12336
- return _ref3.apply(this, arguments);
12419
+ return function getMinTransferableAmount(_x3) {
12420
+ return _ref4.apply(this, arguments);
12337
12421
  };
12338
12422
  }();
12339
12423
 
@@ -12460,57 +12544,6 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(_ref, isDotAsset, custo
12460
12544
  };
12461
12545
  };
12462
12546
 
12463
- var FEE_PADDING = 30;
12464
- var sumHopFees = function sumHopFees(result, asset) {
12465
- return result.hops.reduce(function (acc, hop) {
12466
- // only add if asset is equal
12467
- return isAssetEqual(hop.result.asset, asset) ? acc + hop.result.fee : acc;
12468
- }, 0n);
12469
- };
12470
- var computeAllFees = /*#__PURE__*/function () {
12471
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, buildTx) {
12472
- var origin, dest, assetInfo, _context$options, senderAddress, address, currency, feeCurrency, result, hopFees, destFee;
12473
- return _regenerator().w(function (_context) {
12474
- while (1) switch (_context.n) {
12475
- case 0:
12476
- origin = context.origin, dest = context.dest, assetInfo = context.assetInfo, _context$options = context.options, senderAddress = _context$options.senderAddress, address = _context$options.address, currency = _context$options.currency, feeCurrency = _context$options.feeCurrency;
12477
- assertSenderAddress(senderAddress);
12478
- assertAddressIsString(address);
12479
- if (hasDryRunSupport(context.origin.chain)) {
12480
- _context.n = 1;
12481
- break;
12482
- }
12483
- return _context.a(2, null);
12484
- case 1:
12485
- _context.n = 2;
12486
- return getXcmFeeInternal({
12487
- api: origin.api,
12488
- buildTx: buildTx,
12489
- origin: origin.chain,
12490
- destination: dest.chain,
12491
- senderAddress: senderAddress,
12492
- address: address,
12493
- currency: currency,
12494
- feeAsset: feeCurrency,
12495
- disableFallback: false,
12496
- skipReverseFeeCalculation: true
12497
- });
12498
- case 2:
12499
- result = _context.v;
12500
- hopFees = sumHopFees(result, assetInfo);
12501
- destFee = result.destination.fee;
12502
- return _context.a(2, {
12503
- hopFees: padValueBy(hopFees, FEE_PADDING),
12504
- destFee: padValueBy(destFee, FEE_PADDING)
12505
- });
12506
- }
12507
- }, _callee);
12508
- }));
12509
- return function computeAllFees(_x, _x2) {
12510
- return _ref.apply(this, arguments);
12511
- };
12512
- }();
12513
-
12514
12547
  var RELAY_ASSET_LOCATIONS = [RELAY_LOCATION, {
12515
12548
  parents: 2,
12516
12549
  interior: {
@@ -12650,9 +12683,7 @@ var createCustomXcm = function createCustomXcm(context, assetCount, isForFeeCalc
12650
12683
  if (isSubBridge || origin.chain !== reserve.chain && dest.chain !== reserve.chain) {
12651
12684
  var buyExecutionAmount = resolveBuyExecutionAmount(context, isForFeeCalc, fees, systemAssetAmount);
12652
12685
  if (buyExecutionAmount < 0n && !isForFeeCalc) throw new AmountTooLowError();
12653
- var filter = isForFeeCalc ? {
12654
- Wild: 'All'
12655
- } : {
12686
+ var filter = {
12656
12687
  Definite: assetsFilter
12657
12688
  };
12658
12689
  var buyExecution = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/sdk-core",
3
- "version": "11.14.1",
3
+ "version": "11.14.3",
4
4
  "description": "SDK core for ParaSpell XCM/XCMP tool for developers",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,9 +26,9 @@
26
26
  "@noble/hashes": "^1.8.0",
27
27
  "@scure/base": "^2.0.0",
28
28
  "viem": "^2.38.5",
29
- "@paraspell/assets": "11.14.1",
30
- "@paraspell/sdk-common": "11.14.1",
31
- "@paraspell/pallets": "11.14.1"
29
+ "@paraspell/assets": "11.14.3",
30
+ "@paraspell/sdk-common": "11.14.3",
31
+ "@paraspell/pallets": "11.14.3"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/plugin-syntax-import-attributes": "^7.27.1",