@moonbeam-network/mrl 1.0.0-dev.290 → 1.0.0-dev.291

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
@@ -16796,7 +16796,7 @@ import {
16796
16796
  import {
16797
16797
  AssetAmount as AssetAmount3,
16798
16798
  EvmChain as EvmChain3,
16799
- EvmParachain as EvmParachain2
16799
+ EvmParachain as EvmParachain3
16800
16800
  } from "@moonbeam-network/xcm-types";
16801
16801
  import { toBigInt as toBigInt3 } from "@moonbeam-network/xcm-utils";
16802
16802
  import Big2 from "big.js";
@@ -16960,7 +16960,7 @@ var SnowbridgeService = class _SnowbridgeService {
16960
16960
 
16961
16961
  // src/getTransferData/getBridgeChainData.ts
16962
16962
  import { getBalance, getDestinationFee } from "@moonbeam-network/xcm-sdk";
16963
- import { Parachain } from "@moonbeam-network/xcm-types";
16963
+ import { EvmParachain, Parachain } from "@moonbeam-network/xcm-types";
16964
16964
  import {
16965
16965
  getMultilocationDerivedAddresses,
16966
16966
  isEthAddress as isEthAddress2
@@ -17020,17 +17020,17 @@ function getBridgeChainAddress({
17020
17020
  const bridgeChain = route.mrl.bridgeChain.chain;
17021
17021
  const isDestinationBridgeChain = bridgeChain.isEqual(destination);
17022
17022
  const isSourceBridgeChain = bridgeChain.isEqual(source);
17023
- const isDifferentEcosystem = source.ecosystem !== bridgeChain.ecosystem;
17024
17023
  let bridgeChainAddress = isDestinationBridgeChain ? destinationAddress : sourceAddress;
17025
17024
  if (Parachain.isExactly(bridgeChain) && isEthAddress2(bridgeChainAddress)) {
17026
17025
  bridgeChainAddress = evmToAddress(bridgeChainAddress);
17027
17026
  return bridgeChainAddress;
17028
17027
  }
17029
17028
  if (Parachain.is(source) && !isSourceBridgeChain) {
17029
+ const isSourceEvmSigner = EvmParachain.is(source) && source.isEvmSigner;
17030
17030
  const { address20: computedOriginAccount } = getMultilocationDerivedAddresses({
17031
- address: sourceAddress,
17031
+ address: isSourceEvmSigner ? evmToAddress(sourceAddress) : sourceAddress,
17032
17032
  paraId: source.parachainId,
17033
- parents: isDifferentEcosystem ? 2 : 1
17033
+ isParents: true
17034
17034
  });
17035
17035
  bridgeChainAddress = computedOriginAccount;
17036
17036
  }
@@ -17072,8 +17072,7 @@ import {
17072
17072
  } from "@moonbeam-network/xcm-builder";
17073
17073
  import {
17074
17074
  moonbaseAlpha,
17075
- moonbeam,
17076
- moonriver
17075
+ moonbeam
17077
17076
  } from "@moonbeam-network/xcm-config";
17078
17077
  import {
17079
17078
  convertToChainDecimals,
@@ -17081,7 +17080,7 @@ import {
17081
17080
  getMin,
17082
17081
  PolkadotService
17083
17082
  } from "@moonbeam-network/xcm-sdk";
17084
- import { AssetAmount, EvmParachain } from "@moonbeam-network/xcm-types";
17083
+ import { AssetAmount, EvmParachain as EvmParachain2 } from "@moonbeam-network/xcm-types";
17085
17084
  import {
17086
17085
  getMultilocationDerivedAddresses as getMultilocationDerivedAddresses2,
17087
17086
  getPolkadotApi
@@ -17094,7 +17093,6 @@ import {
17094
17093
  } from "viem";
17095
17094
  var MOON_CHAIN_AUTOMATIC_GAS_ESTIMATION = {
17096
17095
  [moonbeam.key]: 1273110n,
17097
- [moonriver.key]: 1273110n,
17098
17096
  [moonbaseAlpha.key]: 1470417n
17099
17097
  };
17100
17098
  function getBridgeChainFeeValueOnSource({
@@ -17102,7 +17100,7 @@ function getBridgeChainFeeValueOnSource({
17102
17100
  bridgeChainData,
17103
17101
  sourceData
17104
17102
  }) {
17105
- const isSourceParachain = EvmParachain.isAnyParachain(sourceData.chain);
17103
+ const isSourceParachain = EvmParachain2.isAnyParachain(sourceData.chain);
17106
17104
  const isDestinationBridgeChain = destinationData.chain.isEqual(
17107
17105
  bridgeChainData.chain
17108
17106
  );
@@ -17137,7 +17135,7 @@ function getMrlMin({
17137
17135
  });
17138
17136
  }
17139
17137
  function requiresTransact(route) {
17140
- return route.mrl?.transfer.provider === Provider.Wormhole && EvmParachain.isAnyParachain(route.source.chain);
17138
+ return route.mrl?.transfer.provider === Provider.Wormhole && EvmParachain2.isAnyParachain(route.source.chain);
17141
17139
  }
17142
17140
  async function buildTransfer(params) {
17143
17141
  const { route } = params;
@@ -17177,8 +17175,8 @@ async function getMrlBuilderParams({
17177
17175
  const destination = route.destination.chain;
17178
17176
  const bridgeChain = route.mrl.bridgeChain.chain;
17179
17177
  const [sourceApi, destinationApi, bridgeApi] = await Promise.all([
17180
- EvmParachain.isAnyParachain(source) ? getPolkadotApi(source.ws) : void 0,
17181
- EvmParachain.isAnyParachain(destination) ? getPolkadotApi(destination.ws) : void 0,
17178
+ EvmParachain2.isAnyParachain(source) ? getPolkadotApi(source.ws) : void 0,
17179
+ EvmParachain2.isAnyParachain(destination) ? getPolkadotApi(destination.ws) : void 0,
17182
17180
  getPolkadotApi(bridgeChain.ws)
17183
17181
  ]);
17184
17182
  return {
@@ -17203,14 +17201,13 @@ async function getTransact(params) {
17203
17201
  const { sourceAddress, source, bridgeChain } = params;
17204
17202
  const polkadot = await PolkadotService.create(bridgeChain);
17205
17203
  const bridgeChainGasLimit = await getBridgeChainGasLimit(params);
17206
- if (!EvmParachain.isAnyParachain(source)) {
17204
+ if (!EvmParachain2.isAnyParachain(source)) {
17207
17205
  throw new Error("Source chain must be Parachain or EvmParachain");
17208
17206
  }
17209
- const isDifferentEcosystem = source.ecosystem !== bridgeChain.ecosystem;
17210
17207
  const { address20 } = getMultilocationDerivedAddresses2({
17211
17208
  address: sourceAddress,
17212
17209
  paraId: source.parachainId,
17213
- parents: isDifferentEcosystem ? 2 : 1
17210
+ isParents: true
17214
17211
  });
17215
17212
  const extrinsic = MrlBuilder2().wormhole().extrinsic().ethereumXcm().transact().build({ ...params, bridgeChainGasLimit });
17216
17213
  const { weight } = await polkadot.getPaymentInfo(address20, extrinsic);
@@ -17224,10 +17221,10 @@ async function getTransact(params) {
17224
17221
  }
17225
17222
  async function getBridgeChainGasLimit(params) {
17226
17223
  const { asset, isAutomatic, bridgeChain, source, sourceAddress } = params;
17227
- if (!EvmParachain.isAnyParachain(source)) {
17224
+ if (!EvmParachain2.isAnyParachain(source)) {
17228
17225
  throw new Error("Source chain must be Parachain or EvmParachain");
17229
17226
  }
17230
- if (!EvmParachain.is(bridgeChain)) {
17227
+ if (!EvmParachain2.is(bridgeChain)) {
17231
17228
  throw new Error("Bridge chain must be an EvmParachain");
17232
17229
  }
17233
17230
  const client = createPublicClient2({
@@ -17237,7 +17234,7 @@ async function getBridgeChainGasLimit(params) {
17237
17234
  const { address20 } = getMultilocationDerivedAddresses2({
17238
17235
  address: sourceAddress,
17239
17236
  paraId: source.parachainId,
17240
- parents: 1
17237
+ isParents: true
17241
17238
  });
17242
17239
  if (isAutomatic) {
17243
17240
  return MOON_CHAIN_AUTOMATIC_GAS_ESTIMATION[bridgeChain.key] * 110n / 100n;
@@ -17723,7 +17720,7 @@ async function getTransferData({
17723
17720
  sendOnlyRemoteExecution,
17724
17721
  sourceAddress
17725
17722
  });
17726
- if (ContractConfig3.is(transfer) && (EvmChain3.is(source) || EvmParachain2.is(source))) {
17723
+ if (ContractConfig3.is(transfer) && (EvmChain3.is(source) || EvmParachain3.is(source))) {
17727
17724
  if (!evmSigner) {
17728
17725
  throw new Error("EVM Signer must be provided");
17729
17726
  }
@@ -17731,7 +17728,7 @@ async function getTransferData({
17731
17728
  const hash = await evm.transfer(evmSigner, transfer);
17732
17729
  return [hash];
17733
17730
  }
17734
- if (ExtrinsicConfig.is(transfer) && EvmParachain2.isAnyParachain(source)) {
17731
+ if (ExtrinsicConfig.is(transfer) && EvmParachain3.isAnyParachain(source)) {
17735
17732
  if (!polkadotSigner) {
17736
17733
  throw new Error("Polkadot signer must be provided");
17737
17734
  }
@@ -17744,14 +17741,14 @@ async function getTransferData({
17744
17741
  );
17745
17742
  return [hash];
17746
17743
  }
17747
- if (WormholeConfig2.is(transfer) && (EvmChain3.is(source) || EvmParachain2.is(source))) {
17744
+ if (WormholeConfig2.is(transfer) && (EvmChain3.is(source) || EvmParachain3.is(source))) {
17748
17745
  if (!evmSigner) {
17749
17746
  throw new Error("EVM Signer must be provided");
17750
17747
  }
17751
17748
  const wh = WormholeService.create(source);
17752
17749
  return wh.transfer(evmSigner, transfer);
17753
17750
  }
17754
- if (SnowbridgeConfig2.is(transfer) && (EvmChain3.is(source) || EvmParachain2.is(source))) {
17751
+ if (SnowbridgeConfig2.is(transfer) && (EvmChain3.is(source) || EvmParachain3.is(source))) {
17755
17752
  if (!evmSigner) {
17756
17753
  throw new Error("EVM Signer must be provided");
17757
17754
  }