-
-
Notifications
You must be signed in to change notification settings - Fork 273
feat: make wallet_sendCalls more reliable
#7816
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: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import type { KeyringTypes } from '@metamask/keyring-controller'; | ||
| import { JsonRpcError, rpcErrors } from '@metamask/rpc-errors'; | ||
| import { JsonRpcError, providerErrors, rpcErrors } from '@metamask/rpc-errors'; | ||
| import type { | ||
| BatchTransactionParams, | ||
| IsAtomicBatchSupportedResultEntry, | ||
|
|
@@ -47,6 +47,7 @@ export type ProcessSendCallsHooks = { | |
| request: ValidateSecurityRequest, | ||
| chainId: Hex, | ||
| ) => Promise<void>; | ||
| getPermittedAccountsForOrigin: () => Promise<Hex[]>; | ||
| /** Function to validate if auxiliary funds capability is supported. */ | ||
| isAuxiliaryFundsSupported: (chainId: Hex) => boolean; | ||
| }; | ||
|
|
@@ -82,6 +83,7 @@ export async function processSendCalls( | |
| getDismissSmartAccountSuggestionEnabled, | ||
| isAtomicBatchSupported, | ||
| validateSecurity: validateSecurityHook, | ||
| getPermittedAccountsForOrigin, | ||
| isAuxiliaryFundsSupported, | ||
| } = hooks; | ||
|
|
||
|
|
@@ -94,9 +96,13 @@ export async function processSendCalls( | |
| networkClientId, | ||
| ).configuration; | ||
|
|
||
| const from = | ||
| paramFrom ?? | ||
| (messenger.call('AccountsController:getSelectedAccount').address as Hex); | ||
| // The first account returned by `getPermittedAccountsForOrigin` is the selected account for the origin | ||
| const [selectedAccount] = await getPermittedAccountsForOrigin(); | ||
| const from = paramFrom ?? selectedAccount; | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sender selection relies on account orderingHigh Severity When |
||
| if (!from) { | ||
| throw providerErrors.unauthorized(); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unneeded accounts lookup can break sendCallsMedium Severity
|
||
|
|
||
| const securityAlertId = uuid(); | ||
| const validateSecurity = validateSecurityHook.bind(null, securityAlertId); | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.