Skip to content

Conversation

@jacobmakarsky
Copy link
Contributor

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.

tokenVaultV3Contract,
fallbackProvider,
pollingProvider,
undefined, // pollingProvider is being deprecated

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

Copy link
Contributor Author

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,

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?

Copy link
Contributor Author

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

Copy link
Contributor

@bhflm bhflm left a 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

@jacobmakarsky
Copy link
Contributor Author

jacobmakarsky commented Jan 25, 2025

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

@jacobmakarsky jacobmakarsky marked this pull request as draft January 25, 2025 00:45
@jacobmakarsky
Copy link
Contributor Author

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

@socket-security
Copy link

socket-security bot commented Jan 25, 2025

@jacobmakarsky
Copy link
Contributor Author

TODO: getFallbackProviderForNetwork will need to either conditionally allow a single provider (JsonRpcProvider or WebSocketProvider), or a new setup for retrieving the existing provider like getProviderForNetwork will need created.

"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",
Copy link
Contributor

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];
Copy link
Contributor

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
Copy link
Contributor

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)) {
Copy link
Contributor

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;
};

Copy link
Contributor

@bhflm bhflm left a 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

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 this pull request may close these issues.

4 participants