@moonbeam-network/xcm-builder 3.2.2 → 3.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.d.ts CHANGED
@@ -82,8 +82,9 @@ declare class ContractConfig extends BaseConfig {
82
82
  type ContractConfigBuilder = ConfigBuilder<ContractConfig>;
83
83
 
84
84
  declare function XcmPrecompile(): {
85
- transferAssetsToPara20: () => ContractConfigBuilder;
86
- transferAssetsToPara32: () => ContractConfigBuilder;
85
+ transferAssetsToPara20: (shouldTransferAssetPrecedeFeeAsset?: boolean) => ContractConfigBuilder;
86
+ transferAssetsToPara32: (shouldTransferAssetPrecedeFeeAsset?: boolean) => ContractConfigBuilder;
87
+ transferAssetsToRelay: () => ContractConfigBuilder;
87
88
  };
88
89
 
89
90
  declare function Xtokens(): {
package/build/index.mjs CHANGED
@@ -756,40 +756,72 @@ var XCM_ABI = [
756
756
  var XCM_PRECOMPILE_ADDRESS = "0x000000000000000000000000000000000000081A";
757
757
  function XcmPrecompile() {
758
758
  return {
759
- transferAssetsToPara20: () => ({
760
- build: ({ destinationAddress, asset, destination }) => {
759
+ transferAssetsToPara20: (shouldTransferAssetPrecedeFeeAsset = true) => ({
760
+ build: ({ destinationAddress, asset, destination, fee }) => {
761
+ const assets3 = getAssets(
762
+ asset,
763
+ fee,
764
+ shouldTransferAssetPrecedeFeeAsset
765
+ );
766
+ return new ContractConfig({
767
+ address: XCM_PRECOMPILE_ADDRESS,
768
+ abi: XCM_ABI,
769
+ args: [destination.parachainId, destinationAddress, assets3, 0],
770
+ func: "transferAssetsToPara20",
771
+ module: "Xcm"
772
+ });
773
+ }
774
+ }),
775
+ transferAssetsToPara32: (shouldTransferAssetPrecedeFeeAsset = false) => ({
776
+ build: ({ destinationAddress, asset, destination, fee }) => {
777
+ const assets3 = getAssets(
778
+ asset,
779
+ fee,
780
+ shouldTransferAssetPrecedeFeeAsset
781
+ );
761
782
  return new ContractConfig({
762
783
  address: XCM_PRECOMPILE_ADDRESS,
763
784
  abi: XCM_ABI,
764
785
  args: [
765
786
  destination.parachainId,
766
- destinationAddress,
767
- [[asset.address, asset.amount]],
787
+ u8aToHex2(decodeAddress2(destinationAddress)),
788
+ assets3,
768
789
  0
769
790
  ],
770
- func: "transferAssetsToPara20",
791
+ func: "transferAssetsToPara32",
771
792
  module: "Xcm"
772
793
  });
773
794
  }
774
795
  }),
775
- transferAssetsToPara32: () => ({
776
- build: ({ destinationAddress, asset, destination }) => {
796
+ transferAssetsToRelay: () => ({
797
+ build: ({ destinationAddress, asset }) => {
777
798
  return new ContractConfig({
778
799
  address: XCM_PRECOMPILE_ADDRESS,
779
800
  abi: XCM_ABI,
780
801
  args: [
781
- destination.parachainId,
782
802
  u8aToHex2(decodeAddress2(destinationAddress)),
783
803
  [[asset.address, asset.amount]],
784
804
  0
785
805
  ],
786
- func: "transferAssetsToPara32",
806
+ func: "transferAssetsToRelay",
787
807
  module: "Xcm"
788
808
  });
789
809
  }
790
810
  })
791
811
  };
792
812
  }
813
+ function getAssets(asset, feeAsset, shouldTransferAssetPrecedeFeeAsset) {
814
+ if (feeAsset.isSame(asset)) {
815
+ return [[asset.address, asset.amount]];
816
+ }
817
+ return shouldTransferAssetPrecedeFeeAsset ? [
818
+ [asset.address, asset.amount],
819
+ [feeAsset.address, feeAsset.amount]
820
+ ] : [
821
+ [feeAsset.address, feeAsset.amount],
822
+ [asset.address, asset.amount]
823
+ ];
824
+ }
793
825
 
794
826
  // src/contract/contracts/Xtokens/Xtokens.ts
795
827
  import { formatAssetIdToERC20 } from "@moonbeam-network/xcm-utils";