-
Notifications
You must be signed in to change notification settings - Fork 177
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
SwapWidget not accepting ethers providers #216
Comments
Yeah i have the same issue, using the most recent version of wagmi, I cant use the provider in the Uni wap widget. Seems like it must be an older version of the provider needed, not sure exactly which version tho, |
I think it's just a typescript error so if you cast your provider to a Web3Provider it will work. |
I tried this now. It doesn't give the typescript error anymore, but it also doesn't work. I still have to manually connect my wallet through the widget. It doesn't detect the provider. I also use wagmi, by the way. |
https://wagmi.sh/docs/hooks/useWebSocketProvider use the websocket provider. It worked for me. You actually don't need the cast then. You have to pass in the chain Id through |
So, I tested it, and it does work for fetching the price, but unfortunately it is still not picking up on the actual connected wallet. Thank you for these tips, though. |
I figured out, that we should get provider from wallet connector.
|
@rowanryan did anything change regarding this after the latest updates to the widget? |
This is what I found working with the latest import { Web3Provider } from '@ethersproject/providers'
import { useAccount } from 'wagmi'
import { SwapWidget } from '@uniswap/widgets'
// some code...
const [provider, setProvider] = useState<Web3Provider | undefined>()
const { connector } = useAccount()
useEffect(() => {
if (!connector) {
return () => setProvider(undefined)
}
connector.getProvider().then((provider) => {
setProvider(new Web3Provider(provider))
})
}, [connector])
// some code...
<SwapWidget
provider={provider} /> |
@farreldarian Nice solution! I spent hours on this today and came up with a slightly different approach.
Then just get the provider for the widget:
|
@paintoshi the widget keep refreshing and loosing state using this method - any ideas ? |
Bug Description
Ethers.js FallbackProvider not working with SwapWidget. The FallbackProvider is what is returned by ethers.getDefaultPovider(). When using an editor like VSCode, the editor tells you that the passed in provider is missing properties of the jsonRpcProvider. This is weird, because the documentation says I can also pass in any ethers provider or any EIP-1193 provider.
Steps to Reproduce
Expected Behavior
I expect the widget to accept any ethers provider, like the documentation says.
Additional Context
I am using version 2.8.1 of the "@uniswap/widgets package".
Version 5.7.0 of the "ethers" package.
Image of the error:
![image](https://user-images.githubusercontent.com/29815785/191553711-52de3e97-3491-4bde-8b81-1cba65d57453.png)
The text was updated successfully, but these errors were encountered: