-
Notifications
You must be signed in to change notification settings - Fork 0
Fix: Fix wallet event listeners for multiple installed wallets, expand wallet support #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Fix wallet event listeners for multiple installed wallets, expand wallet support #113
Conversation
Co-authored-by: yosriady <[email protected]>
|
Cursor Agent can help with this pull request. Just |
|
bugbot run |
Co-authored-by: yosriady <[email protected]>
Co-authored-by: yosriady <[email protected]>
|
bugbot run |
Co-authored-by: yosriady <[email protected]>
|
bugbot run |
Co-authored-by: yosriady <[email protected]>
Co-authored-by: yosriady <[email protected]>
|
bugbot run |
Co-authored-by: yosriady <[email protected]>
…acking Co-authored-by: yosriady <[email protected]>
Co-authored-by: yosriady <[email protected]>
|
bugbot run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Bugbot reviewed your changes and found no bugs!
| this._providerInstances.add(provider); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Provider Deduplication Fails in Subscription Callback
The provider deduplication logic in the store.subscribe callback could lead to duplicate entries in the _providers array. The code adds providers to _providers without checking if they already exist there, only checking against _seenProviders. Since these data structures could become out of sync (e.g., if _providers is modified elsewhere but _seenProviders isn't updated accordingly), the same provider could be added multiple times to _providers array.
src/FormoAnalytics.ts
Outdated
| this.signature({ | ||
| status: SignatureStatus.CONFIRMED, | ||
| ...this.buildSignatureEventPayload(method, params, response, capturedChainId), | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Signature Tracking Misidentifies Falsy Responses
Signature confirmation tracking now reports any response as CONFIRMED, including falsy values. The if (response) check was removed, which can lead to inaccurate analytics where failed or cancelled signatures (e.g., for personal_sign or eth_signTypedData_v4 methods) are incorrectly marked as confirmed.
|
bugbot run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements EIP-6963 multi-provider support to enable reliable wallet event handling when multiple wallets are installed. The primary change refactors the wallet provider system from relying on a single window.ethereum provider to tracking multiple providers individually, ensuring proper event attribution and preventing missed events.
Key changes:
- Refactored provider tracking to support multiple EIP-6963 compatible wallets with per-provider event listeners
- Added fallback mechanisms for injected providers and improved provider detection logic
- Enhanced error handling and validation throughout the wallet interaction flow
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types/provider.ts | Added symbols and interfaces for wrapped request function tracking |
| src/types/events.ts | Made chainId and address optional in DisconnectAPIEvent for better event handling |
| src/lib/event/EventFactory.ts | Updated generateDisconnectEvent to accept optional parameters |
| src/initialization.ts | Removed type assertion for window.formo assignment |
| src/index.ts | Removed type assertion for window.formofy assignment |
| src/constants/base.ts | Added default provider icon constant |
| src/FormoAnalytics.ts | Major refactor implementing EIP-6963 multi-provider support with comprehensive provider tracking |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
🎉 This PR is included in version 1.19.7 🎉 |
Tested and is compatible with:
Implement EIP-6963 multi-provider support to ensure wallet events (connect, disconnect, chain change) fire reliably when multiple wallets are installed.
The previous implementation primarily relied on
window.ethereumand a single_providerinstance, which caused events to be missed or incorrectly attributed when multiple EIP-6963 compatible wallets were present. This change refactors event listening and request wrapping to operate on a per-provider basis, dynamically selecting the active provider based on the event source.