@moonbeam-network/xcm-builder 4.0.1 → 4.1.1

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
@@ -447,6 +447,7 @@ interface FeeConfigBuilderParams {
447
447
  interface XcmPaymentFeeProps {
448
448
  isAssetReserveChain: boolean;
449
449
  shouldTransferAssetPrecedeFeeAsset?: boolean;
450
+ isEcosystemBridge?: boolean;
450
451
  parents?: number;
451
452
  }
452
453
  interface MoonbeamRuntimeXcmConfigAssetType extends Enum {
package/build/index.mjs CHANGED
@@ -2735,6 +2735,7 @@ function ExtrinsicBuilder() {
2735
2735
  }
2736
2736
 
2737
2737
  // src/fee/FeeBuilder.utils.ts
2738
+ import { EvmParachain as EvmParachain2 } from "@moonbeam-network/xcm-types";
2738
2739
  import { isEthAddress as isEthAddress2 } from "@moonbeam-network/xcm-utils";
2739
2740
  import { u8aToHex as u8aToHex5 } from "@polkadot/util";
2740
2741
  import { decodeAddress as decodeAddress5 } from "@polkadot/util-crypto";
@@ -2754,6 +2755,32 @@ function getWithdrawAssetInstruction(assetTypes) {
2754
2755
  }))
2755
2756
  };
2756
2757
  }
