@moonbeam-network/mrl 1.0.0-dev.277 → 1.0.0-dev.278

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
@@ -16808,6 +16808,7 @@ import {
16808
16808
  } from "@moonbeam-network/xcm-builder";
16809
16809
  import { EvmService as EvmService2 } from "@moonbeam-network/xcm-sdk";
16810
16810
  import { EvmChain } from "@moonbeam-network/xcm-types";
16811
+ import { isEthAddress } from "@moonbeam-network/xcm-utils";
16811
16812
  import { u8aToHex } from "@polkadot/util";
16812
16813
  import { decodeAddress } from "@polkadot/util-crypto";
16813
16814
  import { encodeFunctionData } from "viem";
@@ -16873,16 +16874,17 @@ var SnowbridgeService = class _SnowbridgeService {
16873
16874
  requiresApproval
16874
16875
  } = args;
16875
16876
  const value = requiresApproval ? bridgeFeeAmount : amount + bridgeFeeAmount;
16877
+ const isEthereumDestination = isEthAddress(destinationAddress);
16878
+ const destination = isEthereumDestination ? { kind: 2, data: destinationAddress } : { kind: 1, data: u8aToHex(decodeAddress(destinationAddress)) };
16876
16879
  const contractArgs = [
16877
16880
  tokenAddress,
16878
16881
  destinationParaId,
16879
- {
16880
- kind: 1,
16881
- data: u8aToHex(decodeAddress(destinationAddress))
16882
- },
16883
- 0n,
16882
+ destination,
16883
+ 10000000000000n,
16884
+ // TODO mjm get from config
16884
16885
  amount
16885
16886
  ];
16887
+ console.log("contractArgs", contractArgs);
16886
16888
  return new ContractConfig({
16887
16889
  address: this.#gatewayAddress,
16888
16890
  abi: GATEWAY_ABI,
@@ -16961,7 +16963,10 @@ var SnowbridgeService = class _SnowbridgeService {
16961
16963
  // src/getTransferData/getBridgeChainData.ts
16962
16964
  import { getBalance, getDestinationFee } from "@moonbeam-network/xcm-sdk";
16963
16965
  import { EvmParachain, Parachain } from "@moonbeam-network/xcm-types";
16964
- import { getMultilocationDerivedAddresses } from "@moonbeam-network/xcm-utils";
16966
+ import {
16967
+ getMultilocationDerivedAddresses,
16968
+ isEthAddress as isEthAddress2
16969
+ } from "@moonbeam-network/xcm-utils";
16965
16970
  import { evmToAddress } from "@polkadot/util-crypto";
16966
16971
  async function getBridgeChainData({
16967
16972
  route,
@@ -16979,6 +16984,7 @@ async function getBridgeChainData({
16979
16984
  sourceAddress,
16980
16985
  destinationAddress
16981
16986
  });
16987
+ console.log("bridgeChain bridgeChainAddress", bridgeChainAddress);
16982
16988
  const fee = await getDestinationFee({
16983
16989
  address: bridgeChainAddress,
16984
16990
  asset: route.source.asset,
@@ -16987,18 +16993,21 @@ async function getBridgeChainData({
16987
16993
  feeAsset: route.mrl.bridgeChain.fee.asset,
16988
16994
  source: route.source.chain
16989
16995
  });
16996
+ console.log("bridgeChain fee", fee);
16990
16997
  const balance = await getBalance({
16991
16998
  address: bridgeChainAddress,
16992
16999
  asset: bridgeChain.getChainAsset(route.mrl.bridgeChain.asset),
16993
17000
  builder: route.mrl.bridgeChain.balance,
16994
17001
  chain: bridgeChain
16995
17002
  });
17003
+ console.log("bridgeChain balance", balance);
16996
17004
  const feeBalance = await getBalance({
16997
17005
  address: bridgeChainAddress,
16998
17006
  asset: bridgeChain.getChainAsset(route.mrl.bridgeChain.fee.asset),
16999
17007
  builder: route.mrl.bridgeChain.fee.balance,
17000
17008
  chain: bridgeChain
17001
17009
  });
17010
+ console.log("bridgeChain feeBalance", feeBalance);
17002
17011
  return {
17003
17012
  address: bridgeChainAddress,
17004
17013
  balance,
@@ -17018,6 +17027,9 @@ function getBridgeChainAddress({
17018
17027
  const isDestinationBridgeChain = bridgeChain.isEqual(destination);
17019
17028
  const isSourceBridgeChain = bridgeChain.isEqual(source);
17020
17029
  let bridgeChainAddress = isDestinationBridgeChain ? destinationAddress : sourceAddress;
17030
+ if (Parachain.isExactly(bridgeChain) && isEthAddress2(bridgeChainAddress)) {
17031
+ bridgeChainAddress = evmToAddress(bridgeChainAddress);
17032
+ }
17021
17033
  if (Parachain.is(source) && !isSourceBridgeChain) {
17022
17034
  const isSourceEvmSigner = EvmParachain.is(source) && source.isEvmSigner;
17023
17035
  const { address20: computedOriginAccount } = getMultilocationDerivedAddresses({