@moonbeam-network/xcm-builder 3.2.6 → 3.3.0

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/build/index.d.ts CHANGED
@@ -370,12 +370,18 @@ declare function polkadotXcm$1(): {
370
370
  };
371
371
  transferAssets: () => {
372
372
  here: (parents?: number) => ExtrinsicConfigBuilder;
373
+ X2: () => ExtrinsicConfigBuilder;
374
+ X3: () => ExtrinsicConfigBuilder;
373
375
  X2AndFeeHere: () => ExtrinsicConfigBuilder;
374
376
  };
375
377
  transferAssetsUsingTypeAndThen: () => {
376
378
  here: () => ExtrinsicConfigBuilder;
377
379
  globalConsensusEthereum: () => ExtrinsicConfigBuilder;
378
380
  };
381
+ transferAssetsToEcosystem: () => {
382
+ X1: () => ExtrinsicConfigBuilder;
383
+ X3: () => ExtrinsicConfigBuilder;
384
+ };
379
385
  };
380
386
 
381
387
  declare function xTokens(): {
package/build/index.mjs CHANGED
@@ -1489,6 +1489,7 @@ function getPolkadotXcmExtrinsicArgs({
1489
1489
  }) {
1490
1490
  const version = getExtrinsicArgumentVersion(func);
1491
1491
  return [
1492
+ // dest
1492
1493
  {
1493
1494
  [version]: normalizeX1(version, {
1494
1495
  parents,
@@ -1499,6 +1500,7 @@ function getPolkadotXcmExtrinsicArgs({
1499
1500
  }
1500
1501
  })
1501
1502
  },
1503
+ // beneficiary
1502
1504
  {
1503
1505
  [version]: normalizeX1(version, {
1504
1506
  parents: 0,
@@ -1507,10 +1509,13 @@ function getPolkadotXcmExtrinsicArgs({
1507
1509
  }
1508
1510
  })
1509
1511
  },
1512
+ // assets
1510
1513
  {
1511
1514
  [version]: asset
1512
1515
  },
1516
+ // feeAssetItem
1513
1517
  feeIndex,
1518
+ // weightLimit
1514
1519
  "Unlimited"
1515
1520
  ];
1516
1521
  }
@@ -1717,6 +1722,104 @@ function polkadotXcm() {
1717
1722
  }
1718
1723
  })
1719
1724
  }),
1725
+ X2: () => ({
1726
+ build: (params) => new ExtrinsicConfig({
1727
+ module: pallet2,
1728
+ func,
1729
+ getArgs: (extrinsicFunction) => {
1730
+ const version = getExtrinsicArgumentVersion(extrinsicFunction);
1731
+ const assetInDestination = params.destination.getChainAsset(
1732
+ params.asset
1733
+ );
1734
+ return getPolkadotXcmExtrinsicArgs({
1735
+ ...params,
1736
+ func: extrinsicFunction,
1737
+ asset: [
1738
+ {
1739
+ id: normalizeConcrete(version, {
1740
+ parents: 1,
1741
+ interior: {
1742
+ X2: [
1743
+ {
1744
+ Parachain: params.destination.parachainId
1745
+ },
1746
+ {
1747
+ PalletInstance: assetInDestination.getAssetPalletInstance()
1748
+ }
1749
+ ]
1750
+ }
1751
+ }),
1752
+ fun: {
1753
+ Fungible: params.asset.amount
1754
+ }
1755
+ }
1756
+ ]
1757
+ });
1758
+ }
1759
+ })
1760
+ }),
1761
+ X3: () => ({
1762
+ build: (params) => new ExtrinsicConfig({
1763
+ module: pallet2,
1764
+ func,
1765
+ getArgs: (extrinsicFunction) => {
1766
+ const version = getExtrinsicArgumentVersion(extrinsicFunction);
1767
+ const assetInDestination = params.destination.getChainAsset(
1768
+ params.asset
1769
+ );
1770
+ const feeAssetInDestination = params.destination.getChainAsset(
1771
+ params.fee
1772
+ );
1773
+ return getPolkadotXcmExtrinsicArgs({
1774
+ ...params,
1775
+ func: extrinsicFunction,
1776
+ asset: [
1777
+ {
1778
+ id: normalizeConcrete(version, {
1779
+ parents: 1,
1780
+ interior: {
1781
+ X2: [
1782
+ {
1783
+ Parachain: params.destination.parachainId
1784
+ },
1785
+ {
1786
+ PalletInstance: feeAssetInDestination.getAssetPalletInstance()
1787
+ }
1788
+ ]
1789
+ }
1790
+ }),
1791
+ fun: {
1792
+ Fungible: params.fee.amount
1793
+ }
1794
+ },
1795
+ {
1796
+ id: normalizeConcrete(version, {
1797
+ parents: 1,
1798
+ interior: {
1799
+ X3: [
1800
+ {
1801
+ Parachain: params.destination.parachainId
1802
+ },
1803
+ {
1804
+ PalletInstance: assetInDestination.getAssetPalletInstance()
1805
+ },
1806
+ {
1807
+ AccountKey20: {
1808
+ key: assetInDestination.address
1809
+ }
1810
+ }
1811
+ ]
1812
+ }
1813
+ }),
1814
+ fun: {
1815
+ Fungible: params.asset.amount
1816
+ }
1817
+ }
1818
+ ]
1819
+ });
1820
+ }
1821
+ })
1822
+ }),
1720
1823
  X2AndFeeHere: () => ({
1721
1824
  build: (params) => new ExtrinsicConfig({
1722
1825
  module: pallet2,
@@ -1909,6 +2012,151 @@ function polkadotXcm() {
1909
2012
  })
1910
2013
  })
1911
2014
  };
