trilitech / tezos-unity-sdk

Tezos Unity SDK for developers. Discover the future of Web3 gaming.
https://tezos.com/unity
MIT License
24 stars 12 forks source link

Silent Wallet Connection? #154

Open DevLaTron opened 9 months ago

DevLaTron commented 9 months ago

I'm having the following issue:

I setup the Users Wallet in Scene 1, then transition to Scene 2. During this Phase, the user may not interact with the Application.

In Scene 2, Wallet information should be displayed if a wallet is connected.

Right now the only way to connect the dapp is by using Connect(), which will now force a URL opening, which will then cause trouble.

My expected Workflow would be:

1) Initialize Tezos SDK 2) Check Beacon Dapp and initialize to check if a wallet is connected 3) Be able to check if wallet connection is availabe and set information, if not continue silently. 4) In next Scene be able to give the user the option to connect a wallet or disconnect a wallet.

In the past a workaround was to surpress the redirect, this option isn't available anymore.

In my opinion, the process of initiating a Handshake should be left to be decided by the Developer, not the SDK.

I may be missing something in the transition to 3.0.0, of course.

DevLaTron commented 9 months ago

Specifically, I think this should be splitable into two Methods optionally:

InitAsyncAndConnect() in BeaconClientManager

oskar-ziller commented 9 months ago

Hi @DevLaTron,

We're currently working on an update that will modify many functions, including OnHandshakeReceived in WalletProvider. This change will make these functions public virtual, allowing developers like yourself to create custom implementations. Do you think this approach would effectively address your needs?

DevLaTron commented 9 months ago

While this would allow me to prevent the dispatch of the "URL call" for devices, I believe the cleaner way would be for me to initiate the handshake on my own or the users interaction at a later stage in the App. My goal is to pre- initialize the Beacon Connection early in the App, but leaving further interaction optional.

Feel free to hit me up on the Tezos Discord if you need more information.

I've added a patch with a workaround for current main to show what I'd need, but it's rather quick and dirty, by simply adding a forcePairing parameter to the InitandConnect Methods.

splitpairingfrominit.txt

oskar-ziller commented 9 months ago

I understand, and I might reach out to you on Discord later. The main reason for the change was that requesting wallet permissions from a different thread than the one receiving the handshake led to some issues. I'm going to delve deeper into this to see if it's still a problem or if there are alternative solutions.

Your suggestion seems similar to the previous approach. If other methods fail, I'll consider implementing a version of it. I believe the handshake event should always occur, though acting on it could be optional. Your approach seems to prevent the event from happening at all. I'll investigate this further. Thanks for all your input and help, and I'm always open to more feedback.