Skip to content

Commit 9104b8e

Browse files
fix: Avoid nonce flicker when transaction is submitted (#30193)
<!-- 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** <!-- 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? --> Submitting or cancelling a transaction was clearing the custom nonce field before the confirmation popup had time to close. This PR fixes that. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/30193?quickstart=1) ## **Related issues** Fixes: MetaMask/MetaMask-planning#4140 ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> https://github.com/user-attachments/assets/fc803f67-cb8a-4bda-bbaa-745036fae9e3 https://github.com/user-attachments/assets/95a679f8-acba-4155-82a1-d1b536e1c5d8 ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] 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). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] 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.
1 parent baf9b08 commit 9104b8e

File tree

2 files changed

+0
-30
lines changed

2 files changed

+0
-30
lines changed

ui/pages/confirmations/components/confirm/footer/footer.test.tsx

-24
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,8 @@ describe('ConfirmFooter', () => {
136136
// TODO: Replace `any` with type
137137
// eslint-disable-next-line @typescript-eslint/no-explicit-any
138138
.mockImplementation(() => ({} as any));
139-
const updateCustomNonceSpy = jest
140-
.spyOn(Actions, 'updateCustomNonce')
141-
// TODO: Replace `any` with type
142-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
143-
.mockImplementation(() => ({} as any));
144-
const setNextNonceSpy = jest
145-
.spyOn(Actions, 'setNextNonce')
146-
// TODO: Replace `any` with type
147-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
148-
.mockImplementation(() => ({} as any));
149139
fireEvent.click(cancelButton);
150140
expect(rejectSpy).toHaveBeenCalled();
151-
expect(updateCustomNonceSpy).toHaveBeenCalledWith('');
152-
expect(setNextNonceSpy).toHaveBeenCalledWith('');
153141
});
154142

155143
it('invoke required actions when submit button is clicked', () => {
@@ -160,20 +148,8 @@ describe('ConfirmFooter', () => {
160148
// TODO: Replace `any` with type
161149
// eslint-disable-next-line @typescript-eslint/no-explicit-any
162150
.mockImplementation(() => ({} as any));
163-
const updateCustomNonceSpy = jest
164-
.spyOn(Actions, 'updateCustomNonce')
165-
// TODO: Replace `any` with type
166-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
167-
.mockImplementation(() => ({} as any));
168-
const setNextNonceSpy = jest
169-
.spyOn(Actions, 'setNextNonce')
170-
// TODO: Replace `any` with type
171-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
172-
.mockImplementation(() => ({} as any));
173151
fireEvent.click(submitButton);
174152
expect(resolveSpy).toHaveBeenCalled();
175-
expect(updateCustomNonceSpy).toHaveBeenCalledWith('');
176-
expect(setNextNonceSpy).toHaveBeenCalledWith('');
177153
});
178154

179155
it('displays a danger "Confirm" button there are danger alerts', async () => {

ui/pages/confirmations/components/confirm/footer/footer.tsx

-6
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ import useAlerts from '../../../../../hooks/useAlerts';
2020
import {
2121
rejectPendingApproval,
2222
resolvePendingApproval,
23-
setNextNonce,
2423
///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask)
2524
updateAndApproveTx,
2625
///: END:ONLY_INCLUDE_IF
27-
updateCustomNonce,
2826
} from '../../../../../store/actions';
2927
import { isSignatureTransactionType } from '../../../utils';
3028
import { useConfirmContext } from '../../../context/confirm';
@@ -190,8 +188,6 @@ const Footer = () => {
190188
dispatch(
191189
rejectPendingApproval(currentConfirmation.id, serializeError(error)),
192190
);
193-
dispatch(updateCustomNonce(''));
194-
dispatch(setNextNonce(''));
195191
},
196192
[currentConfirmation],
197193
);
@@ -223,8 +219,6 @@ const Footer = () => {
223219
} else {
224220
dispatch(resolvePendingApproval(currentConfirmation.id, undefined));
225221
}
226-
dispatch(updateCustomNonce(''));
227-
dispatch(setNextNonce(''));
228222
}, [currentConfirmation, customNonceValue]);
229223

230224
const handleFooterCancel = useCallback(() => {

0 commit comments

Comments
 (0)