MetaMask / MetaMask/metamask-extension

[State Sync Redesign 2.2] Migrate `_onStateUpdate` to direct messenger subscriptions

Open
#40,053 0 comments 0 reactions 0 assignees View on GitHub
INVALID-ISSUE-TEMPLATE team-extension-platform
Dominant language
TypeScript
Stars
13.2k
Forks
5.6k
Avg merge
2d 5h
Merged PRs (30d)
451

Description

`_onStateUpdate` reads `isUnlocked` and calls `_notifyChainChange`. Replace with focused subscriptions.

## Steps

1. Subscribe to `KeyringController:stateChange` for `isUnlocked`
2. Subscribe to `NetworkController:stateChange` for `_notifyChainChange`
3. Remove `this.on('update', _onStateUpdate)` listener

## Files

- `app/scripts/metamask-controller.js`

## Risk

Low — two focused subscriptions.

## Dependencies

None (can proceed immediately)

## Context

Part of [State Sync Redesign — Epic 2: Background cleanup].

Contributor guide

Open the contributing guide

Research direction

Start in app/scripts/metamask-controller.js at _onStateUpdate and inspect nearby messenger subscription patterns. Replace the update listener with the two focused state-change subscriptions described in the issue, then verify the old listener is removed and each subscription handles only its specified responsibility.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.