-
Notifications
You must be signed in to change notification settings - Fork 5
Fix usage of WebSocketProvider and absence of pollingInterval #41
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
…ider in FallbackProvider as it defaults to polling which defeats purpose of WebSocketProvider
| const providerURL = config.provider; | ||
| // Ensure providerURL exists and is a string | ||
| if (!isDefined(providerURL)) { | ||
| throw new Error('provider is required for single provider configuration'); |
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.
Just as a reminder, lets try to make this errors look similar to #38
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.
Could you provide an example? Not clear what change is being asked for
| } catch (cause) { | ||
| if (!(cause instanceof Error)) { | ||
| throw new Error( | ||
| 'Non-error thrown from createFallbackProviderFromJsonConfig', |
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.
Might this be a typo!? this error message is createFallbackProviderFromJsonConfig, but the function is named createProviderFromJsonConfig, is this intended ?
| @@ -0,0 +1,117 @@ | |||
| import { FallbackProvider, JsonRpcProvider, WebSocketProvider } from 'ethers'; | |||
| import { FallbackProviderConfig } from 'ethers/lib.commonjs/providers/provider-fallback'; | |||
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.
I've did not notice we were importing this type from the internal structure of ethers!, given that any update on this might be a breaking change for us, is there any better way we can handle this type ? Mirroring this type with an interface of ours probably ?? or inferring the type.. idk 🤣
bhflm
left a comment
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.
Overall looks good to me, just some comments regarding types imports and misc things
Problem
FallbackProvider should never allow a WebSocketProvider, as it will use polling which defeats the purpose of the
eth_subscribelistener. See WebSocketProvider in FallbackProvider causes polling ethers-io/ethers.js#4932FallbackProvider creation currently doesn't allow passing the pollingInterval from wallet.
Solution