-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
QueuedRequestController: Fix list of methods that should have requests enqueued and/or switch the globally selected network #4066
Merged
Merged
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0f08f89
wip
jiexi cedfd28
Merge branch 'main' into jl/fix-request-queue-switching-too-often
jiexi cd7d8d8
update method list
jiexi 16a618f
lint
jiexi 1e6355f
delete duplicate scenario
jiexi 2eb0ff2
Add specs for new constants
jiexi 908a3a6
add comments to constants
jiexi 3705d8d
lint
jiexi 7d6cb80
Merge branch 'main' into jl/fix-request-queue-switching-too-often
jiexi 9decce6
fix conflict
jiexi d75b97c
Add methodsRequiringNetworkSwitch to QueuedRequestController
jiexi ad8dc07
fix QueuedRequestController specs. DRY builder
jiexi 7043f74
Add methodsWithConfirmation param to QueuedRequestMiddleware
jiexi cf38935
fix QueuedRequestMiddleware specs. DRY builders
jiexi da8a670
remove constants
jiexi 4215f65
update CHANGELOG
jiexi 0f8e411
Merge branch 'main' into jl/fix-request-queue-switching-too-often
jiexi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* This is a list of methods that require the globally selected network | ||
* to match the dapp selected network before being processed. These can | ||
* be for UI/UX reasons where the currently selected network is displayed | ||
* in the confirmation even though it will be submitted on the correct | ||
* network for the dapp. It could also be that a method expects the | ||
* globally selected network to match some value in the request params itself. | ||
*/ | ||
export const methodsRequiringNetworkSwitch = [ | ||
'eth_sendTransaction', | ||
'eth_sendRawTransaction', | ||
'wallet_switchEthereumChain', | ||
'wallet_addEthereumChain', | ||
'wallet_watchAsset', | ||
'eth_signTypedData_v4', | ||
'personal_sign', | ||
]; | ||
|
||
/** | ||
* This is a list of methods that can cause a confirmation to be | ||
* presented to the user. Note that some of these methods may | ||
* only sometimes cause a confirmation to appear. | ||
*/ | ||
export const methodsWithConfirmation = [ | ||
...methodsRequiringNetworkSwitch, | ||
'wallet_requestPermissions', | ||
'wallet_requestSnaps', | ||
'wallet_snap', | ||
'wallet_invokeSnap', | ||
'eth_decrypt', | ||
'eth_sign', | ||
'eth_requestAccounts', | ||
'eth_getEncryptionPublicKey', | ||
]; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Rather than describing these here as constants, perhaps we should accept them as controller or middleware options? The current set of supported methods, and whether each one has a confirmation or not, may differ between platforms. Listing this at the platform layer should let us reuse this list for other functionality as well, and it would perhaps make it less likely we'd forget to update this list after adding a new confirmation.
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.
This would also let us ship it as a non-breaking change, as we could use the existing list as a fallback