-
Notifications
You must be signed in to change notification settings - Fork 62
feat: unite connection requests #1923
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
base: master
Are you sure you want to change the base?
feat: unite connection requests #1923
Conversation
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.
Main issue I noticed was a few new failing unit tests. You should be able to run those locally with yarn test
to debug. Trying to understand more about the resolver concept here as well
Here is the failing test logs: https://github.com/rainbow-me/browser-extension/actions/runs/16313515910/job/46074063502?pr=1923
@@ -20,7 +20,7 @@ echo "Anvil Launched..." | |||
|
|||
# Run the tests and store the result | |||
echo "Running Tests..." | |||
NODE_OPTIONS='--no-experimental-fetch' vitest |
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.
I can't recall exactly why we adopted this, but this conflicts with amockFetch
injection; this could have changed since node v18
}, | ||
removePendingRequest: (id) => { | ||
const pendingRequests = get().pendingRequests; | ||
set({ | ||
pendingRequests: pendingRequests.filter((request) => request.id !== id), | ||
}); | ||
}, | ||
addConnectionResolver: (host, resolver) => { |
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.
Can you add some notes about the resolver paradigm used here? Trying to wrap my head around the goal.
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.
added some in code comments :) Basically it's needed to allow multiple connect requests to resolve when one dialog gets accepted/declined
}); | ||
}; | ||
|
||
const resolveConnectionRequestsIfNeeded = ( |
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.
Is there any duplicative implementation between this concept and handleTabAndWindowUpdates
? We attach to the window/tab listeners there for things like expiry
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.
helped me to prevent some memory leaks, thanks
but in general I think it's not the same concept
tabId -> popups/requests
vs
popup/request -> inpage request resolvers
|
Fixes BX-1802
What changed
If the same tab with the same host sends 2 or more connection requests, we just focus the existing approve window and resolve all requests based on that
What to test
Try to break the connection flow with any dapp, try to connect multiple times on the same host and tab, and same host in 2 different tabs etc
PR-Codex overview
This PR enhances the handling of connection requests in the application, specifically targeting the
eth_requestAccounts
method. It introduces deduplication for connection requests from the same host and improves the management of pending requests and connection resolvers.Detailed summary
NODE_OPTIONS
setting when running tests.getSenderHost
andgetTabIdString
utility functions.handleTabAndWindowUpdates
to clean up pending requests and resolve connection requests.addPendingRequest
to prevent duplicates from the same host and tab.messengerProviderRequest
to handle existing requests and connection resolution.