Skip to content
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

fix: adding warning for origin on redesigned pages #26306

Merged
merged 31 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4e7bf90
Show warning on redesigned pages if origin has special characters
jpuri Aug 2, 2024
cc7594a
Show warning on redesigned pages if origin has special characters
jpuri Aug 2, 2024
8ece60e
update
jpuri Aug 2, 2024
94101b7
Merge branch 'develop' into add_origin_warning
jpuri Aug 13, 2024
4dec32b
Merge branch 'add_origin_warning' of github.com:MetaMask/metamask-ext…
jpuri Aug 13, 2024
94f039e
update
jpuri Aug 13, 2024
8359c67
update
jpuri Aug 13, 2024
4087e33
update
jpuri Aug 13, 2024
76cbbcf
update
jpuri Aug 13, 2024
5298cd4
Merge branch 'develop' into add_origin_warning
jpuri Aug 13, 2024
04c51c3
update
jpuri Aug 13, 2024
58a6c05
Merge branch 'add_origin_warning' of github.com:MetaMask/metamask-ext…
jpuri Aug 13, 2024
d6754b0
Merge branch 'develop' into add_origin_warning
jpuri Aug 13, 2024
75f64c8
Merge branch 'add_origin_warning' of github.com:MetaMask/metamask-ext…
jpuri Aug 13, 2024
a529909
update
jpuri Aug 13, 2024
eefda43
update
jpuri Aug 13, 2024
429c4cc
merge
jpuri Aug 15, 2024
f665393
Update
jpuri Aug 15, 2024
f504441
Update
jpuri Aug 15, 2024
16ced3d
update
jpuri Aug 15, 2024
c39642a
update
jpuri Aug 15, 2024
1b824f2
update
jpuri Aug 15, 2024
5b03446
Merge branch 'develop' into add_origin_warning
jpuri Aug 15, 2024
df804dd
update
jpuri Aug 15, 2024
53be467
Merge branch 'add_origin_warning' of github.com:MetaMask/metamask-ext…
jpuri Aug 15, 2024
2f8bafd
update
jpuri Aug 16, 2024
61caead
update
jpuri Aug 19, 2024
bce48ab
update
jpuri Aug 19, 2024
b76e671
update
jpuri Aug 19, 2024
050865e
merge
jpuri Aug 20, 2024
501302a
update
jpuri Aug 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ui/components/app/confirm/info/row/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export enum RowAlertKey {
EstimatedFee = 'estimatedFee',
SigningInWith = 'signingInWith',
Speed = 'speed',
RequestFrom = 'requestFrom',
}

export enum AlertActionKey {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ exports[`Info renders info section for typed sign request 1`] = `
>
<div
class="mm-box confirm-info-row mm-box--margin-top-2 mm-box--margin-bottom-2 mm-box--padding-right-2 mm-box--padding-left-2 mm-box--display-flex mm-box--flex-direction-row mm-box--flex-wrap-wrap mm-box--justify-content-space-between mm-box--color-text-default mm-box--rounded-lg"
style="overflow-wrap: anywhere; min-height: 24px; position: relative;"
style="overflow-wrap: anywhere; min-height: 24px; position: relative; background: transparent;"
>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start"
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start mm-box--color-text-default"
>
<p
class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ exports[`<ContractInteractionInfo /> renders component for contract interaction
<div
class="mm-box confirm-info-row mm-box--margin-top-2 mm-box--margin-bottom-2 mm-box--padding-right-2 mm-box--padding-left-2 mm-box--display-flex mm-box--flex-direction-row mm-box--flex-wrap-wrap mm-box--justify-content-space-between mm-box--color-text-default mm-box--rounded-lg"
data-testid="transaction-details-origin-row"
style="overflow-wrap: anywhere; min-height: 24px; position: relative;"
style="overflow-wrap: anywhere; min-height: 24px; position: relative; background: transparent;"
>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start"
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start mm-box--color-text-default"
>
<p
class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit"
Expand Down Expand Up @@ -467,10 +467,10 @@ exports[`<ContractInteractionInfo /> renders component for contract interaction
<div
class="mm-box confirm-info-row mm-box--margin-top-2 mm-box--margin-bottom-2 mm-box--padding-right-2 mm-box--padding-left-2 mm-box--display-flex mm-box--flex-direction-row mm-box--flex-wrap-wrap mm-box--justify-content-space-between mm-box--color-text-default mm-box--rounded-lg"
data-testid="transaction-details-origin-row"
style="overflow-wrap: anywhere; min-height: 24px; position: relative;"
style="overflow-wrap: anywhere; min-height: 24px; position: relative; background: transparent;"
>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start"
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start mm-box--color-text-default"
>
<p
class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit"
Expand Down Expand Up @@ -830,10 +830,10 @@ exports[`<ContractInteractionInfo /> renders component for contract interaction
<div
class="mm-box confirm-info-row mm-box--margin-top-2 mm-box--margin-bottom-2 mm-box--padding-right-2 mm-box--padding-left-2 mm-box--display-flex mm-box--flex-direction-row mm-box--flex-wrap-wrap mm-box--justify-content-space-between mm-box--color-text-default mm-box--rounded-lg"
data-testid="transaction-details-origin-row"
style="overflow-wrap: anywhere; min-height: 24px; position: relative;"
style="overflow-wrap: anywhere; min-height: 24px; position: relative; background: transparent;"
>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start"
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start mm-box--color-text-default"
>
<p
class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ConfirmInfoRowText,
ConfirmInfoRowUrl,
} from '../../../../../../components/app/confirm/info/row';
import { RowAlertKey } from '../../../../../../components/app/confirm/info/row/constants';
import { useI18nContext } from '../../../../../../hooks/useI18nContext';
import { currentConfirmationSelector } from '../../../../../../selectors';
import {
Expand All @@ -17,7 +18,6 @@ import { SignatureRequestType } from '../../../../types/confirm';
import { selectUseTransactionSimulations } from '../../../../selectors/preferences';
import { isSIWESignatureRequest } from '../../../../utils';
import { ConfirmInfoAlertRow } from '../../../../../../components/app/confirm/info/row/alert-row/alert-row';
import { RowAlertKey } from '../../../../../../components/app/confirm/info/row/constants';
import { ConfirmInfoSection } from '../../../../../../components/app/confirm/info/row/section';
import { SIWESignInfo } from './siwe-sign';

Expand Down Expand Up @@ -51,7 +51,7 @@ const PersonalSignInfo: React.FC = () => {
)}
<ConfirmInfoSection>
<ConfirmInfoAlertRow
alertKey="requestFrom"
alertKey={RowAlertKey.RequestFrom}
ownerId={currentConfirmation.id}
label={t('requestFrom')}
tooltip={isSIWE ? undefined : t('requestFromInfo')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ exports[`<TransactionDetails /> renders component for transaction details 1`] =
<div
class="mm-box confirm-info-row mm-box--margin-top-2 mm-box--margin-bottom-2 mm-box--padding-right-2 mm-box--padding-left-2 mm-box--display-flex mm-box--flex-direction-row mm-box--flex-wrap-wrap mm-box--justify-content-space-between mm-box--color-text-default mm-box--rounded-lg"
data-testid="transaction-details-origin-row"
style="overflow-wrap: anywhere; min-height: 24px; position: relative;"
style="overflow-wrap: anywhere; min-height: 24px; position: relative; background: transparent;"
>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start"
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start mm-box--color-text-default"
>
<p
class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ import mockState from '../../../../../../../../test/data/mock-state.json';
import { renderWithProvider } from '../../../../../../../../test/lib/render-helpers';
import { TransactionDetails } from './transaction-details';

jest.mock(
'../../../../../../../components/app/alert-system/contexts/alertMetricsContext',
() => ({
useAlertMetrics: jest.fn(() => ({
trackAlertMetrics: jest.fn(),
})),
}),
);

describe('<TransactionDetails />', () => {
const middleware = [thunk];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import { TransactionMeta } from '@metamask/transaction-controller';
import { isValidAddress } from 'ethereumjs-util';
import React from 'react';
import { useSelector } from 'react-redux';

import { ConfirmInfoAlertRow } from '../../../../../../../components/app/confirm/info/row/alert-row/alert-row';
import {
ConfirmInfoRow,
ConfirmInfoRowAddress,
ConfirmInfoRowText,
ConfirmInfoRowUrl,
} from '../../../../../../../components/app/confirm/info/row';
import { ConfirmInfoSection } from '../../../../../../../components/app/confirm/info/row/section';
import { RowAlertKey } from '../../../../../../../components/app/confirm/info/row/constants';
import { useI18nContext } from '../../../../../../../hooks/useI18nContext';
import { selectPaymasterAddress } from '../../../../../../../selectors/account-abstraction';
import { currentConfirmationSelector } from '../../../../../selectors';
Expand All @@ -28,13 +31,15 @@ const OriginRow = () => {
}

return (
<ConfirmInfoRow
<ConfirmInfoAlertRow
alertKey={RowAlertKey.RequestFrom}
ownerId={currentConfirmation.id}
data-testid="transaction-details-origin-row"
label={t('requestFrom')}
tooltip={t('requestFromTransactionDescription')}
>
<ConfirmInfoRowUrl url={origin} />
</ConfirmInfoRow>
</ConfirmInfoAlertRow>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ exports[`TypedSignInfo correctly renders typed sign data request 1`] = `
>
<div
class="mm-box confirm-info-row mm-box--margin-top-2 mm-box--margin-bottom-2 mm-box--padding-right-2 mm-box--padding-left-2 mm-box--display-flex mm-box--flex-direction-row mm-box--flex-wrap-wrap mm-box--justify-content-space-between mm-box--color-text-default mm-box--rounded-lg"
style="overflow-wrap: anywhere; min-height: 24px; position: relative;"
style="overflow-wrap: anywhere; min-height: 24px; position: relative; background: transparent;"
>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start"
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start mm-box--color-text-default"
>
<p
class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,25 @@ import { renderWithProvider } from '../../../../../../../test/lib/render-helpers
import { unapprovedTypedSignMsgV1 } from '../../../../../../../test/data/confirmations/typed_sign';
import TypedSignInfoV1 from './typed-sign-v1';

jest.mock(
'../../../../../../components/app/alert-system/contexts/alertMetricsContext',
() => ({
useAlertMetrics: jest.fn(() => ({
trackAlertMetrics: jest.fn(),
})),
}),
);

describe('TypedSignInfo', () => {
it('correctly renders typed sign data request', () => {
const mockState = {
confirm: {
currentConfirmation: unapprovedTypedSignMsgV1,
},
confirmAlerts: {
alerts: [],
confirmed: [],
},
};
const mockStore = configureMockStore([])(mockState);
const { container } = renderWithProvider(<TypedSignInfoV1 />, mockStore);
Expand All @@ -27,6 +40,10 @@ describe('TypedSignInfo', () => {
type: 'json_request',
},
},
confirmAlerts: {
alerts: [],
confirmed: [],
},
};
const mockStore = configureMockStore([])(mockState);
const { container } = renderWithProvider(<TypedSignInfoV1 />, mockStore);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react';
import { useSelector } from 'react-redux';

import { ConfirmInfoAlertRow } from '../../../../../../components/app/confirm/info/row/alert-row/alert-row';
import {
ConfirmInfoRow,
ConfirmInfoRowUrl,
} from '../../../../../../components/app/confirm/info/row';
import { RowAlertKey } from '../../../../../../components/app/confirm/info/row/constants';
import { useI18nContext } from '../../../../../../hooks/useI18nContext';
import { currentConfirmationSelector } from '../../../../../../selectors';
import {
Expand All @@ -27,9 +29,14 @@ const TypedSignV1Info: React.FC = () => {
return (
<>
<ConfirmInfoSection>
<ConfirmInfoRow label={t('requestFrom')} tooltip={t('requestFromInfo')}>
<ConfirmInfoAlertRow
alertKey={RowAlertKey.RequestFrom}
ownerId={currentConfirmation.id}
label={t('requestFrom')}
tooltip={t('requestFromInfo')}
>
<ConfirmInfoRowUrl url={currentConfirmation.msgParams.origin} />
</ConfirmInfoRow>
</ConfirmInfoAlertRow>
</ConfirmInfoSection>
<ConfirmInfoSection>
<ConfirmInfoRow label={t('message')}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ exports[`TypedSignInfo correctly renders permit sign type 1`] = `
/>
<div
class="mm-box confirm-info-row mm-box--margin-top-2 mm-box--margin-bottom-2 mm-box--padding-right-2 mm-box--padding-left-2 mm-box--display-flex mm-box--flex-direction-row mm-box--flex-wrap-wrap mm-box--justify-content-space-between mm-box--color-text-default mm-box--rounded-lg"
style="overflow-wrap: anywhere; min-height: 24px; position: relative;"
style="overflow-wrap: anywhere; min-height: 24px; position: relative; background: transparent;"
>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start"
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start mm-box--color-text-default"
>
<p
class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit"
Expand Down Expand Up @@ -483,10 +483,10 @@ exports[`TypedSignInfo renders origin for typed sign data request 1`] = `
>
<div
class="mm-box confirm-info-row mm-box--margin-top-2 mm-box--margin-bottom-2 mm-box--padding-right-2 mm-box--padding-left-2 mm-box--display-flex mm-box--flex-direction-row mm-box--flex-wrap-wrap mm-box--justify-content-space-between mm-box--color-text-default mm-box--rounded-lg"
style="overflow-wrap: anywhere; min-height: 24px; position: relative;"
style="overflow-wrap: anywhere; min-height: 24px; position: relative; background: transparent;"
>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start"
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start mm-box--color-text-default"
>
<p
class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit"
Expand Down Expand Up @@ -906,10 +906,10 @@ exports[`TypedSignInfo should render message for typed sign v3 request 1`] = `
>
<div
class="mm-box confirm-info-row mm-box--margin-top-2 mm-box--margin-bottom-2 mm-box--padding-right-2 mm-box--padding-left-2 mm-box--display-flex mm-box--flex-direction-row mm-box--flex-wrap-wrap mm-box--justify-content-space-between mm-box--color-text-default mm-box--rounded-lg"
style="overflow-wrap: anywhere; min-height: 24px; position: relative;"
style="overflow-wrap: anywhere; min-height: 24px; position: relative; background: transparent;"
>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start"
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start mm-box--color-text-default"
>
<p
class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit"
Expand Down Expand Up @@ -1329,10 +1329,10 @@ exports[`TypedSignInfo should render message for typed sign v4 request 1`] = `
>
<div
class="mm-box confirm-info-row mm-box--margin-top-2 mm-box--margin-bottom-2 mm-box--padding-right-2 mm-box--padding-left-2 mm-box--display-flex mm-box--flex-direction-row mm-box--flex-wrap-wrap mm-box--justify-content-space-between mm-box--color-text-default mm-box--rounded-lg"
style="overflow-wrap: anywhere; min-height: 24px; position: relative;"
style="overflow-wrap: anywhere; min-height: 24px; position: relative; background: transparent;"
>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start"
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-center mm-box--align-items-flex-start mm-box--color-text-default"
>
<p
class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ import {
} from '../../../../../../../test/data/confirmations/typed_sign';
import TypedSignInfo from './typed-sign';

jest.mock(
'../../../../../../components/app/alert-system/contexts/alertMetricsContext',
() => ({
useAlertMetrics: jest.fn(() => ({
trackAlertMetrics: jest.fn(),
})),
}),
);

jest.mock('../../../../../../store/actions', () => {
return {
getTokenStandardAndDetails: jest.fn().mockResolvedValue({ decimals: 2 }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import React, { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import { isValidAddress } from 'ethereumjs-util';

import { ConfirmInfoAlertRow } from '../../../../../../components/app/confirm/info/row/alert-row/alert-row';
import { parseTypedDataMessage } from '../../../../../../../shared/modules/transaction.utils';
import { RowAlertKey } from '../../../../../../components/app/confirm/info/row/constants';
import {
ConfirmInfoRow,
ConfirmInfoRowAddress,
Expand Down Expand Up @@ -70,9 +72,14 @@ const TypedSignInfo: React.FC = () => {
<ConfirmInfoRowDivider />
</>
)}
<ConfirmInfoRow label={t('requestFrom')} tooltip={t('requestFromInfo')}>
<ConfirmInfoAlertRow
alertKey={RowAlertKey.RequestFrom}
ownerId={currentConfirmation.id}
label={t('requestFrom')}
tooltip={t('requestFromInfo')}
>
<ConfirmInfoRowUrl url={currentConfirmation.msgParams.origin} />
</ConfirmInfoRow>
</ConfirmInfoAlertRow>
{isValidAddress(verifyingContract) && (
<ConfirmInfoRow label={t('interactingWith')}>
<ConfirmInfoRowAddress address={verifyingContract} />
Expand Down
Loading