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
101 stars 65 forks source link

Duplicate wc2 event listeners #758

Closed klassare closed 4 months ago

klassare commented 5 months ago

Describe the bug (current behavior) Duplicate (or more) event listeners are set up when a dapp is opened in more than one tab. Resulting in ACTIVE_ACCOUNT_SET being emitted multiple times.

To Reproduce Steps to reproduce the behavior:

  1. Go to the example dapp
  2. Connect with Kukai using the wc2 transport and approve the permission request
  3. open the example dapp in a 2th tab
  4. do an account change from the wallet

Expected (correct) behavior ACTIVE_ACCOUNT_SET should only be emitted once

Additional context Subscriptions can be set up twice in refreshState(). Directly and indirectly via getSignClient()

IsaccoSordo commented 5 months ago

Hi @klassare, The issue was caused by our cleanup logic. Because of refreshState some uncleared subscriptions were triggered again upon receiving an event.

IsaccoSordo commented 5 months ago

Hi @klassare, the cleanup should now be correctly handled. You can see the changes in #764

IsaccoSordo commented 4 months ago

The fix has been included in v4.2.2