WalletConnect / walletconnect-monorepo

WalletConnect Monorepo
Apache License 2.0
1.3k stars 650 forks source link

fix: process incoming requests in order #4638

Closed ganchoradkov closed 2 months ago

ganchoradkov commented 3 months ago

Description

Updated intake logic of incoming relay messages so they are processed by Sign Client one by one instead of all at the same time. The old approach was resulting in conflicts when messages were dependent on each other such as session_update adding new chain to the session and session_eventinstructing the client to switch to that new chain. In the above case, the session_event must be processed after the session_update has finished the update, else the client has no knowledge of that new chain.

Additionally, implemented relayMessageCache that stores any messages received while the client is still initializing and the messages are processed after init has finished. This allows implementing apps to setup all event listeners and not miss events

Type of change

How has this been tested?

dogfooding

Checklist

Additional Information (Optional)

Please include any additional information that may be useful for the reviewer.

ganchoradkov commented 2 months ago

Are all tests passing ? Should we add unhappy path cases ?

Not sure how to slow down the client and force the behaviour thus has been manually dogfooded. Will tinker @Cali93