Skip to content

Commit

Permalink
fix: add alert when selected account is different from signing accoun…
Browse files Browse the repository at this point in the history
…t in confirmation (#28562)

## **Description**

Show warning when signing account in confirmation is different from
currently selected account in MM.

## **Related issues**

Fixes: #28015

## **Manual testing steps**

1. Go to test dapp and connect with an account
2. Switch to a different account
3. Submit a confirmation and check warning next to signing account

## **Screenshots/Recordings**
Signature Request:
<img width="358" alt="Screenshot 2024-11-20 at 6 12 02 PM"
src="https://github.com/user-attachments/assets/34dcd6c6-8e19-4f92-b258-735373e4181b">

Contract Interaction:
<img width="359" alt="Screenshot 2024-11-20 at 6 12 16 PM"
src="https://github.com/user-attachments/assets/44aef003-bed7-4896-9c5b-55b016c052f8">

Send token:
<img width="360" alt="Screenshot 2024-11-20 at 6 47 29 PM"
src="https://github.com/user-attachments/assets/af1c6729-ccd0-4211-9524-e4eae4aea4e2">

## **Pre-merge author checklist**

- [X] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [X] I've completed the PR template to the best of my ability
- [X] I’ve included tests if applicable
- [X] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [X] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
jpuri authored Nov 25, 2024
1 parent 9eff241 commit ebb4926
Show file tree
Hide file tree
Showing 24 changed files with 2,123 additions and 46 deletions.
6 changes: 6 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.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,81 @@ exports[`<ApproveInfo /> renders component for approve request 1`] = `
</p>
</div>
</div>
<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--align-items-flex-start mm-box--color-text-default mm-box--rounded-lg"
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 mm-box--color-text-default"
>
<div
class="mm-box mm-box--display-flex mm-box--align-items-center"
>
<p
class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit"
>
Signing in with
</p>
</div>
</div>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--align-items-center"
>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--align-items-center"
>
<div
class="mm-box mm-text mm-avatar-base mm-avatar-base--size-xs mm-avatar-account mm-text--body-xs mm-text--text-transform-uppercase mm-box--display-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-text-default mm-box--background-color-background-alternative mm-box--rounded-full mm-box--border-color-transparent box--border-style-solid box--border-width-1"
>
<div
class="mm-avatar-account__jazzicon"
>
<div
style="border-radius: 50px; overflow: hidden; padding: 0px; margin: 0px; width: 16px; height: 16px; display: inline-block; background: rgb(24, 100, 242);"
>
<svg
height="16"
width="16"
x="0"
y="0"
>
<rect
fill="#C81420"
height="16"
transform="translate(-2.752618452452339 -2.6325616818687707) rotate(385.9 8 8)"
width="16"
x="0"
y="0"
/>
<rect
fill="#E9F500"
height="16"
transform="translate(5.337234703363199 6.214964079596694) rotate(184.5 8 8)"
width="16"
x="0"
y="0"
/>
<rect
fill="#FAB300"
height="16"
transform="translate(0.9077275996181156 -13.015140953188144) rotate(431.3 8 8)"
width="16"
x="0"
y="0"
/>
</svg>
</div>
</div>
</div>
<p
class="mm-box mm-text mm-text--body-md mm-box--margin-left-2 mm-box--color-inherit"
data-testid="confirm-info-row-display-name"
>
0x2e0D7...5d09B
</p>
</div>
</div>
</div>
<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--align-items-flex-start mm-box--color-text-default mm-box--rounded-lg"
data-testid="transaction-details-recipient-row"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ConfirmInfoSection } from '../../../../../../../components/app/confirm/
import { useI18nContext } from '../../../../../../../hooks/useI18nContext';
import { useConfirmContext } from '../../../../../context/confirm';
import { selectConfirmationAdvancedDetailsOpen } from '../../../../../selectors/preferences';
import { SigningInWithRow } from '../../shared/sign-in-with-row/sign-in-with-row';
import { useDecodedTransactionData } from '../../hooks/useDecodedTransactionData';
import { Container } from '../../shared/transaction-data/transaction-data';
import {
Expand Down Expand Up @@ -81,6 +82,7 @@ export const ApproveDetails = ({
<ConfirmInfoSection data-testid="confirmation__approve-details">
<Spender isSetApprovalForAll={isSetApprovalForAll} />
<OriginRow />
<SigningInWithRow />
{showAdvancedDetails && (
<>
<RecipientRow />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from 'react';
import { ConfirmInfoSection } from '../../../../../../../components/app/confirm/info/row/section';
import { OriginRow } from '../../shared/transaction-details/transaction-details';
import { SigningInWithRow } from '../../shared/sign-in-with-row/sign-in-with-row';

export const RevokeDetails = () => {
return (
<ConfirmInfoSection>
<OriginRow />
<SigningInWithRow />
</ConfirmInfoSection>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,81 @@ exports[`<BaseTransactionInfo /> renders component for contract interaction requ
</div>
</div>
</div>
<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--align-items-flex-start mm-box--color-text-default mm-box--rounded-lg"
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 mm-box--color-text-default"
>
<div
class="mm-box mm-box--display-flex mm-box--align-items-center"
>
<p
class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit"
>
Signing in with
</p>
</div>
</div>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--align-items-center"
>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--align-items-center"
>
<div
class="mm-box mm-text mm-avatar-base mm-avatar-base--size-xs mm-avatar-account mm-text--body-xs mm-text--text-transform-uppercase mm-box--display-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-text-default mm-box--background-color-background-alternative mm-box--rounded-full mm-box--border-color-transparent box--border-style-solid box--border-width-1"
>
<div
class="mm-avatar-account__jazzicon"
>
<div
style="border-radius: 50px; overflow: hidden; padding: 0px; margin: 0px; width: 16px; height: 16px; display: inline-block; background: rgb(24, 100, 242);"
>
<svg
height="16"
width="16"
x="0"
y="0"
>
<rect
fill="#C81420"
height="16"
transform="translate(-2.752618452452339 -2.6325616818687707) rotate(385.9 8 8)"
width="16"
x="0"
y="0"
/>
<rect
fill="#E9F500"
height="16"
transform="translate(5.337234703363199 6.214964079596694) rotate(184.5 8 8)"
width="16"
x="0"
y="0"
/>
<rect
fill="#FAB300"
height="16"
transform="translate(0.9077275996181156 -13.015140953188144) rotate(431.3 8 8)"
width="16"
x="0"
y="0"
/>
</svg>
</div>
</div>
</div>
<p
class="mm-box mm-text mm-text--body-md mm-box--margin-left-2 mm-box--color-inherit"
data-testid="confirm-info-row-display-name"
>
0x2e0D7...5d09B
</p>
</div>
</div>
</div>
</div>
<div
class="mm-box mm-box--margin-bottom-4 mm-box--padding-2 mm-box--background-color-background-default mm-box--rounded-md"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,81 @@ exports[`PersonalSignInfo handle reverse string properly 1`] = `
</p>
</div>
</div>
<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--align-items-flex-start mm-box--color-text-default mm-box--rounded-lg"
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 mm-box--color-text-default"
>
<div
class="mm-box mm-box--display-flex mm-box--align-items-center"
>
<p
class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit"
>
Signing in with
</p>
</div>
</div>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--align-items-center"
>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--align-items-center"
>
<div
class="mm-box mm-text mm-avatar-base mm-avatar-base--size-xs mm-avatar-account mm-text--body-xs mm-text--text-transform-uppercase mm-box--display-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-text-default mm-box--background-color-background-alternative mm-box--rounded-full mm-box--border-color-transparent box--border-style-solid box--border-width-1"
>
<div
class="mm-avatar-account__jazzicon"
>
<div
style="border-radius: 50px; overflow: hidden; padding: 0px; margin: 0px; width: 16px; height: 16px; display: inline-block; background: rgb(250, 58, 0);"
>
<svg
height="16"
width="16"
x="0"
y="0"
>
<rect
fill="#18CDF2"
height="16"
transform="translate(-0.52419675189697 -1.6521420347302493) rotate(328.9 8 8)"
width="16"
x="0"
y="0"
/>
<rect
fill="#035E56"
height="16"
transform="translate(-9.149230854416022 5.2962309358743) rotate(176.2 8 8)"
width="16"
x="0"
y="0"
/>
<rect
fill="#F26602"
height="16"
transform="translate(8.333921009111961 -7.102569861498541) rotate(468.9 8 8)"
width="16"
x="0"
y="0"
/>
</svg>
</div>
</div>
</div>
<p
class="mm-box mm-text mm-text--body-md mm-box--margin-left-2 mm-box--color-inherit"
data-testid="confirm-info-row-display-name"
>
Test Account
</p>
</div>
</div>
</div>
</div>
<div
class="mm-box mm-box--margin-bottom-4 mm-box--padding-2 mm-box--background-color-background-default mm-box--rounded-md"
Expand Down Expand Up @@ -151,6 +226,81 @@ exports[`PersonalSignInfo renders correctly for personal sign request 1`] = `
</p>
</div>
</div>
<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--align-items-flex-start mm-box--color-text-default mm-box--rounded-lg"
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 mm-box--color-text-default"
>
<div
class="mm-box mm-box--display-flex mm-box--align-items-center"
>
<p
class="mm-box mm-text mm-text--body-md-medium mm-box--color-inherit"
>
Signing in with
</p>
</div>
</div>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--align-items-center"
>
<div
class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--align-items-center"
>
<div
class="mm-box mm-text mm-avatar-base mm-avatar-base--size-xs mm-avatar-account mm-text--body-xs mm-text--text-transform-uppercase mm-box--display-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-text-default mm-box--background-color-background-alternative mm-box--rounded-full mm-box--border-color-transparent box--border-style-solid box--border-width-1"
>
<div
class="mm-avatar-account__jazzicon"
>
<div
style="border-radius: 50px; overflow: hidden; padding: 0px; margin: 0px; width: 16px; height: 16px; display: inline-block; background: rgb(250, 58, 0);"
>
<svg
height="16"
width="16"
x="0"
y="0"
>
<rect
fill="#18CDF2"
height="16"
transform="translate(-0.52419675189697 -1.6521420347302493) rotate(328.9 8 8)"
width="16"
x="0"
y="0"
/>
<rect
fill="#035E56"
height="16"
transform="translate(-9.149230854416022 5.2962309358743) rotate(176.2 8 8)"
width="16"
x="0"
y="0"
/>
<rect
fill="#F26602"
height="16"
transform="translate(8.333921009111961 -7.102569861498541) rotate(468.9 8 8)"
width="16"
x="0"
y="0"
/>
</svg>
</div>
</div>
</div>
<p
class="mm-box mm-text mm-text--body-md mm-box--margin-left-2 mm-box--color-inherit"
data-testid="confirm-info-row-display-name"
>
Test Account
</p>
</div>
</div>
</div>
</div>
<div
class="mm-box mm-box--margin-bottom-4 mm-box--padding-2 mm-box--background-color-background-default mm-box--rounded-md"
Expand Down
Loading

0 comments on commit ebb4926

Please sign in to comment.