Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cosmos-extension-metamask window checking issue #518

Open
chalabi2 opened this issue Dec 10, 2024 · 0 comments
Open

cosmos-extension-metamask window checking issue #518

chalabi2 opened this issue Dec 10, 2024 · 0 comments

Comments

@chalabi2
Copy link
Contributor

ISSUE

The cosmos-extension-metamask wallet does not properly check if metamask is installed or not.

SUMMARY

In the Leap metamask snap extension we properly check for the metamask window with

interface MetamaskWindow {
  ethereum?: {
    isMetaMask?: boolean;
  };
}

export const isMetamaskInstalled: () => Promise<boolean> = async () => {
  if (typeof window === 'undefined') {
    return false;
  }

  const ethereum = (window as MetamaskWindow).ethereum;

  if (ethereum?.isMetaMask) {
    return true;
  }

  if (document.readyState === 'complete') {
    if (ethereum?.isMetaMask) {
      return true;
    } else {
      throw ClientNotExistError;
    }
  }

But in the cosmos-extension we do not

interface SnapWindow {
cosmos?: CosmosSnap;
}

export const getSnapProviderFromExtension: () => Promise<
CosmosSnap | undefined
> = async () => {
if (typeof window === 'undefined') {
  return void 0;
}

const cosmos = (window as SnapWindow).cosmos;

if (cosmos) {
  return cosmos;
}

if (document.readyState === 'complete') {
  if (cosmos) {
    return cosmos;
  } else {
    throw ClientNotExistError;
  }
}

Fix for this is in #517

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant