-
Notifications
You must be signed in to change notification settings - Fork 972
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
More hooks #996
Comments
Wagmi also wraps low level functions with React Query which can be pretty handy for caching |
I wanted to avoid needing React Query as a dependency so I am rebuilding the most basic things about it. |
We are working on something similar to the Wallet Adapter at WalletConnect. If it's an external package it would be great if it could support both |
Thanks for the suggestion, and for your work on implementing some of it. However, I don't think we should add this to the wallet-adapter library. Wallet-adapter aims to be un-opinionated about how an app is built, while Wagmi as mentioned wraps Tanstack Query and builds these features on top of it. I don't think we can build these in a useful way without wrapping something like Tanstack Query, and I don't think we should do that in wallet-adapter. Apps that use some data fetching library (React/Tanstack Query, or anything else) will want it to be used for this - because they'll have their own configuration/caching logic etc that makes sense for them. So I wouldn't want to implement this with its own data fetching, because that makes things harder for apps. These features also don't really fit well with wallet-adapter IMO. For example, IMO the best way to build this would be as a community maintained package that builds on top of web3.js tech preview (mostly because it's much lighter weight and less opinionated) + Tanstack Query. I'd definitely be keen to see what that could look like! |
I've been doing some experimenting with how a web3js-based library could work and I think I've come up with a pretty cool pattern! You can use a JS Proxy (this is how the new web3js RPC methods work) and some typescript trickery to turn every RPC method into a hook. This is really nice because it means your bundle is tiny, you don't have to have actual implementations of a wrapper of every function. The new web3js RPC is also extensible, so if eg Helius publish types for it then you'd automatically get hooks for all of them too. Example replit here: https://replit.com/@mcintyre94/SolanaHooks?v=1 (all the magic is 50ish lines in hooks.ts) Some notes:
Ultimately I don't think we as Anza would want to publish this because it's more opinionated than we like to be about how apps are built. You should only use this But if you'd be interested in running with it, that'd be awesome! I'd be happy to help out, and the Replit code is Apache 2.0 licensed (same as this repo). |
Is your feature request related to a problem? Please describe.
It would be nice to have hooks with getters for the most common things like balances and whatever else the connection object allows. This is inspired by the wagmi package
Describe the solution you'd like
Actually I am willing to implement these myself, I have some code ready to go, I just need instructions on how to build so I can test. (typescript dependency seems to be absent from the react package)
EDIT: I got them to build. See #997
I needed to disable a test and add typescript to the dependencies to get it to build (I haven't commited those changes as I probably am just too dumb to build right)
Also would love to have a discussion on whether these hooks should come with this package (I think so) or separately.
Describe alternatives you've considered
Additional context
As mentioned it would be nice if someone could point me to some instructions on how to best build the react package.
The text was updated successfully, but these errors were encountered: