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

[Bug]: The Pure JS example doesn't work, fail to detect Metamask extension #916

Closed
jimgreen2013 opened this issue Jun 25, 2024 · 4 comments · May be fixed by #930
Closed

[Bug]: The Pure JS example doesn't work, fail to detect Metamask extension #916

jimgreen2013 opened this issue Jun 25, 2024 · 4 comments · May be fixed by #930
Assignees
Labels
Bug Triage Issues to be triaged in the next session

Comments

@jimgreen2013
Copy link

SDK

Web

Provide environment information

I've tried firefox, chromium and Braver browser, my os is Linux/Fedora

MetaMask SDK Version

0.18.5

MetaMask Mobile app Version

Just web

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

image

Expected Behavior

image

Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

https://github.com/MetaMask/metamask-sdk/tree/main/packages/examples/pure-javascript

To Reproduce

open the index.html and click connect

@christopherferreira9 christopherferreira9 added the Bug Triage Issues to be triaged in the next session label Jun 26, 2024
@christopherferreira9 christopherferreira9 self-assigned this Jun 28, 2024
@christopherferreira9
Copy link
Collaborator

Hi @jimgreen2013 ! I wasn't able to reproduce this using OSX. Will try to give this one a go using Linux. I'll get back to this issue as soon as possible.

@jimgreen2013
Copy link
Author

jimgreen2013 commented Jun 28, 2024

Hi @jimgreen2013 ! I wasn't able to reproduce this using OSX. Will try to give this one a go using Linux. I'll get back to this issue as soon as possible.

I try my best to do some investigation, here are my findings:

  1. the vue example worked as expected;
  2. The key difference is that the vue example successfully inject window.etherum and window.extension while the pureJs example only inject window.etherum.

jimgreen2013 added a commit to jimgreen2013/metamask-sdk that referenced this issue Jul 7, 2024
Update the README to include steps for using a local HTTP server to serve 
index.html, as opening the file directly in the browser causes the Metamask 
SDK to fail to detect the MetaMask extension.

Added:
- Explanation about the need for a local HTTP server.
- Steps to run the example using node http-server.

Closes MetaMask#916
@jimgreen2013
Copy link
Author

jimgreen2013 commented Jul 7, 2024

@christopherferreira9 Finally, I find out the reason, it's not a bug but due to opening the index.html directly in the browser instead of serving it through a http server.

I have updated the README file and add more information, here is the pull request #930

@christopherferreira9
Copy link
Collaborator

awesome @jimgreen2013 ! We'll be addressing your PR soon. I'm closing this issue in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Triage Issues to be triaged in the next session
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants