@paraspell/sdk-core 10.4.7 → 10.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { blake2b } from '@noble/hashes/blake2';
2
- import { isNodeEvm, getAssetsObject, getNativeAssetSymbol, getOtherAssets, getRelayChainSymbol, InvalidCurrencyError, isForeignAsset, findAssetForNodeOrThrow, findAsset, isOverrideMultiLocationSpecifier, findAssetByMultiLocation, isTMultiAsset, getExistentialDeposit, isAssetEqual, findAssetOnDestOrThrow, normalizeSymbol, getExistentialDepositOrThrow, hasDryRunSupport, hasSupportForAsset, extractMultiAssetLoc, isSymbolSpecifier, normalizeMultiLocation, getAssetId } from '@paraspell/assets';
2
+ import { isNodeEvm, getAssetsObject, getNativeAssetSymbol, getOtherAssets, getRelayChainSymbol, isForeignAsset, InvalidCurrencyError, findAssetForNodeOrThrow, isOverrideMultiLocationSpecifier, findAssetByMultiLocation, findAsset, isTMultiAsset, getExistentialDeposit, getExistentialDepositOrThrow, isAssetEqual, findAssetOnDestOrThrow, normalizeSymbol, hasDryRunSupport, hasSupportForAsset, extractMultiAssetLoc, isSymbolSpecifier, normalizeMultiLocation, getAssetId } from '@paraspell/assets';
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
5
  import { isAddress, createPublicClient, http, getContract } from 'viem';
6
- import { Parents, Version, isTMultiLocation, isRelayChain, NODE_NAMES_DOT_KSM, hasJunction, deepEqual, isDotKsmBridge } from '@paraspell/sdk-common';
6
+ import { Parents, isTMultiLocation, Version, isRelayChain, replaceBigInt, NODE_NAMES_DOT_KSM, hasJunction, deepEqual, isDotKsmBridge } from '@paraspell/sdk-common';
7
7
  export * from '@paraspell/sdk-common';
8
8
  import { getSupportedPalletsDetails, getDefaultPallet } from '@paraspell/pallets';
9
9
  export * from '@paraspell/pallets';
@@ -69,7 +69,7 @@ function _defineProperties(e, r) {
69
69
  }
70
70
  }
71
71
  function _createClass(e, r, t) {
72
- return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
72
+ return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
73
73
  writable: false
74
74
  }), e;
75
75
  }
@@ -705,6 +705,23 @@ var MAX_WEIGHT = {
705
705
  refTime: MAX_U64
706
706
  };
707
707
 
708
+ var ERR_MULTILOCATION_DEST_NOT_SUPPORTED = 'Multilocation destinations are not supported for specific transfer you are trying to create. In special cases such as xTokens or xTransfer pallet try using address multilocation instead (for both destination and address in same multilocation set (eg. X2 - Parachain, Address). For further assistance please open issue in our repository.';
709
+
710
+ var addXcmVersionHeader = function addXcmVersionHeader(obj, version) {
711
+ return _defineProperty({}, version, obj);
712
+ };
713
+
714
+ var assertToIsString = function assertToIsString(to, overrideMsg) {
715
+ if (isTMultiLocation(to)) {
716
+ throw new InvalidParameterError(overrideMsg !== null && overrideMsg !== void 0 ? overrideMsg : 'Multi-Location destination is not supported for XCM fee calculation.');
717
+ }
718
+ };
719
+ var assertAddressIsString = function assertAddressIsString(address) {
720
+ if (isTMultiLocation(address)) {
721
+ throw new InvalidParameterError('Multi-Location address is not supported for XCM fee calculation.');
722
+ }
723
+ };
724
+
708
725
  var AssetHubPolkadot$1 = {
709
726
  name: "AssetHub",
710
727
  info: "PolkadotAssetHub",
@@ -2400,10 +2417,6 @@ var getNode = function getNode(node) {
2400
2417
  return nodeMap[node];
2401
2418
  };
2402
2419
 
2403
- var replaceBigInt = function replaceBigInt(_key, value) {
2404
- return typeof value === 'bigint' ? value.toString() : value;
2405
- };
2406
-
2407
2420
  var resolveParaId = function resolveParaId(paraId, destination) {
2408
2421
  if (isTMultiLocation(destination) || isRelayChain(destination) || destination === 'Ethereum') {
2409
2422
  return undefined;
@@ -2438,66 +2451,6 @@ var determineRelayChain = function determineRelayChain(node) {
2438
2451
  return getRelayChainSymbol(node) === 'KSM' ? 'Kusama' : 'Polkadot';
2439
2452
  };
2440
2453
 
2441
- var findParachainJunction = function findParachainJunction(multilocation) {
2442
- var interior = multilocation.interior;
2443
- if (interior === 'Here') {
2444
- return null;
2445
- }
2446
- for (var key in interior) {
2447
- var junctions = interior[key];
2448
- if (Array.isArray(junctions)) {
2449
- var _iterator = _createForOfIteratorHelper(junctions),
2450
- _step;
2451
- try {
2452
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
2453
- var junction = _step.value;
2454
- if ('Parachain' in junction) {
2455
- return Number(junction.Parachain);
2456
- }
2457
- }
2458
- } catch (err) {
2459
- _iterator.e(err);
2460
- } finally {
2461
- _iterator.f();
2462
- }
2463
- } else if (_typeof(junctions) === 'object' && junctions !== null && 'Parachain' in junctions) {
2464
- return Number(junctions.Parachain);
2465
- }
2466
- }
2467
- return null;
2468
- };
2469
-
2470
- var constructRelayToParaParameters = function constructRelayToParaParameters(_ref, version) {
2471
- var api = _ref.api,
2472
- destination = _ref.destination,
2473
- asset = _ref.asset,
2474
- address = _ref.address,
2475
- paraIdTo = _ref.paraIdTo;
2476
- var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
2477
- includeFee: false
2478
- },
2479
- includeFee = _ref2.includeFee;
2480
- var paraId = resolveParaId(paraIdTo, destination);
2481
- return _objectSpread2({
2482
- dest: createVersionedDestination('RelayToPara', version, destination, paraId),
2483
- beneficiary: createVersionedBeneficiary({
2484
- api: api,
2485
- scenario: 'RelayToPara',
2486
- pallet: null,
2487
- recipientAddress: address,
2488
- version: version,
2489
- paraId: paraId
2490
- }),
2491
- assets: createVersionedMultiAssets(version, asset.amount, {
2492
- parents: Parents.ZERO,
2493
- interior: 'Here'
2494
- }),
2495
- fee_asset_item: DEFAULT_FEE_ASSET
2496
- }, includeFee && {
2497
- weight_limit: 'Unlimited'
2498
- });
2499
- };
2500
-
2501
2454
  var createMultiAsset = function createMultiAsset(version, amount, multiLocation) {
2502
2455
  if (version === Version.V4 || version === Version.V5) {
2503
2456
  return {
@@ -2516,83 +2469,28 @@ var createMultiAsset = function createMultiAsset(version, amount, multiLocation)
2516
2469
  }
2517
2470
  };
2518
2471
  };
2519
- var addXcmVersionHeader = function addXcmVersionHeader(obj, version) {
2520
- return _defineProperty({}, version, obj);
2521
- };
2522
- var extractVersionFromHeader = function extractVersionFromHeader(versionHeader) {
2523
- var keys = Object.keys(versionHeader);
2524
- if (keys.length !== 1) {
2525
- throw new InvalidParameterError('Invalid version header: expected exactly one key.');
2526
- }
2527
- var version = keys[0];
2528
- var value = versionHeader[version];
2529
- if (value === undefined) {
2530
- throw new InvalidParameterError('Invalid version header: value is undefined.');
2531
- }
2532
- return [version, value];
2472
+ var createVersionedMultiAssets = function createVersionedMultiAssets(version, amount, multiLocation) {
2473
+ var multiAsset = createMultiAsset(version, amount, multiLocation);
2474
+ return addXcmVersionHeader([multiAsset], version);
2533
2475
  };
2476
+
2534
2477
  var maybeOverrideMultiAssets = function maybeOverrideMultiAssets(version, amount, multiAssets, overriddenCurrency) {
2535
2478
  if (!overriddenCurrency) {
2536
2479
  return multiAssets;
2537
2480
  }
2538
2481
  return isTMultiLocation(overriddenCurrency) ? [createMultiAsset(version, amount, overriddenCurrency)] : overriddenCurrency;
2539
2482
  };
2540
- var createVersionedMultiAssets = function createVersionedMultiAssets(version, amount, multiLocation) {
2541
- var multiAssets = createMultiAsset(version, amount, multiLocation);
2542
- return addXcmVersionHeader([multiAssets], version);
2543
- };
2544
- var createDestination = function createDestination(scenario, version, destination, nodeId, junction, parents) {
2545
- var parentsResolved = parents !== null && parents !== void 0 ? parents : scenario === 'RelayToPara' ? Parents.ZERO : Parents.ONE;
2546
- var interior = scenario === 'ParaToRelay' ? 'Here' : createX1Payload(version, junction !== null && junction !== void 0 ? junction : {
2547
- Parachain: nodeId
2548
- });
2549
- var isMultiLocationDestination = isTMultiLocation(destination);
2550
- return isMultiLocationDestination ? destination : {
2551
- parents: parentsResolved,
2552
- interior: interior
2553
- };
2554
- };
2555
- var createVersionedDestination = function createVersionedDestination(scenario, version, destination, nodeId, junction, parents) {
2556
- var plainDestination = createDestination(scenario, version, destination, nodeId, junction, parents);
2557
- return addXcmVersionHeader(plainDestination, version);
2558
- };
2559
- var createBridgePolkadotXcmDest = function createBridgePolkadotXcmDest(version, ecosystem, destination, nodeId) {
2560
- var multiLocation = {
2561
- parents: Parents.TWO,
2562
- interior: {
2563
- X2: [{
2564
- GlobalConsensus: ecosystem
2565
- }, {
2566
- Parachain: nodeId
2567
- }]
2568
- }
2569
- };
2570
- var isMultiLocationDestination = isTMultiLocation(destination);
2571
- return addXcmVersionHeader(isMultiLocationDestination ? destination : multiLocation, version);
2572
- };
2573
- var resolveTNodeFromMultiLocation = function resolveTNodeFromMultiLocation(relayChain, multiLocation) {
2574
- var _NODE_NAMES_DOT_KSM$f;
2575
- var parachainId = findParachainJunction(multiLocation);
2576
- if (parachainId === null) {
2577
- throw new InvalidParameterError('Parachain ID not found in destination multi location.');
2578
- }
2579
- var node = (_NODE_NAMES_DOT_KSM$f = NODE_NAMES_DOT_KSM.find(function (nodeName) {
2580
- return getParaId(nodeName) === parachainId && determineRelayChain(nodeName) === relayChain;
2581
- })) !== null && _NODE_NAMES_DOT_KSM$f !== void 0 ? _NODE_NAMES_DOT_KSM$f : null;
2582
- if (node === null) {
2583
- throw new InvalidParameterError('Node with specified paraId not found in destination multi location.');
2483
+ var maybeOverrideMultiAsset = function maybeOverrideMultiAsset(version, amount, multiAsset, overriddenCurrency) {
2484
+ if (!overriddenCurrency) {
2485
+ return multiAsset;
2584
2486
  }
2585
- return node;
2586
- };
2587
- var throwUnsupportedCurrency = function throwUnsupportedCurrency(currency, node) {
2588
- var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
2589
- isDestination: false
2590
- },
2591
- isDestination = _ref2.isDestination;
2592
- if ('multilocation' in currency) {
2593
- throw new InvalidCurrencyError("\n Selected chain doesn't support multilocation you provided. Maybe you meant custom multilocation. If so, you need to use override option. Your selection should look like this: {multilocation: Override(".concat(JSON.stringify(currency.multilocation), ")}."));
2487
+ if (Array.isArray(overriddenCurrency)) {
2488
+ if (overriddenCurrency.length !== 1) {
2489
+ throw new InvalidParameterError('Expected a single TMultiAsset in overriddenCurrency array.');
2490
+ }
2491
+ return overriddenCurrency[0];
2594
2492
  }
2595
- throw new InvalidCurrencyError("".concat(isDestination ? 'Destination' : 'Origin', " node ").concat(node, " does not support currency ").concat(JSON.stringify(currency), "."));
2493
+ return createMultiAsset(version, amount, overriddenCurrency);
2596
2494
  };
2597
2495
 
2598
2496
  var resolveMultiLocationFromDest = function resolveMultiLocationFromDest(destination, asset) {
@@ -2658,12 +2556,13 @@ var getModifiedCurrencySelection = function getModifiedCurrencySelection(input)
2658
2556
  return createDefaultCurrencySelection(input);
2659
2557
  };
2660
2558
 
2661
- var getXTokensParameters = function getXTokensParameters(isMultiAssetTransfer, currencySelection, addressSelection, amount, fees, overriddenAsset) {
2559
+ var getXTokensParameters = function getXTokensParameters(isMultiAssetTransfer, currencySelection, destLocation, amount, fees, version, overriddenAsset) {
2560
+ var versionedDestLocation = addXcmVersionHeader(destLocation, version);
2662
2561
  if (!isMultiAssetTransfer) {
2663
2562
  return {
2664
2563
  currency_id: currencySelection,
2665
2564
  amount: BigInt(amount),
2666
- dest: addressSelection,
2565
+ dest: versionedDestLocation,
2667
2566
  dest_weight_limit: fees
2668
2567
  };
2669
2568
  }
@@ -2676,7 +2575,7 @@ var getXTokensParameters = function getXTokensParameters(isMultiAssetTransfer, c
2676
2575
  return _objectSpread2(_objectSpread2(_defineProperty({}, assetKey, currencySelection), isOverriddenMultiAssets && {
2677
2576
  fee_item: feeIndexWithFallback
2678
2577
  }), {}, {
2679
- dest: addressSelection,
2578
+ dest: versionedDestLocation,
2680
2579
  dest_weight_limit: fees
2681
2580
  });
2682
2581
  };
@@ -2700,14 +2599,15 @@ var getXTokensMethod = function getXTokensMethod(useMultiAsset, overriddenAsset)
2700
2599
  };
2701
2600
  var buildXTokensCall = function buildXTokensCall(input, currencySelection, fees) {
2702
2601
  var overriddenAsset = input.overriddenAsset,
2703
- addressSelection = input.addressSelection,
2602
+ destLocation = input.destLocation,
2704
2603
  asset = input.asset,
2705
2604
  pallet = input.pallet,
2605
+ version = input.version,
2706
2606
  methodOverride = input.method;
2707
2607
  var useMultiAsset = shouldUseMultiAssetTransfer(input);
2708
2608
  var modifiedCurrencySelection = useMultiAsset ? getModifiedCurrencySelection(input) : currencySelection;
2709
2609
  var method = getXTokensMethod(useMultiAsset, overriddenAsset);
2710
- var parameters = getXTokensParameters(useMultiAsset, modifiedCurrencySelection, addressSelection, asset.amount, fees, overriddenAsset);
2610
+ var parameters = getXTokensParameters(useMultiAsset, modifiedCurrencySelection, destLocation, asset.amount, fees, version, overriddenAsset);
2711
2611
  return {
2712
2612
  module: pallet !== null && pallet !== void 0 ? pallet : 'XTokens',
2713
2613
  method: methodOverride !== null && methodOverride !== void 0 ? methodOverride : method,
@@ -2715,22 +2615,129 @@ var buildXTokensCall = function buildXTokensCall(input, currencySelection, fees)
2715
2615
  };
2716
2616
  };
2717
2617
 
2718
- var ERR_MULTILOCATION_DEST_NOT_SUPPORTED = 'Multilocation destinations are not supported for specific transfer you are trying to create. In special cases such as xTokens or xTransfer pallet try using address multilocation instead (for both destination and address in same multilocation set (eg. X2 - Parachain, Address). For further assistance please open issue in our repository.';
2719
- var validateDestination$1 = function validateDestination(destination) {
2720
- var isMultiLocationDestination = _typeof(destination) === 'object';
2721
- if (isMultiLocationDestination) {
2722
- throw new InvalidParameterError(ERR_MULTILOCATION_DEST_NOT_SUPPORTED);
2723
- }
2724
- };
2618
+ // Contains basic structure of xTokens call
2725
2619
  var transferXTokens = function transferXTokens(input, currencySelection) {
2726
2620
  var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_FEE;
2727
2621
  var api = input.api,
2728
2622
  destination = input.destination;
2729
- validateDestination$1(destination);
2623
+ assertToIsString(destination, ERR_MULTILOCATION_DEST_NOT_SUPPORTED);
2730
2624
  var call = buildXTokensCall(input, currencySelection, fees);
2731
2625
  return api.callTxMethod(call);
2732
2626
  };
2733
2627
 
2628
+ var findParachainJunction = function findParachainJunction(multilocation) {
2629
+ var interior = multilocation.interior;
2630
+ if (interior === 'Here') {
2631
+ return null;
2632
+ }
2633
+ for (var key in interior) {
2634
+ var junctions = interior[key];
2635
+ if (Array.isArray(junctions)) {
2636
+ var _iterator = _createForOfIteratorHelper(junctions),
2637
+ _step;
2638
+ try {
2639
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
2640
+ var junction = _step.value;
2641
+ if ('Parachain' in junction) {
2642
+ return Number(junction.Parachain);
2643
+ }
2644
+ }
2645
+ } catch (err) {
2646
+ _iterator.e(err);
2647
+ } finally {
2648
+ _iterator.f();
2649
+ }
2650
+ } else if (_typeof(junctions) === 'object' && junctions !== null && 'Parachain' in junctions) {
2651
+ return Number(junctions.Parachain);
2652
+ }
2653
+ }
2654
+ return null;
2655
+ };
2656
+
2657
+ var constructRelayToParaParameters = function constructRelayToParaParameters(_ref, version) {
2658
+ var api = _ref.api,
2659
+ destination = _ref.destination,
2660
+ asset = _ref.asset,
2661
+ address = _ref.address,
2662
+ paraIdTo = _ref.paraIdTo;
2663
+ var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
2664
+ includeFee: false
2665
+ },
2666
+ includeFee = _ref2.includeFee;
2667
+ var paraId = resolveParaId(paraIdTo, destination);
2668
+ return _objectSpread2({
2669
+ dest: createVersionedDestination('RelayToPara', version, destination, paraId),
2670
+ beneficiary: createVersionedBeneficiary({
2671
+ api: api,
2672
+ scenario: 'RelayToPara',
2673
+ pallet: null,
2674
+ recipientAddress: address,
2675
+ version: version,
2676
+ paraId: paraId
2677
+ }),
2678
+ assets: createVersionedMultiAssets(version, asset.amount, {
2679
+ parents: Parents.ZERO,
2680
+ interior: 'Here'
2681
+ }),
2682
+ fee_asset_item: DEFAULT_FEE_ASSET
2683
+ }, includeFee && {
2684
+ weight_limit: 'Unlimited'
2685
+ });
2686
+ };
2687
+
2688
+ var createDestination = function createDestination(scenario, version, destination, nodeId, junction, parents) {
2689
+ var parentsResolved = parents !== null && parents !== void 0 ? parents : scenario === 'RelayToPara' ? Parents.ZERO : Parents.ONE;
2690
+ var interior = scenario === 'ParaToRelay' ? 'Here' : createX1Payload(version, junction !== null && junction !== void 0 ? junction : {
2691
+ Parachain: nodeId
2692
+ });
2693
+ var isMultiLocationDestination = isTMultiLocation(destination);
2694
+ return isMultiLocationDestination ? destination : {
2695
+ parents: parentsResolved,
2696
+ interior: interior
2697
+ };
2698
+ };
2699
+ var createVersionedDestination = function createVersionedDestination(scenario, version, destination, nodeId, junction, parents) {
2700
+ var plainDestination = createDestination(scenario, version, destination, nodeId, junction, parents);
2701
+ return addXcmVersionHeader(plainDestination, version);
2702
+ };
2703
+ var createBridgeDestination = function createBridgeDestination(ecosystem, destination, nodeId) {
2704
+ var multiLocation = {
2705
+ parents: Parents.TWO,
2706
+ interior: {
2707
+ X2: [{
2708
+ GlobalConsensus: ecosystem
2709
+ }, {
2710
+ Parachain: nodeId
2711
+ }]
2712
+ }
2713
+ };
2714
+ return isTMultiLocation(destination) ? destination : multiLocation;
2715
+ };
2716
+ var resolveTNodeFromMultiLocation = function resolveTNodeFromMultiLocation(relayChain, multiLocation) {
2717
+ var _NODE_NAMES_DOT_KSM$f;
2718
+ var parachainId = findParachainJunction(multiLocation);
2719
+ if (parachainId === null) {
2720
+ throw new InvalidParameterError('Parachain ID not found in destination multi location.');
2721
+ }
2722
+ var node = (_NODE_NAMES_DOT_KSM$f = NODE_NAMES_DOT_KSM.find(function (nodeName) {
2723
+ return getParaId(nodeName) === parachainId && determineRelayChain(nodeName) === relayChain;
2724
+ })) !== null && _NODE_NAMES_DOT_KSM$f !== void 0 ? _NODE_NAMES_DOT_KSM$f : null;
2725
+ if (node === null) {
2726
+ throw new InvalidParameterError('Node with specified paraId not found in destination multi location.');
2727
+ }
2728
+ return node;
2729
+ };
2730
+ var throwUnsupportedCurrency = function throwUnsupportedCurrency(currency, node) {
2731
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
2732
+ isDestination: false
2733
+ },
2734
+ isDestination = _ref.isDestination;
2735
+ if ('multilocation' in currency) {
2736
+ throw new InvalidCurrencyError("\n Selected chain doesn't support multilocation you provided. Maybe you meant custom multilocation. If so, you need to use override option. Your selection should look like this: {multilocation: Override(".concat(JSON.stringify(currency.multilocation), ")}."));
2737
+ }
2738
+ throw new InvalidCurrencyError("".concat(isDestination ? 'Destination' : 'Origin', " node ").concat(node, " does not support currency ").concat(JSON.stringify(currency, replaceBigInt), "."));
2739
+ };
2740
+
2734
2741
  /**
2735
2742
  * Retrieves the node name corresponding to a specified parachain ID.
2736
2743
  *
@@ -3373,29 +3380,23 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
3373
3380
  wallet: signer
3374
3381
  }
3375
3382
  });
3376
- foundAsset = findAsset(from, currency, to);
3377
- if (!(foundAsset === null)) {
3378
- _context.n = 3;
3379
- break;
3380
- }
3381
- throw new InvalidCurrencyError("Origin node ".concat(from, " does not support currency ").concat(JSON.stringify(currency), "."));
3382
- case 3:
3383
+ foundAsset = findAssetForNodeOrThrow(from, currency, to);
3383
3384
  if (!(foundAsset.symbol === getNativeAssetSymbol(from))) {
3384
- _context.n = 4;
3385
+ _context.n = 3;
3385
3386
  break;
3386
3387
  }
3387
3388
  asset = NATIVE_ASSET_ID;
3388
- _context.n = 6;
3389
+ _context.n = 5;
3389
3390
  break;
3390
- case 4:
3391
+ case 3:
3391
3392
  if (!(!isForeignAsset(foundAsset) || !foundAsset.assetId)) {
3392
- _context.n = 5;
3393
+ _context.n = 4;
3393
3394
  break;
3394
3395
  }
3395
3396
  throw new InvalidCurrencyError('Currency must be a foreign asset with valid assetId');
3396
- case 5:
3397
+ case 4:
3397
3398
  asset = formatAssetIdToERC20(foundAsset.assetId);
3398
- case 6:
3399
+ case 5:
3399
3400
  destMultiLocation = getDestinationMultilocation(api, address, to);
3400
3401
  weight = U_64_MAX; // Partially inspired by Moonbeam XCM-SDK
3401
3402
  // https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/sdk/src/contract/contracts/Xtokens/Xtokens.ts#L53
@@ -3405,27 +3406,27 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
3405
3406
  };
3406
3407
  multiCurrencySymbols = ['xcPINK', 'xcDED', 'xcSTINK', 'xcWIFD', 'xcNCTR'];
3407
3408
  useMultiAssets = from === 'Moonbeam' && to === 'AssetHubPolkadot' && multiCurrencySymbols.includes(foundAsset.symbol);
3408
- usdtAsset = findAsset(from, {
3409
+ usdtAsset = findAssetForNodeOrThrow(from, {
3409
3410
  symbol: 'xcUSDT'
3410
3411
  }, to);
3411
3412
  if (!useMultiAssets) {
3412
- _context.n = 8;
3413
+ _context.n = 7;
3413
3414
  break;
3414
3415
  }
3415
- _context.n = 7;
3416
+ _context.n = 6;
3416
3417
  return createTx('transferMultiCurrencies', [[[asset, currency.amount], [formatAssetIdToERC20((_usdtAsset$assetId = usdtAsset.assetId) !== null && _usdtAsset$assetId !== void 0 ? _usdtAsset$assetId : ''), '200000']], 1,
3417
3418
  // index of the fee asset
3418
3419
  destMultiLocation, weight]);
3419
- case 7:
3420
+ case 6:
3420
3421
  _t = _context.v;
3421
- _context.n = 10;
3422
- break;
3423
- case 8:
3424
3422
  _context.n = 9;
3423
+ break;
3424
+ case 7:
3425
+ _context.n = 8;
3425
3426
  return createTx('transfer', [asset, currency.amount, destMultiLocation, weight]);
3426
- case 9:
3427
+ case 8:
3427
3428
  _t = _context.v;
3428
- case 10:
3429
+ case 9:
3429
3430
  tx = _t;
3430
3431
  return _context.a(2, tx);
3431
3432
  }
@@ -3697,26 +3698,20 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
3697
3698
  }
3698
3699
  throw new InvalidParameterError('Override multilocation is not supported for Evm transfers');
3699
3700
  case 5:
3700
- foundAsset = findAsset(from, currency, to);
3701
- if (!(foundAsset === null)) {
3702
- _context.n = 6;
3703
- break;
3704
- }
3705
- throw new InvalidCurrencyError("Origin node ".concat(from, " does not support currency ").concat(JSON.stringify(currency), "."));
3706
- case 6:
3701
+ foundAsset = findAssetForNodeOrThrow(from, currency, to);
3707
3702
  if (!(!isForeignAsset(foundAsset) || !foundAsset.multiLocation)) {
3708
- _context.n = 7;
3703
+ _context.n = 6;
3709
3704
  break;
3710
3705
  }
3711
3706
  throw new InvalidCurrencyError('Currency must be a foreign asset with valid multi-location');
3712
- case 7:
3707
+ case 6:
3713
3708
  ethAsset = findAssetByMultiLocation(getOtherAssets('Ethereum'), foundAsset.multiLocation);
3714
3709
  if (!(!ethAsset || !ethAsset.assetId)) {
3715
- _context.n = 8;
3710
+ _context.n = 7;
3716
3711
  break;
3717
3712
  }
3718
3713
  throw new InvalidCurrencyError("Could not obtain Ethereum asset address for ".concat(JSON.stringify(foundAsset)));
3719
- case 8:
3714
+ case 7:
3720
3715
  contract = getContract({
3721
3716
  abi: abi,
3722
3717
  address: xcmInterfacePrecompile,
@@ -3730,17 +3725,17 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
3730
3725
  });
3731
3726
  senderAddress = (_signer$account = signer.account) === null || _signer$account === void 0 ? void 0 : _signer$account.address;
3732
3727
  if (senderAddress) {
3733
- _context.n = 9;
3728
+ _context.n = 8;
3734
3729
  break;
3735
3730
  }
3736
3731
  throw new InvalidParameterError('Unable to get sender address');
3732
+ case 8:
3733
+ _context.n = 9;
3734
+ return api.init(from, TX_CLIENT_TIMEOUT_MS);
3737
3735
  case 9:
3738
3736
  _context.n = 10;
3739
- return api.init(from, TX_CLIENT_TIMEOUT_MS);
3740
- case 10:
3741
- _context.n = 11;
3742
3737
  return generateMessageId(api, senderAddress, getParaId(from), ethAsset.assetId, address, currency.amount);
3743
- case 11:
3738
+ case 10:
3744
3739
  messageId = _context.v;
3745
3740
  customXcm = createCustomXcmOnDest({
3746
3741
  api: api,
@@ -3753,17 +3748,17 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
3753
3748
  }),
3754
3749
  version: Version.V4
3755
3750
  }, from, messageId);
3756
- _context.n = 12;
3751
+ _context.n = 11;
3757
3752
  return api.objectToHex(customXcm, 'XcmVersionedXcm');
3758
- case 12:
3753
+ case 11:
3759
3754
  customXcmOnDest = _context.v;
3760
- _context.n = 13;
3755
+ _context.n = 12;
3761
3756
  return api.createApiForNode('AssetHubPolkadot');
3762
- case 13:
3757
+ case 12:
3763
3758
  assetHubApi = _context.v;
3764
- _context.n = 14;
3759
+ _context.n = 13;
3765
3760
  return getParaEthTransferFees(assetHubApi);
3766
- case 14:
3761
+ case 13:
3767
3762
  _yield$getParaEthTran = _context.v;
3768
3763
  _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
3769
3764
  bridgeFee = _yield$getParaEthTran2[0];
@@ -3778,7 +3773,7 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
3778
3773
  throw new InvalidParameterError('Input must be a valid number');
3779
3774
  }() : "0x".concat((num >>> 0).toString(16).padStart(8, '0'));
3780
3775
  }; // Execute the custom XCM message with the precompile
3781
- _context.n = 15;
3776
+ _context.n = 14;
3782
3777
  return createTx('transferAssetsUsingTypeAndThenAddress', [
3783
3778
  // This represents (1,X1(Parachain(1000)))
3784
3779
  [1, ['0x00' + numberToHex32(getParaId('AssetHubPolkadot')).slice(2)]],
@@ -3790,7 +3785,7 @@ var transferMoonbeamToEth = /*#__PURE__*/function () {
3790
3785
  0,
3791
3786
  // The TransferType corresponding to fee asset
3792
3787
  2, customXcmOnDest]);
3793
- case 15:
3788
+ case 14:
3794
3789
  tx = _context.v;
3795
3790
  return _context.a(2, tx);
3796
3791
  }
