@moonbeam-network/xcm-builder 3.2.2 → 3.2.4
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 +3 -2
- package/build/index.mjs +48 -18
- package/build/index.mjs.map +1 -1
- package/package.json +4 -4
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
|
-
|
|
787
|
+
u8aToHex2(decodeAddress2(destinationAddress)),
|
|
788
|
+
assets3,
|
|
768
789
|
0
|
|
769
790
|
],
|
|
770
|
-
func: "
|
|
791
|
+
func: "transferAssetsToPara32",
|
|
771
792
|
module: "Xcm"
|
|
772
793
|
});
|
|
773
794
|
}
|
|
774
795
|
}),
|
|
775
|
-
|
|
776
|
-
build: ({ destinationAddress, asset
|
|
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: "
|
|
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";
|
|
@@ -3607,7 +3639,7 @@ function Gmp() {
|
|
|
3607
3639
|
import { convertAddressTo32Bytes } from "@moonbeam-network/xcm-utils";
|
|
3608
3640
|
|
|
3609
3641
|
// src/mrl/providers/wormhole/wormhole/wormhole.ts
|
|
3610
|
-
import { EvmChain, EvmParachain as
|
|
3642
|
+
import { EvmChain, EvmParachain as EvmParachain4, Parachain as Parachain3 } from "@moonbeam-network/xcm-types";
|
|
3611
3643
|
import { getMultilocationDerivedAddresses as getMultilocationDerivedAddresses3 } from "@moonbeam-network/xcm-utils";
|
|
3612
3644
|
import { evmToAddress as evmToAddress4 } from "@polkadot/util-crypto/address";
|
|
3613
3645
|
import { Wormhole as Wormhole2 } from "@wormhole-foundation/sdk-connect";
|
|
@@ -3626,22 +3658,20 @@ var WormholeConfig = class _WormholeConfig {
|
|
|
3626
3658
|
};
|
|
3627
3659
|
|
|
3628
3660
|
// src/mrl/providers/wormhole/wormhole/wormholeFactory.ts
|
|
3661
|
+
import { EvmParachain as EvmParachain3 } from "@moonbeam-network/xcm-types";
|
|
3629
3662
|
import { Wormhole } from "@wormhole-foundation/sdk-connect";
|
|
3630
3663
|
import { EvmPlatform } from "@wormhole-foundation/sdk-evm";
|
|
3631
3664
|
function wormholeFactory(chain) {
|
|
3632
3665
|
return new Wormhole(
|
|
3633
3666
|
chain.isTestChain ? "Testnet" : "Mainnet",
|
|
3634
3667
|
[EvmPlatform],
|
|
3635
|
-
{
|
|
3668
|
+
EvmParachain3.isAnyEvmChain(chain) && chain.wh ? {
|
|
3636
3669
|
chains: {
|
|
3637
|
-
|
|
3638
|
-
rpc:
|
|
3639
|
-
},
|
|
3640
|
-
Moonbeam: {
|
|
3641
|
-
rpc: "https://rpc.api.moonbeam.network"
|
|
3670
|
+
[chain.wh.name]: {
|
|
3671
|
+
rpc: chain.rpc
|
|
3642
3672
|
}
|
|
3643
3673
|
}
|
|
3644
|
-
}
|
|
3674
|
+
} : void 0
|
|
3645
3675
|
);
|
|
3646
3676
|
}
|
|
3647
3677
|
|
|
@@ -3706,7 +3736,7 @@ function getPayload({
|
|
|
3706
3736
|
destination,
|
|
3707
3737
|
destinationAddress
|
|
3708
3738
|
}) {
|
|
3709
|
-
if (!
|
|
3739
|
+
if (!EvmParachain4.isAnyParachain(destination)) {
|
|
3710
3740
|
throw new Error(
|
|
3711
3741
|
`Destination ${destination.name} is not a Parachain or EvmParachain`
|
|
3712
3742
|
);
|