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 theNetworkConfiguration
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
: AnOption<Vec<RpcConfig>>
. IfSome
and not empty, these URLs are used to configure the provider. IfNone
orSome
but empty, the function falls back to using the public RPC URLs defined by thenetwork
’sNetworkConfiguration
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
).