Skip to content

Metamask signer triggers redundant "Account request" popups #122

@ross-weir

Description

@ross-weir

An Account Request popup is triggered every time the metamask signer calls Signer.publicKey to retrieve the users pubkey. There can be 2 of these when submitting a transaction resulting in 3 prompts to sign a transactions.

The Account Request prompt was added due to an action item resulting from the audit - we need to explicitly ask the users permission to access their public key.

We could cache the account details on first call instead of prompting the user every time. This is an example provided to nebula team:

export const cachedMetaMask = (opts: MetaMaskSnapSignerOpt): Signer => {
  const base = newMetaMaskSnapSigner(opts);
  let cachedPubKey: Uint8Array | undefined = undefined;

  return {
    ...base,
    async publicKey() {
      if (cachedPubKey) {
        return cachedPubKey;
      }

      cachedPubKey = await base.publicKey();
      return cachedPubKey;
    },
  };
};

While this works it won't be cached across page navigation so could still result in an annoying amount of prompts, might be better to also store the key in local storage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions