Skip to content

Commit

Permalink
refactor: rename json_rpc_url to url in ForkConfig of edr_napi and ed…
Browse files Browse the repository at this point in the history
…r_provider.
  • Loading branch information
IftequarIffu committed Dec 15, 2024
1 parent 907eda3 commit a071a56
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions crates/edr_napi/src/provider/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct ChainConfig {
#[napi(object)]
pub struct ForkConfig {
/// The URL of the JSON-RPC endpoint to fork from
pub json_rpc_url: String,
pub url: String,
/// The block number to fork from. If not provided, the latest safe block is
/// used.
pub block_number: Option<BigInt>,
Expand Down Expand Up @@ -140,7 +140,7 @@ impl TryFrom<ForkConfig> for edr_provider::hardhat_rpc_types::ForkConfig {
});

Ok(Self {
json_rpc_url: value.json_rpc_url,
url: value.url,
block_number,
http_headers,
})
Expand Down
10 changes: 5 additions & 5 deletions crates/edr_provider/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2609,7 +2609,7 @@ fn create_blockchain_and_state(
.transpose()?;

let rpc_client = Arc::new(EthRpcClient::<L1ChainSpec>::new(
&fork_config.json_rpc_url,
&fork_config.url,
config.cache_dir.clone(),
http_headers.clone(),
)?);
Expand Down Expand Up @@ -2837,9 +2837,9 @@ pub(crate) mod test_utils {
}

fn with_fork(fork: Option<String>) -> anyhow::Result<Self> {
let fork = fork.map(|json_rpc_url| {
let fork = fork.map(|url| {
ForkConfig {
json_rpc_url,
url,
// Random recent block for better cache consistency
block_number: Some(FORK_BLOCK_NUMBER),
http_headers: None,
Expand Down Expand Up @@ -3948,7 +3948,7 @@ mod tests {
let mut fixture = ProviderTestFixture::new_local()?;

let fork_config = Some(ForkConfig {
json_rpc_url: get_alchemy_url(),
url: get_alchemy_url(),
// Random recent block for better cache consistency
block_number: Some(FORK_BLOCK_NUMBER),
http_headers: None,
Expand Down Expand Up @@ -4040,7 +4040,7 @@ mod tests {
.build()?;

let default_config = create_test_config_with_fork(Some(ForkConfig {
json_rpc_url: get_alchemy_url(),
url: get_alchemy_url(),
block_number: Some(EIP_1559_ACTIVATION_BLOCK),
http_headers: None,
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct ResetProviderConfig {
#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ForkConfig {
pub json_rpc_url: String,
pub url: String,
pub block_number: Option<u64>,
pub http_headers: Option<HashMap<String, String>>,
}
2 changes: 1 addition & 1 deletion crates/edr_provider/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ where
pub async fn run_full_block(url: String, block_number: u64, chain_id: u64) -> anyhow::Result<()> {
let runtime = tokio::runtime::Handle::current();
let default_config = create_test_config_with_fork(Some(ForkConfig {
json_rpc_url: url.clone(),
url: url.clone(),
block_number: Some(block_number - 1),
http_headers: None,
}));
Expand Down
2 changes: 1 addition & 1 deletion crates/edr_provider/tests/hardhat_request_serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn serde_hardhat_mine() {
fn serde_hardhat_reset() {
help_test_method_invocation_serde(MethodInvocation::Reset(Some(ResetProviderConfig {
forking: Some(ForkConfig {
json_rpc_url: String::from("http://whatever.com/whatever"),
url: String::from("http://whatever.com/whatever"),
block_number: Some(123456),
http_headers: None,
}),
Expand Down
2 changes: 1 addition & 1 deletion crates/edr_provider/tests/issues/issue_324.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn issue_324() -> anyhow::Result<()> {
let subscriber = Box::new(|_event| {});

let mut config = create_test_config_with_fork(Some(ForkConfig {
json_rpc_url: get_alchemy_url().replace("mainnet", "sepolia"),
url: get_alchemy_url().replace("mainnet", "sepolia"),
block_number: Some(DEPLOYMENT_BLOCK_NUMBER),
http_headers: None,
}));
Expand Down
2 changes: 1 addition & 1 deletion crates/edr_provider/tests/issues/issue_356.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async fn issue_356() -> anyhow::Result<()> {
let subscriber = Box::new(|_event| {});

let mut config = create_test_config_with_fork(Some(ForkConfig {
json_rpc_url: get_alchemy_url().replace("mainnet", "sepolia"),
url: get_alchemy_url().replace("mainnet", "sepolia"),
// Pre-cancun Sepolia block
block_number: Some(4243456),
http_headers: None,
Expand Down
2 changes: 1 addition & 1 deletion crates/edr_provider/tests/issues/issue_384.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async fn avalanche_chain_mine_local_block() -> anyhow::Result<()> {
let subscriber = Box::new(|_event| {});

let config = create_test_config_with_fork(Some(ForkConfig {
json_rpc_url: get_infura_url().replace("mainnet", "avalanche-mainnet"),
url: get_infura_url().replace("mainnet", "avalanche-mainnet"),
block_number: Some(BLOCK_NUMBER),
http_headers: None,
}));
Expand Down
2 changes: 1 addition & 1 deletion crates/edr_provider/tests/issues/issue_503.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async fn issue_503() -> anyhow::Result<()> {
let subscriber = Box::new(|_event| {});

let mut config = create_test_config_with_fork(Some(ForkConfig {
json_rpc_url: get_alchemy_url(),
url: get_alchemy_url(),
block_number: Some(19_909_475),
http_headers: None,
}));
Expand Down
2 changes: 1 addition & 1 deletion crates/edr_provider/tests/issues/issue_533.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async fn issue_533() -> anyhow::Result<()> {
let subscriber = Box::new(|_event| {});

let mut config = create_test_config_with_fork(Some(ForkConfig {
json_rpc_url: get_alchemy_url(),
url: get_alchemy_url(),
block_number: Some(20_384_300),
http_headers: None,
}));
Expand Down
2 changes: 1 addition & 1 deletion crates/edr_provider/tests/issues/issue_570.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn get_provider() -> anyhow::Result<Provider<Infallible>> {
let subscriber = Box::new(|_event| {});

let mut config = create_test_config_with_fork(Some(ForkConfig {
json_rpc_url: get_alchemy_url().replace("eth-mainnet", "base-sepolia"),
url: get_alchemy_url().replace("eth-mainnet", "base-sepolia"),
block_number: Some(BLOCK_NUMBER),
http_headers: None,
}));
Expand Down
2 changes: 1 addition & 1 deletion crates/edr_provider/tests/issues/issue_588.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async fn issue_588() -> anyhow::Result<()> {
let subscriber = Box::new(|_event| {});

let early_mainnet_fork = create_test_config_with_fork(Some(ForkConfig {
json_rpc_url: get_alchemy_url(),
url: get_alchemy_url(),
block_number: Some(2_675_000),
http_headers: None,
}));
Expand Down

0 comments on commit a071a56

Please sign in to comment.