react-native-examples icon indicating copy to clipboard operation
react-native-examples copied to clipboard

[bug]: SyntaxError: Non-base16 character

Open jungtaesu opened this issue 2 years ago • 4 comments

Description

image

everything works fine except for respondSessionRequest.

connection great, response, request all good. but with respondSessionRequest, I get that Non-base16 error.

My app signs with hardwallet which worked really well in WalletConnect V1.

what only changed is Libraries and codes for V2.

"@walletconnect/jsonrpc-types": "^1.0.3",
"@walletconnect/react-native-compat": "^2.8.1",
"@walletconnect/web3wallet": "^1.8.0",

this is what I use.

Issue Environment

  • [ ] dapps/v2Explorer
  • [ ] wallets/rn_cli_wallet
  • [ ] wallets/rn_cli_wallet_068_5
  • [ ] wallets/expo_wallet
  • [ ] wallets/web3wallet_tutorial
  • [X] In my own code

Output of npx react-native info

System: OS: macOS 12.2.1 CPU: (8) arm64 Apple M1 Pro Memory: 112.16 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 18.13.0 - /usr/local/bin/node Yarn: 1.22.19 - /opt/homebrew/bin/yarn npm: 8.19.3 - /usr/local/bin/npm Watchman: 2023.06.12.00 - /usr/local/bin/watchman Managers: CocoaPods: Not Found SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: API Levels: 23, 28, 29, 30, 31, 32, 33 Build Tools: 28.0.3, 29.0.2, 30.0.0, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0, 33.0.0, 33.0.1 System Images: android-29 | Intel x86 Atom, android-29 | Google APIs ARM 64 v8a, android-29 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64, android-30 | Google APIs ARM 64 v8a, android-30 | Google Play ARM 64 v8a Android NDK: 22.1.7171670 IDEs: Android Studio: 2022.2 AI-222.4459.24.2221.9971841 Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild Languages: Java: 11.0.15 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.68.1 => 0.68.1 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

IN this web, https://react-dapp-v2-with-ethers.vercel.app/

I do login successfully with my App. and click personal sign, I get response.

but when I sign with my hardwallet, get that error. Jun-19-2023 18-23-20

Snack, code example, screenshot, or link to a repository

case 'personal_sign': console.log( 'oPayload.params.request.params[0].from:', oPayload.params.request.params[0].from, ); $sMessage = fsHexaStringToAsciiString( oPayload.params.request.params[0], ); console.log('$sMessage:', $sMessage); $sDataToSign = hashMessage($sMessage); console.log('$sDataToSign:', $sDataToSign);

    $anDataToSign = fanHexaStringToByteArray($sDataToSign);
    console.log('$anDataToSign:', $anDataToSign);

    $sAddressRequested = oPayload.params.request.params[1];
    console.log('$sAddressRequested:', $sAddressRequested);
    console.log('oState.oMetaStoneInfo:', oState.oMetaStoneInfo);
    if (sAddress.toLowerCase() === $sAddressRequested.toLowerCase()) {
      const anlSignature: number[] | null = await KeyWallet.afanlSign(
        oState.oMetaStoneInfo,
        $anDataToSign,
      );
      // eslint-disable-next-line @typescript-eslint/no-unused-vars
      if (anlSignature !== null) {
        console.log('anlSignature:', anlSignature);
        $sResult = fsByteArrayToHexaString(anlSignature);
      } else {
        $sError = 'KeyWallet sign error';
      }
    } else {
      $sError = 'Address requested does not match active account';
    }
    break;
    
    if (oPayload.params.request.method === 'eth_sendTransaction') {
      await web3Wallet.respondSessionRequest({
        topic: oPayload.topic,
        // response: formatJsonRpcResult(oState.pairedProposal.id, response),
        response: response,
      });
      console.log('sendTransaction response;');
    }

jungtaesu avatar Jun 19 '23 09:06 jungtaesu

still

Turtus avatar Jun 27 '23 11:06 Turtus

@jungtaesu it seems the dapp is receiving a malformed response, but cannot assure it. Can you compare your implementation with this one to see if you notice any difference with your implementation?

Also, can you provide an example repository so we can reproduce the error?

ignaciosantise avatar Jun 27 '23 22:06 ignaciosantise

I have the same problem when trying to disconnect a pairing from my wallet. It only happens when I remove my Wallet (android app) and reinstalling it, with a given pairing/session.

When my dApp (with existing session) is reconnecting to my reinstalled wallet (missing session but existing pairing) the disconnecting function is throwing this error.

Maybe this helps. But I'll upload my dApp tomorrow. The wallet can be found here: https://github.com/consensusmonky/NamiNative/

Sailoshi avatar Jul 13 '23 22:07 Sailoshi

closing this as i couldn't reproduce. Please update to the latest version of web3wallet and if it keeps happening, reach out again with a Minimal Reproducible Example 🙏

ignaciosantise avatar Jul 11 '24 19:07 ignaciosantise