HyperPlay-Gaming / hyperplay-desktop-client

The HyperPlay desktop app
https://hyperplay.xyz
GNU General Public License v3.0
70 stars 27 forks source link

eth_sign JSON-RPC method returns error #304

Closed awantoch closed 1 year ago

awantoch commented 1 year ago

Describe the bug

When calling the eth_sign RPC method, with an example payload like:

{
   "request":{
      "method":"eth_sign"
   },
   "chain":{
      "chainId":"1"
   },
   "params": [
       "0xA5917Aecb8d4cF513B9087aB4058d221Cb5c5022",
       "localhost wants you to sign in with your Ethereum account:\n0xA5917Aecb8d4cF513B9087aB4058d221Cb5c5022\n\nThis is a test statement.\n\nURI: https://localhost:3000\nVersion: 1\nChain ID: 1\nNonce: yx3hiXuPSvFf4dAbc\nIssued At: 2023-05-05T21:02:27.202Z"
   ]
}

The following error is returned:

{
    "message": "{\"code\":-32603,\"message\":\"Cannot read properties of undefined (reading '0')\",\"data\":{\"originalError\":{}}}"
}

Add logs

(12:47:58) INFO: [Legendary]: Refreshing library... (12:47:58) INFO: [Backend]: Loading MetaMask extension (12:47:58) INFO: [Connection]: Connectivity: check-online (12:47:58) INFO: [Connection]: Pinging external endpoints (12:47:58) INFO: [Backend]: Creating abort controller for legendary-version (12:47:58) INFO: [Legendary]: Running command: /Applications/HyperPlay.app/Contents/Resources/app.asar.unpacked/build/bin/darwin/legendary --version (12:47:58) INFO: [Legendary]: Legendary location: /Applications/HyperPlay.app/Contents/Resources/app.asar.unpacked/build/bin/darwin/legendary (12:47:58) INFO: [Gog]: GOGDL location: /Applications/HyperPlay.app/Contents/Resources/app.asar.unpacked/build/bin/darwin/gogdl (12:47:58) INFO: [Gog]: GOGDL location: /Applications/HyperPlay.app/Contents/Resources/app.asar.unpacked/build/bin/darwin/gogdl (12:47:58) WARNING: [Backend]: Protocol already registered. (12:47:58) INFO: [Backend]: App is starting in headless mode = undefined isCLINoGui = false startInTray = undefined (12:47:58) INFO: [Backend]: MetaMask extension loaded (12:47:58) INFO: [Connection]: Connectivity: online (12:47:58) INFO: [Backend]: User Not Found, removing it from Store (12:47:58) INFO: [Backend]: Auto Updater found version: 0.1.0 released on 2023-04-18T08:52:11.048Z with name Version 0.1.0 Alpha (12:47:59) INFO: [Backend]: Loading Screen Ready (12:47:59) INFO: [Backend]: Frontend Ready (12:47:59) INFO: [Frontend]: Refreshing Library (12:47:59) INFO: [Frontend]: No cache found, getting data from legendary... (12:47:59) INFO: [Legendary]: Refreshing library... (12:47:59) WARNING: [Backend]: listUpdateableGames not implemented on HyperPlay Library Manager (12:47:59) WARNING: [Backend]: listUpdateableGames not implemented on Sideload Library Manager (12:47:59) INFO: [Gog]: Found 0 game(s) to update (12:48:00) INFO: [Backend]: Deleting abort controller for legendary-version (12:48:00) INFO: [Backend]: Creating abort controller for gogdl-version (12:48:00) INFO: [Gog]: Running command: /Applications/HyperPlay.app/Contents/Resources/app.asar.unpacked/build/bin/darwin/gogdl --version (12:48:02) INFO: [Backend]: Deleting abort controller for gogdl-version (12:48:03) INFO: [Backend]:

HyperPlay Version: 0.1.0 Legendary Version: 0.20.32 Dark Energy (hotfix #6) GOGdl Version: 0.6 OS: macOS Ventura 13.3.1 KERNEL: 22.4.0 ARCH: arm64 CPU: Apple M1 Pro @2.4 RAM: Total: 32 GiB Available: 22.35 GiB GRAPHICS: GPU0: Apple M1 Pro

(12:48:04) INFO: [Backend]: Starting the Download Queue

Steps to reproduce

  1. Go to '...'
  2. Click on '...'
  3. Scroll down to '...'
  4. See error

Expected behavior

  1. Connect to localhost:9680/rpc server via http client
  2. Pass SIWE message signature request using the SIWE JSON-RPC call & payload
  3. Signature request popup should appear in MetaMask via HyperPlay
  4. Signature should be sent back to the calling client

Screenshots

No response

hyperplay Version

Latest Stable

System Information

Additional information

No response

BrettCleary commented 1 year ago

params should be inside the request object. eth_sign has to be enabled in metamask advanced settings as well.

it's also recommended to use eth_signTypedData_v3 instead of eth_sign if possible too. metamask will show warnings with eth_sign. be sure to replace 0xC1267CE68a966482e742EEba62f58402243A5767 with the currently connected metamask account too

here's a working example @awantoch

curl -H "content-type:application/json" -X POST -d "{\"request\":{\"method\":\"eth_sign\",\"params\":[\"0xC1267CE68a966482e742EEba62f58402243A5767\", \"0xC1267CE68a966482e742EEba62f58402243A576758402243A576757675840224\"]},\"chain\":{\"chainId\":\"5\"}}" http://localhost:9680/rpc
awantoch commented 1 year ago

Turns out this is a non-issue for the following reasons:

A correct call looks like the following:


{
   "request":{
      "method":"personal_sign",
      "params": [
       "message_request_here",
       "0xDE31A8E636E1222E736ff0Fe7e4e95aCb0018C6E"
    ]
   },
   "chain":{
      "chainId":"1"
   }
}