@@ -3949,7 +3944,7 @@ var getOriginFeeDetails = /*#__PURE__*/function () {
3949
3944
 
3950
3945
  var getTransferableAmountInternal = /*#__PURE__*/function () {
3951
3946
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
3952
- var api, senderAddress, node, destination, currency, tx, feeAsset, resolvedFeeAsset, asset, balance, ed, edBN, isNativeAsset, shouldSubstractFee, feeToSubtract, _yield$getOriginXcmFe, fee, transferable;
3947
+ var api, senderAddress, node, destination, currency, tx, feeAsset, resolvedFeeAsset, asset, balance, ed, isNativeAsset, shouldSubstractFee, feeToSubtract, _yield$getOriginXcmFe, fee, transferable;
3953
3948
  return _regenerator().w(function (_context) {
3954
3949
  while (1) switch (_context.n) {
3955
3950
  case 0:
@@ -3966,22 +3961,15 @@ var getTransferableAmountInternal = /*#__PURE__*/function () {
3966
3961
  });
3967
3962
  case 1:
3968
3963
  balance = _context.v;
3969
- ed = getExistentialDeposit(node, currency);
3970
- if (!(ed === null)) {
3971
- _context.n = 2;
3972
- break;
3973
- }
3974
- throw new InvalidParameterError("Cannot get existential deposit for currency ".concat(JSON.stringify(currency), "."));
3975
- case 2:
3976
- edBN = BigInt(ed);
3964
+ ed = getExistentialDepositOrThrow(node, currency);
3977
3965
  isNativeAsset = getNativeAssetSymbol(node) === asset.symbol;
3978
3966
  shouldSubstractFee = isNativeAsset || node === 'AssetHubPolkadot' && resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, asset);
3979
3967
  feeToSubtract = 0n;
3980
3968
  if (!shouldSubstractFee) {
3981
- _context.n = 5;
3969
+ _context.n = 4;
3982
3970
  break;
3983
3971
  }
3984
- _context.n = 3;
3972
+ _context.n = 2;
3985
3973
  return getOriginXcmFee({
3986
3974
  api: api,
3987
3975
  tx: tx,
@@ -3992,18 +3980,18 @@ var getTransferableAmountInternal = /*#__PURE__*/function () {
3992
3980
  currency: currency,
3993
3981
  disableFallback: false
3994
3982
  });
3995
- case 3:
3983
+ case 2:
3996
3984
  _yield$getOriginXcmFe = _context.v;
3997
3985
  fee = _yield$getOriginXcmFe.fee;
3998
3986
  if (!(fee === undefined)) {
3999
- _context.n = 4;
3987
+ _context.n = 3;
4000
3988
  break;
4001
3989
  }
4002
- throw new InvalidParameterError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency), " on node ").concat(node, "."));
4003
- case 4:
3990
+ throw new InvalidParameterError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency, replaceBigInt), " on node ").concat(node, "."));
3991
+ case 3:
4004
3992
  feeToSubtract = fee;
4005
- case 5:
4006
- transferable = balance - edBN - feeToSubtract;
3993
+ case 4:
3994
+ transferable = balance - ed - feeToSubtract;
4007
3995
  return _context.a(2, transferable > 0n ? transferable : 0n);
4008
3996
  }
4009
3997
  }, _callee);
@@ -4063,7 +4051,7 @@ var buildDestInfo = /*#__PURE__*/function () {
4063
4051
  _context.n = 2;
4064
4052
  break;
4065
4053
  }
4066
- throw new InvalidParameterError("Existential deposit not found for ".concat(destination, " with currency ").concat(JSON.stringify(currency)));
4054
+ throw new InvalidParameterError("Existential deposit not found for ".concat(destination, " with currency ").concat(JSON.stringify(currency, replaceBigInt)));
4067
4055
  case 2:
4068
4056
  edDestBn = BigInt(edDest);
4069
4057
  destCurrency = destAsset.multiLocation ? {
@@ -4241,7 +4229,7 @@ var buildHopInfo = /*#__PURE__*/function () {
4241
4229
 
4242
4230
  var getTransferInfo = /*#__PURE__*/function () {
4243
4231
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
4244
- var api, tx, origin, destination, senderAddress, ahAddress, address, currency, feeAsset, resolvedFeeAsset, originAsset, originBalanceFee, originBalance, edOrigin, edOriginBn, _yield$getXcmFee, _yield$getXcmFee$orig, originFee, originFeeCurrency, assetHubFeeResult, bridgeHubFeeResult, destFeeDetail, isFeeAssetAh, originBalanceAfter, originBalanceFeeAfter, originBalanceNativeSufficient, originBalanceSufficient, assetHub, bridgeHub, bridgeHubNode, destinationInfo, _t;
4232
+ var api, tx, origin, destination, senderAddress, ahAddress, address, currency, feeAsset, resolvedFeeAsset, originAsset, originBalanceFee, originBalance, edOrigin, _yield$getXcmFee, _yield$getXcmFee$orig, originFee, originFeeCurrency, assetHubFeeResult, bridgeHubFeeResult, destFeeDetail, isFeeAssetAh, originBalanceAfter, originBalanceFeeAfter, originBalanceNativeSufficient, originBalanceSufficient, assetHub, bridgeHub, bridgeHubNode, destinationInfo, _t;
4245
4233
  return _regenerator().w(function (_context) {
4246
4234
  while (1) switch (_context.n) {
4247
4235
  case 0:
@@ -4294,15 +4282,8 @@ var getTransferInfo = /*#__PURE__*/function () {
4294
4282
  });
4295
4283
  case 8:
4296
4284
  originBalance = _context.v;
4297
- edOrigin = getExistentialDeposit(origin, currency);
4298
- if (edOrigin) {
4299
- _context.n = 9;
4300
- break;
4301
- }
4302
- throw new InvalidParameterError("Existential deposit not found for ".concat(origin, " with currency ").concat(JSON.stringify(currency)));
4303
- case 9:
4304
- edOriginBn = BigInt(edOrigin);
4305
- _context.n = 10;
4285
+ edOrigin = getExistentialDepositOrThrow(origin, currency);
4286
+ _context.n = 9;
4306
4287
  return getXcmFee({
4307
4288
  api: api,
4308
4289
  tx: tx,
@@ -4314,7 +4295,7 @@ var getTransferInfo = /*#__PURE__*/function () {
4314
4295
  feeAsset: feeAsset,
4315
4296
  disableFallback: false
4316
4297
  });
4317
- case 10:
4298
+ case 9:
4318
4299
  _yield$getXcmFee = _context.v;
4319
4300
  _yield$getXcmFee$orig = _yield$getXcmFee.origin;
4320
4301
  originFee = _yield$getXcmFee$orig.fee;
@@ -4323,21 +4304,21 @@ var getTransferInfo = /*#__PURE__*/function () {
4323
4304
  bridgeHubFeeResult = _yield$getXcmFee.bridgeHub;
4324
4305
  destFeeDetail = _yield$getXcmFee.destination;
4325
4306
  if (!(originFee === undefined)) {
4326
- _context.n = 11;
4307
+ _context.n = 10;
4327
4308
  break;
4328
4309
  }
4329
- throw new InvalidParameterError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency), " on node ").concat(origin, "."));
4330
- case 11:
4310
+ throw new InvalidParameterError("Cannot get origin xcm fee for currency ".concat(JSON.stringify(currency, replaceBigInt), " on node ").concat(origin, "."));
4311
+ case 10:
4331
4312
  isFeeAssetAh = origin === 'AssetHubPolkadot' && resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, originAsset);
4332
4313
  originBalanceAfter = originBalance - BigInt(currency.amount);
4333
4314
  originBalanceFeeAfter = isFeeAssetAh ? originBalanceFee - BigInt(currency.amount) : originBalanceFee - originFee;
4334
4315
  originBalanceNativeSufficient = originBalanceFee >= originFee;
4335
- originBalanceSufficient = originBalanceAfter >= edOriginBn;
4316
+ originBalanceSufficient = originBalanceAfter >= edOrigin;
4336
4317
  if (!assetHubFeeResult) {
4337
- _context.n = 13;
4318
+ _context.n = 12;
4338
4319
  break;
4339
4320
  }
4340
- _context.n = 12;
4321
+ _context.n = 11;
4341
4322
  return buildHopInfo({
4342
4323
  api: api,
4343
4324
  node: determineRelayChain(origin) === 'Polkadot' ? 'AssetHubPolkadot' : 'AssetHubKusama',
@@ -4347,15 +4328,15 @@ var getTransferInfo = /*#__PURE__*/function () {
4347
4328
  senderAddress: senderAddress,
4348
4329
  ahAddress: ahAddress
4349
4330
  });
4350
- case 12:
4331
+ case 11:
4351
4332
  assetHub = _context.v;
4352
- case 13:
4333
+ case 12:
4353
4334
  if (!bridgeHubFeeResult) {
4354
- _context.n = 15;
4335
+ _context.n = 14;
4355
4336
  break;
4356
4337
  }
4357
4338
  bridgeHubNode = determineRelayChain(origin) === 'Polkadot' ? 'BridgeHubPolkadot' : 'BridgeHubKusama';
4358
- _context.n = 14;
4339
+ _context.n = 13;
4359
4340
  return buildHopInfo({
4360
4341
  api: api,
4361
4342
  node: bridgeHubNode,
@@ -4365,10 +4346,10 @@ var getTransferInfo = /*#__PURE__*/function () {
4365
4346
  senderAddress: senderAddress,
4366
4347
  ahAddress: ahAddress
4367
4348
  });
4368
- case 14:
4349
+ case 13:
4369
4350
  bridgeHub = _context.v;
4370
- case 15:
4371
- _context.n = 16;
4351
+ case 14:
4352
+ _context.n = 15;
4372
4353
  return buildDestInfo({
4373
4354
  api: api,
4374
4355
  origin: origin,
@@ -4381,7 +4362,7 @@ var getTransferInfo = /*#__PURE__*/function () {
4381
4362
  assetHubFee: assetHubFeeResult === null || assetHubFeeResult === void 0 ? void 0 : assetHubFeeResult.fee,
4382
4363
  bridgeFee: bridgeHubFeeResult === null || bridgeHubFeeResult === void 0 ? void 0 : bridgeHubFeeResult.fee
4383
4364
  });
4384
- case 16:
4365
+ case 15:
4385
4366
  destinationInfo = _context.v;
4386
4367
  return _context.a(2, {
4387
4368
  chain: {
@@ -4395,7 +4376,7 @@ var getTransferInfo = /*#__PURE__*/function () {
4395
4376
  balance: originBalance,
4396
4377
  balanceAfter: originBalanceAfter,
4397
4378
  currencySymbol: originAsset.symbol,
4398
- existentialDeposit: edOriginBn
4379
+ existentialDeposit: edOrigin
4399
4380
  },
4400
4381
  xcmFee: {
4401
4382
  sufficient: originBalanceNativeSufficient,
@@ -4409,17 +4390,17 @@ var getTransferInfo = /*#__PURE__*/function () {
4409
4390
  bridgeHub: bridgeHub,
4410
4391
  destination: destinationInfo
4411
4392
  });
4412
- case 17:
4413
- _context.p = 17;
4393
+ case 16:
4394
+ _context.p = 16;
4414
4395
  api.setDisconnectAllowed(true);
4415
- _context.n = 18;
4396
+ _context.n = 17;
4416
4397
  return api.disconnect();
4398
+ case 17:
4399
+ return _context.f(16);
4417
4400
  case 18:
4418
- return _context.f(17);
4419
- case 19:
4420
4401
  return _context.a(2);
4421
4402
  }
4422
- }, _callee, null, [[3,, 17, 19]]);
4403
+ }, _callee, null, [[3,, 16, 18]]);
4423
4404
  }));
4424
4405
  return function getTransferInfo(_x) {
4425
4406
  return _ref2.apply(this, arguments);
@@ -4439,7 +4420,7 @@ var calculateTotalXcmFee = function calculateTotalXcmFee(feeResult) {
4439
4420
  };
4440
4421
  var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
4441
4422
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
4442
- var api, tx, origin, destination, address, senderAddress, feeAsset, currency, destApi, asset, destCurrency, ed, edBN, balance, xcmFeeResult, dryRunError, assetHubFeeResult, bridgeHubFeeResult, _xcmFeeResult$destina, destFee, destFeeCurrency, destDryRunError, hopDryRunError, totalFee, method, feeToSubtract;
4423
+ var api, tx, origin, destination, address, senderAddress, feeAsset, currency, destApi, asset, destCurrency, ed, balance, xcmFeeResult, dryRunError, assetHubFeeResult, bridgeHubFeeResult, _xcmFeeResult$destina, destFee, destFeeCurrency, destDryRunError, hopDryRunError, totalFee, method, feeToSubtract;
4443
4424
  return _regenerator().w(function (_context) {
4444
4425
  while (1) switch (_context.n) {
4445
4426
  case 0:
@@ -4473,24 +4454,17 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
4473
4454
  } : {
4474
4455
  symbol: asset.symbol
4475
4456
  };
4476
- ed = getExistentialDeposit(destination, destCurrency);
4477
- if (!(ed === null)) {
4478
- _context.n = 5;
4479
- break;
4480
- }
4481
- throw new InvalidParameterError("Cannot get existential deposit for currency ".concat(JSON.stringify(currency)));
4482
- case 5:
4483
- edBN = BigInt(ed);
4484
- _context.n = 6;
4457
+ ed = getExistentialDepositOrThrow(destination, destCurrency);
4458
+ _context.n = 5;
4485
4459
  return getAssetBalanceInternal({
4486
4460
  address: address,
4487
4461
  node: destination,
4488
4462
  api: destApi,
4489
4463
  currency: destCurrency
4490
4464
  });
4491
- case 6:
4465
+ case 5:
4492
4466
  balance = _context.v;
4493
- _context.n = 7;
4467
+ _context.n = 6;
4494
4468
  return getXcmFee({
4495
4469
  api: api,
4496
4470
  tx: tx,
@@ -4502,40 +4476,40 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
4502
4476
  feeAsset: feeAsset,
4503
4477
  disableFallback: false
4504
4478
  });
4505
- case 7:
4479
+ case 6:
4506
4480
  xcmFeeResult = _context.v;
4507
4481
  dryRunError = xcmFeeResult.origin.dryRunError, assetHubFeeResult = xcmFeeResult.assetHub, bridgeHubFeeResult = xcmFeeResult.bridgeHub, _xcmFeeResult$destina = xcmFeeResult.destination, destFee = _xcmFeeResult$destina.fee, destFeeCurrency = _xcmFeeResult$destina.currency, destDryRunError = _xcmFeeResult$destina.dryRunError;
4508
4482
  if (!(destFee === undefined)) {
4509
- _context.n = 8;
4483
+ _context.n = 7;
4510
4484
  break;
4511
4485
  }
4512
- throw new InvalidParameterError("Cannot get destination xcm fee for currency ".concat(JSON.stringify(currency), " on node ").concat(destination, "."));
4513
- case 8:
4486
+ throw new InvalidParameterError("Cannot get destination xcm fee for currency ".concat(JSON.stringify(currency, replaceBigInt), " on node ").concat(destination, "."));
4487
+ case 7:
4514
4488
  if (!dryRunError) {
4515
- _context.n = 9;
4489
+ _context.n = 8;
4516
4490
  break;
4517
4491
  }
4518
4492
  throw new DryRunFailedError(dryRunError, 'origin');
4519
- case 9:
4493
+ case 8:
4520
4494
  hopDryRunError = (assetHubFeeResult === null || assetHubFeeResult === void 0 ? void 0 : assetHubFeeResult.dryRunError) || (bridgeHubFeeResult === null || bridgeHubFeeResult === void 0 ? void 0 : bridgeHubFeeResult.dryRunError);
4521
4495
  if (!hopDryRunError) {
4522
- _context.n = 10;
4496
+ _context.n = 9;
4523
4497
  break;
4524
4498
  }
4525
4499
  throw new DryRunFailedError(hopDryRunError, assetHubFeeResult !== null && assetHubFeeResult !== void 0 && assetHubFeeResult.dryRunError ? 'assetHub' : 'bridgeHub');
4526
- case 10:
4500
+ case 9:
4527
4501
  if (!destDryRunError) {
4528
- _context.n = 11;
4502
+ _context.n = 10;
4529
4503
  break;
4530
4504
  }
4531
4505
  throw new UnableToComputeError("Unable to compute fee for the destination asset. Destination dry run error: ".concat(destDryRunError));
4532
- case 11:
4506
+ case 10:
4533
4507
  if (!(normalizeSymbol(asset.symbol) !== normalizeSymbol(destFeeCurrency))) {
4534
- _context.n = 12;
4508
+ _context.n = 11;
4535
4509
  break;
4536
4510
  }
4537
4511
  throw new UnableToComputeError("The XCM fee could not be calculated because the origin or destination chain does not support DryRun.\n As a result, fee estimation is only available through PaymentInfo, which provides the cost in the native asset.\n This limitation restricts support to transfers involving the native asset of the Destination chain only.");
4538
- case 12:
4512
+ case 11:
4539
4513
  totalFee = calculateTotalXcmFee(xcmFeeResult);
4540
4514
  method = api.getMethod(tx);
4541
4515
  if (method === 'transfer_assets_using_type_and_then' || method === 'transferAssetsUsingTypeAndThen') {
@@ -4543,7 +4517,7 @@ var verifyEdOnDestinationInternal = /*#__PURE__*/function () {
4543
4517
  } else {
4544
4518
  feeToSubtract = destFee;
4545
4519
  }
4546
- return _context.a(2, BigInt(currency.amount) - feeToSubtract > (balance < edBN ? edBN : 0));
4520
+ return _context.a(2, BigInt(currency.amount) - feeToSubtract > (balance < ed ? ed : 0));
4547
4521
  }
4548
4522
  }, _callee);
4549
4523
  }));
@@ -4670,54 +4644,48 @@ var getDestXcmFee = /*#__PURE__*/function () {
4670
4644
  }
4671
4645
  return _context.a(2, 0n);
4672
4646
  case 1:
4673
- originAsset = findAsset(origin, currency, destination);
4674
- if (originAsset) {
4675
- _context.n = 2;
4676
- break;
4677
- }
4678
- throw new InvalidCurrencyError("Currency ".concat(JSON.stringify(currency, replaceBigInt), " not found in ").concat(origin));
4679
- case 2:
4647
+ originAsset = findAssetForNodeOrThrow(origin, currency, destination);
4680
4648
  if (!originAsset.multiLocation) {
4681
- _context.n = 8;
4649
+ _context.n = 7;
4682
4650
  break;
4683
4651
  }
4684
- _context.p = 3;
4685
- _context.n = 4;
4652
+ _context.p = 2;
4653
+ _context.n = 3;
4686
4654
  return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
4687
4655
  destination: destination
4688
4656
  }), {
4689
4657
  multilocation: originAsset.multiLocation
4690
4658
  });
4691
- case 4:
4659
+ case 3:
4692
4660
  return _context.a(2, _context.v);
4693
- case 5:
4694
- _context.p = 5;
4661
+ case 4:
4662
+ _context.p = 4;
4695
4663
  _t = _context.v;
4696
4664
  if (!(_t instanceof InvalidCurrencyError)) {
4697
- _context.n = 7;
4665
+ _context.n = 6;
4698
4666
  break;
4699
4667
  }
4700
- _context.n = 6;
4668
+ _context.n = 5;
4701
4669
  return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
4702
4670
  destination: destination
4703
4671
  }), {
4704
4672
  symbol: originAsset.symbol
4705
4673
  });
4706
- case 6:
4674
+ case 5:
4707
4675
  return _context.a(2, _context.v);
4708
- case 7:
4676
+ case 6:
4709
4677
  throw _t;
4710
- case 8:
4711
- _context.n = 9;
4678
+ case 7:
4679
+ _context.n = 8;
4712
4680
  return getReverseTxFee(_objectSpread2(_objectSpread2({}, options), {}, {
4713
4681
  destination: destination
4714
4682
  }), {
4715
4683
  symbol: originAsset.symbol
4716
4684
  });
4717
- case 9:
4685
+ case 8:
4718
4686
  return _context.a(2, _context.v);
4719
4687
  }
4720
- }, _callee, null, [[3, 5]]);
4688
+ }, _callee, null, [[2, 4]]);
4721
4689
  }));
