Commit 902d193
authored
fix(confirmations): cp-8.0.0 skip initial gas estimate for sponsored money account transactions (#32129)
## **Description**
Money Account deposit and withdrawal batches trigger synchronous gas
estimation when `addTransactionBatch` is called. On networks where gas
is sponsored (e.g. Monad Mainnet), a bug in gas estimation can cause a
crash when the RPC unexpectedly returns `null` for the latest block — an
error condition we are now handling defensively.
This PR passes `skipInitialGasEstimate: true` to deposit and withdrawal
batches when `isGasFeeSponsored` is true, deferring gas estimation to
the async background path where this error condition is handled safely.
Non-sponsored flows are unaffected.
## **Changelog**
CHANGELOG entry: Fixed a crash that could occur when initiating Money
Account transactions on Monad
## **Related issues**
Fixes:
## **Manual testing steps**
```gherkin
Feature: Money Account deposit and withdrawal on a sponsored-gas network
Scenario: user initiates a deposit on Monad Mainnet
Given the user has a Money Account on Monad Mainnet
And Monad Mainnet is selected
When user taps Deposit and confirms the transaction
Then the batch is submitted without crashing
And gas estimation completes in the background
Scenario: user initiates a withdrawal on Monad Mainnet
Given the user has a Money Account with a mUSD balance on Monad Mainnet
When user taps Withdraw and confirms the transaction
Then the batch is submitted without crashing
Scenario: user initiates a withdrawal on a non-sponsored network
Given the user has a Money Account on a non-Monad network
When user taps Withdraw and confirms the transaction
Then skipInitialGasEstimate is false and gas is estimated synchronously as before
```
## **Screenshots/Recordings**
### **Before**
N/A
### **After**
N/A
## **Pre-merge author checklist**
- [ ] 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).
- [ ] 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-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
#### Performance checks (if applicable)
- [ ] I've tested on Android
- Ideally on a mid-range device; emulator is acceptable
- [ ] 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
- [ ] 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
## **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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Touches confirmation/transaction submission for Money Account flows;
behavior change is gated to sponsored-gas (Monad) chains, with tests
updated for withdrawals only.
>
> **Overview**
> **Money Account** deposit and withdrawal now pass
**`skipInitialGasEstimate: true`** into `addTransactionBatch` when the
vault chain is Monad Mainnet (same condition as **`isGasFeeSponsored`**
via `isMonadMainnetChainId`), so synchronous gas estimation is skipped
and runs on the async path instead.
>
> Deposits also set **`isGasFeeSponsored`** on the batch (previously
only withdrawals did). Withdrawal tests on Monad assert both sponsored
flags; non-Monad withdrawal behavior is unchanged aside from not setting
`skipInitialGasEstimate`.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
85a41fe. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 8e2efd1 commit 902d193
2 files changed
Lines changed: 14 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
| 479 | + | |
479 | 480 | | |
480 | 481 | | |
481 | 482 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| |||
120 | 121 | | |
121 | 122 | | |
122 | 123 | | |
| 124 | + | |
| 125 | + | |
123 | 126 | | |
| 127 | + | |
| 128 | + | |
124 | 129 | | |
125 | 130 | | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
| 138 | + | |
| 139 | + | |
137 | 140 | | |
138 | 141 | | |
139 | 142 | | |
| |||
178 | 181 | | |
179 | 182 | | |
180 | 183 | | |
| 184 | + | |
181 | 185 | | |
182 | 186 | | |
183 | 187 | | |
| |||
199 | 203 | | |
200 | 204 | | |
201 | 205 | | |
| 206 | + | |
| 207 | + | |
202 | 208 | | |
| 209 | + | |
| 210 | + | |
203 | 211 | | |
204 | 212 | | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
| 213 | + | |
209 | 214 | | |
210 | 215 | | |
211 | 216 | | |
| |||
0 commit comments