@moonbeam-network/mrl 4.2.6 → 4.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.mjs CHANGED
@@ -16798,7 +16798,7 @@ import {
16798
16798
  import {
16799
16799
  AssetAmount as AssetAmount3,
16800
16800
  EvmChain as EvmChain3,
16801
- EvmParachain as EvmParachain3
16801
+ EvmParachain as EvmParachain2
16802
16802
  } from "@moonbeam-network/xcm-types";
16803
16803
  import { toBigInt as toBigInt3 } from "@moonbeam-network/xcm-utils";
16804
16804
  import Big2 from "big.js";
@@ -16980,7 +16980,7 @@ var SnowbridgeService = class _SnowbridgeService {
16980
16980
 
16981
16981
  // src/getTransferData/getBridgeChainData.ts
16982
16982
  import { getBalance, getDestinationFee } from "@moonbeam-network/xcm-sdk";
16983
- import { EvmParachain, Parachain } from "@moonbeam-network/xcm-types";
16983
+ import { Parachain } from "@moonbeam-network/xcm-types";
16984
16984
  import {
16985
16985
  getMultilocationDerivedAddresses,
16986
16986
  isEthAddress as isEthAddress2
@@ -17040,17 +17040,17 @@ function getBridgeChainAddress({
17040
17040
  const bridgeChain = route.mrl.bridgeChain.chain;
17041
17041
  const isDestinationBridgeChain = bridgeChain.isEqual(destination);
17042
17042
  const isSourceBridgeChain = bridgeChain.isEqual(source);
17043
+ const isDifferentEcosystem = source.ecosystem !== bridgeChain.ecosystem;
17043
17044
  let bridgeChainAddress = isDestinationBridgeChain ? destinationAddress : sourceAddress;
17044
17045
  if (Parachain.isExactly(bridgeChain) && isEthAddress2(bridgeChainAddress)) {
17045
17046
  bridgeChainAddress = evmToAddress(bridgeChainAddress);
17046
17047
  return bridgeChainAddress;
17047
17048
  }
17048
17049
  if (Parachain.is(source) && !isSourceBridgeChain) {
17049
- const isSourceEvmSigner = EvmParachain.is(source) && source.isEvmSigner;
17050
17050
  const { address20: computedOriginAccount } = getMultilocationDerivedAddresses({
17051
- address: isSourceEvmSigner ? evmToAddress(sourceAddress) : sourceAddress,
17051
+ address: sourceAddress,
17052
17052
  paraId: source.parachainId,
17053
- isParents: true
17053
+ parents: isDifferentEcosystem ? 2 : 1
17054
17054
  });
17055
17055
  bridgeChainAddress = computedOriginAccount;
17056
17056
  }
@@ -17092,7 +17092,8 @@ import {
17092
17092
  } from "@moonbeam-network/xcm-builder";
17093
17093
  import {
17094
17094
  moonbaseAlpha,
17095
- moonbeam
17095
+ moonbeam,
17096
+ moonriver
17096
17097
  } from "@moonbeam-network/xcm-config";
17097
17098
  import {
17098
17099
  convertToChainDecimals,
@@ -17100,7 +17101,7 @@ import {
17100
17101
  getMin,
17101
17102
  PolkadotService
17102
17103
  } from "@moonbeam-network/xcm-sdk";
17103
- import { AssetAmount, EvmParachain as EvmParachain2 } from "@moonbeam-network/xcm-types";
17104
+ import { AssetAmount, EvmParachain } from "@moonbeam-network/xcm-types";
17104
17105
  import {
17105
17106
  getMultilocationDerivedAddresses as getMultilocationDerivedAddresses2,
17106
17107
  getPolkadotApi
@@ -17113,6 +17114,7 @@ import {
17113
17114
  } from "viem";
17114
17115
  var MOON_CHAIN_AUTOMATIC_GAS_ESTIMATION = {
17115
17116
  [moonbeam.key]: 1273110n,
17117
+ [moonriver.key]: 1273110n,
17116
17118
  [moonbaseAlpha.key]: 1470417n
17117
17119
  };
17118
17120
  function getBridgeChainFeeValueOnSource({
@@ -17120,7 +17122,7 @@ function getBridgeChainFeeValueOnSource({
17120
17122
  bridgeChainData,
17121
17123
  sourceData
17122
17124
  }) {
17123
- const isSourceParachain = EvmParachain2.isAnyParachain(sourceData.chain);
17125
+ const isSourceParachain = EvmParachain.isAnyParachain(sourceData.chain);
17124
17126
  const isDestinationBridgeChain = destinationData.chain.isEqual(
17125
17127
  bridgeChainData.chain
17126
17128
  );
@@ -17155,7 +17157,7 @@ function getMrlMin({
17155
17157
  });
17156
17158
  }
17157
17159
  function requiresTransact(route) {
17158
- return route.mrl?.transfer.provider === Provider.Wormhole && EvmParachain2.isAnyParachain(route.source.chain);
17160
+ return route.mrl?.transfer.provider === Provider.Wormhole && EvmParachain.isAnyParachain(route.source.chain);
17159
17161
  }
17160
17162
  async function buildTransfer(params) {
17161
17163
  const { route } = params;
@@ -17195,8 +17197,8 @@ async function getMrlBuilderParams({
17195
17197
  const destination = route.destination.chain;
17196
17198
  const bridgeChain = route.mrl.bridgeChain.chain;
17197
17199
  const [sourceApi, destinationApi, bridgeApi] = await Promise.all([
17198
- EvmParachain2.isAnyParachain(source) ? getPolkadotApi(source.ws) : void 0,
17199
- EvmParachain2.isAnyParachain(destination) ? getPolkadotApi(destination.ws) : void 0,
17200
+ EvmParachain.isAnyParachain(source) ? getPolkadotApi(source.ws) : void 0,
17201
+ EvmParachain.isAnyParachain(destination) ? getPolkadotApi(destination.ws) : void 0,
17200
17202
  getPolkadotApi(bridgeChain.ws)
17201
17203
  ]);
17202
17204
  return {
@@ -17221,13 +17223,14 @@ async function getTransact(params) {
17221
17223
  const { sourceAddress, source, bridgeChain } = params;
17222
17224
  const polkadot = await PolkadotService.create(bridgeChain);
17223
17225
  const bridgeChainGasLimit = await getBridgeChainGasLimit(params);
17224
- if (!EvmParachain2.isAnyParachain(source)) {
17226
+ if (!EvmParachain.isAnyParachain(source)) {
17225
17227
  throw new Error("Source chain must be Parachain or EvmParachain");
17226
17228
  }
17229
+ const isDifferentEcosystem = source.ecosystem !== bridgeChain.ecosystem;
17227
17230
  const { address20 } = getMultilocationDerivedAddresses2({
17228
17231
  address: sourceAddress,
17229
17232
  paraId: source.parachainId,
17230
- isParents: true
17233
+ parents: isDifferentEcosystem ? 2 : 1
17231
17234
  });
17232
17235
  const extrinsic = MrlBuilder2().wormhole().extrinsic().ethereumXcm().transact().build({ ...params, bridgeChainGasLimit });
17233
17236
  const { weight } = await polkadot.getPaymentInfo(address20, extrinsic);
@@ -17241,10 +17244,10 @@ async function getTransact(params) {
17241
17244
  }
17242
17245
  async function getBridgeChainGasLimit(params) {
17243
17246
  const { asset, isAutomatic, bridgeChain, source, sourceAddress } = params;
17244
- if (!EvmParachain2.isAnyParachain(source)) {
17247
+ if (!EvmParachain.isAnyParachain(source)) {
17245
17248
  throw new Error("Source chain must be Parachain or EvmParachain");
17246
17249
  }
17247
- if (!EvmParachain2.is(bridgeChain)) {
17250
+ if (!EvmParachain.is(bridgeChain)) {
17248
17251
  throw new Error("Bridge chain must be an EvmParachain");
17249
17252
  }
17250
17253
  const client = createPublicClient2({
@@ -17254,7 +17257,7 @@ async function getBridgeChainGasLimit(params) {
17254
17257
  const { address20 } = getMultilocationDerivedAddresses2({
17255
17258
  address: sourceAddress,
17256
17259
  paraId: source.parachainId,
17257
- isParents: true
17260
+ parents: 1
17258
17261
  });
17259
17262
  if (isAutomatic) {
17260
17263
  return MOON_CHAIN_AUTOMATIC_GAS_ESTIMATION[bridgeChain.key] * 110n / 100n;
@@ -17745,7 +17748,7 @@ async function getTransferData({
17745
17748
  sendOnlyRemoteExecution,
17746
17749
  sourceAddress
17747
17750
  });
17748
- if (ContractConfig3.is(transfer) && (EvmChain3.is(source) || EvmParachain3.is(source))) {
17751
+ if (ContractConfig3.is(transfer) && (EvmChain3.is(source) || EvmParachain2.is(source))) {
17749
17752
  if (!evmSigner) {
17750
17753
  throw new Error("EVM Signer must be provided");
17751
17754
  }
@@ -17753,7 +17756,7 @@ async function getTransferData({
17753
17756
  const hash = await evm.transfer(evmSigner, transfer);
17754
17757
  return [hash];
17755
17758
  }
17756
- if (ExtrinsicConfig.is(transfer) && EvmParachain3.isAnyParachain(source)) {
17759
+ if (ExtrinsicConfig.is(transfer) && EvmParachain2.isAnyParachain(source)) {
17757
17760
  if (!polkadotSigner) {
17758
17761
  throw new Error("Polkadot signer must be provided");
17759
17762
  }
@@ -17766,14 +17769,14 @@ async function getTransferData({
17766
17769
  );
17767
17770
  return [hash];
17768
17771
  }
17769
- if (WormholeConfig2.is(transfer) && (EvmChain3.is(source) || EvmParachain3.is(source))) {
17772
+ if (WormholeConfig2.is(transfer) && (EvmChain3.is(source) || EvmParachain2.is(source))) {
17770
17773
  if (!evmSigner) {
17771
17774
  throw new Error("EVM Signer must be provided");
17772
17775
  }
17773
17776
  const wh = WormholeService.create(source);
17774
17777
  return wh.transfer(evmSigner, transfer);
17775
17778
  }
17776
- if (SnowbridgeConfig2.is(transfer) && (EvmChain3.is(source) || EvmParachain3.is(source))) {
17779
+ if (SnowbridgeConfig2.is(transfer) && (EvmChain3.is(source) || EvmParachain2.is(source))) {
17777
17780
  if (!evmSigner) {
17778
17781
  throw new Error("EVM Signer must be provided");
17779
17782
  }