Skip to content
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

getMainnetSdk should allow provider or signer, not just signer #63

Closed
agcty opened this issue Dec 27, 2021 · 2 comments · Fixed by #97
Closed

getMainnetSdk should allow provider or signer, not just signer #63

agcty opened this issue Dec 27, 2021 · 2 comments · Fixed by #97

Comments

@agcty
Copy link

agcty commented Dec 27, 2021

When calling getMainnetSdk it should be allowed to pass any ethers provider or signer. In our codebase we're using a custom useDapp-like library in conjunction with web3-react.

When no signer (e.g as injected by MetaMask) is available, it defaults to a StaticJsonRPCProvider.

This is very useful in combination with useSWR (or react-query) and suspense as it provides a great DX and UX:

It will actually show the data that only needs a provider and displays a fallback state if it can't fetch the data that needs a signer but will automatically show it when the user connects a wallet that injects a signer.

@agcty
Copy link
Author

agcty commented Dec 28, 2021

this is important for using the hook as described in #65 😎

@krzkaczor
Copy link
Member

This is probably a reasonable improvement. The only problem is that when a user passes a provider then the whole SDK is "read-only" and calling any method that would require a transaction will result in a runtime error.

@agcty feel free to create a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants