-
Notifications
You must be signed in to change notification settings - Fork 10
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
first step to future-proof web3 init #584
Conversation
fixes #595 |
Can we switch the async option today? |
@kosecki123 At this time it appears that the PR has yet to be merged MetaMask/metamask-extension#4703 |
|
||
window.postMessage({ type: 'ETHEREUM_PROVIDER_REQUEST' }, '*'); | ||
|
||
// If the MetaMask message is not received we set web3 to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not as simple as that I believe. In reality message will be received asynchronously and by the time it will be received, web3 will be set to fallback provider (L319). This should be somehow promisified or separated through some checks from using L319 fallback provider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea correct. I'm not sure what the best way to handle the async connection to MetaMask is though. This code just assumes it will replace the fallback web3 with MetaMask web3 when it is approved. We could have all the read-only operations available using back-up provider in the same way we have now and just wait to allow scheduling until MetaMask is unlocked.
With this code, if the message is received async, will the web3 object update and refresh the page?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, we should promisify web3
so, L325 would be something like this.web3 = await web3
With this, |
Following https://medium.com/metamask/https-medium-com-metamask-breaking-change-injecting-web3-7722797916a8
Will have to manage the async initialization of web3.