2758
+ function getUniversalOriginInstruction(source) {
2759
+ if (!EvmParachain2.isAnyParachain(source)) {
2760
+ throw new Error("Source is not a parachain");
2761
+ }
2762
+ return {
2763
+ UniversalOrigin: {
2764
+ GlobalConsensus: {
2765
+ ByGenesis: source.relayGenesisHash
2766
+ }
2767
+ }
2768
+ };
2769
+ }
2770
+ function getDescendOriginInstruction(source) {
2771
+ if (!EvmParachain2.isAnyParachain(source)) {
2772
+ throw new Error("Source is not a parachain");
2773
+ }
2774
+ return {
2775
+ DescendOrigin: {
2776
+ X1: [
2777
+ {
2778
+ Parachain: source.parachainId
2779
+ }
2780
+ ]
2781
+ }
2782
+ };
2783
+ }
2757
2784
  function getReserveAssetDepositedInstruction(assetTypes) {
2758
2785
  return {
2759
2786
  ReserveAssetDeposited: assetTypes.map((assetType) => ({
@@ -3029,15 +3056,25 @@ function getInstructions({
3029
3056
  isAssetReserveChain,
3030
3057
  assets: assets3,
3031
3058
  versionedFeeAssetId,
3032
- address
3059
+ address,
3060
+ source,
3061
+ isEcosystemBridge
3033
3062
  }) {
3034
- return [
3063
+ const instructions = [
3035
3064
  isAssetReserveChain ? getWithdrawAssetInstruction(assets3) : getReserveAssetDepositedInstruction(assets3),
3036
3065
  getClearOriginInstruction(),
3037
3066
  getBuyExecutionInstruction(versionedFeeAssetId),
3038
3067
  getDepositAssetInstruction(address, assets3),
3039
3068
  getSetTopicInstruction()
3040
3069
  ];
3070
+ if (isEcosystemBridge) {
3071
+ return [
3072
+ getUniversalOriginInstruction(source),
3073
+ getDescendOriginInstruction(source),
3074
+ ...instructions
3075
+ ];
3076
+ }
3077
+ return instructions;
3041
3078
  }
3042
3079
 
3043
3080
  // src/fee/xcmPaymentApi/xcmPaymentApi.ts
@@ -3133,7 +3170,9 @@ var createXcmFeeBuilder = ({
3133
3170
  isAssetReserveChain: options.isAssetReserveChain,
3134
3171
  assets: assets3,
3135
3172
  versionedFeeAssetId,
3136
- address: params.address
3173
+ address: params.address,
3174
+ source: params.source,
3175
+ isEcosystemBridge: options.isEcosystemBridge
3137
3176
  });
3138
3177
  return getFeeForXcmInstructionsAndAsset(
3139
3178
  params.api,
@@ -3410,7 +3449,7 @@ function MonitoringBuilder() {
3410
3449
 
3411
3450
  // src/mrl/providers/wormhole/contract/Batch/Batch.ts
3412
3451
  import {
3413
- EvmParachain as EvmParachain2
3452
+ EvmParachain as EvmParachain3
3414
3453
  } from "@moonbeam-network/xcm-types";
3415
3454
  import { getMultilocationDerivedAddresses as getMultilocationDerivedAddresses2 } from "@moonbeam-network/xcm-utils";
3416
3455
  import { evmToAddress as evmToAddress3 } from "@polkadot/util-crypto";
@@ -4210,7 +4249,7 @@ function Batch() {
4210
4249
  sourceApi,
4211
4250
  transact
4212
4251
  }) => {
4213
- if (!EvmParachain2.is(source)) {
4252
+ if (!EvmParachain3.is(source)) {
4214
4253
  throw new Error("Source chain needs to be an EVMParachain");
4215
4254
  }
4216
4255
  if (!sourceApi) {
@@ -4372,20 +4411,20 @@ var WormholeConfig = class _WormholeConfig {
4372
4411
  };
4373
4412
 
4374
4413
  // src/mrl/providers/wormhole/wormhole/wormhole.ts
4375
- import { EvmChain, EvmParachain as EvmParachain4, Parachain as Parachain3 } from "@moonbeam-network/xcm-types";
4414
+ import { EvmChain, EvmParachain as EvmParachain5, Parachain as Parachain3 } from "@moonbeam-network/xcm-types";
4376
4415
  import { getMultilocationDerivedAddresses as getMultilocationDerivedAddresses3 } from "@moonbeam-network/xcm-utils";
4377
4416
  import { evmToAddress as evmToAddress4 } from "@polkadot/util-crypto/address";
4378
4417
  import { Wormhole as Wormhole2 } from "@wormhole-foundation/sdk-connect";
4379
4418
 
4380
4419
  // src/mrl/providers/wormhole/wormhole/wormholeFactory.ts
4381
- import { EvmParachain as EvmParachain3 } from "@moonbeam-network/xcm-types";
4420
+ import { EvmParachain as EvmParachain4 } from "@moonbeam-network/xcm-types";
4382
4421
  import { Wormhole } from "@wormhole-foundation/sdk-connect";
4383
4422
  import { EvmPlatform } from "@wormhole-foundation/sdk-evm";
4384
4423
  function wormholeFactory(chain) {
4385
4424
  return new Wormhole(
4386
4425
  chain.isTestChain ? "Testnet" : "Mainnet",
4387
4426
  [EvmPlatform],
4388
- EvmParachain3.isAnyEvmChain(chain) && chain.wh ? {
4427
+ EvmParachain4.isAnyEvmChain(chain) && chain.wh ? {
4389
4428
  chains: {
4390
4429
  [chain.wh.name]: {
4391
4430
  rpc: chain.rpc
@@ -4456,12 +4495,12 @@ function getPayload({
4456
4495
  destination,
4457
4496
  destinationAddress
4458
4497
  }) {
4459
- if (!EvmParachain4.isAnyParachain(destination)) {
4498
+ if (!EvmParachain5.isAnyParachain(destination)) {
4460
4499
  throw new Error(
4461
4500
  `Destination ${destination.name} is not a Parachain or EvmParachain`
4462
4501
  );
4463
4502
  }
4464
- const isEvmDestination = EvmParachain4.is(destination);
4503
+ const isEvmDestination = EvmParachain5.is(destination);
4465
4504
  const version = getExtrinsicArgumentVersion(moonApi.tx.polkadotXcm.send);
4466
4505
  const multilocation = moonApi.createType("XcmVersionedLocation", {
4467
4506
  [version]: {