MetaMask / MetaMask/metamask-extension
UI <=> Background - Stop dispatching methods that do not need to be thunks
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
### **Epic: Define deeper boundaries between background and redux state**
https://github.com/MetaMask/metamask-extension/issues/18054
### **Tasks:**
- Stop dispatching methods that do not need to be thunks. There are several of these in the actions file that do not need to be a part of redux at all. They shouldn’t be dispatched. Here's an example for https://github.com/MetaMask/metamask-extension/blob/develop/ui/store/actions.ts#L303
**_Before:_**
```
export function tryReverseResolveAddress(
address: string,
): ThunkAction {
return () => {
return new Promise((resolve) => {
callBackgroundMethod('tryReverseResolveAddress', [address], (err) => {
if (err) {
logErrorWithMessage(err);
}
resolve();
});
});
};
}
```
**_After:_**
```
export function tryReverseResolveAddress(
address: string,
) {
return new Promise((resolve) => {
callBackgroundMethod('tryReverseResolveAddress', [address], (err) => {
if (err) {
logErrorWithMessage(err);
}
resolve();
});
});
};
```
You can refer this simple method https://github.com/MetaMask/metamask-extension/blob/develop/ui/store/actions.ts#L279
Contributor guide
Research direction
Start in ui/store/actions.ts, especially the tryReverseResolveAddress example around line 303 and the simple method around line 279. Review the other action methods to identify those that do not need thunk or Redux dispatch behavior, then trace their call sites. Done means those methods are invoked directly rather than dispatched as thunks, without changing their background calls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100