You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: providers.rs
    path of file: ./repos/foundry/crates/script/src
    
    the code of the file until where you have to start completion: use alloy_primitives::U256;
use ethers_providers::{Middleware, Provider};
use eyre::{Result, WrapErr};
use foundry_common::{
    provider::ethers::{get_http_provider, RpcUrl},
    runtime_client::RuntimeClient,
    types::ToAlloy,
};
use foundry_config::Chain;
use std::{
    collections::{hash_map::Entry, HashMap},
    ops::Deref,
    sync::Arc,
};

/// Contains a map of RPC urls to single instances of [`ProviderInfo`].
#[derive(Default)]
pub struct ProvidersManager {
    pub inner: HashMap<RpcUrl, ProviderInfo>,
}

impl ProvidersManager {
    /// Get or initialize the R
    
    pub async fn new(rpc: &str, mut is_legacy: bool) -> Result<ProviderInfo> {
        let provider = Arc::new(get_http_provider(rpc));
        let chain = provider.get_chainid().await?.as_u64();

        if let Some(chain) = Chain::from(chain).named() {
            is_legacy |= chain.is_legacy();
        };

        let gas_price = if is_legacy {
            GasPrice::Legacy(
                provider
                    .get_gas_price()
                    .await
                    .wrap_err("Failed to get legacy gas price")
                    .map(|p| p.to_alloy()),
            )
        } else {
            GasPrice::EIP1559(
                provider
                    .estimate_eip1559_fees(None)
                    .await
                    .wrap_err("Failed to get EIP-1559 fees")
                    .map(|p| (p.0.to_alloy(), p.1.to_alloy())),
            )
        };

        Ok(ProviderInfo { provider, chain, gas_price, is_legacy })
    }