diff --git a/src/ui/views/Approval/components/SignTypedDataExplain/parseSignTypedDataMessage.ts b/src/ui/views/Approval/components/SignTypedDataExplain/parseSignTypedDataMessage.ts index 80504fc682b..47df5c13b8b 100644 --- a/src/ui/views/Approval/components/SignTypedDataExplain/parseSignTypedDataMessage.ts +++ b/src/ui/views/Approval/components/SignTypedDataExplain/parseSignTypedDataMessage.ts @@ -6,6 +6,18 @@ export const parseSignTypedDataMessage = (raw: string) => { } const { primaryType, message, types } = data; + return filterPrimaryType({ primaryType, types, message }); +}; + +export const filterPrimaryType = ({ + primaryType, + types, + message, +}: { + primaryType: string; + types: Record; + message: Record; +}) => { const keys = types[primaryType]; const filteredMessage: Record = {}; diff --git a/src/ui/views/Approval/components/TypedDataActions/utils.ts b/src/ui/views/Approval/components/TypedDataActions/utils.ts index b2f912355d4..a580bda51f0 100644 --- a/src/ui/views/Approval/components/TypedDataActions/utils.ts +++ b/src/ui/views/Approval/components/TypedDataActions/utils.ts @@ -5,6 +5,7 @@ import { encodeSingle } from '@metamask/eth-sig-util'; import { bufferToHex } from 'ethereumjs-util'; import { hexToString } from 'web3-utils'; import BigNumber from 'bignumber.js'; +import { filterPrimaryType } from '../SignTypedDataExplain/parseSignTypedDataMessage'; export const getActionTypeText = (data: ParsedTypedDataActionData | null) => { const { t } = i18n; @@ -149,5 +150,12 @@ function parseSignTypedData(typedData: { typedData.message = parseAndDecode(message, primaryType); + // Filter out the fields that are not part of the primary type + typedData.message = filterPrimaryType({ + primaryType, + types, + message: typedData.message, + }); + return typedData; }