Commit 8ea647f
authored
fix: check for token address in delegation matching in upgrade step (MetaMask#9075)
## Explanation
**Current state:** The `register-intents` step filters stored
delegations by delegator address, delegate address, chain, and redeemer
caveat before submitting them to CHOMP as intents. However, it does not
filter by token address. This means that if the configured token
addresses ever change (e.g. a boring vault contract is redeployed to a
new address during development), any delegation written against the old
address that still happens to carry a valid redeemer caveat will be
picked up and registered as an intent against the new configuration —
producing a stale, mismatched intent.
**Solution:** A `matchesConfiguredToken` predicate is added to the
`needsIntent` filter that checks the delegation's `tokenAddress` against
the two currently-configured addresses (`musdTokenAddress` for deposits,
`boringVaultAddress` for withdrawals). Only delegations whose token
address matches one of these two values are eligible for intent
registration. Delegations for any other token address are silently
skipped.
<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?
For example:
* Fixes #12345
* Related to #67890
-->
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes which delegations are registered as CHOMP intents during
account upgrade; incorrect filtering could skip valid intents or still
allow mismatches, but the change is narrow and test-backed.
>
> **Overview**
> **Fixes stale intent registration** when stored delegations still
match delegator, delegate, chain, and redeemer caveats but point at an
old token contract (e.g. a redeployed boring vault).
>
> The `register-intents` step now requires each delegation’s
`metadata.tokenAddress` to match the current **mUSD**
(`musdTokenAddress`) or **withdrawal vmUSD** (`boringVaultAddress`)
before it is submitted to CHOMP. Other token addresses are skipped. A
regression test covers a stale withdrawal delegation that would
previously have been eligible.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
f8ed22f. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent fa2f9a1 commit 8ea647f
3 files changed
Lines changed: 41 additions & 0 deletions
File tree
- packages/money-account-upgrade-controller
- src/steps
| 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 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
432 | 432 | | |
433 | 433 | | |
434 | 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 | + | |
435 | 463 | | |
436 | 464 | | |
437 | 465 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
| 55 | + | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
| |||
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
73 | 81 | | |
74 | 82 | | |
75 | 83 | | |
76 | 84 | | |
| 85 | + | |
77 | 86 | | |
78 | 87 | | |
79 | 88 | | |
| |||
0 commit comments