Commit fa79ebb
authored
fix: clear gas sponsorship flag for hardware wallet transactions cp-7.77.0 (#29262)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until this PR meets the canonical
Definition of Ready For Review in `docs/readme/ready-for-review.md`.
In short: the template must be materially complete (not just section
titles
present), all status checks must be currently passing, and the only
expected
follow-up commits must be reviewer-driven.
-->
## **Description**
Hardware wallet (Ledger/QR) transactions on gas-sponsored networks (MON,
SEI) incorrectly showed "Paid by MetaMask" in the activity transaction
details. The root cause was twofold:
1. **Confirm callback gap**: The `isGasFeeSponsored` override in
`useTransactionConfirm` only ran inside `handleSmartTransaction` and
`handleGasless7702`, both of which exit early when no
`selectedGasFeeToken` is present — which is always the case for HW
wallets since gasless is not supported. The flag was never cleared on
the persisted transaction metadata.
2. **Missing UI guard**: The activity list `TransactionDetails`
component passed `isGasFeeSponsored` from stored transaction data
without checking if the account is a hardware wallet.
**Fix**: Moved the `isGasFeeSponsored` override to the top of
`onConfirm` so it runs unconditionally for every transaction, and added
an `isHardwareAccount` guard in the activity list UI (matching the
pattern already used in Bridge `TransactionDetails`).
## **Changelog**
CHANGELOG entry: Fixed "Paid by MetaMask" incorrectly showing for
hardware wallet transactions on gas-sponsored networks
## **Related issues**
Fixes: #29241
## **Manual testing steps**
```gherkin
Feature: Gas sponsorship display for hardware wallets
Background:
Given I am logged into MetaMask Mobile
And I have a Ledger or QR hardware wallet connected
Scenario: HW wallet send on MON does not show "Paid by MetaMask"
Given I am connected to the Monad network with a hardware wallet
When user sends MON to another address
And user confirms the transaction on the hardware device
And user navigates to the activity log
And user selects the completed transaction
Then the network fee field should show the actual gas fee amount
And "Paid by MetaMask" should not appear
Scenario: HW wallet send on SEI does not show "Paid by MetaMask"
Given I am connected to the Sei network with a hardware wallet
When user sends SEI to another address
And user confirms the transaction on the hardware device
And user navigates to the activity log
And user selects the completed transaction
Then the network fee field should show the actual gas fee amount
And "Paid by MetaMask" should not appear
Scenario: Non-HW wallet send on sponsored network still shows "Paid by MetaMask"
Given I am connected to a gas-sponsored network with a software wallet
And the transaction is eligible for gas sponsorship
When user sends a transaction
And user navigates to the activity log
And user selects the completed transaction
Then "Paid by MetaMask" should appear in the network fee field
```
## **Screenshots/Recordings**
### **Before**
N/A
### **After**
N/A
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/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-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
#### Performance checks (if applicable)
- [x] I've tested on Android
- Ideally on a mid-range device; emulator is acceptable
- [x] I've tested with a power user scenario
- Use these [power-user
SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93)
to import wallets with many accounts and tokens
- [x] I've instrumented key operations with Sentry traces for production
performance metrics
- See [`trace()`](/app/util/trace.ts) for usage and
[`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274)
for an example
For performance guidelines and tooling, see the [Performance
Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers).
## **Pre-merge reviewer checklist**
- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] 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.
<!-- Generated with the help of the pr-description AI skill -->
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Touches transaction confirmation metadata and the activity
transaction-details UI; incorrect gating could hide or show sponsorship
inappropriately on supported networks, but the change is narrowly scoped
and covered by tests.
>
> **Overview**
> Fixes incorrect "Paid by MetaMask" labeling for hardware-wallet
transactions by **clearing `isGasFeeSponsored` in
`useTransactionConfirm` whenever gasless isn’t supported**, even when no
`selectedGasFeeToken` is present.
>
> Adds a UI guard in `TransactionDetails` to **suppress sponsored-fee
display for hardware accounts** (based on `txParams.from` +
`isHardwareAccount`), and extends unit tests to cover both the
confirmation override behavior and the hardware-wallet UI suppression.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
60007da. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent b9f3ee5 commit fa79ebb
4 files changed
Lines changed: 129 additions & 27 deletions
File tree
- app/components
- UI/TransactionElement/TransactionDetails
- Views/confirmations/hooks/transactions
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
333 | 334 | | |
334 | 335 | | |
335 | 336 | | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
336 | 341 | | |
337 | 342 | | |
338 | 343 | | |
| |||
474 | 479 | | |
475 | 480 | | |
476 | 481 | | |
477 | | - | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
478 | 485 | | |
479 | 486 | | |
480 | 487 | | |
| |||
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
| |||
511 | 517 | | |
512 | 518 | | |
513 | 519 | | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
514 | 535 | | |
Lines changed: 90 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
399 | 489 | | |
400 | 490 | | |
401 | 491 | | |
| |||
Lines changed: 10 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | 75 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 76 | + | |
93 | 77 | | |
94 | 78 | | |
95 | 79 | | |
| |||
99 | 83 | | |
100 | 84 | | |
101 | 85 | | |
102 | | - | |
103 | | - | |
104 | 86 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
| 87 | + | |
111 | 88 | | |
112 | 89 | | |
113 | 90 | | |
| |||
121 | 98 | | |
122 | 99 | | |
123 | 100 | | |
124 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
125 | 108 | | |
126 | 109 | | |
127 | 110 | | |
| |||
169 | 152 | | |
170 | 153 | | |
171 | 154 | | |
| 155 | + | |
172 | 156 | | |
173 | 157 | | |
174 | 158 | | |
| |||
0 commit comments