-
Notifications
You must be signed in to change notification settings - Fork 28
Deprecate use of polling provider #105
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
| tokenVaultV3Contract, | ||
| fallbackProvider, | ||
| pollingProvider, | ||
| undefined, // pollingProvider is being deprecated |
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.
Type error here. I do not think it's a breaking change to change the type to ? on the functions that take the now deprecated polling provider such that you no longer have to pass them
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.
Are you saying to remove the optional param and not pass undefined? Or just stating that it is okay
It is part of the last commit to the relating engine PR Railgun-Community/engine@3e3f607
| /** | ||
| * @deprecated pollingInterval - DEPRECATED | ||
| */ | ||
| pollingInterval: number, |
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.
Add deprecated to this too?
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.
It's already there if you are asking to ensure it has deprecated on it
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.
minor suggestions feel free to apply
…r engine.loadNetwork call, ensure test catches invalid provider json
|
TODO: This contains a shared-models patch from Railgun-Community/shared-models#41 - update version when it is merged Allows pollingInterval to be passed with FallbackProvider |
|
TODO: This contains an engine patch from Railgun-Community/engine#112 - update version when it is merged Allows for type WebSocketProvider to be passed into engine |
…on does not need to specify it
|
TODO: |
… provider creation function
| "lint": "npm run check-circular-deps && npm run eslint && npm run tsc && npm run tsc-test", | ||
| "prepare": "npm run build", | ||
| "postinstall": "node postinstall.js", | ||
| "postinstall": "node postinstall.js && patch-package", |
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.
we plan to remove this once the pr is approved right ?
| providerJsonConfig: FallbackProviderJsonConfig | ProviderJson, | ||
| pollingInterval?: number, | ||
| ): Promise<Provider> => { | ||
| const existingProvider = providerMap[networkName]; |
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.
It's throwing a lint error for me here
Unexpected any value in conditional. An explicit comparison or type cast is required
| networkName: NetworkName, | ||
| ): void => { | ||
| pauseAllPollingProviders( | ||
| networkName, // excludeNetworkName |
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 we rename this to excludedNetworkName instead of just having it as a comment ?
| } | ||
|
|
||
| // Ensure provider has resume functionality | ||
| if (!('paused' in provider && 'resume' in provider)) { |
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.
We could do a validateProvider function rather than having this statement twice, since the flow itself its pretty similar
something like
type PausableProvider extends Provider {
pause(): voidl;
resume(): void;
paused: boolean;
}
function isPausableProvider(provider: Provider): provider is PausableProvider {
return 'pause' in provider && 'resume' in provider && 'paused' in provider;
}
const validateProvider = (networkName: NetworkName, provider?: Provider) => {
if (!isDefined(provider)) {
throw new Error(`No provider found for network: ${networkName}`);
}
if (!isPausableProvider(provider)) {
throw new Error(`Provider for network ${networkName} is not a pausable provider`);
}
return provider;
};
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.
LGTM, minor comments on nice to have refactors
Problem
Polling provider is deprecated in engine PR Railgun-Community/engine#112
Solution
This helps remove call to engine.loadNetwork() with a pollingProvider, as the engine PR does not use polling provider. It only allows passing it now to prevent a breaking change and allow time for full deprecation.