You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(accounts-controller): do not fire events during update blocks (#5555)
## Explanation
Events should be fired after making a state update. Otherwise we could
end up with race conditions like some other component react to
`AccountsController:accountAdded` and try to call
`getAccount(account.id)`, it might not the same value compared to the
`account` being passed during the event (since the state update has not
been persisted yet).
This PR now moves all events firing after the state update.
It also includes a small refactor of the `KeyringController:stateChange`
handler (which made the new events firing logic, a bit easier).
Test E2E PR:
- MetaMask/metamask-extension#31393 (CI is
passing)
## References
N/A
## Changelog
TODO
## Checklist
- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
- [ ] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
---------
Co-authored-by: Monte Lai <[email protected]>
0 commit comments