4722
4690
  return function calcPaymentInfoFee() {
4723
4691
  return _ref2.apply(this, arguments);
@@ -5144,7 +5112,7 @@ var validateAssetSupport = function validateAssetSupport(_ref, assetCheckEnabled
5144
5112
  var isRelayDestination = !isTMultiLocation(destination) && isRelayChain(destination);
5145
5113
  var isMultiLocationDestination = _typeof(destination) === 'object';
5146
5114
  if (!isBridge && !isRelayDestination && !isMultiLocationDestination && (asset === null || asset === void 0 ? void 0 : asset.symbol) !== undefined && assetCheckEnabled && !('id' in currency) && !hasSupportForAsset(destination, asset.symbol)) {
5147
- throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency), "."));
5115
+ throw new InvalidCurrencyError("Destination node ".concat(destination, " does not support currency ").concat(JSON.stringify(currency, replaceBigInt), "."));
5148
5116
  }
5149
5117
  if (!isBridge && asset === null && assetCheckEnabled) {
5150
5118
  throwUnsupportedCurrency(currency, origin);
@@ -5186,7 +5154,7 @@ var resolveOverriddenAsset = function resolveOverriddenAsset(options, isBridge,
5186
5154
  var assets = currency.multiasset.map(function (currency) {
5187
5155
  var asset = findAsset(origin, currency, !isTMultiLocation(destination) ? destination : null);
5188
5156
  if (asset && !asset.multiLocation) {
5189
- throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency), " does not have a multiLocation"));
5157
+ throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(currency, replaceBigInt), " does not have a multiLocation"));
5190
5158
  }
5191
5159
  if (!asset) {
5192
5160
  throw new InvalidCurrencyError("Origin node ".concat(origin, " does not support currency ").concat(JSON.stringify(currency)));
@@ -5954,7 +5922,8 @@ var ParachainNode = /*#__PURE__*/function () {
5954
5922
  input = {
5955
5923
  api: api,
5956
5924
  asset: asset,
5957
- addressSelection: createVersionedBeneficiary({
5925
+ // Refactor this
5926
+ destLocation: createBeneficiary({
5958
5927
  api: api,
5959
5928
  scenario: scenario,
5960
5929
  pallet: 'XTokens',
@@ -5988,7 +5957,8 @@ var ParachainNode = /*#__PURE__*/function () {
5988
5957
  api: api,
5989
5958
  asset: asset,
5990
5959
  recipientAddress: address,
5991
- paraId: paraId,
5960
+ paraIdTo: paraId,
5961
+ scenario: scenario,
5992
5962
  origin: this.node,
5993
5963
  destination: destination,
5994
5964
  overriddenAsset: overriddenAsset,
@@ -6002,8 +5972,8 @@ var ParachainNode = /*#__PURE__*/function () {
6002
5972
  }
6003
5973
  _options = {
6004
5974
  api: api,
6005
- header: this.createVersionedDestination(scenario, version, destination, paraId),
6006
- addressSelection: createVersionedBeneficiary({
5975
+ destLocation: createDestination(scenario, version, destination, paraId),
5976
+ beneficiaryLocation: createBeneficiary({
6007
5977
  api: api,
6008
5978
  scenario: scenario,
6009
5979
  pallet: 'PolkadotXcm',
@@ -6012,7 +5982,7 @@ var ParachainNode = /*#__PURE__*/function () {
6012
5982
  paraId: paraId
6013
5983
  }),
6014
5984
  address: address,
6015
- currencySelection: this.createCurrencySpec(asset.amount, scenario, version, asset, overriddenAsset !== undefined),
5985
+ multiAsset: this.createCurrencySpec(asset.amount, scenario, version, asset, overriddenAsset !== undefined),
6016
5986
  overriddenAsset: overriddenAsset,
6017
5987
  asset: asset,
6018
5988
  currency: currency,
@@ -6083,16 +6053,11 @@ var ParachainNode = /*#__PURE__*/function () {
6083
6053
  }, {
6084
6054
  key: "createCurrencySpec",
6085
6055
  value: function createCurrencySpec(amount, scenario, version, _asset, _isOverridenAsset) {
6086
- return createVersionedMultiAssets(version, amount, {
6056
+ return createMultiAsset(version, amount, {
6087
6057
  parents: scenario === 'ParaToRelay' ? Parents.ONE : Parents.ZERO,
6088
6058
  interior: 'Here'
6089
6059
  });
6090
6060
  }
6091
- }, {
6092
- key: "createVersionedDestination",
6093
- value: function createVersionedDestination$1(scenario, version, destination, paraId) {
6094
- return createVersionedDestination(scenario, version, destination, paraId);
6095
- }
6096
6061
  }, {
6097
6062
  key: "getNativeAssetSymbol",
6098
6063
  value: function getNativeAssetSymbol$1() {
@@ -6203,13 +6168,13 @@ var ParachainNode = /*#__PURE__*/function () {
6203
6168
  throw new DryRunFailedError(dryRunResult.origin.failureReason);
6204
6169
  case 5:
6205
6170
  // Pad fee by 50%
6206
- dryRunFeePadded = BigInt(dryRunResult.origin.fee) * BigInt(3) / BigInt(2);
6171
+ dryRunFeePadded = BigInt(dryRunResult.origin.fee) * 3n / 2n;
6207
6172
  dest = createDestination(scenario, version, destination, paraIdTo);
6208
6173
  call = {
6209
6174
  module: 'PolkadotXcm',
6210
6175
  method: 'transfer_assets_using_type_and_then',
6211
6176
  parameters: {
6212
- dest: this.createVersionedDestination(scenario, version, destination, getParaId('AssetHubPolkadot')),
6177
+ dest: createVersionedDestination(scenario, version, destination, getParaId('AssetHubPolkadot')),
6213
6178
  assets: addXcmVersionHeader([].concat(_toConsumableArray(!feeAsset ? [createMultiAsset(version, PARA_TO_PARA_FEE_DOT, DOT_MULTILOCATION)] : []), [ethMultiAsset]), version),
6214
6179
  assets_transfer_type: 'DestinationReserve',
6215
6180
  remote_fees_id: addXcmVersionHeader((_feeAsset$multiLocati = feeAsset === null || feeAsset === void 0 ? void 0 : feeAsset.multiLocation) !== null && _feeAsset$multiLocati !== void 0 ? _feeAsset$multiLocati : DOT_MULTILOCATION, version),
@@ -6266,7 +6231,7 @@ var ParachainNode = /*#__PURE__*/function () {
6266
6231
  };
6267
6232
  return _context2.a(2, api.callTxMethod(call));
6268
6233
  }
6269
- }, _callee2, this);
6234
+ }, _callee2);
6270
6235
  }));
6271
6236
  function transferEthAssetViaAH(_x2) {
6272
6237
  return _transferEthAssetViaAH.apply(this, arguments);
@@ -6394,7 +6359,7 @@ var ParachainNode = /*#__PURE__*/function () {
6394
6359
  module: 'PolkadotXcm',
6395
6360
  method: 'transfer_assets_using_type_and_then',
6396
6361
  parameters: {
6397
- dest: this.createVersionedDestination(scenario, version, destination, getParaId('AssetHubPolkadot')),
6362
+ dest: createVersionedDestination(scenario, version, destination, getParaId('AssetHubPolkadot')),
6398
6363
  assets: addXcmVersionHeader([].concat(_toConsumableArray(!feeAsset ? [createMultiAsset(version, fee, DOT_MULTILOCATION)] : []), [ethMultiAsset]), version),
6399
6364
  assets_transfer_type: 'DestinationReserve',
6400
6365
  remote_fees_id: addXcmVersionHeader((_feeAsset$multiLocati2 = feeAsset === null || feeAsset === void 0 ? void 0 : feeAsset.multiLocation) !== null && _feeAsset$multiLocati2 !== void 0 ? _feeAsset$multiLocati2 : DOT_MULTILOCATION, version),
@@ -6479,46 +6444,35 @@ var Acala = /*#__PURE__*/function (_ParachainNode) {
6479
6444
  }]);
6480
6445
  }(ParachainNode);
6481
6446
 
6482
- var PolkadotXCMTransferImpl = /*#__PURE__*/function () {
6483
- function PolkadotXCMTransferImpl() {
6484
- _classCallCheck(this, PolkadotXCMTransferImpl);
6485
- }
6486
- return _createClass(PolkadotXCMTransferImpl, null, [{
6487
- key: "transferPolkadotXCM",
6488
- value: function transferPolkadotXCM(_ref, method) {
6489
- var api = _ref.api,
6490
- header = _ref.header,
6491
- asset = _ref.asset,
6492
- addressSelection = _ref.addressSelection,
6493
- currencySelection = _ref.currencySelection,
6494
- overriddenAsset = _ref.overriddenAsset,
6495
- pallet = _ref.pallet,
6496
- methodOverride = _ref.method;
6497
- var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
6498
- var _extractVersionFromHe = extractVersionFromHeader(currencySelection),
6499
- _extractVersionFromHe2 = _slicedToArray(_extractVersionFromHe, 2),
6500
- version = _extractVersionFromHe2[0],
6501
- multiAssets = _extractVersionFromHe2[1];
6502
- var resolvedMultiAssets = addXcmVersionHeader(maybeOverrideMultiAssets(version, asset.amount, multiAssets, overriddenAsset), version);
6503
- var feeAssetIndex = overriddenAsset === undefined || isTMultiLocation(overriddenAsset) ? DEFAULT_FEE_ASSET : overriddenAsset.findIndex(function (asset) {
6504
- return asset.isFeeAsset;
6505
- });
6506
- var call = {
6507
- module: pallet !== null && pallet !== void 0 ? pallet : 'PolkadotXcm',
6508
- method: methodOverride !== null && methodOverride !== void 0 ? methodOverride : method,
6509
- parameters: _objectSpread2({
6510
- dest: header,
6511
- beneficiary: addressSelection,
6512
- assets: resolvedMultiAssets,
6513
- fee_asset_item: feeAssetIndex
6514
- }, fees !== undefined ? {
6515
- weight_limit: fees
6516
- } : {})
6517
- };
6518
- return api.callTxMethod(call);
6519
- }
6520
- }]);
6521
- }();
6447
+ var transferPolkadotXcm = function transferPolkadotXcm(_ref, method) {
6448
+ var api = _ref.api,
6449
+ destLocation = _ref.destLocation,
6450
+ asset = _ref.asset,
6451
+ beneficiaryLocation = _ref.beneficiaryLocation,
6452
+ multiAsset = _ref.multiAsset,
6453
+ overriddenAsset = _ref.overriddenAsset,
6454
+ pallet = _ref.pallet,
6455
+ version = _ref.version,
6456
+ methodOverride = _ref.method;
6457
+ var fees = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
6458
+ var resolvedMultiAssets = maybeOverrideMultiAssets(version, asset.amount, [multiAsset], overriddenAsset);
6459
+ var feeAssetIndex = overriddenAsset === undefined || isTMultiLocation(overriddenAsset) ? DEFAULT_FEE_ASSET : overriddenAsset.findIndex(function (asset) {
6460
+ return asset.isFeeAsset;
6461
+ });
6462
+ var call = {
6463
+ module: pallet !== null && pallet !== void 0 ? pallet : 'PolkadotXcm',
6464
+ method: methodOverride !== null && methodOverride !== void 0 ? methodOverride : method,
6465
+ parameters: _objectSpread2({
6466
+ dest: addXcmVersionHeader(destLocation, version),
6467
+ beneficiary: addXcmVersionHeader(beneficiaryLocation, version),
6468
+ assets: addXcmVersionHeader(resolvedMultiAssets, version),
6469
+ fee_asset_item: feeAssetIndex
6470
+ }, fees !== undefined ? {
6471
+ weight_limit: fees
6472
+ } : {})
6473
+ };
6474
+ return Promise.resolve(api.callTxMethod(call));
6475
+ };
6522
6476
 
6523
6477
  var Ajuna = /*#__PURE__*/function (_ParachainNode) {
6524
6478
  function Ajuna() {
@@ -6542,7 +6496,7 @@ var Ajuna = /*#__PURE__*/function (_ParachainNode) {
6542
6496
  }, {
6543
6497
  key: "transferPolkadotXCM",
6544
6498
  value: function transferPolkadotXCM(input) {
6545
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'transfer_assets', 'Unlimited'));
6499
+ return transferPolkadotXcm(input, 'transfer_assets', 'Unlimited');
6546
6500
  }
6547
6501
  }, {
6548
6502
  key: "canUseXTokens",
@@ -6670,7 +6624,7 @@ var AssetHubKusama = /*#__PURE__*/function (_ParachainNode) {
6670
6624
  // TESTED https://kusama.subscan.io/xcm_message/kusama-ddc2a48f0d8e0337832d7aae26f6c3053e1f4ffd
6671
6625
  // TESTED https://kusama.subscan.io/xcm_message/kusama-8e423130a4d8b61679af95dbea18a55124f99672
6672
6626
  if (destination === 'AssetHubPolkadot') {
6673
- return Promise.resolve(getNode('AssetHubPolkadot').handleBridgeTransfer(input, 'Polkadot'));
6627
+ return getNode('AssetHubPolkadot').handleBridgeTransfer(input, 'Polkadot');
6674
6628
  }
6675
6629
  var isSystemNode = !isTMultiLocation(destination) && SYSTEM_NODES_KUSAMA.includes(destination);
6676
6630
  if (scenario === 'ParaToPara' && asset.symbol === 'KSM' && !isForeignAsset(asset) && !isSystemNode) {
@@ -6680,7 +6634,7 @@ var AssetHubKusama = /*#__PURE__*/function (_ParachainNode) {
6680
6634
  throw new ScenarioNotSupportedError(this.node, scenario, 'Bridged DOT cannot currently be transfered from AssetHubKusama, if you are sending different DOT asset, please specify {id: <DOTID>}.');
6681
6635
  }
6682
6636
  var method = scenario === 'ParaToPara' && !isSystemNode ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
6683
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, method, 'Unlimited'));
6637
+ return transferPolkadotXcm(input, method, 'Unlimited');
6684
6638
  }
6685
6639
  }, {
6686
6640
  key: "getRelayToParaOverrides",
@@ -7039,7 +6993,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7039
6993
  module: 'PolkadotXcm',
7040
6994
  method: 'transfer_assets_using_type_and_then',
7041
6995
  parameters: {
7042
- dest: _this.createVersionedDestination(scenario, version, destination, paraIdTo),
6996
+ dest: createVersionedDestination(scenario, version, destination, paraIdTo),
7043
6997
  assets: addXcmVersionHeader([].concat(_toConsumableArray(useDOTAsFeeAsset ? [createMultiAsset(version, PARA_TO_PARA_FEE_DOT, DOT_MULTILOCATION)] : []), [createMultiAsset(version, asset.amount, asset.multiLocation)]), version),
7044
6998
  assets_transfer_type: 'LocalReserve',
7045
6999
  remote_fees_id: addXcmVersionHeader(useDOTAsFeeAsset ? DOT_MULTILOCATION : asset.multiLocation, version),
@@ -7066,8 +7020,8 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7066
7020
  paraIdTo = input.paraIdTo;
7067
7021
  if (targetChain === 'Kusama' && ((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toUpperCase()) === 'KSM' || targetChain === 'Polkadot' && ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === void 0 ? void 0 : _asset$symbol2.toUpperCase()) === 'DOT') {
7068
7022
  var modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
7069
- header: createBridgePolkadotXcmDest(version, targetChain, destination, paraIdTo),
7070
- addressSelection: createVersionedBeneficiary({
7023
+ destLocation: createBridgeDestination(targetChain, destination, paraIdTo),
7024
+ beneficiaryLocation: createBeneficiary({
7071
7025
  api: api,
7072
7026
  scenario: scenario,
7073
7027
  pallet: 'PolkadotXcm',
@@ -7075,15 +7029,15 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7075
7029
  version: version,
7076
7030
  paraId: paraIdTo
7077
7031
  }),
7078
- currencySelection: createVersionedMultiAssets(version, asset.amount, asset.multiLocation)
7032
+ multiAsset: createMultiAsset(version, asset.amount, asset.multiLocation)
7079
7033
  });
7080
- return PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, 'transfer_assets', 'Unlimited');
7034
+ return transferPolkadotXcm(modifiedInput, 'transfer_assets', 'Unlimited');
7081
7035
  } else if (targetChain === 'Polkadot' && ((_asset$symbol3 = asset.symbol) === null || _asset$symbol3 === void 0 ? void 0 : _asset$symbol3.toUpperCase()) === 'KSM' || targetChain === 'Kusama' && ((_asset$symbol4 = asset.symbol) === null || _asset$symbol4 === void 0 ? void 0 : _asset$symbol4.toUpperCase()) === 'DOT') {
7082
7036
  var _modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
7083
- header: createBridgePolkadotXcmDest(version, targetChain, destination, paraIdTo),
7084
- currencySelection: createVersionedMultiAssets(version, asset.amount, DOT_MULTILOCATION)
7037
+ destLocation: createBridgeDestination(targetChain, destination, paraIdTo),
7038
+ multiAsset: createMultiAsset(version, asset.amount, DOT_MULTILOCATION)
7085
7039
  });
7086
- return PolkadotXCMTransferImpl.transferPolkadotXCM(_modifiedInput, 'limited_reserve_transfer_assets', 'Unlimited');
7040
+ return transferPolkadotXcm(_modifiedInput, 'limited_reserve_transfer_assets', 'Unlimited');
7087
7041
  }
7088
7042
  throw new InvalidCurrencyError("Polkadot <-> Kusama bridge does not support currency ".concat(asset.symbol));
7089
7043
  }
@@ -7212,8 +7166,8 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7212
7166
  return _context2.a(2, this.handleEthBridgeNativeTransfer(input));
7213
7167
  case 5:
7214
7168
  modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
7215
- header: createVersionedDestination(scenario, this.version, destination, paraIdTo, ETHEREUM_JUNCTION, Parents.TWO),
7216
- addressSelection: createVersionedBeneficiary({
7169
+ destLocation: createDestination(scenario, this.version, destination, paraIdTo, ETHEREUM_JUNCTION, Parents.TWO),
7170
+ beneficiaryLocation: createBeneficiary({
7217
7171
  api: api,
7218
7172
  scenario: scenario,
7219
7173
  pallet: 'PolkadotXcm',
@@ -7221,9 +7175,9 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7221
7175
  version: this.version,
7222
7176
  paraId: paraIdTo
7223
7177
  }),
7224
- currencySelection: createVersionedMultiAssets(version, asset.amount, asset.multiLocation)
7178
+ multiAsset: createMultiAsset(version, asset.amount, asset.multiLocation)
7225
7179
  });
7226
- return _context2.a(2, PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, 'transfer_assets', 'Unlimited'));
7180
+ return _context2.a(2, transferPolkadotXcm(modifiedInput, 'transfer_assets', 'Unlimited'));
7227
7181
  }
7228
7182
  }, _callee2, this);
7229
7183
  }));
@@ -7252,8 +7206,8 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7252
7206
  }
7253
7207
  };
7254
7208
  var modifiedInput = _objectSpread2(_objectSpread2({}, input), {}, {
7255
- header: this.createVersionedDestination(scenario, version, destination, paraId),
7256
- addressSelection: createVersionedBeneficiary({
7209
+ destLocation: createDestination(scenario, version, destination, paraId),
7210
+ beneficiaryLocation: createBeneficiary({
7257
7211
  api: api,
7258
7212
  scenario: scenario,
7259
7213
  pallet: 'PolkadotXcm',
@@ -7261,9 +7215,9 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7261
7215
  version: version,
7262
7216
  paraId: paraId
7263
7217
  }),
7264
- currencySelection: createVersionedMultiAssets(version, asset.amount, customMultiLocation)
7218
+ multiAsset: createMultiAsset(version, asset.amount, customMultiLocation)
7265
7219
  });
7266
- return PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, 'limited_teleport_assets', 'Unlimited');
7220
+ return transferPolkadotXcm(modifiedInput, 'limited_teleport_assets', 'Unlimited');
7267
7221
  }
7268
7222
  }, {
7269
7223
  key: "patchInput",
@@ -7274,7 +7228,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7274
7228
  version = _input$version === void 0 ? this.version : _input$version;
7275
7229
  if ((destination === 'Hydration' || destination === 'Polimec' || destination === 'Moonbeam' || destination === 'BifrostPolkadot') && asset.symbol === 'DOT') {
7276
7230
  return _objectSpread2(_objectSpread2({}, input), {}, {
7277
- currencySelection: createVersionedMultiAssets(version, asset.amount, DOT_MULTILOCATION)
7231
+ multiAsset: createMultiAsset(version, asset.amount, DOT_MULTILOCATION)
7278
7232
  });
7279
7233
  }
7280
7234
  return input;
@@ -7290,7 +7244,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7290
7244
  key: "handleExecuteTransfer",
7291
7245
  value: function () {
7292
7246
  var _handleExecuteTransfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(input) {
7293
- var api, senderAddress, asset, feeAsset, version, decimals, multiplier, base, scaledMultiplier, MIN_FEE, call, dryRunResult, paddedFee, xcm, weight;
7247
+ var api, senderAddress, asset, feeAsset, version, decimals, multiplier, base, scaledMultiplier, MIN_FEE, checkAmount, call, dryRunResult, paddedFee, xcm, weight;
7294
7248
  return _regenerator().w(function (_context3) {
7295
7249
  while (1) switch (_context3.n) {
7296
7250
  case 0:
@@ -7307,6 +7261,12 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7307
7261
  base = BigInt(Math.pow(10, decimals));
7308
7262
  scaledMultiplier = BigInt(Math.floor(multiplier * Math.pow(10, decimals)));
7309
7263
  MIN_FEE = base * scaledMultiplier / BigInt(Math.pow(10, decimals));
7264
+ checkAmount = function checkAmount(fee) {
7265
+ if (feeAsset && isAssetEqual(asset, feeAsset) && BigInt(asset.amount) <= fee * 2n) {
7266
+ throw new InvalidParameterError("Asset amount ".concat(asset.amount, " is too low, please increase the amount or use a different fee asset."));
7267
+ }
7268
+ };
7269
+ checkAmount(MIN_FEE);
7310
7270
  call = createExecuteCall(createExecuteXcm(input, MIN_FEE, version), MAX_WEIGHT);
7311
7271
  _context3.n = 2;
7312
7272
  return api.getDryRunCall({
@@ -7324,6 +7284,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7324
7284
  throw new DryRunFailedError(dryRunResult.failureReason);
7325
7285
  case 3:
7326
7286
  paddedFee = dryRunResult.fee * 120n / 100n;
7287
+ checkAmount(paddedFee);
7327
7288
  xcm = createExecuteXcm(input, paddedFee, version);
7328
7289
  _context3.n = 4;
7329
7290
  return api.getXcmWeight(xcm);
@@ -7421,7 +7382,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7421
7382
  case 11:
7422
7383
  method = this.getMethod(scenario, destination);
7423
7384
  modifiedInput = this.patchInput(input);
7424
- return _context4.a(2, PolkadotXCMTransferImpl.transferPolkadotXCM(modifiedInput, method, 'Unlimited'));
7385
+ return _context4.a(2, transferPolkadotXcm(modifiedInput, method, 'Unlimited'));
7425
7386
  }
7426
7387
  }, _callee4, this);
7427
7388
  }));
@@ -7452,7 +7413,7 @@ var AssetHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7452
7413
  throw new InvalidCurrencyError('Asset does not have a multiLocation defined');
7453
7414
  }
7454
7415
  var transformedMultiLocation = hasJunction(multiLocation, 'Parachain', 1000) ? transformMultiLocation(multiLocation) : multiLocation;
7455
- return createVersionedMultiAssets(version, amount, transformedMultiLocation);
7416
+ return createMultiAsset(version, amount, transformedMultiLocation);
7456
7417
  } else {
7457
7418
  return _superPropGet(AssetHubPolkadot, "createCurrencySpec", this, 3)([amount, scenario, version, asset]);
7458
7419
  }
