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

Provider instance is created even when MetaMask is not installed #65

Closed
johnmendonca opened this issue Jul 8, 2020 · 2 comments · Fixed by #120
Closed

Provider instance is created even when MetaMask is not installed #65

johnmendonca opened this issue Jul 8, 2020 · 2 comments · Fixed by #120

Comments

@johnmendonca
Copy link

johnmendonca commented Jul 8, 2020

I am using this package to work around a Firefox issue where the eth provider cannot be injected: MetaMask/metamask-extension#3133

On Chromium with no metamask extension installed, this package still creates a full provider object, though some of the properties are undefined.

I am just wondering what is the correct way to check if the provider is good to use. I am planning for now to check the value of chainId, but I don't know if this is actually a bug.

Here is the console.log output for the provider:

Proxy {_events: {…}, _eventsCount: 1, _maxListeners: 100, isMetaMask: true, _state: {…}, …}
[[Handler]]: Object
deleteProperty: () => true
__proto__: Object
[[Target]]: MetamaskInpageProvider
autoRefreshOnNetworkChange: false
chainId: undefined
enable: ƒ ()
isMetaMask: true
networkVersion: undefined
request: ƒ ()
selectedAddress: null
send: ƒ ()
sendAsync: ƒ ()
_events: {connect: ƒ}
_eventsCount: 1
_handleAccountsChanged: ƒ ()
_handleDisconnect: ƒ ()
_maxListeners: 100
_metamask: Proxy {isUnlocked: ƒ, requestBatch: ƒ, isEnabled: ƒ, isApproved: ƒ}
_publicConfigStore: ObservableStore {_events: {…}, _eventsCount: 1, _maxListeners: undefined, _state: {…}}
_rpcEngine: RpcEngine {_events: {…}, _eventsCount: 0, _maxListeners: undefined, _middleware: Array(3)}
_rpcRequest: ƒ ()
_sendSync: ƒ ()
_state: {sentWarnings: {…}, isConnected: true, accounts: undefined, isUnlocked: undefined}
_warnOfDeprecation: ƒ ()
_web3Ref: undefined
__proto__: SafeEventEmitter
[[IsRevoked]]: false
@johnmendonca
Copy link
Author

It's possible that I did have metamask installed at one point and have deleted since then. I am looking around chrome://about to see if I can find any local data that might be left behind, but I don't know exactly where it would be.

@rekmarks
Copy link
Member

rekmarks commented Jul 8, 2020

There's an event pair, connect/disconnect, and a related method, isConnected, that are supposed to be used for this purpose, but unfortunately they're not correctly implemented yet. I'll keep this issue open until they are.

Meanwhile, checking if the chainId is undefined is a good solution. The chainId is only populated if the provider successfully connects to MetaMask, so its absence implies the absence of MetaMask.

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

Successfully merging a pull request may close this issue.

2 participants