-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix useAppKitProvider: Don't wrap walletProvider with ref
#5418
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: main
Are you sure you want to change the base?
Conversation
|
|
@dima74 is attempting to deploy a commit to the Reown Team on Vercel. A member of the Team first needs to authorize it. |
|
All contributors have signed the CTA ✍️ ✅ |
|
I have read the CTA Document and I hereby sign the CTA |
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.
Pull request overview
This PR fixes a bug in the Vue implementation where wrapping walletProvider with Vue's ref created deep reactive Proxies that caused errors with certain wallets (e.g., MetaMask + Solana) when interfacing with the Solana Anchor framework.
- Changed
reftoshallowReffor provider objects to prevent deep reactivity - Maintained reactivity for subscription updates while avoiding Proxy-related errors
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const walletProvider = shallowRef(ProviderController.state.providers[chainNamespace] as T | undefined) | ||
| const walletProviderType = shallowRef(ProviderController.state.providerIds[chainNamespace]) |
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.
Can you describe a case where ref caused an issue/problem just so i can reproduce the issue on my end?
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.
Created demo: https://stackblitz.com/edit/github-j6in4egw?file=src%2Fcomponents%2Fdemo.ts
Open the project, connect metamask, observe TypeError: Cannot read private member from an object whose class did not declare it exception in browser logs
|
this is most probably because Anchor is expecting a different interface, you will probably need to build an adapter |
Problem is with ref/reactive wrapping. Without wrapping (e.g. using shallowRef as proposed in this PR), there will be no error and everything will work correctly. |
|
have you tried using binding then? |
Sorry what binding do you mean? |
|
how do you know it's a ref issue? the Anchor class requires a Wallet Standard wallet, walletProvider is a completely custom class built by AppKit internally |
There will be no error and everything will work correctly without ref/reactive wrapping (e.g. using shallowRef as proposed in this PR) |
Description
Currently
walletProvideris wrapped withrefinuseAppKitProvider. This creates Proxy forwalletProvider, which could result in error like this on some wallets (e.g. MetaMask + Solana) when passing resultingwalletProvideras argument toAnchorProvider(solana primary framework):Type of change
Checklist