MoralisWeb3 / unity-web3-game-kit

Unity Web3 Game Kit is the fastest way to connect and build games for Web3. It provides a single workflow for building high performance dapps. Fully compatible with your favourite platform.
MIT License
533 stars 222 forks source link

WalletConnect Session Fails to Reconnect #92

Closed schwindy closed 2 years ago

schwindy commented 2 years ago

Has anyone had WalletConnect session issues with the Unity Boilerplate?

If I start the app and authorize via QR with MetaMask, all operations including ETH/Token sending work fine.

But if I close the app and re-open it, the WalletConnect session almost never reconnects successfully. I can tell when it fails because it is supposed to ask the wallet to sign when the application launches afaik, and it does "rarely", but most of the time restarting the game does not send a sign request to the wallet, causing the WalletConnect session to be invalid/non-working.

It has forced me to modify the boilerplate to force it to clear the WalletConnect session OnApplicationQuit, so that each time the game is launched the User is prompted to re-scan the QR code aka restart the session. Otherwise, the User is given an experience where they have a Moralis User Session but DO NOT have a valid WalletConnect Session. This means that wallet balances show, but operations like Send ETH/Token do not work. The only way I found to fix this was to clear the session when the game quits and re-authorize via QR scan each time it starts...

Trashing the WalletConnect session OnApplicationQuit by running MainMenuScript.Quit a total of 10 times seems to be a consistent workaround for now. It also prevents a ton of extra MetaMask WalletConnect Sessions from existing. Before I did this, my MM app showed like 50 open sessions to my game. Now, once I close my game, I always have zero open sessions to my game.

The big downside with this is that it forces the player to re-scan their QR code each time they launch. For a VR game, this is more complicated to do...requires us to email them the QR code 🐒 Ideally it would only ask their wallet to sign, of course.

Thank you all for this glorious boilerplate!

xactant commented 2 years ago

Hello and thanks for reporting this.

I have not seen this behavior but will try your steps to see if I can reproduce.

Please let me know which Moralis, and Unity versions, and build targets you are using in your project.

schwindy commented 2 years ago

@xactant We are using Unity version 2020.3.30f1. We also tried using version 2020.3.25f1 when we tried to use 0xProf's project as we were debugging this issue: https://github.com/0xPr0f/Moralis-Unity

We have been using SDK version 1.0.9. I have not tried the latest SDK release yet, but the release notes did not mention any changes to this behavior.

We are building for Windows/Mac/Linux Standalone.

If it helps, here is a short conversation in the Discord regarding this issue: https://discord.com/channels/819584798443569182/922873005170917416/958785737778659389

0xPr0f commented 2 years ago

This is regrading to the inconsistency of wallet connect

KoenRijpstra commented 2 years ago

Fixed in the new 1.2.0 release 🥳

schwindy commented 2 years ago

@KoenRijpstra YAY! This is massive, we will test this ASAP tyvm!