Commit 6f9a290
authored
Fix Across Predict withdraw gas payment edges (#8762)
## Summary
This is PR 4 of 4 in the core stack for Predict withdraws over Across.
- Fixes TransactionController gas-fee-token publishing when native token
usage is explicitly excluded.
- Handles Across gas-station edge cases for post-quote Predict
withdraws, including source-token gas pricing fallback when the gas
station cannot price the token directly.
- Caps prefunded post-quote Predict withdraw gas estimates at the
configured Across fallback when batch simulation inflates the estimate.
- Keeps transaction-pay-controller coverage at 100% and exercises the
transaction-controller gas-fee-token path.
## Stack
1. #8759: plumbing to identify Predict Across withdraws
2. #8760: quote support
3. #8761: submit support
4. This PR: gas payment edge cases
## Validation
- `yarn workspace @metamask/transaction-pay-controller run jest
--no-coverage src/strategy/across/across-quotes.test.ts
src/strategy/across/across-submit.test.ts
src/strategy/across/AcrossStrategy.test.ts`
- `yarn workspace @metamask/transaction-controller run jest
--no-coverage src/utils/gas-fee-tokens.test.ts`
- `yarn changelog:validate`
- `yarn workspace @metamask/transaction-pay-controller run test`
- `yarn workspace @metamask/transaction-controller run test`
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes transaction publishing and Across quote fee estimation logic
around gas-fee tokens and EIP-7702, which can affect whether
transactions are priced and signed correctly in edge cases.
>
> **Overview**
> Fixes gas-fee-token handling when publishing transactions that
explicitly set `excludeNativeTokenForFee`, ensuring the pre-publish
check skips native-balance logic and forces `isExternalSign`/nonce
clearing when a gas fee token is selected.
>
> Improves Across post-quote Predict-withdraw fee calculation by (1)
capping inflated prefunded EIP-7702 batch gas estimates to the
configured Across fallback, (2) falling back to fiat-derived
source-token gas pricing when the gas station can’t price the source
token, and (3) preferring source-token gas pricing for post-quote
Predict withdraws (while keeping native-gas pricing when the account
can’t use 7702). Tests were expanded to cover these new paths and edge
cases.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
2d30cef. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent b3dd204 commit 6f9a290
7 files changed
Lines changed: 685 additions & 31 deletions
File tree
- packages
- transaction-controller
- src/utils
- transaction-pay-controller
- src
- strategy/across
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
Lines changed: 31 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
483 | 513 | | |
484 | 514 | | |
485 | 515 | | |
| |||
503 | 533 | | |
504 | 534 | | |
505 | 535 | | |
506 | | - | |
| 536 | + | |
507 | 537 | | |
508 | 538 | | |
509 | 539 | | |
| |||
Lines changed: 25 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
150 | 154 | | |
151 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
152 | 159 | | |
153 | 160 | | |
154 | 161 | | |
155 | 162 | | |
156 | 163 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
166 | 169 | | |
167 | 170 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
172 | 175 | | |
173 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
174 | 183 | | |
175 | 184 | | |
176 | 185 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
| |||
0 commit comments