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

Session update not working #618

Closed klassare closed 1 year ago

klassare commented 1 year ago

Describe the bug (current behavior) Session updates are not always handled by Beacon

To Reproduce Steps to reproduce the behavior:

  1. Pair with Kukai from the example dapp
  2. Refresh the example dapp
  3. Change account in Kukai for the active session

Expected (correct) behavior Session update should be handled correctly

Environment

Additional context Branch: feat/transport-kukai-wc2

IsaccoSordo commented 1 year ago

Hi @klassare, the issue was caused by the fact that the transports weren't listening to messages immediately after the init phase. Before #644 we loaded all the transports lazily, in other words whenever a function got executed (requestPermissions, signPayload etc...) then, and only then, the transports would have been initialised. What happens now is that we eagerly initialise the transport whenever an account is loaded from localStorage and the transport is not p2p. Relevant lines of code: DAppClient.ts#L377-#L383