MetaMask / MetaMask/metamask-extension

on("accountsChanged") not firing

Open
#11,403 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-api
Dominant language
TypeScript
Stars
13.2k
Forks
5.6k
Avg merge
2d 5h
Merged PRs (30d)
451

Description

An application may request accounts from the user using the `eth_requestAccounts` RPC method.

The user may refresh this page, leaving a pending account request on MetaMask.

When the user later finishes accepting this account request, the `accountsChanged` event does not trigger on the page.

Therefore, there is no way of determining if the user has accepted an account request after a page reload has occurred in-between.

Temporary solution which should work: Poll the `eth_accounts` RPC method every few seconds and if an account appears then it is clear that the user has accepted the account request. This method does not allow you to detect if account request denied.

I assume the purpose of event handlers is to avoid polling like this, so I hope that the event logic gets changed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the sequence involving eth_requestAccounts, a page refresh, and later completion of the pending request. Trace the implementation of the accountsChanged event and verify that it fires after the request is accepted following a reload, rather than requiring polling eth_accounts.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.