@moonbeam-network/xcm-builder 1.0.0-dev.270 → 1.0.0-dev.271

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.mjs CHANGED
@@ -3841,7 +3841,6 @@ import {
3841
3841
  Parachain as Parachain2
3842
3842
  } from "@moonbeam-network/xcm-types";
3843
3843
  import { getMultilocationDerivedAddresses } from "@moonbeam-network/xcm-utils";
3844
- import { moonriver } from "viem/chains";
3845
3844
  var BUY_EXECUTION_FEE = 100000000000000000n;
3846
3845
  var CROSS_CHAIN_FEE = 100000000000000000n;
3847
3846
  function polkadotXcm2() {
@@ -3906,16 +3905,6 @@ function polkadotXcm2() {
3906
3905
  transact
3907
3906
  });
3908
3907
  const transactionsToSend = sendOnlyRemoteExecution ? [send] : [...assetTransferTxs, send];
3909
- console.log("send", send.toHuman());
3910
- console.log(
3911
- "assetTransferTxs",
3912
- assetTransferTxs.map((tx) => tx.toHuman())
3913
- );
3914
- console.log("transact", transact);
3915
- console.log(
3916
- "transactionsToSend",
3917
- transactionsToSend.map((tx) => tx.toHuman())
3918
- );
3919
3908
  return new ExtrinsicConfig({
3920
3909
  module: "utility",
3921
3910
  func: "batchAll",
@@ -3939,12 +3928,9 @@ function buildSendExtrinsic({
3939
3928
  return sourceApi.tx.polkadotXcm.send(
3940
3929
  {
3941
3930
  [version]: normalizeX1(version, {
3942
- parents: 2,
3931
+ parents: 1,
3943
3932
  interior: {
3944
- X2: [
3945
- { GlobalConsensus: "Polkadot" },
3946
- { Parachain: moonChain.parachainId }
3947
- ]
3933
+ X1: { Parachain: moonChain.parachainId }
3948
3934
  }
3949
3935
  })
3950
3936
  },
@@ -4032,31 +4018,9 @@ function getAssetTransferTxs({
4032
4018
  sourceAddress,
4033
4019
  sourceApi
4034
4020
  }) {
4035
- const { transferAssets } = sourceApi.tx.polkadotXcm;
4021
+ const { transfer, transferMulticurrencies } = sourceApi.tx.xTokens;
4036
4022
  const transferBuilder = ExtrinsicBuilder().xTokens().transfer();
4037
- const polkadotXcmBuilder = ExtrinsicBuilder().polkadotXcm().transferAssetsToEcosystem().X4();
4038
4023
  const transferMulticurrenciesBuilder = ExtrinsicBuilder().xTokens().transferMultiCurrencies();
4039
- const testMoonriver = source.name === moonriver.name;
4040
- console.log("testMoonriver", testMoonriver);
4041
- if (testMoonriver) {
4042
- const transferAssetsTx = transferAssets(
4043
- ...polkadotXcmBuilder.build({
4044
- asset,
4045
- destination: moonChain,
4046
- destinationAddress: computedOriginAccount,
4047
- destinationApi: moonApi,
4048
- fee: AssetAmount.fromChainAsset(source.getChainAsset(moonAsset), {
4049
- amount: CROSS_CHAIN_FEE + BUY_EXECUTION_FEE
4050
- }),
4051
- source,
4052
- sourceAddress,
4053
- sourceApi
4054
- }).getArgs(transferAssets)
4055
- );
4056
- console.log("transferAssetsTx", transferAssetsTx.toHuman());
4057
- return [transferAssetsTx];
4058
- }
4059
- const { transfer, transferMulticurrencies } = sourceApi.tx.xTokens;
4060
4024
  if (asset.isSame(fee)) {
4061
4025
  const assetTransferTx = transfer(
4062
4026
  ...transferBuilder.build({
@@ -4898,12 +4862,7 @@ function wormhole() {
4898
4862
  from: whSourceAddress,
4899
4863
  to: whDestinationAddress,
4900
4864
  protocol: isAutomatic ? "AutomaticTokenBridge" /* AutomaticTokenBridge */ : "TokenBridge" /* TokenBridge */,
4901
- payload: isDestinationMoonChain || isDestinationEvmChain ? void 0 : getPayload({
4902
- destination,
4903
- destinationAddress,
4904
- moonApi,
4905
- moonChain
4906
- })
4865
+ payload: isDestinationMoonChain || isDestinationEvmChain ? void 0 : getPayload({ destination, destinationAddress, moonApi })
4907
4866
  },
4908
4867
  func: "tokenTransfer"
4909
4868
  });
@@ -4914,67 +4873,16 @@ function wormhole() {
4914
4873
  function getPayload({
4915
4874
  moonApi,
4916
4875
  destination,
4917
- destinationAddress,
4918
- moonChain
4919
- }) {
4920
- const multilocation = getMultilocation({
4921
- destination,
4922
- destinationAddress,
4923
- moonApi,
4924
- moonChain
4925
- });
4926
- console.log("multilocation", multilocation.toHuman());
4927
- const action = moonApi.createType("XcmRoutingUserAction", {
4928
- destination: multilocation
4929
- });
4930
- const versioned = moonApi.createType("VersionedUserAction", {
4931
- V1: action
4932
- });
4933
- return versioned.toU8a();
4934
- }
4935
- function getMultilocation({
4936
- moonApi,
4937
- destination,
4938
- destinationAddress,
4939
- moonChain
4876
+ destinationAddress
4940
4877
  }) {
4941
4878
  if (!EvmParachain5.isAnyParachain(destination)) {
4942
4879
  throw new Error(
4943
4880
  `Destination ${destination.name} is not a Parachain or EvmParachain`
4944
4881
  );
4945
4882
  }
4946
- const version = getExtrinsicArgumentVersion(moonApi.tx.polkadotXcm.send);
4947
- const isDifferentEcosystem = destination.ecosystem !== moonChain.ecosystem;
4948
4883
  const isEvmDestination = EvmParachain5.is(destination);
4949
- console.log("destination", destination);
4950
- console.log("isEvmDestination", isEvmDestination);
4951
- console.log("destinationAddress", destinationAddress);
4952
- console.log(
4953
- "evmToAddress(destinationAddress)",
4954
- evmToAddress4(destinationAddress)
4955
- );
4956
- if (isDifferentEcosystem) {
4957
- return moonApi.createType("XcmVersionedLocation", {
4958
- [version]: {
4959
- parents: 2,
4960
- interior: {
4961
- X3: [
4962
- {
4963
- GlobalConsensus: getGlobalConsensus(destination)
4964
- },
4965
- {
4966
- Parachain: destination.parachainId
4967
- },
4968
- // wrong
4969
- getExtrinsicAccount(
4970
- isEvmDestination ? evmToAddress4(destinationAddress) : destinationAddress
4971
- )
4972
- ]
4973
- }
4974
- }
4975
- });
4976
- }
4977
- return moonApi.createType("XcmVersionedLocation", {
4884
+ const version = getExtrinsicArgumentVersion(moonApi.tx.polkadotXcm.send);
4885
+ const multilocation = moonApi.createType("XcmVersionedLocation", {
4978
4886
  [version]: {
4979
4887
  parents: 1,
4980
4888
  interior: {
@@ -4989,6 +4897,13 @@ function getMultilocation({
4989
4897
  }
4990
4898
  }
4991
4899
  });
4900
+ const action = moonApi.createType("XcmRoutingUserAction", {
4901
+ destination: multilocation
4902
+ });
4903
+ const versioned = moonApi.createType("VersionedUserAction", {
4904
+ V1: action
4905
+ });
4906
+ return versioned.toU8a();
4992
4907
  }
4993
4908
 
4994
4909
  // src/mrl/providers/wormhole/contract/TokenBridge/TokenBridgeAbi.ts