Repository navigation
Commit 85e928e
authored
chore: Migrate Confirmations-involved legacy API method calls to messengers (#47326)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
Currently, the background process aggregates methods from various
controllers and services into an API object, and the UI calls a method
on this object by passing its name and arguments to
`submitRequestToBackground`.
The "root" messenger — the messenger for MetamaskController — is meant
to replace this API, and we want to transition to it by replacing
`submitRequestToBackground` calls so that they pass action type strings
(e.g. `NetworkController:addNetwork`) instead of method names (e.g.
`addNetwork`). Then, eventually, we want to remove the original methods
from the legacy API object. This PR is one of a series of PRs which aims
to unlock this refactor.
The tactic used to create this PR was to look for
`submitRequestToBackground` calls in controllers, services, and files
owned by the Confirmations team (although the changes may have affected
other files as well).
Most of the migrations that would have taken place in this commit have
already happened in a previous one. As a result, the following API
methods have been removed from the TransactionController init file:
- `getLayer1GasFee`
- `getTransactions`
- `isAtomicBatchSupported`
- `updateAtomicBatchData`
- `updateEditableParams`
- `updatePreviousGasParams`
- `updateSelectedGasFeeToken`
- `updateTransactionGasFees`
Calls for the following API methods defined within
`MetamaskController.getApi` were migrated to use messenger action type
strings:
- `updateTransaction` (-> `TransactionController:updateTransaction`)
Calls for the following API methods defined within the
TransactionController wallet library config file were not migrated for
the following reasons:
- `abortTransactionSigning` (is used by hardware wallets, and will be
migrated later)
- `updateBatchTransactions` (not registered on the messenger)
- `checkFirstTimeInteraction` (not registered on the messenger)
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: null
## **Related issues**
https://consensyssoftware.atlassian.net/browse/WPC-1426
## **Manual testing steps**
This PR should have no functional changes. All flows should work like
they do today, and the changes here should be covered by tests.
## **Screenshots/Recordings**
(N/A)
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/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-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **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 transaction persistence and gas-fee update IPC paths in
confirmations; behavior should be unchanged but regressions would affect
signing and approval flows.
>
> **Overview**
> Continues the move from the legacy background API to **messenger
action strings** for Confirmations-related transaction work.
>
> **Legacy API cleanup:** `getTransactionControllerApi` no longer
exposes eight `TransactionController` methods (`getLayer1GasFee`,
`getTransactions`, atomic-batch and gas-fee updaters, etc.); callers are
expected to use the corresponding `TransactionController:*` messenger
actions instead. **`updateBatchTransactions`** and
**`checkFirstTimeInteraction`** remain on the legacy surface.
>
> **UI call sites:** Money Account withdraw persistence now invokes
**`TransactionController:updateTransaction`** (not `updateTransaction`)
and passes a note string, **`Prepared Money Account withdrawal for
approval`**, alongside the transaction meta; tests assert that shape.
>
> **Gas fees thunk:** The background request was already
**`TransactionController:updateTransactionGasFees`**; the change
replaces a `@ts-expect-error` with an explicit cast for the
**`userEditedGasLimit`** string vs boolean mismatch.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
c8e1ac3. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent cf3309c commit 85e928e
4 files changed
Lines changed: 18 additions & 32 deletions
File tree
- app/scripts/wallet-init/instance-options
- ui
- pages/confirmations/hooks/transactions
- store/actions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | 178 | | |
191 | 179 | | |
192 | 180 | | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | 181 | | |
208 | 182 | | |
209 | 183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
156 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
157 | 160 | | |
158 | 161 | | |
159 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | 22 | | |
25 | 23 | | |
26 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
27 | 33 | | |
28 | 34 | | |
29 | 35 | | |
| |||
0 commit comments