@@ -7503,7 +7464,7 @@ var Astar = /*#__PURE__*/function (_ParachainNode) {
7503
7464
  return _createClass(Astar, [{
7504
7465
  key: "transferPolkadotXCM",
7505
7466
  value: function transferPolkadotXCM(input) {
7506
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
7467
+ return transferPolkadotXcm(input, 'limited_reserve_transfer_assets', 'Unlimited');
7507
7468
  }
7508
7469
  }, {
7509
7470
  key: "transferXTokens",
@@ -7643,8 +7604,8 @@ var BifrostPolkadot = /*#__PURE__*/function (_ParachainNode) {
7643
7604
  value: function transferToAssetHub(input) {
7644
7605
  var _getAssetId;
7645
7606
  var asset = input.asset;
7646
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(_objectSpread2(_objectSpread2({}, input), {}, {
7647
- currencySelection: createVersionedMultiAssets(this.version, asset.amount, {
7607
+ return transferPolkadotXcm(_objectSpread2(_objectSpread2({}, input), {}, {
7608
+ multiAsset: createMultiAsset(this.version, asset.amount, {
7648
7609
  parents: asset.symbol === 'DOT' ? Parents.ONE : Parents.TWO,
7649
7610
  interior: asset.symbol === 'WETH' ? {
7650
7611
  X2: [ETHEREUM_JUNCTION, {
@@ -7654,7 +7615,7 @@ var BifrostPolkadot = /*#__PURE__*/function (_ParachainNode) {
7654
7615
  }]
7655
7616
  } : 'Here'
7656
7617
  })
7657
- }), 'transfer_assets', 'Unlimited'));
7618
+ }), 'transfer_assets', 'Unlimited');
7658
7619
  }
7659
7620
  }, {
7660
7621
  key: "transferPolkadotXCM",
@@ -7710,7 +7671,7 @@ var BridgeHubKusama = /*#__PURE__*/function (_ParachainNode) {
7710
7671
  throw new ScenarioNotSupportedError(this.node, scenario, 'Unable to use bridge hub for transfers to other Parachains. Please move your currency to AssetHub to transfer to other Parachains.');
7711
7672
  }
7712
7673
  var method = 'limited_teleport_assets';
7713
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, method, 'Unlimited'));
7674
+ return transferPolkadotXcm(input, method, 'Unlimited');
7714
7675
  }
7715
7676
  }, {
7716
7677
  key: "getRelayToParaOverrides",
@@ -7737,7 +7698,7 @@ var BridgeHubPolkadot = /*#__PURE__*/function (_ParachainNode) {
7737
7698
  throw new ScenarioNotSupportedError(this.node, scenario, 'Unable to use bridge hub for transfers to other Parachains. Please move your currency to AssetHub to transfer to other Parachains.');
7738
7699
  }
7739
7700
  var method = 'limited_teleport_assets';
7740
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, method, 'Unlimited'));
7701
+ return transferPolkadotXcm(input, method, 'Unlimited');
7741
7702
  }
7742
7703
  }, {
7743
7704
  key: "getRelayToParaOverrides",
@@ -7814,7 +7775,7 @@ var Collectives = /*#__PURE__*/function (_ParachainNode) {
7814
7775
  if (scenario === 'ParaToPara') {
7815
7776
  throw new ScenarioNotSupportedError(this.node, scenario);
7816
7777
  }
7817
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_teleport_assets', 'Unlimited'));
7778
+ return transferPolkadotXcm(input, 'limited_teleport_assets', 'Unlimited');
7818
7779
  }
7819
7780
  }, {
7820
7781
  key: "getRelayToParaOverrides",
@@ -7824,11 +7785,6 @@ var Collectives = /*#__PURE__*/function (_ParachainNode) {
7824
7785
  includeFee: true
7825
7786
  };
7826
7787
  }
7827
- }, {
7828
- key: "createCurrencySpec",
7829
- value: function createCurrencySpec(amount, scenario, version, asset) {
7830
- return _superPropGet(Collectives, "createCurrencySpec", this, 3)([amount, scenario, version, asset]);
7831
- }
7832
7788
  }]);
7833
7789
  }(ParachainNode);
7834
7790
 
@@ -7862,7 +7818,7 @@ var CoretimeKusama = /*#__PURE__*/function (_ParachainNode) {
7862
7818
  // TESTED block hash on Rococo: 0x78ace0f1bf7cac9a42e56143321b617d98327e2750f795efb0abb833025c9082
7863
7819
  var scenario = input.scenario;
7864
7820
  var method = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
7865
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, method, 'Unlimited'));
7821
+ return transferPolkadotXcm(input, method, 'Unlimited');
7866
7822
  }
7867
7823
  }, {
7868
7824
  key: "getRelayToParaOverrides",
@@ -7886,7 +7842,7 @@ var CoretimePolkadot = /*#__PURE__*/function (_ParachainNode) {
7886
7842
  value: function transferPolkadotXCM(input) {
7887
7843
  var scenario = input.scenario;
7888
7844
  var method = scenario === 'ParaToPara' ? 'limited_reserve_transfer_assets' : 'limited_teleport_assets';
7889
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, method, 'Unlimited'));
7845
+ return transferPolkadotXcm(input, method, 'Unlimited');
7890
7846
  }
7891
7847
  }, {
7892
7848
  key: "getRelayToParaOverrides",
@@ -7910,7 +7866,7 @@ var Crab = /*#__PURE__*/function (_ParachainNode) {
7910
7866
  value: function transferPolkadotXCM(input) {
7911
7867
  // TESTED https://kusama.subscan.io/xcm_message/kusama-ce7396ec470ba0c6516a50075046ee65464572dc
7912
7868
  if (input.scenario === 'ParaToPara') {
7913
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'reserve_transfer_assets'));
7869
+ return transferPolkadotXcm(input, 'reserve_transfer_assets');
7914
7870
  }
7915
7871
  throw new ScenarioNotSupportedError(this.node, input.scenario);
7916
7872
  }
