-
Notifications
You must be signed in to change notification settings - Fork 36
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?
Changes from 1 commit
d43f658
4ff6e52
7c05beb
0ac5673
ac818ed
c5ff86f
c23d095
9907a34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,16 +13,12 @@ import { reportAndSanitizeError } from '../../../utils/error'; | |
| import { WalletPOI } from '../../poi/wallet-poi'; | ||
| import { getEngine } from './engine'; | ||
| import { | ||
| PollingJsonRpcProvider, | ||
| RailgunVersionedSmartContracts, | ||
| createPollingJsonRpcProviderForListeners, | ||
| } from '@railgun-community/engine'; | ||
| import { FallbackProvider } from 'ethers' | ||
| import { | ||
| fallbackProviderMap, | ||
| pollingProviderMap, | ||
| setFallbackProviderForNetwork, | ||
| setPollingProviderForNetwork, | ||
| } from './providers'; | ||
| import { WalletPOINodeInterface } from '../../poi/wallet-poi-node-interface'; | ||
|
|
||
|
|
@@ -41,32 +37,20 @@ const createFallbackProviderForNetwork = async ( | |
| return fallbackProvider; | ||
| }; | ||
|
|
||
| const createPollingProviderForNetwork = async ( | ||
| networkName: NetworkName, | ||
| fallbackProvider: FallbackProvider, | ||
| pollingInterval: number, | ||
| ): Promise<PollingJsonRpcProvider> => { | ||
| const existingProvider = pollingProviderMap[networkName]; | ||
| if (existingProvider) { | ||
| return existingProvider; | ||
| } | ||
| const network = NETWORK_CONFIG[networkName]; | ||
| if (!isDefined(network)) { | ||
| throw new Error('No network found'); | ||
| } | ||
| const pollingProvider = await createPollingJsonRpcProviderForListeners( | ||
| fallbackProvider, | ||
| network.chain.id, | ||
| pollingInterval, | ||
| ); | ||
| setPollingProviderForNetwork(networkName, pollingProvider); | ||
| return pollingProvider; | ||
| }; | ||
|
|
||
| /** | ||
| * | ||
| * @param chain | ||
| * @param networkName | ||
| * @param fallbackProviderJsonConfig | ||
| * @param pollingInterval - DEPRECATED | ||
|
jacobmakarsky marked this conversation as resolved.
Outdated
|
||
| */ | ||
| const loadProviderForNetwork = async ( | ||
| chain: Chain, | ||
| networkName: NetworkName, | ||
| fallbackProviderJsonConfig: FallbackProviderJsonConfig, | ||
| /** | ||
| * @deprecated pollingInterval - DEPRECATED | ||
|
jacobmakarsky marked this conversation as resolved.
Outdated
jacobmakarsky marked this conversation as resolved.
Outdated
|
||
| */ | ||
| pollingInterval: number, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add deprecated to this too?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| ) => { | ||
| sendMessage(`Load provider for network: ${networkName}`); | ||
|
|
@@ -75,11 +59,6 @@ const loadProviderForNetwork = async ( | |
| networkName, | ||
| fallbackProviderJsonConfig, | ||
| ); | ||
| const pollingProvider = await createPollingProviderForNetwork( | ||
| networkName, | ||
| fallbackProvider, | ||
| pollingInterval | ||
| ); | ||
|
|
||
| const network = NETWORK_CONFIG[networkName]; | ||
| const { | ||
|
|
@@ -126,7 +105,7 @@ const loadProviderForNetwork = async ( | |
| poseidonMerkleVerifierV3Contract, | ||
| tokenVaultV3Contract, | ||
| fallbackProvider, | ||
| pollingProvider, | ||
| undefined, // pollingProvider is being deprecated | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| deploymentBlocks, | ||
| poi?.launchBlock, | ||
| supportsV3, | ||
|
|
@@ -140,6 +119,9 @@ const loadProviderForNetwork = async ( | |
| export const loadProvider = async ( | ||
| fallbackProviderJsonConfig: FallbackProviderJsonConfig, | ||
| networkName: NetworkName, | ||
| /** | ||
| * @deprecated pollingInterval - DEPRECATED | ||
|
jacobmakarsky marked this conversation as resolved.
Outdated
|
||
| */ | ||
| pollingInterval = 15000, | ||
| ): Promise<LoadProviderResponse> => { | ||
| try { | ||
|
|
@@ -198,19 +180,17 @@ export const unloadProvider = async ( | |
| ): Promise<void> => { | ||
| WalletPOINodeInterface.pause(NETWORK_CONFIG[networkName].chain); | ||
| await fallbackProviderMap[networkName]?.destroy(); | ||
| pollingProviderMap[networkName]?.destroy(); | ||
| delete fallbackProviderMap[networkName]; | ||
| delete pollingProviderMap[networkName]; | ||
| }; | ||
|
|
||
| export const pauseAllPollingProviders = ( | ||
| excludeNetworkName?: NetworkName, | ||
| ): void => { | ||
| Object.keys(pollingProviderMap).forEach(networkName => { | ||
| Object.keys(fallbackProviderMap).forEach(networkName => { | ||
| if (networkName === excludeNetworkName) { | ||
| return; | ||
| } | ||
| const pollingProvider = pollingProviderMap[networkName]; | ||
| const pollingProvider = fallbackProviderMap[networkName]; | ||
| if (isDefined(pollingProvider) && !pollingProvider.paused) { | ||
| pollingProvider.pause(); | ||
| } | ||
|
|
@@ -223,7 +203,7 @@ export const resumeIsolatedPollingProviderForNetwork = ( | |
| pauseAllPollingProviders( | ||
| networkName, // excludeNetworkName | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ? |
||
| ); | ||
| const pollingProviderForNetwork = pollingProviderMap[networkName]; | ||
| const pollingProviderForNetwork = fallbackProviderMap[networkName]; | ||
| if ( | ||
| isDefined(pollingProviderForNetwork) && | ||
| pollingProviderForNetwork.paused | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.