airgap-it / beacon-sdk

The beacon sdk allows developers of dApps and wallets on Tezos to implement the wallet interaction standard tzip-10.
https://walletbeacon.io
MIT License
103 stars 65 forks source link

Requests sent to wallet with no name #625

Closed klassare closed 1 year ago

klassare commented 1 year ago

Describe the bug (current behavior) In some states the dapp can send requests to a wallet with no name.

To Reproduce Steps to reproduce the behavior:

  1. Pair with Kukai from the example dapp
  2. Open the example dapp in a 2th tab
  3. Click "reset & refresh" in the 2th tab
  4. Go back to the 1st tab and send a request

Expected (correct) behavior It should show an error message if there is no connection with the wallet anymore.

Screenshots and/or logs

Skärmavbild 2023-10-18 kl  17 03 18

Environment

Additional context Branch: feat/transport-kukai-wc2

IsaccoSordo commented 1 year ago

Hi @klassare, the issue was caused by an internal signClient state misalignment with localStorage. Namely if you have two DApps, let's say A and B, if you first sync with A and then you reset&refresh with B (note with this action you are clearing storage entries) signClient in A won't notice those changes and therefore a subsequent call to signClient.session.getAll() and signClient.pairing.getAll() will return the old (and now discarded) sessions/pairings With one of the changes inside #612, we now give more importance to the values stored inside the storage rather than signClient. Relevant lines of code:

  1. DAppClient.ts#L1751-#L1752
  2. WalletConnectTransport.ts#L67-#L81