diff --git a/.storybook/images/icons/info.svg b/.storybook/images/icons/info.svg new file mode 100644 index 000000000000..929561d16a83 --- /dev/null +++ b/.storybook/images/icons/info.svg @@ -0,0 +1,3 @@ + + + diff --git a/.storybook/images/icons/question.svg b/.storybook/images/icons/question.svg new file mode 100644 index 000000000000..a8ba55cd769d --- /dev/null +++ b/.storybook/images/icons/question.svg @@ -0,0 +1,3 @@ + + + diff --git a/.storybook/main.js b/.storybook/main.js index 2a48b3b88654..3c67bb2b5ce1 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -26,6 +26,10 @@ module.exports = { '@storybook/addon-designs', ], staticDirs: ['../app', './images'], + env: (config) => ({ + ...config, + ENABLE_CONFIRMATION_REDESIGN: true, + }), // Uses babel.config.js settings and prevents "Missing class properties transform" error babel: async (options) => ({ overrides: options.overrides, diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 1c0491a9e812..bff9a724c2d4 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -912,6 +912,12 @@ "confirmConnectionTitle": { "message": "Confirm connection to $1" }, + "confirmFieldPaymaster": { + "message": "Fee paid by" + }, + "confirmFieldTooltipPaymaster": { + "message": "The fee for this transaction will be paid by the paymaster smart contract." + }, "confirmPassword": { "message": "Confirm password" }, diff --git a/test/data/confirmations/contract-interaction.ts b/test/data/confirmations/contract-interaction.ts index dd0500bbaec2..55bcb4b26ad0 100644 --- a/test/data/confirmations/contract-interaction.ts +++ b/test/data/confirmations/contract-interaction.ts @@ -4,6 +4,9 @@ import { } from '@metamask/transaction-controller'; import { Confirmation } from '../../../ui/pages/confirmations/types/confirm'; +export const PAYMASTER_AND_DATA = + '0x9d6ac51b972544251fcc0f2902e633e3f9bd3f2900000000000000000000000000000000000000000000000000000000666bfd410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003498a76eb88b702e5e52b00fbc16a36baf89ebe3e0dd23170949cffc0a623011383cced660ff67930308c22e5aa746a2d586629ddbd87046a146225bf80e9d6f1b'; + export const CONTRACT_INTERACTION_SENDER_ADDRESS = '0x2e0d7e8c45221fca00d74a3609a0f7097035d09b'; diff --git a/ui/components/app/confirm/info/__snapshots__/info.test.tsx.snap b/ui/components/app/confirm/info/__snapshots__/info.test.tsx.snap index 1054ecabe66a..a257e3ee3fa8 100644 --- a/ui/components/app/confirm/info/__snapshots__/info.test.tsx.snap +++ b/ui/components/app/confirm/info/__snapshots__/info.test.tsx.snap @@ -77,7 +77,7 @@ exports[`ConfirmInfo should match snapshot 1`] = `
`; diff --git a/ui/components/app/confirm/info/row/__snapshots__/section.test.tsx.snap b/ui/components/app/confirm/info/row/__snapshots__/section.test.tsx.snap new file mode 100644 index 000000000000..8f48917bd4f3 --- /dev/null +++ b/ui/components/app/confirm/info/row/__snapshots__/section.test.tsx.snap @@ -0,0 +1,21 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ConfirmInfoSection should match snapshot 1`] = ` +
+
+ Test Content +
+
+`; + +exports[`ConfirmInfoSection should match snapshot without padding 1`] = ` +
+
+ Test Content +
+
+`; diff --git a/ui/components/app/confirm/info/row/alert-row/alert-row.stories.tsx b/ui/components/app/confirm/info/row/alert-row/alert-row.stories.tsx index b3d64ac65651..c6b9a3664375 100644 --- a/ui/components/app/confirm/info/row/alert-row/alert-row.stories.tsx +++ b/ui/components/app/confirm/info/row/alert-row/alert-row.stories.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { ConfirmInfoRowVariant } from '../row'; -import { AlertRow } from './alert-row'; +import { ConfirmInfoAlertRow } from './alert-row'; import configureStore from '../../../../../../store/store'; import { Provider } from 'react-redux'; import { Meta } from '@storybook/react'; @@ -41,7 +41,7 @@ const storeMock = configureStore({ const ConfirmInfoRowStory = { title: 'Components/App/Confirm/AlertRow', - component: AlertRow, + component: ConfirmInfoAlertRow, argTypes: { variant: { control: 'select', @@ -55,9 +55,9 @@ const ConfirmInfoRowStory = { }, }, decorators: [(story) => {story()}], -} as Meta; +} as Meta; -export const DefaultStory = (args) => ; +export const DefaultStory = (args) => ; DefaultStory.storyName = 'Default'; diff --git a/ui/components/app/confirm/info/row/alert-row/alert-row.test.tsx b/ui/components/app/confirm/info/row/alert-row/alert-row.test.tsx index 968c4238509a..f539326a9284 100644 --- a/ui/components/app/confirm/info/row/alert-row/alert-row.test.tsx +++ b/ui/components/app/confirm/info/row/alert-row/alert-row.test.tsx @@ -5,7 +5,7 @@ import { Text } from '../../../../../component-library'; import { renderWithProvider } from '../../../../../../../test/lib/render-helpers'; import { Severity } from '../../../../../../helpers/constants/design-system'; import mockState from '../../../../../../../test/data/mock-state.json'; -import { AlertRow, AlertRowProps } from './alert-row'; +import { ConfirmInfoAlertRow, ConfirmInfoAlertRowProps } from './alert-row'; const onProcessActionMock = jest.fn(); @@ -36,7 +36,7 @@ describe('AlertRow', () => { }, ]; const renderAlertRow = ( - props?: Partial, + props?: Partial, state?: Record, ) => { const STATE_MOCK = { @@ -60,7 +60,7 @@ describe('AlertRow', () => { const mockStore = configureMockStore([])(STATE_MOCK); return renderWithProvider( - value} ownerId={OWNER_ID_NO_ALERT_MOCK} diff --git a/ui/components/app/confirm/info/row/alert-row/alert-row.tsx b/ui/components/app/confirm/info/row/alert-row/alert-row.tsx index ef84818904ad..919f77286233 100644 --- a/ui/components/app/confirm/info/row/alert-row/alert-row.tsx +++ b/ui/components/app/confirm/info/row/alert-row/alert-row.tsx @@ -13,7 +13,7 @@ import { import { Box } from '../../../../../component-library'; import { MultipleAlertModal } from '../../../../alert-system/multiple-alert-modal'; -export type AlertRowProps = ConfirmInfoRowProps & { +export type ConfirmInfoAlertRowProps = ConfirmInfoRowProps & { alertKey: string; ownerId: string; }; @@ -36,12 +36,12 @@ function getAlertTextColors( } } -export const AlertRow = ({ +export const ConfirmInfoAlertRow = ({ alertKey, ownerId, variant, ...rowProperties -}: AlertRowProps) => { +}: ConfirmInfoAlertRowProps) => { const { getFieldAlerts } = useAlerts(ownerId); const fieldAlerts = getFieldAlerts(alertKey); const hasFieldAlert = fieldAlerts.length > 0; diff --git a/ui/components/app/confirm/info/row/divider.tsx b/ui/components/app/confirm/info/row/divider.tsx index cc2c1ac70e2a..98c09840f4bb 100644 --- a/ui/components/app/confirm/info/row/divider.tsx +++ b/ui/components/app/confirm/info/row/divider.tsx @@ -6,6 +6,9 @@ export const ConfirmInfoRowDivider: React.FC = () => { style={{ height: '1px', backgroundColor: 'var(--color-border-muted)', + // Ignore the padding from the section. + marginLeft: '-8px', + marginRight: '-8px', }} >
); diff --git a/ui/components/app/confirm/info/row/section.stories.tsx b/ui/components/app/confirm/info/row/section.stories.tsx new file mode 100644 index 000000000000..8ce7be068ffb --- /dev/null +++ b/ui/components/app/confirm/info/row/section.stories.tsx @@ -0,0 +1,55 @@ +import React from 'react'; +import { ConfirmInfoSection } from './section'; +import { ConfirmInfoRow } from './row'; +import { ConfirmInfoRowText } from './text'; + +const ConfirmInfoSectionStory = { + title: 'Components/App/Confirm/InfoSection', + component: ConfirmInfoSection, + + decorators: [ + (story) => ( +
+ {story()} +
+ ), + ], + + argTypes: { + noPadding: { + control: 'boolean', + }, + }, +}; + +export const DefaultStory = (args) => ( + <> + + + + + + + + + + + + + + + + + +); + +DefaultStory.args = { + noPadding: false, +}; + +export default ConfirmInfoSectionStory; diff --git a/ui/components/app/confirm/info/row/section.test.tsx b/ui/components/app/confirm/info/row/section.test.tsx new file mode 100644 index 000000000000..e9c344caf0cb --- /dev/null +++ b/ui/components/app/confirm/info/row/section.test.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import { render } from '@testing-library/react'; +import { ConfirmInfoSection } from './section'; + +describe('ConfirmInfoSection', () => { + it('should match snapshot', () => { + const { container } = render( + Test Content, + ); + expect(container).toMatchSnapshot(); + }); + + it('should match snapshot without padding', () => { + const { container } = render( + Test Content, + ); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/ui/components/app/confirm/info/row/section.tsx b/ui/components/app/confirm/info/row/section.tsx new file mode 100644 index 000000000000..f49c8103fae4 --- /dev/null +++ b/ui/components/app/confirm/info/row/section.tsx @@ -0,0 +1,27 @@ +import React from 'react'; +import { Box } from '../../../../component-library'; +import { + BackgroundColor, + BorderRadius, +} from '../../../../../helpers/constants/design-system'; + +export type ConfirmInfoSectionProps = { + children: React.ReactNode | string; + noPadding?: boolean; +}; + +export const ConfirmInfoSection = ({ + children, + noPadding, +}: ConfirmInfoSectionProps) => { + return ( + + {children} + + ); +}; diff --git a/ui/components/app/mmi-signature-mismatch-banner/mmi-signature-mismatch-banner.tsx b/ui/components/app/mmi-signature-mismatch-banner/mmi-signature-mismatch-banner.tsx index 3fd8d7449d53..4d1e2a583c61 100644 --- a/ui/components/app/mmi-signature-mismatch-banner/mmi-signature-mismatch-banner.tsx +++ b/ui/components/app/mmi-signature-mismatch-banner/mmi-signature-mismatch-banner.tsx @@ -48,8 +48,8 @@ const MMISignatureMismatchBanner: React.FC = memo(() => { }, [currentConfirmation, allAccounts]); if ( - selectedAccount && - fromAccount && + !selectedAccount || + !fromAccount || selectedAccount.address === fromAccount.address ) { return null; diff --git a/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap b/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap index 3988a5be2c86..d9f473782e78 100644 --- a/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap +++ b/ui/pages/confirmations/components/confirm/info/__snapshots__/info.test.tsx.snap @@ -78,122 +78,114 @@ exports[`Info renders info section for personal sign request 1`] = ` exports[`Info renders info section for typed sign request 1`] = `
-
-

+

+
- Request from -

-
-
- -
+
-
+
+

-

- metamask.github.io -

-
+ metamask.github.io +

-
-

- Interacting with -

-
+ Interacting with +

+
+
-

- 0xCcCCc...ccccC -

+

+ 0xCcCCc...ccccC +

diff --git a/ui/pages/confirmations/components/confirm/info/contract-interaction/__snapshots__/contract-interaction.test.tsx.snap b/ui/pages/confirmations/components/confirm/info/contract-interaction/__snapshots__/contract-interaction.test.tsx.snap index 79e5b0031e34..f09075446df0 100644 --- a/ui/pages/confirmations/components/confirm/info/contract-interaction/__snapshots__/contract-interaction.test.tsx.snap +++ b/ui/pages/confirmations/components/confirm/info/contract-interaction/__snapshots__/contract-interaction.test.tsx.snap @@ -7,7 +7,7 @@ exports[` does not render if required data is not pre exports[` renders component for contract interaction request 1`] = `
= ({ return ( <> - + - + {showAdvancedDetails && } diff --git a/ui/pages/confirmations/components/confirm/info/personal-sign/personal-sign.tsx b/ui/pages/confirmations/components/confirm/info/personal-sign/personal-sign.tsx index 6421dd684b9b..f94dd25f5fe0 100644 --- a/ui/pages/confirmations/components/confirm/info/personal-sign/personal-sign.tsx +++ b/ui/pages/confirmations/components/confirm/info/personal-sign/personal-sign.tsx @@ -9,11 +9,6 @@ import { } from '../../../../../../components/app/confirm/info/row'; import { useI18nContext } from '../../../../../../hooks/useI18nContext'; import { currentConfirmationSelector } from '../../../../../../selectors'; -import { Box } from '../../../../../../components/component-library'; -import { - BackgroundColor, - BorderRadius, -} from '../../../../../../helpers/constants/design-system'; import { hexToText, sanitizeString, @@ -21,7 +16,8 @@ import { import { SignatureRequestType } from '../../../../types/confirm'; import { selectUseTransactionSimulations } from '../../../../selectors/preferences'; import { isSIWESignatureRequest } from '../../../../utils'; -import { AlertRow } from '../../../../../../components/app/confirm/info/row/alert-row/alert-row'; +import { ConfirmInfoAlertRow } from '../../../../../../components/app/confirm/info/row/alert-row/alert-row'; +import { ConfirmInfoSection } from '../../../../../../components/app/confirm/info/row/section'; import { SIWESignInfo } from './siwe-sign'; const PersonalSignInfo: React.FC = () => { @@ -43,50 +39,35 @@ const PersonalSignInfo: React.FC = () => { return ( <> {isSIWE && useTransactionSimulations && ( - + - + )} - - + - + {isSIWE && ( )} - - + + {isSIWE ? ( ) : ( - { hexToText(currentConfirmation.msgParams?.data), )} /> - + )} - + ); }; diff --git a/ui/pages/confirmations/components/confirm/info/shared/advanced-details/__snapshots__/advanced-details.test.tsx.snap b/ui/pages/confirmations/components/confirm/info/shared/advanced-details/__snapshots__/advanced-details.test.tsx.snap index de531cb73c51..295aa2510d56 100644 --- a/ui/pages/confirmations/components/confirm/info/shared/advanced-details/__snapshots__/advanced-details.test.tsx.snap +++ b/ui/pages/confirmations/components/confirm/info/shared/advanced-details/__snapshots__/advanced-details.test.tsx.snap @@ -3,49 +3,45 @@ exports[` does not render component for advanced transaction details 1`] = `
-
-

+

+
- Nonce -

-
-
- -
+
-
+
+

-

- undefined -

-
+ undefined +

@@ -55,90 +51,86 @@ exports[` does not render component for advanced transaction exports[` renders component for advanced transaction details 1`] = `
-
-

- Nonce -

-
-
- -
-
-
-
-

- 12 -

- +
+
+

+ 12 +

+ +
-
-

- Hex -

-
-
+
+
+

-

- 0xd0e30db0 -

-
+ 0xd0e30db0 +

+
+