feat: enhance speed up and cancel logic#40734
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
✨ Files requiring CODEOWNER review ✨✅ @MetaMask/confirmations (20 files, +601 -250)
👨🔧 @MetaMask/core-extension-ux (1 files, +1 -13)
📜 @MetaMask/policy-reviewers (4 files, +308 -4)
Tip Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers. 🧪 @MetaMask/qa (2 files, +87 -9)
|
Builds ready [d67145b]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [f8b973b]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [3d4bdab]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|
Review — posted on behalf of @cryptotavares I reviewed this PR as part of tracking Q1 confirmation work. Architecture in issue-7051 was written by the implementor and has no recorded team sign-off or discussion comments. The spec is detailed, but there is no evidence of collaborative pre-approval before 4 reviewer teams were engaged. The confirmations team review is especially critical here. Beyond the process concern, the diff contains two bugs that I believe will block users from submitting cancel/speedup on production: BUG 1 — HIGH: EIP-1559 cancel/speedup confirm button permanently disabledFile: const hasEIP1559Gas =
txParams?.maxFeePerGas &&
txParams?.maxPriorityFeePerGas &&
txParams?.gasLimit; // ← wrong field
The fix is already demonstrated elsewhere in the same PR ( txParams?.gasLimit ?? txParams?.gasBUG 2 — HIGH: Legacy (non-EIP-1559) cancel/speedup always blockedSame A separate path is needed to set BUG 3 — MEDIUM: Tests assert known-wrong fee valuesFile: The test file contains inline comments acknowledging that the expected fee constants are incorrect (the author notes the intended values should be higher). Merging these tests locks in a broken fee display as the regression baseline. Either fix the underlying fee calculation and update the constants, or do not assert specific fee strings until the logic is correct. Minor: Dead stateFile:
Bugs 1 and 2 together mean the cancel/speedup flow would be broken for all users on both EIP-1559 and legacy networks. Would recommend blocking merge until these are resolved. |
ui/pages/confirmations/components/gas-timing/gas-timing.component.js
Outdated
Show resolved
Hide resolved
|
Policies updated. 🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff ✅ lavamoat/browserify/beta/policy.json changes match main/policy.json policy changes |
411f6ab
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
|
Builds ready [6475ccd]
⚡ Performance Benchmarks
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚀 Bundle size reduced!]
|




Description
This PR modernizes the cancel/speed-up transaction UI to use the same GasFeeModal context and gas-details patterns as the main confirmation flow, and fixes the "useConfirmContext must be used within ConfirmContextProvider" error when opening the gas modal from cancel-speedup.
What was done
transactionMetaandeditGasMode.GasFeeModalWrapperwraps modal content inConfirmContextProviderwithcurrentConfirmationOverride={transactionMeta}when opened from cancel-speedup so gas modals can useuseConfirmContext().GasFeeModalContextProvider(transactionMeta, editGasMode),useCancelSpeedupGasState, anduseCancelSpeedupInitialGas. Renders shared gas UI (e.g. GasFeesSection) and opens the gas modal via context.AdvancedEIP1559Modal,AdvancedGasPriceModal, anduseGasFeeEstimateLevelOptionsuseuseConfirmContext()again; nouseTransactionForGasModalin the modal flow.ConfirmContextProvidersupports optionalcurrentConfirmationOverride; when set, route sync and navigate-on-dismiss are skipped so the gas modal can be used outside the confirm route.useCancelSpeedupGasStateprovides effective transaction and actions;useCancelSpeedupInitialGasruns the initial gas rule (medium vs tenPercentIncreased) when the cancel-speedup modal is open.Changelog
CHANGELOG entry: Fixed gas edit opening from cancel/speed-up transaction flow and aligned cancel-speedup gas UI with the main confirmation flow.
Related issues
Fixes: https://github.com/MetaMask/MetaMask-planning/issues/7051
Manual testing steps
Screenshots/Recordings
cancel_new_ex.webm
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches transaction replacement gas calculation and confirmation/gas modal context wiring; mistakes could cause underpriced replacements or broken cancel/speed-up UX, but changes are localized and well-covered by tests.
Overview
Modernizes the cancel/speed-up transaction modal to use the shared confirmation gas modal flow. The cancel/speed-up UI now uses
GasFeeModalContextProvider+GasFeeModalWrapper, shared fee display hooks (useFeeCalculations,useEIP1559TxFees), and new hooks (useCancelSpeedupGasState,useCancelSpeedupInitialGas) instead of the legacyGasFeeContextProvider/inline logic.Fixes gas modal usage outside the confirm route.
ConfirmContextProvidernow supportscurrentConfirmationOverride, andGasFeeModalWrapperwraps the modal inConfirmContextProviderwhen opened from cancel/speed-up, preventinguseConfirmContexterrors; related gas UI components add fallback estimate sourcing and safer optional context access.Hardens replacement transaction gas pricing. Adds
getGasValuesForReplacementand updatesuseTransactionFunctionsto ensure cancel/speed-up transactions use at leastpreviousGas × CANCEL_RATE/SPEED_UP_RATE, while persistingpreviousGaswhen the modal opens and disabling confirm until it exists.Tests and policy updates. Updates/extends unit tests and E2E page objects/specs for the new modal behavior and labels (e.g. "Site suggested"), and expands LavaMoat MV3 policies to allow new controller dependencies (
@metamask/gas-fee-controller,@metamask/polling-controller, nonce-tracker deps).Written by Cursor Bugbot for commit 6475ccd. This will update automatically on new commits. Configure here.