@@ -7923,7 +7879,7 @@ var Crab = /*#__PURE__*/function (_ParachainNode) {
7923
7879
  key: "createCurrencySpec",
7924
7880
  value: function createCurrencySpec(amount, scenario, version, _asset) {
7925
7881
  if (scenario === 'ParaToPara') {
7926
- return createVersionedMultiAssets(version, amount, {
7882
+ return createMultiAsset(version, amount, {
7927
7883
  parents: Parents.ZERO,
7928
7884
  interior: {
7929
7885
  X1: {
@@ -8064,13 +8020,13 @@ var Darwinia = /*#__PURE__*/function (_ParachainNode) {
8064
8020
  if (scenario === 'ParaToPara' && asset.symbol !== this.getNativeAssetSymbol()) {
8065
8021
  throw new ScenarioNotSupportedError(this.node, scenario);
8066
8022
  }
8067
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
8023
+ return transferPolkadotXcm(input, 'limited_reserve_transfer_assets', 'Unlimited');
8068
8024
  }
8069
8025
  }, {
8070
8026
  key: "createCurrencySpec",
8071
8027
  value: function createCurrencySpec(amount, scenario, version, _asset) {
8072
8028
  if (scenario === 'ParaToPara') {
8073
- return createVersionedMultiAssets(version, amount, {
8029
+ return createMultiAsset(version, amount, {
8074
8030
  parents: Parents.ZERO,
8075
8031
  interior: {
8076
8032
  X1: {
@@ -8119,7 +8075,7 @@ var Encointer = /*#__PURE__*/function (_ParachainNode) {
8119
8075
  // NO PARA TO PARA SCENARIOS ON SUBSCAN
8120
8076
  // TESTED https://encointer.subscan.io/xcm_message/kusama-418501e86e947b16c4e4e9040694017e64f9b162
8121
8077
  if (input.scenario === 'ParaToRelay') {
8122
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_teleport_assets', 'Unlimited'));
8078
+ return transferPolkadotXcm(input, 'limited_teleport_assets', 'Unlimited');
8123
8079
  }
8124
8080
  throw new ScenarioNotSupportedError(this.node, input.scenario);
8125
8081
  }
@@ -8151,7 +8107,7 @@ var Heima = /*#__PURE__*/function (_ParachainNode) {
8151
8107
  if (asset.symbol !== this.getNativeAssetSymbol()) {
8152
8108
  throw new InvalidCurrencyError("Asset ".concat(asset.symbol, " is not supported by node ").concat(this.node, "."));
8153
8109
  }
8154
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
8110
+ return transferPolkadotXcm(input, 'limited_reserve_transfer_assets', 'Unlimited');
8155
8111
  }
8156
8112
  }]);
8157
8113
  }(ParachainNode);
@@ -8171,9 +8127,9 @@ var getAssetMultiLocation = function getAssetMultiLocation(asset) {
8171
8127
  };
8172
8128
  var createTransferAssetsTransfer = function createTransferAssetsTransfer(options, version) {
8173
8129
  var asset = options.asset;
8174
- var currencySelection = addXcmVersionHeader([createMultiAsset(version, asset.amount, getAssetMultiLocation(asset))], version);
8175
- return PolkadotXCMTransferImpl.transferPolkadotXCM(_objectSpread2(_objectSpread2({}, options), {}, {
8176
- currencySelection: currencySelection
8130
+ var location = getAssetMultiLocation(asset);
8131
+ return transferPolkadotXcm(_objectSpread2(_objectSpread2({}, options), {}, {
8132
+ multiAsset: createMultiAsset(version, asset.amount, location)
8177
8133
  }), 'transfer_assets', 'Unlimited');
8178
8134
  };
8179
8135
  var createTypeAndThenDest = function createTypeAndThenDest(destination, scenario, version) {
@@ -8274,7 +8230,7 @@ var Polimec = /*#__PURE__*/function (_ParachainNode) {
8274
8230
  break;
8275
8231
  }
8276
8232
  _call = createTypeAndThenTransfer(input, version);
8277
- return _context.a(2, Promise.resolve(api.callTxMethod(_call)));
8233
+ return _context.a(2, api.callTxMethod(_call));
8278
8234
  case 1:
8279
8235
  if (!(scenario === 'ParaToPara' && (destination === 'AssetHubPolkadot' || destination === 'Hydration'))) {
8280
8236
  _context.n = 2;
@@ -8374,7 +8330,7 @@ var Hydration = /*#__PURE__*/function (_ParachainNode) {
8374
8330
  module: 'PolkadotXcm',
8375
8331
  method: 'transfer_assets_using_type_and_then',
8376
8332
  parameters: {
8377
- dest: this.createVersionedDestination(scenario, version, destination, getParaId('AssetHubPolkadot')),
8333
+ dest: createVersionedDestination(scenario, version, destination, getParaId('AssetHubPolkadot')),
8378
8334
  assets: _defineProperty({}, version, [createMultiAsset(version, asset.amount, DOT_MULTILOCATION)]),
8379
8335
  assets_transfer_type: 'DestinationReserve',
8380
8336
  remote_fees_id: _defineProperty({}, version, {
@@ -8398,7 +8354,7 @@ var Hydration = /*#__PURE__*/function (_ParachainNode) {
8398
8354
  var symbol = asset.symbol.toUpperCase();
8399
8355
  if (symbol === 'DOT') {
8400
8356
  var call = createTypeAndThenTransfer(options, version);
8401
- return api.callTxMethod(call);
8357
+ return Promise.resolve(api.callTxMethod(call));
8402
8358
  }
8403
8359
  if ((symbol === 'USDC' || symbol === 'USDT') && !hasJunction(asset.multiLocation, 'Parachain', getParaId('AssetHubPolkadot'))) {
8404
8360
  throw new InvalidCurrencyError('The selected asset is not supported for transfer to Polimec');
@@ -8580,7 +8536,7 @@ var KiltSpiritnet = /*#__PURE__*/function (_ParachainNode) {
8580
8536
  if (scenario === 'ParaToPara' && asset.symbol !== this.getNativeAssetSymbol()) {
8581
8537
  throw new ScenarioNotSupportedError(this.node, scenario, 'KiltSpiritnet only supports native asset ParaToPara transfers');
8582
8538
  }
8583
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
8539
+ return transferPolkadotXcm(input, 'limited_reserve_transfer_assets', 'Unlimited');
8584
8540
  }
8585
8541
  }, {
8586
8542
  key: "transferRelayToPara",
@@ -8723,9 +8679,9 @@ var Moonbeam = /*#__PURE__*/function (_ParachainNode) {
8723
8679
  return this.transferToEthereum(input);
8724
8680
  }
8725
8681
  var multiLocation = this.getMultiLocation(asset, scenario);
8726
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(_objectSpread2(_objectSpread2({}, input), {}, {
8727
- currencySelection: createVersionedMultiAssets(version, asset.amount, multiLocation)
8728
- }), 'transfer_assets', 'Unlimited'));
8682
+ return transferPolkadotXcm(_objectSpread2(_objectSpread2({}, input), {}, {
8683
+ multiAsset: createMultiAsset(version, asset.amount, multiLocation)
8684
+ }), 'transfer_assets', 'Unlimited');
8729
8685
  }
8730
8686
  }, {
8731
8687
  key: "getRelayToParaOverrides",
@@ -8791,9 +8747,9 @@ var Moonriver = /*#__PURE__*/function (_ParachainNode) {
8791
8747
  _input$version = input.version,
8792
8748
  version = _input$version === void 0 ? this.version : _input$version;
8793
8749
  var multiLocation = this.getMultiLocation(asset, scenario);
8794
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(_objectSpread2(_objectSpread2({}, input), {}, {
8795
- currencySelection: createVersionedMultiAssets(version, asset.amount, multiLocation)
8796
- }), 'transfer_assets', 'Unlimited'));
8750
+ return transferPolkadotXcm(_objectSpread2(_objectSpread2({}, input), {}, {
8751
+ multiAsset: createMultiAsset(version, asset.amount, multiLocation)
8752
+ }), 'transfer_assets', 'Unlimited');
8797
8753
  }
8798
8754
  }, {
8799
8755
  key: "getRelayToParaOverrides",
@@ -8830,7 +8786,7 @@ var Mythos = /*#__PURE__*/function (_ParachainNode) {
8830
8786
  if (asset.symbol !== nativeSymbol) {
8831
8787
  throw new InvalidCurrencyError("Node ".concat(this.node, " does not support currency ").concat(asset.symbol));
8832
8788
  }
8833
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, destination === 'AssetHubPolkadot' ? 'limited_teleport_assets' : 'limited_reserve_transfer_assets', 'Unlimited'));
8789
+ return transferPolkadotXcm(input, destination === 'AssetHubPolkadot' ? 'limited_teleport_assets' : 'limited_reserve_transfer_assets', 'Unlimited');
8834
8790
  }
8835
8791
  }, {
8836
8792
  key: "transferPolkadotXCM",
@@ -8877,7 +8833,7 @@ var NeuroWeb = /*#__PURE__*/function (_ParachainNode) {
8877
8833
  return _createClass(NeuroWeb, [{
8878
8834
  key: "transferPolkadotXCM",
8879
8835
  value: function transferPolkadotXCM(input) {
8880
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
8836
+ return transferPolkadotXcm(input, 'limited_reserve_transfer_assets', 'Unlimited');
8881
8837
  }
8882
8838
  }]);
8883
8839
  }(ParachainNode);
@@ -8899,7 +8855,7 @@ var Nodle = /*#__PURE__*/function (_ParachainNode) {
8899
8855
  if (asset.symbol !== this.getNativeAssetSymbol()) {
8900
8856
  throw new InvalidCurrencyError("Asset ".concat(asset.symbol, " is not supported by node ").concat(this.node, "."));
8901
8857
  }
8902
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
8858
+ return transferPolkadotXcm(input, 'limited_reserve_transfer_assets', 'Unlimited');
8903
8859
  }
8904
8860
  }, {
8905
8861
  key: "transferRelayToPara",
@@ -9007,7 +8963,7 @@ var PeopleKusama = /*#__PURE__*/function (_ParachainNode) {
9007
8963
  throw new ScenarioNotSupportedError(this.node, scenario);
9008
8964
  }
9009
8965
  var method = 'limited_teleport_assets';
9010
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, method, 'Unlimited'));
8966
+ return transferPolkadotXcm(input, method, 'Unlimited');
9011
8967
  }
9012
8968
  }, {
9013
8969
  key: "getRelayToParaOverrides",
@@ -9033,8 +8989,7 @@ var PeoplePolkadot = /*#__PURE__*/function (_ParachainNode) {
9033
8989
  if (scenario === 'ParaToPara') {
9034
8990
  throw new ScenarioNotSupportedError(this.node, scenario);
9035
8991
  }
9036
- var method = 'limited_teleport_assets';
9037
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, method, 'Unlimited'));
8992
+ return transferPolkadotXcm(input, 'limited_teleport_assets', 'Unlimited');
9038
8993
  }
9039
8994
  }, {
9040
8995
  key: "getRelayToParaOverrides",
@@ -9060,77 +9015,50 @@ var determineDestWeight = function determineDestWeight(destNode) {
9060
9015
  proof_size: 0n
9061
9016
  };
9062
9017
  }
9063
- throw new NodeNotSupportedError("Node ".concat(destNode, " is not supported"));
9018
+ throw new NodeNotSupportedError("Pallet XTransfer does not support transfering to ".concat(destNode, "."));
9064
9019
  };
9065
9020
 
9066
- var getDestination = function getDestination(_ref) {
9067
- var recipientAddress = _ref.recipientAddress,
9068
- paraId = _ref.paraId,
9069
- api = _ref.api;
9070
- var isMultiLocation = _typeof(recipientAddress) === 'object';
9071
- if (isMultiLocation) {
9072
- return recipientAddress;
9073
- }
9074
- var isEthAddress = isAddress(recipientAddress);
9075
- var addressJunction = isEthAddress ? {
9076
- AccountKey20: {
9077
- key: recipientAddress
9078
- }
9079
- } : {
9080
- AccountId32: {
9081
- id: api.accountToHex(recipientAddress)
9082
- }
9083
- };
9084
- return {
9085
- parents: Parents.ONE,
9086
- interior: {
9087
- X2: [{
9088
- Parachain: paraId
9089
- }, addressJunction]
9021
+ var transferXTransfer = function transferXTransfer(input) {
9022
+ var api = input.api,
9023
+ destination = input.destination,
9024
+ scenario = input.scenario,
9025
+ asset = input.asset,
9026
+ overriddenAsset = input.overriddenAsset,
9027
+ recipientAddress = input.recipientAddress,
9028
+ pallet = input.pallet,
9029
+ methodOverride = input.method,
9030
+ paraIdTo = input.paraIdTo;
9031
+ assertToIsString(destination, ERR_MULTILOCATION_DEST_NOT_SUPPORTED);
9032
+ // XTransfer pallet does not require version specification
9033
+ // but the XCM syntax matches the V3 format
9034
+ var version = Version.V3;
9035
+ var multiAsset = createMultiAsset(version, asset.amount, {
9036
+ parents: Parents.ZERO,
9037
+ interior: 'Here'
9038
+ });
9039
+ var resolvedMultiAsset = maybeOverrideMultiAsset(version, asset.amount, multiAsset, overriddenAsset);
9040
+ var dest = createBeneficiaryMultiLocation({
9041
+ api: api,
9042
+ scenario: scenario,
9043
+ pallet: 'XTokens',
9044
+ recipientAddress: recipientAddress,
9045
+ version: version,
9046
+ paraId: paraIdTo
9047
+ });
9048
+ var destWeight = determineDestWeight(destination);
9049
+ var method = 'transfer';
9050
+ var call = {
9051
+ module: pallet !== null && pallet !== void 0 ? pallet : 'XTransfer',
9052
+ method: methodOverride !== null && methodOverride !== void 0 ? methodOverride : method,
9053
+ parameters: {
9054
+ asset: resolvedMultiAsset,
9055
+ dest: dest,
9056
+ dest_weight: destWeight
9090
9057
  }
9091
9058
  };
9059
+ return api.callTxMethod(call);
9092
9060
  };
9093
9061
 
9094
- var XTransferTransferImpl = /*#__PURE__*/function () {
9095
- function XTransferTransferImpl() {
9096
- _classCallCheck(this, XTransferTransferImpl);
9097
- }
9098
- return _createClass(XTransferTransferImpl, null, [{
9099
- key: "transferXTransfer",
9100
- value: function transferXTransfer(input) {
9101
- var api = input.api,
9102
- destination = input.destination,
9103
- asset = input.asset,
9104
- overriddenAsset = input.overriddenAsset,
9105
- pallet = input.pallet,
9106
- methodOverride = input.method;
9107
- var isMultiLocationDestination = _typeof(destination) === 'object';
9108
- if (isMultiLocationDestination) {
9109
- throw new InvalidParameterError('Multilocation destinations are not supported for specific transfer you are trying to create. In special cases such as xTokens or xTransfer pallet try using address multilocation instead (for both destination and address in same multilocation set (eg. X2 - Parachain, Address). For further assistance please open issue in our repository.');
9110
- }
9111
- var version = Version.V3;
9112
- var multiAssets = [createMultiAsset(version, asset.amount, {
9113
- parents: Parents.ZERO,
9114
- interior: 'Here'
9115
- })];
9116
- var resolvedMultiAssets = maybeOverrideMultiAssets(version, asset.amount, multiAssets, overriddenAsset);
9117
- var dest = getDestination(input);
9118
- var method = 'transfer';
9119
- var destWeight = determineDestWeight(destination);
9120
- var call = {
9121
- module: pallet !== null && pallet !== void 0 ? pallet : 'XTransfer',
9122
- method: methodOverride !== null && methodOverride !== void 0 ? methodOverride : method,
9123
- parameters: {
9124
- asset: resolvedMultiAssets[0],
9125
- dest: dest,
9126
- dest_weight: destWeight
9127
- }
9128
- };
9129
- return api.callTxMethod(call);
9130
- }
9131
- }]);
9132
- }();
9133
-
9134
9062
  var Phala = /*#__PURE__*/function (_ParachainNode) {
9135
9063
  function Phala() {
9136
9064
  _classCallCheck(this, Phala);
@@ -9139,12 +9067,12 @@ var Phala = /*#__PURE__*/function (_ParachainNode) {
9139
9067
  _inherits(Phala, _ParachainNode);
9140
9068
  return _createClass(Phala, [{
9141
9069
  key: "transferXTransfer",
9142
- value: function transferXTransfer(input) {
9070
+ value: function transferXTransfer$1(input) {
9143
9071
  var asset = input.asset;
9144
9072
  if (asset.symbol !== this.getNativeAssetSymbol()) {
9145
9073
  throw new InvalidCurrencyError("Node ".concat(this.node, " does not support currency ").concat(asset.symbol));
9146
9074
  }
9147
- return XTransferTransferImpl.transferXTransfer(input);
9075
+ return transferXTransfer(input);
9148
9076
  }
9149
9077
  }, {
9150
9078
  key: "transferLocalNonNativeAsset",
@@ -9204,7 +9132,7 @@ var RobonomicsKusama = /*#__PURE__*/function (_ParachainNode) {
9204
9132
  return _createClass(RobonomicsKusama, [{
9205
9133
  key: "transferPolkadotXCM",
9206
9134
  value: function transferPolkadotXCM(input) {
9207
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
9135
+ return transferPolkadotXcm(input, 'limited_reserve_transfer_assets', 'Unlimited');
9208
9136
  }
9209
9137
  }, {
9210
9138
  key: "transferLocalNonNativeAsset",
@@ -9223,7 +9151,7 @@ var RobonomicsPolkadot = /*#__PURE__*/function (_ParachainNode) {
9223
9151
  return _createClass(RobonomicsPolkadot, [{
9224
9152
  key: "transferPolkadotXCM",
9225
9153
  value: function transferPolkadotXCM(input) {
9226
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
9154
+ return transferPolkadotXcm(input, 'limited_reserve_transfer_assets', 'Unlimited');
9227
9155
  }
9228
9156
  }, {
9229
9157
  key: "transferLocalNonNativeAsset",
@@ -9301,7 +9229,7 @@ var Subsocial = /*#__PURE__*/function (_ParachainNode) {
9301
9229
  if (asset.symbol !== this.getNativeAssetSymbol()) {
9302
9230
  throw new InvalidCurrencyError("Asset ".concat(asset.symbol, " is not supported by node ").concat(this.node, "."));
9303
9231
  }
9304
- return Promise.resolve(PolkadotXCMTransferImpl.transferPolkadotXCM(input, 'limited_reserve_transfer_assets', 'Unlimited'));
9232
+ return transferPolkadotXcm(input, 'limited_reserve_transfer_assets', 'Unlimited');
9305
9233
  }
9306
9234
  }]);
9307
9235
  }(ParachainNode);
@@ -9580,17 +9508,6 @@ var AssetClaimBuilder = /*#__PURE__*/function () {
9580
9508
  }]);
9581
9509
  }();
9582
9510
 
9583
- var assertToIsString = function assertToIsString(to) {
9584
- if (isTMultiLocation(to)) {
9585
- throw new InvalidParameterError('Multi-Location destination is not supported for XCM fee calculation.');
9586
- }
9587
- };
9588
- var assertAddressIsString = function assertAddressIsString(address) {
9589
- if (isTMultiLocation(address)) {
9590
- throw new InvalidParameterError('Multi-Location address is not supported for XCM fee calculation.');
9591
- }
9592
- };
9593
-
9594
9511
  var BatchTransactionManager = /*#__PURE__*/function () {
9595
9512
  function BatchTransactionManager() {
9596
9513
  _classCallCheck(this, BatchTransactionManager);
@@ -10299,4 +10216,4 @@ var Builder = function Builder(api) {
10299
10216
  return new GeneralBuilder(api, new BatchTransactionManager());
10300
10217
  };
10301
10218
 
10302
- export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiary, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, replaceBigInt, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };
10219
+ export { AssetClaimBuilder, BatchMode, BridgeHaltedError, Builder, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETHEREUM_JUNCTION, ETH_CHAIN_ID, GeneralBuilder, IncompatibleNodesError, InvalidAddressError, InvalidParameterError, NoXCMSupportImplementedError, NodeNotSupportedError, PolkadotXcmError, ScenarioNotSupportedError, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, UnableToComputeError, XTokensError, addXcmVersionHeader, assertAddressIsString, assertToIsString, blake2b256, blake2b512, claimAssets, computeFeeFromDryRun, computeFeeFromDryRunPjs, convertSs58, createApiInstanceForNode, createBeneficiary, createBeneficiaryMultiLocation, createVersionedBeneficiary, createX1Payload, deriveAccountId, determineRelayChain, dryRun, dryRunOrigin, encodeSs58, getAssetBalance, getAssetBalanceInternal, getBalanceForeign, getBalanceForeignInternal, getBalanceNative, getBalanceNativeInternal, getBridgeStatus, getFees, getNode, getNodeConfig, getNodeProviders, getOriginFeeDetails, getOriginFeeDetailsInternal, getOriginXcmFee, getOriginXcmFeeEstimate, getParaEthTransferFees, getParaId, getTNode, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeEstimate, resolveModuleError, resolveParaId, reverseTransformMultiLocation, send, transferMoonbeamEvm, transferMoonbeamToEth, transferRelayToPara, transformMultiLocation, validateAddress, verifyEdOnDestination };