-
Notifications
You must be signed in to change notification settings - Fork 115
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
Use @solana/wallet-adapter-react
for compatibility with Mobile Wallet Adapter and the Wallet Standard
#423
base: main
Are you sure you want to change the base?
Conversation
@jordansexton is attempting to deploy a commit to the blockworks-foundation Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
const wallets = useMemo( | ||
() => [ | ||
new BackpackWalletAdapter(), |
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.
looks like backpack disappeared
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.
oh i see this works now without adapter, awesome
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.
Exactly! We should be able to remove the Glow adapter soon also. The desktop browser extension supports the standard, but the mobile WebView version doesn't yet.
Updated to the latest RC of wallet-adapter-react. No functional changes for dapps, just makes how wallets are detected on the window more robust. |
Maybe don't review just yet, still making some internal changes. This won't affect you, but want to avoid spamming you with new RCs. |
@solana/wallet-adapter-react
for compatibility with Mobile Wallet Adapter and the Wallet Standard@solana/wallet-adapter-react
for compatibility with Mobile Wallet Adapter and the Wallet Standard
We're at RC 9, which looks likely to be the last RC. This now updates Mango to use the latest RC. I'll follow up once we hit full release. There are no functional changes for apps with this update. It makes how wallets attach to the window more robust. |
@solana/wallet-adapter-react
for compatibility with Mobile Wallet Adapter and the Wallet Standard@solana/wallet-adapter-react
for compatibility with Mobile Wallet Adapter and the Wallet Standard
i just tried your changes locally on devnet
|
@mschneider thanks for the repro steps, will try this. What version of node are you on so I can run the same? |
17.4 |
In this PR we upgrade
@solana/wallet-adapter-react
and replace a modifiedWalletProvider
and various hooks. The main benefit of doing so is that Mango gets the following for free:You can read much more about the wider effort to upgrade the entire ecosystem of Solana web apps at: anza-xyz/wallet-adapter#604
Approach
Mango's UI makes use of a custom
WalletProvider
context provider implementation. This copies many behaviors from the one in@solana/wallet-adapter-react
, but removes the clearing of wallets on disconnection and errors. Because the stock@solana/wallet-adapter-react
WalletProvider
is needed to get the above benefits, we restore it in this PR.However, we extend this with a custom child provider that implements the behavior that Mango's UI currently has, of preselecting the first displayed wallet, remembering it, and displaying it in the connect button. In this way, we're able to keep what I think is the desired behavior, while restoring auto-connect functionality that improves the UX on desktop and especially on mobile using Mobile Wallet Adapter.
I've (manually, but heavily) tested connect, disconnect, wallet switching, error handling, autoconnect, and account viewing on desktop with multiple wallets. I didn't test transactions in Mango because the UI is currently warned to be non-functional.
Screenshots
Wallet Menu
Backpack and Glow, both Standard Wallets, are detected without using adapters. Glow's adapter is included in the code, but the Standard Wallet is used instead, without duplication.
Connected Wallet
Backpack, a Standard Wallet, is shown connected to Mango without using an adapter.