2015
+ },
2016
+ transferAssetsToEcosystem: () => {
2017
+ const func = "transferAssets";
2018
+ return {
2019
+ X1: () => ({
2020
+ build: (params) => {
2021
+ return new ExtrinsicConfig({
2022
+ module: pallet2,
2023
+ func,
2024
+ getArgs: (extrinsicFunction) => {
2025
+ const version = getExtrinsicArgumentVersion(extrinsicFunction);
2026
+ return [
2027
+ // dest
2028
+ {
2029
+ [version]: normalizeX1(version, {
2030
+ parents: 2,
2031
+ interior: {
2032
+ X2: [
2033
+ {
2034
+ GlobalConsensus: {
2035
+ ByGenesis: params.destination.relayGenesisHash
2036
+ }
2037
+ },
2038
+ {
2039
+ Parachain: params.destination.parachainId
2040
+ }
2041
+ ]
2042
+ }
2043
+ })
2044
+ },
2045
+ // beneficiary
2046
+ {
2047
+ [version]: normalizeX1(version, {
2048
+ parents: 0,
2049
+ interior: {
2050
+ X1: getExtrinsicAccount(params.destinationAddress)
2051
+ }
2052
+ })
2053
+ },
2054
+ // assets
2055
+ {
2056
+ [version]: [
2057
+ {
2058
+ id: normalizeConcrete(
2059
+ version,
2060
+ normalizeX1(version, {
2061
+ parents: 0,
2062
+ interior: {
2063
+ X1: {
2064
+ PalletInstance: params.asset.getAssetPalletInstance()
2065
+ }
2066
+ }
2067
+ })
2068
+ ),
2069
+ fun: {
2070
+ Fungible: params.asset.amount
2071
+ }
2072
+ }
2073
+ ]
2074
+ },
2075
+ // feeAssetItem
2076
+ 0,
2077
+ // weightLimit
2078
+ "Unlimited"
2079
+ ];
2080
+ }
2081
+ });
2082
+ }
2083
+ }),
2084
+ X3: () => ({
2085
+ build: (params) => {
2086
+ const assetInDestination = params.destination.getChainAsset(
2087
+ params.asset
2088
+ );
2089
+ return new ExtrinsicConfig({
2090
+ module: pallet2,
2091
+ func,
2092
+ getArgs: (extrinsicFunction) => {
2093
+ const version = getExtrinsicArgumentVersion(extrinsicFunction);
2094
+ return [
2095
+ // dest
2096
+ {
2097
+ [version]: normalizeX1(version, {
2098
+ parents: 2,
2099
+ interior: {
2100
+ X2: [
2101
+ {
2102
+ GlobalConsensus: {
2103
+ ByGenesis: params.destination.relayGenesisHash
2104
+ }
2105
+ },
2106
+ {
2107
+ Parachain: params.destination.parachainId
2108
+ }
2109
+ ]
2110
+ }
2111
+ })
2112
+ },
2113
+ // beneficiary
2114
+ {
2115
+ [version]: normalizeX1(version, {
2116
+ parents: 0,
2117
+ interior: {
2118
+ X1: getExtrinsicAccount(params.destinationAddress)
2119
+ }
2120
+ })
2121
+ },
2122
+ // assets
2123
+ {
2124
+ [version]: [
2125
+ {
2126
+ id: normalizeConcrete(version, {
2127
+ parents: 2,
2128
+ interior: {
2129
+ X3: [
2130
+ {
2131
+ GlobalConsensus: {
2132
+ ByGenesis: params.destination.relayGenesisHash
2133
+ }
2134
+ },
2135
+ {
2136
+ Parachain: params.destination.parachainId
2137
+ },
2138
+ {
2139
+ PalletInstance: assetInDestination.getAssetPalletInstance()
2140
+ }
2141
+ ]
2142
+ }
2143
+ }),
2144
+ fun: {
2145
+ Fungible: params.asset.amount
2146
+ }
2147
+ }
2148
+ ]
2149
+ },
2150
+ // feeAssetItem
2151
+ 0,
2152
+ // weightLimit
2153
+ "Unlimited"
2154
+ ];
2155
+ }
2156
+ });
2157
+ }
2158
+ })
2159
+ };
1912
2160
  }
1913
2161
  };
1914
2162
  }
@@ -2426,7 +2674,6 @@ function BuildVersionedAsset() {
2426
2674
  parents: 2
2427
2675
  }),
2428
2676
  fromPalletInstance: (asset) => {
2429
- validatePalletInstance(asset);
2430
2677
  return {
2431
2678
  interior: {
2432
2679
  X1: [
@@ -2439,7 +2686,6 @@ function BuildVersionedAsset() {
2439
2686
  };
2440
2687
  },
2441
2688
  fromPalletInstanceAndGeneralIndex: (asset) => {
2442
- validatePalletInstance(asset);
2443
2689
  return {
2444
2690
  interior: {
2445
2691
  X2: [
@@ -2460,7 +2706,6 @@ function BuildVersionedAsset() {
2460
2706
  );
2461
2707
  }
2462
2708
  const sourceAsset = source.getChainAsset(asset);
2463
- validatePalletInstance(sourceAsset);
2464
2709
  return {
2465
2710
  interior: {
2466
2711
  X3: [
@@ -2479,7 +2724,6 @@ function BuildVersionedAsset() {
2479
2724
  );
2480
2725
  }
2481
2726
  const sourceAsset = source.getChainAsset(asset);
2482
- validatePalletInstance(sourceAsset);
2483
2727
  return {
2484
2728
  interior: {
2485
2729
  X2: [
@@ -2499,7 +2743,6 @@ function BuildVersionedAsset() {
2499
2743
  );
2500
2744
  }
2501
2745
  const sourceAsset = source.getChainAsset(asset);
2502
- validatePalletInstance(sourceAsset);
2503
2746
  return {
2504
2747
  interior: {
2505
2748
  X3: [
@@ -2546,13 +2789,6 @@ function QueryVersionedAsset() {
2546
2789
  }
2547
2790
  };
2548
2791
  }
2549
- var validatePalletInstance = (asset) => {
2550
- if (!asset.getAssetPalletInstance()) {
2551
- throw new Error(
2552
- `No pallet instance configured for the asset ${asset.key} for XcmPaymentApi fee calculation`
2553
- );
2554
- }
2555
- };
2556
2792
 
2557
2793
  // src/fee/xcmPaymentApi/xcmPaymentApi.utils.ts
2558
2794
  async function getVersionedAssets({