openzeppelin_relayer::services::provider

Function get_network_provider

Source
pub fn get_network_provider<N: NetworkConfiguration>(
    network: &N,
    custom_rpc_urls: Option<Vec<RpcConfig>>,
) -> Result<N::Provider, ProviderError>
Expand description

Creates a network-specific provider instance based on the provided configuration.

§Type Parameters

  • N: The type of the network, which must implement the NetworkConfiguration trait. This determines the specific provider type (N::Provider) and how to obtain public RPC URLs.

§Arguments

  • network: A reference to the network configuration object (&N).
  • custom_rpc_urls: An Option<Vec<RpcConfig>>. If Some and not empty, these URLs are used to configure the provider. If None or Some but empty, the function falls back to using the public RPC URLs defined by the network’s NetworkConfiguration implementation.

§Returns

  • Ok(N::Provider): An instance of the network-specific provider on success.
  • Err(ProviderError): An error if configuration fails, such as when no custom URLs are provided and the network has no public RPC URLs defined (ProviderError::NetworkConfiguration).