Skip to content

Commit

Permalink
fix: increase signing or submitting alert severity to danger (#29140)
Browse files Browse the repository at this point in the history
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
This PR addresses an issue where users are currently able to submit
multiple Smart Transaction (STX) requests while one is still pending in
the redesigned confirmation flow. This functionality is already
correctly implemented in the legacy confirmation flow, and the
redesigned flow is updated to match this behaviour.

**Changes Introduced:**
- Updates the alert text to match the copy used in the legacy
confirmation flow.
- Increases the severity of the alert from `Warning` to `Danger`.
- Ensures that dangerous banner alerts block the confirm button to avoid
user actions until resolved.

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/29140?quickstart=1)

## **Related issues**

Fixes: #29138

## **Manual testing steps**

1. Submit a STX
2. Trigger a new transaction

## **Screenshots/Recordings**


[wait_submitted_tx.webm](https://github.com/user-attachments/assets/0eff285e-46b1-409f-8041-4c99fef89839)

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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/main/.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/main/.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
vinistevam authored Dec 13, 2024
1 parent 98be282 commit 72e4987
Show file tree
Hide file tree
Showing 21 changed files with 29 additions and 58 deletions.
3 changes: 0 additions & 3 deletions app/_locales/de/messages.json

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

3 changes: 0 additions & 3 deletions app/_locales/el/messages.json

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

7 changes: 3 additions & 4 deletions app/_locales/en/messages.json

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

3 changes: 0 additions & 3 deletions app/_locales/en_GB/messages.json

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

3 changes: 0 additions & 3 deletions app/_locales/es/messages.json

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

3 changes: 0 additions & 3 deletions app/_locales/fr/messages.json

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

3 changes: 0 additions & 3 deletions app/_locales/hi/messages.json

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

3 changes: 0 additions & 3 deletions app/_locales/id/messages.json

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

3 changes: 0 additions & 3 deletions app/_locales/ja/messages.json

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

3 changes: 0 additions & 3 deletions app/_locales/ko/messages.json

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

3 changes: 0 additions & 3 deletions app/_locales/pt/messages.json

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

3 changes: 0 additions & 3 deletions app/_locales/ru/messages.json

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

3 changes: 0 additions & 3 deletions app/_locales/tl/messages.json

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

3 changes: 0 additions & 3 deletions app/_locales/tr/messages.json

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

3 changes: 0 additions & 3 deletions app/_locales/vi/messages.json

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

3 changes: 0 additions & 3 deletions app/_locales/zh_CN/messages.json

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

4 changes: 2 additions & 2 deletions test/integration/confirmations/transactions/alerts.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -470,14 +470,14 @@ describe('Contract Interaction Confirmation Alerts', () => {
expect(
alerts.some((alert) =>
alert.textContent?.includes(
'This transaction will only go through once your previous transaction is complete.',
'A previous transaction is still being signed or submitted',
),
),
).toBe(true);

expect(
await screen.findByTestId('confirm-footer-button'),
).toBeInTheDocument();
expect(await screen.findByTestId('confirm-footer-button')).toBeEnabled();
expect(await screen.findByTestId('confirm-footer-button')).toBeDisabled();
});
});
18 changes: 18 additions & 0 deletions ui/pages/confirmations/components/confirm/footer/footer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,24 @@ describe('ConfirmFooter', () => {
expect(getByText('Confirm')).toBeInTheDocument();
});

it('renders the "confirm" button disabled when there are blocking dangerous banner alerts', () => {
const stateWithBannerDangerAlertMock = createStateWithAlerts(
[
{
...alertsMock[0],
isBlocking: true,
field: undefined,
},
],
{
[KEY_ALERT_KEY_MOCK]: false,
},
);
const { getByText } = render(stateWithBannerDangerAlertMock);
expect(getByText('Confirm')).toBeInTheDocument();
expect(getByText('Confirm')).toBeDisabled();
});

it('renders the "confirm" button when there are no alerts', () => {
const { getByText } = render();
expect(getByText('Confirm')).toBeInTheDocument();
Expand Down
4 changes: 2 additions & 2 deletions ui/pages/confirmations/components/confirm/footer/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ const ConfirmButton = ({
useState<boolean>(false);

const {
alerts,
hasDangerAlerts,
hasUnconfirmedDangerAlerts,
fieldAlerts,
hasUnconfirmedFieldDangerAlerts,
unconfirmedFieldDangerAlerts,
} = useAlerts(alertOwnerId);

const hasDangerBlockingAlerts = fieldAlerts.some(
const hasDangerBlockingAlerts = alerts.some(
(alert) => alert.severity === Severity.Danger && alert.isBlocking,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import { useSigningOrSubmittingAlerts } from './useSigningOrSubmittingAlerts';
const EXPECTED_ALERT = {
isBlocking: true,
key: 'signingOrSubmitting',
message:
'This transaction will only go through once your previous transaction is complete.',
severity: Severity.Warning,
message: 'A previous transaction is still being signed or submitted',
severity: Severity.Danger,
};
const ACCOUNT_ADDRESS = '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc';
const TRANSACTION_ID_MOCK = '123-456';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export function useSigningOrSubmittingAlerts(): Alert[] {
{
isBlocking: true,
key: 'signingOrSubmitting',
message: t('alertMessageSigningOrSubmitting'),
severity: Severity.Warning,
message: t('isSigningOrSubmitting'),
severity: Severity.Danger,
},
];
}, [isSigningOrSubmitting]);
Expand Down

0 comments on commit 72e4987

Please sign in to comment.