-
Notifications
You must be signed in to change notification settings - Fork 251
Migrate MetaMask Connector to use new SDK (MMConnect) #2326
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
base: master
Are you sure you want to change the base?
Migrate MetaMask Connector to use new SDK (MMConnect) #2326
Conversation
|
@adonesky1 is attempting to deploy a commit to the Consensys Team on Vercel. A member of the Team first needs to authorize it. |
| this.metamaskInstance = await this.metamaskPromise; | ||
| // TODO: Remove this hack | ||
| // Hack to ensure the ConnectEvm instance has fully resumed the connection | ||
| await new Promise((resolve) => setTimeout(resolve, 2000)); |
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.
Note this awful delay to ensure that this async call in the ConnectEvm constructor has fully resolved. We need to fix this on the connect-monorepo side
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.
What is your understanding of how we resolve this on the connect-evm side of things?
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.
| // if (options.autoConnect) { | ||
| // this.rehydrated = false; | ||
| // this.emit(CONNECTOR_EVENTS.REHYDRATION_ERROR, new Error("Failed to resume existing MetaMask Connect session.") as Web3AuthError); | ||
| // } else { |
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.
i think this commented code can be dropped?.. Not sure if it's more appropriate to throw an error if we fail to resume a previous session OR if we just say the connector is ready for new connections
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.
I would think it makes more sense to just say the connector is ready for new connections. But perhaps we should speak with @chaitanyapotti to see what patterns they recommend for their connectors
Summary
@metamask/sdkto@metamask/connect-evmfor improved connection handlingMetaMaskConnectorto use the new SDK'screateEVMClient()API with built-in event handlers and automatic chain managementswitchChain()Videos
Extension:
https://drive.google.com/file/d/1r_lDBvwHWQhP-J4yFfqVHsqRR7bIS6Z1/view?usp=sharing
Mobile (native browser):
https://drive.google.com/file/d/1XECLgCOqa9VEeIK4gp1nUf0cs6RRg2V1/view?usp=sharing