diff --git a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts index cc912b5113a7..bf8921a8a790 100644 --- a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts +++ b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts @@ -1,12 +1,12 @@ import { isEvmAccountType } from '@metamask/keyring-api'; import { RestrictedControllerMessenger } from '@metamask/base-controller'; -import { AccountsControllerGetSelectedAccountAction } from '@metamask/accounts-controller'; +import { AccountsControllerGetSelectedMultichainAccountAction } from '@metamask/accounts-controller'; import { JsonRpcMiddleware } from '@metamask/json-rpc-engine'; import type { Json, JsonRpcParams } from '@metamask/utils'; import { RestrictedEthMethods } from '../../../shared/constants/permissions'; import { unrestrictedEthSigningMethods } from '../controllers/permissions'; -type AllowedActions = AccountsControllerGetSelectedAccountAction; +type AllowedActions = AccountsControllerGetSelectedMultichainAccountAction; export type EvmMethodsToNonEvmAccountFilterMessenger = RestrictedControllerMessenger< @@ -41,8 +41,13 @@ export default function createEvmMethodsToNonEvmAccountReqFilterMiddleware({ end, ) { const selectedAccount = messenger.call( - 'AccountsController:getSelectedAccount', + 'AccountsController:getSelectedMultichainAccount', ); + if (!selectedAccount) { + // If the account is undefined we just skip this middleware (this should never happen + // since it us the current internal account no matter if it's EVM or not). + return next(); + } // If it's an EVM account, there nothing to filter, so jump to the next // middleware directly. diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 9632e072c70b..bb9a9354dbd9 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -5773,7 +5773,7 @@ export default class MetamaskController extends EventEmitter { createEvmMethodsToNonEvmAccountReqFilterMiddleware({ messenger: this.controllerMessenger.getRestricted({ name: 'EvmMethodsToNonEvmAccountFilterMessenger', - allowedActions: ['AccountsController:getSelectedAccount'], + allowedActions: ['AccountsController:getSelectedMultichainAccount'], }), }), );