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

[Bug]: "@metamask/sdk-react": "^0.14.1" connectivity error in react native #596

Closed pratul-mindfire closed 7 months ago

pratul-mindfire commented 8 months ago

SDK

React-Native

Provide environment information

"@metamask/sdk-react": "^0.14.1", "@react-native-async-storage/async-storage": "^1.21.0", "eciesjs": "^0.4.6", "ethers": "^5.7.2", "node-libs-react-native": "^1.2.1", "react": "18.2.0", "react-native": "0.73.1", "react-native-background-timer": "^2.4.1", "react-native-get-random-values": "^1.10.0", "react-native-randombytes": "^3.6.1", "react-native-url-polyfill": "^2.0.0"

MetaMask SDK Version

"@metamask/sdk-react": "^0.14.1",

MetaMask Mobile app Version

7.12.2

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

I am trying to use "@metamask/sdk-react": "^0.14.1", lib in react native cli 1703074264105 but i am getting this error -

Error: While trying to resolve module @metamask/sdk-react from file /Users/pratul/Desktop/MyProject/App.tsx, the package /Users/pratul/Desktop/MyProject/node_modules/@metamask/sdk-react/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/Users/pratul/Desktop/MyProject/node_modules/@metamask/sdk-react/index. Indeed, none of these files exist:

Expected Behavior

I should work in react native cli and user can connect to metamask.

Note - i also tried to run your demo example app - https://github.com/MetaMask/metamask-sdk/tree/main/packages/examples/reactNativeDemo , but i also get same error 1703074264105

Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

No response

To Reproduce

interate "@metamask/sdk-react": "^0.14.1", lib in react native cli and run the app

Cognacy commented 8 months ago

Hi @pratul-mindfire are you able to resolve this error?

sheepmiee commented 8 months ago

Copying the file "index.js" from sdk-react -> dist -> esm directory to the sdk-react folder can temporarily solve this issue

pratul-mindfire commented 8 months ago

@sheepmiee thanks for your response, i got rid of this error but there is an issue that web socket connection breaks automatically and the application behave in random manners(e.g.- sometime we send the transaction but it will not open confirm bottomsheet in metamask app and somtime it works). Some time we call the connect method it open the metamask app but it does not show the connect button and sometime it works IMG-20231221-WA0010

pratul-mindfire commented 8 months ago

@sheepmiee How could I get information when this will be resolved from Metamask team? Can you please drop a message here in this issue as it will be open?

andreahaku commented 8 months ago

@pratul-mindfire @sheepmiee this should be solved with the next update as there's already a fix for it. In the meantime, can you please try with the Expo example here as it should be fixed there.

NoisyBoyII commented 8 months ago

@andreahaku @pratul-mindfire I am trying the expo example but its not running getting error "Bundle URL not present" .. try to run device iPhone 11.. may be some issue ... will check again

omridan159 commented 8 months ago

@NoisyBoyII @pratul-mindfire

The issue has been addressed and resolved in the following Pull Request: https://github.com/MetaMask/metamask-sdk/pull/614.

Please attempt to run it again now, as it should now be functioning correctly.

christopherferreira9 commented 7 months ago

Closing this issue as it was already fixed in https://github.com/MetaMask/metamask-sdk/pull/614