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

Questions about using SDK in React Native #285

Closed judeProground closed 1 year ago

judeProground commented 1 year ago

Describe the bug

  1. I am trying to use the @metamask/sdk in React Native version 0.68, referencing reactNativeDemo. I successfully built it for Android, but when I try to create a MetaMaskSDK object with the following code, I encounter the following error:
MetaMaskSDK error during initialization [Error: Invalid communication protocol]
  1. Additionally, there is a warning as follows. Is there a solution?
    Require cycle: node_modules/react-native-crypto/index.js -> node_modules/react-native-randombytes/index.js -> node_modules/sjcl/sjcl.js -> node_modules/react-native-crypto/index.js

Here's packages I've installed refer to reactNativeDemo

  "dependencies": {
    "@metamask/sdk": "^0.5.3",
    "@react-native-async-storage/async-storage": "^1.18.1",
    "ethers": "5.7.2",
    "node-libs-react-native": "^1.2.1",
    // ... 
    "react-native-background-timer": "^2.4.1",
    "react-native-randombytes": "^3.6.1",
    "react-native-url-polyfill": "^1.3.0"
  },

I apologize for disregarding the template 😅

christopherferreira9 commented 1 year ago

Hi @judeProground ! Can you please try upgrading the ReactNative version you're using to the one we have in the reactNativeDemo project (0.71.7)? Also, do you also get that warning when building the reactNativeDemo project?

judeProground commented 1 year ago

Hi, @christopherferreira9. It seems like I'm encountering an issue possibly due to the React Native version. However, updating current project's RN version might be challenging due to the significant differences in the required changes. For now, I might wait for the metamask-react-native-sdk or explore the option of integrating through WalletConnect. Thank you for the response!

christopherferreira9 commented 1 year ago

Hi @christopherferreira9 , the metamask-react-native-sdk package is still on hold. The reason why we advise users to use 0.71.7 is because the older versions struggle with slow encryption for the initial key exchange. I'll be closing this issue and in the meantime if you need any other assistance, please open a new one.