MetaMask / metamask-sdk

The simplest yet most secure way to connect your blockchain-based applications to millions of MetaMask Wallet users.
https://metamask.io/sdk/
Other
165 stars 101 forks source link

react-native ReferenceError: Property 'MessageEvent' doesn't exist, js engine: hermes #77

Closed ugened47 closed 1 year ago

ugened47 commented 1 year ago

Describe the bug

Hi! I'm having a problem while connecting my RN dapp to metamask-mobile stoped working with sdk 0.1.0 after client has automatically updated to 6.3.0 from store and I believe upgrade sdk to 0.2.0 can help me in this situation. However, upgrading sdk version from 0.1.0 to 0.2.0 react native crashes with message: ReferenceError: Property 'MessageEvent' doesn't exist, js engine: hermes

To Reproduce Steps to reproduce the behaviour:

  1. Upgrade @metamask/sdk from 0.1.0 to 0.2.0
  2. See error

Expected behaviour Works without problems

Screenshots telegram-cloud-photo-size-2-5337172846343999719-y

Provide environment information

abretonc7s commented 1 year ago

Hi @ugened47 , could you please try to update sdk to 0.2.0 ? We have an example of integration in https://github.com/MetaMask/metamask-sdk/tree/main/packages/examples/reactNativeTSApp and a new PR will soon be merged with more updated examples.

ugened47 commented 1 year ago

Hi @ugened47 , could you please try to update sdk to 0.2.0 ? We have an example of integration in https://github.com/MetaMask/metamask-sdk/tree/main/packages/examples/reactNativeTSApp and a new PR will soon be merged with more updated examples.

Sorry, I could be misleading. The above error occurs with @metamask/sdk 0.2.0.

abretonc7s commented 1 year ago

Thanks for reporting the issue, we r looking at it and will publish a fix asap.

ardasatata commented 1 year ago

any news?

prtk418 commented 1 year ago

Facing the same issue, @abretonc7s any updates on this?

andreahaku commented 1 year ago

we should be able to update the SDK to fix those RN related issues later today or tomorrow. We'll let you know when the updated version will be available on npm. Thanks

abretonc7s commented 1 year ago

Hi @ugened47 , sdk version 0.2.2 has been published as well as the examples dapp to work with latest RN version.

prtk418 commented 1 year ago

@abretonc7s Just to confirm - Is this the updated doc for integration - https://docs.metamask.io/wallet/how-to/use-sdk/react-native/

ardasatata commented 1 year ago

@abretonc7s Just to confirm - Is this the updated doc for integration - https://docs.metamask.io/wallet/how-to/use-sdk/react-native/

It's still the old 0.1.0 example tho, you can find the new example in the repo itself here: https://github.com/MetaMask/metamask-sdk/tree/main/packages/examples/reactNativeDemo

prtk418 commented 1 year ago

@abretonc7s Just to confirm - Is this the updated doc for integration - https://docs.metamask.io/wallet/how-to/use-sdk/react-native/

It's still the old 0.1.0 example tho, you can find the new example in the repo itself here: https://github.com/MetaMask/metamask-sdk/tree/main/packages/examples/reactNativeDemo

Thanks for sharing this, is there an updated document where I can check about integration in already running app

ugened47 commented 1 year ago

@abretonc7s Thank you. This error is gone. However started facing other bugs after upgrading to 0.2.2.

i.e. this piece of code stopped working:

  await ethereum.request({ method: 'eth_requestAccounts' });

  const signer = provider.getSigner();

  const { chainId } = await provider.getNetwork();

    if (chainId === EthereumChainId) {
     const ObjectERC20 = new ethers.Contract(
       Config.ERC20_ADDRESS_OBJECT,
       ABI_ERC20_GOERLI,
       signer
    );
    return ObjectERC20;
    ...

Interaction stops on getNetwork() call. Nothing returned back, neither value nor error, so now not able to process any interactions with contracts.