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
102 stars 64 forks source link

Fix: subscription management #764

Closed IsaccoSordo closed 3 months ago

IsaccoSordo commented 3 months ago

This PR addresses multiple instances of failed subscriptions cleanup in Beacon; also there is no need to undergo a big refactor. Namely I found 3 issues:

  1. The Client instance once it had subscribed to the transport, it never cleared its subscriptions. Now we keep track of each subscription and remove each one of them on Client destroy (this needs to be managed on the client instance not on the transport one)
  2. WalletConnectCommunication client never cleared its subscriptions maps when closing the client
  3. Because we are subscribing to WC session events, DAppClient wouldn’t behave correctly while receiving an event (session_update for instance) because our logic assumed that we would have always end up in a one direction flow (one request from the dApp, one response from the Wallet). However, this is no longer true and there is the need to separately acknowledge messages coming from session events.