Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@yosriady
Copy link
Contributor

@yosriady yosriady commented Aug 13, 2025

Tested and is compatible with:

  • Metamask (100%)
  • Rainbow (50%) -> issue with the wallet itself not following standard wallet APIs
  • Phantom (95%)
  • Rabby (100%)
  • Others will be tested gradually

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.ethereum and a single _provider instance, 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.


Open in Cursor Open in Web

@cursor
Copy link

cursor bot commented Aug 13, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@yosriady yosriady requested a review from Copilot August 13, 2025 10:49
@yosriady
Copy link
Contributor Author

bugbot run

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@yosriady yosriady requested a review from Copilot August 14, 2025 07:04
@yosriady
Copy link
Contributor Author

bugbot run

cursor[bot]

This comment was marked as outdated.

This comment was marked as outdated.

@yosriady
Copy link
Contributor Author

bugbot run

cursor[bot]

This comment was marked as outdated.

@yosriady yosriady requested a review from Copilot August 14, 2025 13:40

This comment was marked as outdated.

@yosriady yosriady requested a review from Copilot August 14, 2025 14:34
@yosriady
Copy link
Contributor Author

bugbot run

cursor[bot]

This comment was marked as outdated.

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@yosriady yosriady requested a review from Copilot August 15, 2025 02:07

This comment was marked as outdated.

@yosriady yosriady changed the title [P-853][P-884][P-904] Fix wallet event listeners for multiple installed wallets [P-853][P-884][P-904] Fix wallet event listeners for multiple installed wallets, expand wallet support Aug 18, 2025
@yosriady yosriady requested a review from Copilot August 18, 2025 09:23
@yosriady
Copy link
Contributor Author

bugbot run

This comment was marked as outdated.

Copy link

@cursor cursor bot left a 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);
}
}

Copy link

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.

Fix in Cursor Fix in Web

@yosriady yosriady changed the title [P-853][P-884][P-904] Fix wallet event listeners for multiple installed wallets, expand wallet support [P-853][P-884][P-904] Fix: Fix wallet event listeners for multiple installed wallets, expand wallet support Aug 18, 2025
@yosriady yosriady changed the title [P-853][P-884][P-904] Fix: Fix wallet event listeners for multiple installed wallets, expand wallet support Fix: Fix wallet event listeners for multiple installed wallets, expand wallet support Aug 18, 2025
this.signature({
status: SignatureStatus.CONFIRMED,
...this.buildSignatureEventPayload(method, params, response, capturedChainId),
});
Copy link

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.

Fix in Cursor Fix in Web

@yosriady yosriady requested a review from Copilot August 18, 2025 09:56
@yosriady
Copy link
Contributor Author

bugbot run

This comment was marked as outdated.

@yosriady yosriady requested a review from Copilot August 18, 2025 11:28
Copy link
Contributor

Copilot AI left a 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.

@yosriady yosriady merged commit a490466 into main Aug 18, 2025
6 checks passed
@yosriady yosriady deleted the cursor/fix-wallet-event-listeners-for-multiple-installed-wallets-419a branch August 18, 2025 11:52
@github-actions
Copy link

🎉 This PR is included in version 1.19.7 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants