Eliminate polling for wallet account change
- Dominant language
- TypeScript
- Stars
- 146
- Forks
- 78
- PR merge metrics
- No merged PRs in 30d
Description
Currently we poll every 2000ms for account change in MetaMask.
Instead, we can use a listener for account changes, like this:
```
window.ethereum.on("accountsChanged", (accounts: Array) => {
//Handle the new accounts.
//"accounts" will always be an array, but it can be empty.
//The current account is at accounts[0]
});
```
See also https://docs.metamask.io/guide/ethereum-provider.html#events.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the 2000ms polling code that detects wallet account changes. Read the MetaMask accountsChanged provider event documentation and trace how the current account is consumed. Done means account changes use the listener, including the empty-accounts case, without polling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- blockchain, frontend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100