daostack / daostack/alchemy

Eliminate polling for wallet account change

Open
#2,295 5 comments 0 reactions 0 assignees View on GitHub
Improvement Maintenance optimisation
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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.