WalletConnect / walletconnect-monorepo

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

fix: handle multiple event handlers for the same event #4560

Closed schmanu closed 3 months ago

schmanu commented 3 months ago

Description

Currently when calling the Wallet Connect wallet's on function it registers the onSessionProposal handler multiple times in the signClient. This causes each event to be called as many times as there are event handlers registered for the event.

This fix always calls off before calling on when setting the onSessionProposal handler.

Type of change

How has this been tested?

I added a unit test which caught the issue.

Checklist

Additional Information (Optional)

The bug came up while working on https://github.com/safe-global/safe-wallet-web/pull/3656 and the fix is required to unblock it.