Skip to content

Commit

Permalink
chore: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Karrq committed Oct 7, 2024
1 parent 8150bbb commit 35770f1
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 36 deletions.
11 changes: 5 additions & 6 deletions crates/anvil/src/eth/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ use alloy_consensus::{transaction::eip4844::TxEip4844Variant, Account, TxEnvelop
use alloy_dyn_abi::TypedData;
use alloy_eips::eip2718::Encodable2718;
use alloy_network::{eip2718::Decodable2718, BlockResponse};
use alloy_primitives::{map::{HashMap, HashSet}, Address, Bytes, Parity, TxHash, TxKind, B256, B64, U256, U64};
use alloy_primitives::{
map::{HashMap, HashSet},
Address, Bytes, Parity, TxHash, TxKind, B256, B64, U256, U64,
};
use alloy_rpc_types::{
anvil::{
ForkedNetwork, Forking, Metadata, MineOptions, NodeEnvironment, NodeForkConfig, NodeInfo,
Expand Down Expand Up @@ -79,11 +82,7 @@ use foundry_evm::{
};
use futures::channel::{mpsc::Receiver, oneshot};
use parking_lot::RwLock;
use std::{
future::Future,
sync::Arc,
time::Duration,
};
use std::{future::Future, sync::Arc, time::Duration};

/// The client version: `anvil/v{major}.{minor}.{patch}`
pub const CLIENT_VERSION: &str = concat!("anvil/v", env!("CARGO_PKG_VERSION"));
Expand Down
14 changes: 12 additions & 2 deletions crates/forge/bin/cmd/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,18 @@ impl CreateArgs {
let result = if self.unlocked {
// Deploy with unlocked account
let sender = self.eth.wallet.from.expect("required");
self.deploy_zk(abi, bin.object, params, provider, chain_id, sender, config.transaction_timeout, zk_data, None)
.await
self.deploy_zk(
abi,
bin.object,
params,
provider,
chain_id,
sender,
config.transaction_timeout,
zk_data,
None,
)
.await
} else {
// Deploy with signer
let signer = self.eth.wallet.signer().await?;
Expand Down
7 changes: 2 additions & 5 deletions crates/forge/bin/cmd/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,8 @@ impl TestArgs {
let (_, _, test_result) =
outcome.remove_first().ok_or_eyre("no tests were executed")?;

let sources = ContractSources::from_project_output(
&output,
project.root(),
Some(&libraries),
)?;
let sources =
ContractSources::from_project_output(&output, project.root(), Some(&libraries))?;

// Run the debugger.
let mut builder = Debugger::builder()
Expand Down
13 changes: 10 additions & 3 deletions crates/forge/tests/it/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ use foundry_evm::{
constants::CALLER,
opts::{Env, EvmOpts},
};
use foundry_test_utils::{fd_lock, init_tracing, rpc::next_rpc_endpoint, util::OutputExt, TestCommand, ZkSyncNode};
use foundry_zksync_compiler::{DualCompiledContracts, ZKSYNC_ARTIFACTS_DIR, ZKSYNC_SOLIDITY_FILES_CACHE_FILENAME};
use foundry_test_utils::{
fd_lock, init_tracing, rpc::next_rpc_endpoint, util::OutputExt, TestCommand, ZkSyncNode,
};
use foundry_zksync_compiler::{
DualCompiledContracts, ZKSYNC_ARTIFACTS_DIR, ZKSYNC_SOLIDITY_FILES_CACHE_FILENAME,
};
use semver::Version;
use std::{
env, fmt,
Expand Down Expand Up @@ -617,7 +621,10 @@ pub fn run_zk_script_test(

cmd.arg("script").args(&script_args);

cmd.assert_success().get_output().stdout_lossy().contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL");
cmd.assert_success()
.get_output()
.stdout_lossy()
.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL");

let run_latest = foundry_common::fs::json_files(root.as_ref().join("broadcast").as_path())
.find(|file| file.ends_with("run-latest.json"))
Expand Down
8 changes: 5 additions & 3 deletions crates/forge/tests/it/zk/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
use crate::{config::*, test_helpers::TEST_DATA_DEFAULT};
use forge::revm::primitives::SpecId;
use foundry_config::fs_permissions::PathPermission;
use foundry_test_utils::{util::{self, OutputExt}, Filter};
use foundry_test_utils::{
util::{self, OutputExt},
Filter,
};

#[tokio::test(flavor = "multi_thread")]
async fn test_zk_contract_can_call_function() {
Expand Down Expand Up @@ -58,8 +61,7 @@ async fn test_zk_contract_create2() {
);
util::initialize(prj.root());

cmd.args(["install", "matter-labs/era-contracts", "--no-commit", "--shallow"])
.assert_success();
cmd.args(["install", "matter-labs/era-contracts", "--no-commit", "--shallow"]).assert_success();
cmd.forge_fuse();

let mut config = cmd.config();
Expand Down
11 changes: 9 additions & 2 deletions crates/forge/tests/it/zk/factory_deps.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
//! Forge tests for zksync factory contracts.

use forge::revm::primitives::SpecId;
use foundry_test_utils::{forgetest_async, util::{self, OutputExt}, Filter, ZkSyncNode};
use foundry_test_utils::{
forgetest_async,
util::{self, OutputExt},
Filter, ZkSyncNode,
};

use crate::{config::TestConfig, test_helpers::TEST_DATA_DEFAULT};

Expand Down Expand Up @@ -60,7 +64,10 @@ contract ZkLargeFactoryDependenciesScript is Script {
"--evm-version",
"shanghai",
]);
cmd.assert_success().get_output().stdout_lossy().contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL");
cmd.assert_success()
.get_output()
.stdout_lossy()
.contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL");

let run_latest = foundry_common::fs::json_files(prj.root().join("broadcast").as_path())
.find(|file| file.ends_with("run-latest.json"))
Expand Down
2 changes: 1 addition & 1 deletion crates/forge/tests/it/zk/paymaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async fn test_zk_contract_paymaster() {
"--no-commit",
"--shallow",
])
.assert_success();
.assert_success();
cmd.forge_fuse();

let config = cmd.config();
Expand Down
11 changes: 7 additions & 4 deletions crates/forge/tests/it/zk/traces.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Forge tests for zksync logs.

use std::path::Path;
use std::sync::LazyLock;
use std::{path::Path, sync::LazyLock};

use crate::{config::*, test_helpers::TEST_DATA_DEFAULT};
use alloy_primitives::{address, hex, Address, Bytes};
Expand Down Expand Up @@ -164,7 +163,8 @@ async fn test_zk_traces_work_during_create() {
let results = TestConfig::with_filter(runner, filter).evm_spec(SpecId::SHANGHAI).test();
let traces = results["zk/Trace.t.sol:ZkTraceTest"].test_results
["testZkTraceOutputDuringCreate()"]
.traces.as_slice();
.traces
.as_slice();

assert_execution_trace(
vec![TraceAssertion {
Expand Down Expand Up @@ -253,7 +253,10 @@ struct TraceAssertion {
}

/// Assert that the execution trace matches the actual trace.
fn assert_execution_trace(expected: Vec<TraceAssertion>, traces: &[(TraceKind, SparsedTraceArena)]) {
fn assert_execution_trace(
expected: Vec<TraceAssertion>,
traces: &[(TraceKind, SparsedTraceArena)],
) {
#[allow(dead_code)]
#[derive(Debug)]
struct AssertionFailure {
Expand Down
12 changes: 8 additions & 4 deletions crates/script/src/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ use foundry_common::{
shell, TransactionMaybeSigned,
};
use foundry_config::Config;
use foundry_zksync_core::{convert::{ConvertAddress, ConvertBytes, ConvertSignature, ToSignable}, ZkTransactionMetadata};
use foundry_zksync_core::{
convert::{ConvertAddress, ConvertBytes, ConvertSignature, ToSignable},
ZkTransactionMetadata,
};
use futures::{future::join_all, StreamExt};
use itertools::Itertools;
use std::{
Expand Down Expand Up @@ -132,7 +135,7 @@ pub async fn send_transaction(
factory_deps: zk.factory_deps.clone(),
..Default::default()
})
.expect("failed serializing json"),
.expect("failed serializing json"),
);
}
estimate_gas(tx, &provider, estimate_multiplier).await?;
Expand All @@ -150,8 +153,9 @@ pub async fn send_transaction(
debug!("sending transaction: {:?}", tx);

let signed = if let Some(zk) = zk {
let signer =
signer.signer_by_address(tx.from.expect("no sender")).ok_or(eyre::eyre!("Signer not found"))?;
let signer = signer
.signer_by_address(tx.from.expect("no sender"))
.ok_or(eyre::eyre!("Signer not found"))?;

let (deploy_request, signable) = convert_to_zksync(&provider, tx, zk).await?;
let mut signable = signable.to_signable_tx();
Expand Down
7 changes: 5 additions & 2 deletions crates/verify/src/etherscan/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::{
provider::{VerificationContext, VerificationProvider},
retry::RETRY_CHECK_ON_VERIFY,
zk_provider::{CompilerVerificationContext, ZkVerificationContext},
verify::{VerifyArgs, VerifyCheckArgs},
zk_provider::{CompilerVerificationContext, ZkVerificationContext},
};
use alloy_json_abi::Function;
use alloy_primitives::hex;
Expand Down Expand Up @@ -656,6 +656,9 @@ Compiler run successful!
let context = args.resolve_context().await.unwrap();

let mut etherscan = EtherscanVerificationProvider::default();
etherscan.preflight_verify_check(args, CompilerVerificationContext::Solc(context)).await.unwrap();
etherscan
.preflight_verify_check(args, CompilerVerificationContext::Solc(context))
.await
.unwrap();
});
}
2 changes: 1 addition & 1 deletion crates/verify/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::{
etherscan::EtherscanVerificationProvider,
sourcify::SourcifyVerificationProvider,
verify::{VerifyArgs, VerifyCheckArgs},
zk_provider::CompilerVerificationContext,
};
use crate::zk_provider::CompilerVerificationContext;
use alloy_json_abi::JsonAbi;
use async_trait::async_trait;
use eyre::{OptionExt, Result};
Expand Down
2 changes: 1 addition & 1 deletion crates/verify/src/sourcify.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
provider::VerificationProvider,
zk_provider::CompilerVerificationContext,
verify::{VerifyArgs, VerifyCheckArgs},
zk_provider::CompilerVerificationContext,
};
use async_trait::async_trait;
use eyre::Result;
Expand Down
2 changes: 1 addition & 1 deletion crates/verify/src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use crate::{
etherscan::EtherscanVerificationProvider,
provider::{VerificationContext, VerificationProvider, VerificationProviderType},
zk_provider::{CompilerVerificationContext, ZkVerificationContext},
utils::is_host_only,
zk_provider::{CompilerVerificationContext, ZkVerificationContext},
RetryArgs,
};
use alloy_primitives::Address;
Expand Down
2 changes: 1 addition & 1 deletion crates/zksync/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use convert::{
ToSignable,
};
use eyre::{eyre, OptionExt};
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};

pub use utils::{fix_l2_gas_limit, fix_l2_gas_price};
pub use vm::{balance, encode_create_params, nonce};
Expand Down

0 comments on commit 35770f1

Please sign in to comment.