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
[ ] Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
[x] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Draft PR (breaking/non-breaking change which needs more work for having a proper functionality [Mark this PR as ready to review only when completely ready])
[ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
How has this been tested?
I added a unit test which caught the issue.
Checklist
[x] I have performed a self-review of my own code
[x] My changes generate no new warnings
[x] Any dependent changes have been merged and published in downstream modules
Description
Currently when calling the Wallet Connect wallet's
on
function it registers theonSessionProposal
handler multiple times in thesignClient
. 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 callingon
when setting theonSessionProposal
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.