|
| 1 | +# MoneyAccountUpgradeController — Remaining Work |
| 2 | + |
| 3 | +## Step 0: Associate address |
| 4 | + |
| 5 | +- [ ] **Idempotency check**: `#associateAddress` currently always signs and submits. The CHOMP API returns 409 when already associated (which is handled as success), but we could skip the signing step entirely by checking state or querying CHOMP first. |
| 6 | + |
| 7 | +## Step 1: Submit authorization |
| 8 | + |
| 9 | +- [ ] **Fetch on-chain nonce**: The nonce is hardcoded to `0` (line 202). This needs to be replaced with an actual on-chain nonce fetch for the account — likely via an `eth_getTransactionCount` call or equivalent messenger action. CHOMP validates that the nonce matches. |
| 10 | + |
| 11 | +## Step 2: Verify delegation |
| 12 | + |
| 13 | +- [ ] **Caveat term encoding**: `#encodeCaveatTerms` does naive left-padded hex concatenation. Verify this matches the exact ABI encoding expected by the caveat enforcer contracts (may need proper ABI encoding via `@metamask/abi-utils` or similar). |
| 14 | +- [ ] **Use `@metamask/smart-accounts-kit`**: The description mentions using `createDelegation` from `@metamask/smart-accounts-kit` to build the delegation. This package is not yet in the repo — once it lands, the delegation construction in `#verifyDelegation` should use it instead of manual assembly. |
| 15 | +- [ ] **Import `ROOT_AUTHORITY` from `@metamask/delegation-controller`**: Currently defined locally as a constant. The delegation-controller has it but doesn't export it — once it's exported, import it instead. |
| 16 | + |
| 17 | +## Step 3: Save delegation |
| 18 | + |
| 19 | +- [ ] **Implement Authenticated User Storage save**: `#saveDelegation` is a stub (line 312-316). Needs the `@metamask/authenticated-user-storage` wrapper (PR currently open). Once available, save the signed delegation so CHOMP can read it at execution time via its internal VPC endpoint. |
| 20 | + |
| 21 | +## Step 4: Register intents |
| 22 | + |
| 23 | +- [ ] **Intent configuration**: The deposit/withdrawal intents are hardcoded with `mUSD` token symbol and `MAX_UINT256` allowance. These may need to come from config or be parameterised once requirements solidify. |
| 24 | + |
| 25 | +## General |
| 26 | + |
| 27 | +- [ ] **Resumability**: `upgradeAccount` runs all steps sequentially. If it fails mid-way and is retried, steps 0 and 2-4 will re-run from scratch. Consider checking persisted state at the start of each step to skip already-completed work (step 1 already does this via `getUpgrade`). |
| 28 | +- [ ] **`MoneyAccountController:getMoneyAccount`**: This action is declared in `AllowedActions` but not currently used. It was included anticipating the controller may need to look up account details. Remove if not needed, or use it to validate the address before starting. |
| 29 | +- [ ] **`#saveDelegation` unused `_chainId` parameter**: Will be needed once the stub is implemented — the storage call will likely need it. |
0 commit comments