Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ cache/*
out/
.notes.md
ks-0x12240F5668f61fd4dF728584206b21d70dD87232
ks-0xA84E4F9D72cb37A8276090D3FC50895BD8E5Aaf1
ks-0xA84E4F9D72cb37A8276090D3FC50895BD8E5Aaf1
.hack.md
12 changes: 12 additions & 0 deletions src/data/contracts/registry.rs

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions src/helpers/pre_conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,19 @@ pub fn check_before(contract_to_deploy: Option<&ContractSpec>, args: &CliArgs) {
info!("verify_json_path contract: {:?}", spec.verify_json_path);
info!("salt contract: {:?}", spec.salt);

match verify_create2_address(spec) {
Ok(addr) => {
info!("CREATE2 address verified: {addr}");
if spec.deployer_tx.is_some() {
if let Some(addr) = spec.address {
info!("Contract address (pre-built tx): {addr}");
}
Err(e) => {
error!("CREATE2 verification failed: {e}");
exit(1);
} else {
match verify_create2_address(spec) {
Ok(addr) => {
info!("CREATE2 address verified: {addr}");
}
Err(e) => {
error!("CREATE2 verification failed: {e}");
exit(1);
}
}
}
} else if args.contract_name.is_some() || args.address.is_some() || args.contract_path.is_some()
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use log::{Level, error, warn};
use std::env::var;
use std::process::exit;

use deterministic_deployer_evm::utils::print_intro::print_intro_log;
use deterministic_deployer_evm::client::wallet_client::create_deployers;
use deterministic_deployer_evm::data::contracts::create_contract_spec_from_args;
use deterministic_deployer_evm::helpers::contract_searcher::resolve_contract;
Expand All @@ -16,6 +15,7 @@ use deterministic_deployer_evm::types::constants::Constants;
use deterministic_deployer_evm::types::errors::CliError;
use deterministic_deployer_evm::utils::create_keystore::load_or_create_keystore;
use deterministic_deployer_evm::utils::deploy::run_deployments;
use deterministic_deployer_evm::utils::print_intro::print_intro_log;
use deterministic_deployer_evm::utils::read_buf::parse_args;
use deterministic_deployer_evm::utils::verifier::run_verifications;

Expand Down Expand Up @@ -100,6 +100,6 @@ async fn main() {
ready_for_verify.extend(deployed);

if args.verify {
run_verifications(&ready_for_verify, &spec).await;
run_verifications(&ready_for_verify, &spec, args.source_chain.as_deref()).await;
}
}
19 changes: 19 additions & 0 deletions src/types/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ pub struct EtherscanResponse {
pub result: String,
}

#[derive(Deserialize)]
pub struct SourceCodeResult {
#[serde(rename = "SourceCode")]
pub source_code: String,
#[serde(rename = "ContractName")]
pub contract_name: String,
#[serde(rename = "CompilerVersion")]
pub compiler_version: String,
#[serde(rename = "ConstructorArguments")]
pub constructor_arguments: String,
}

#[derive(Deserialize)]
pub struct GetSourceCodeResponse {
pub status: String,
pub result: Vec<SourceCodeResult>,
}

pub struct CliArgs {
pub contract_path: Option<PathBuf>,
pub chains: Vec<Chain>,
Expand All @@ -70,6 +88,7 @@ pub struct CliArgs {
pub verify: bool,
pub constructor_args: Option<Bytes>,
pub keystore: bool,
pub source_chain: Option<String>,
}

pub struct PrecheckResult {
Expand Down
2 changes: 2 additions & 0 deletions src/types/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ pub enum VerifierError {
HttpError(&'static str, String),
#[error("forge not found — install Foundry: {0}")]
ForgeNotFound(String),
#[error("Contract not verified on source chain {0}")]
NotVerifiedOnSource(String),
}

#[derive(Debug, thiserror::Error)]
Expand Down
15 changes: 9 additions & 6 deletions src/utils/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ pub async fn deploy_contract(
.public()
.ok_or_else(|| DeployError::NoProvider(wallet.address()))?;

let salt: FixedBytes<32> = spec.salt.ok_or(DeployError::MissingSalt(spec.name))?;
let init_code: Bytes = spec
.full_init_code()
.ok_or(DeployError::MissingInitCode(spec.name))?;

let calldata: Bytes = build_calldata(&salt, &init_code);
let calldata: Bytes = if let Some(tx_data) = spec.deployer_tx {
Bytes::from_static(tx_data)
} else {
let salt: FixedBytes<32> = spec.salt.ok_or(DeployError::MissingSalt(spec.name))?;
let init_code: Bytes = spec
.full_init_code()
.ok_or(DeployError::MissingInitCode(spec.name))?;
build_calldata(&salt, &init_code)
};

let tx: TransactionRequest = TransactionRequest::default()
.with_to(*Constants::DETERMINISTIC_DEPLOYER)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ pub mod create_keystore;
pub mod deploy;
pub mod init_explorers;
pub mod init_rpc;
pub mod print_intro;
pub mod read_buf;
pub mod verifier;
pub mod print_intro;
7 changes: 3 additions & 4 deletions src/utils/print_intro.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const INTRO: &'static str = r#"
const INTRO: &str = r"
___________________
/ Deploy \ █████ █████ ███ ███ █████ ███
___________ / Contract in one \ ░░███ ░░███ ░░░ ░░░ ░░███ ░░░
Expand All @@ -22,9 +22,8 @@ const INTRO: &'static str = r#"
/_____| |_____\ ░░░░░ ░░░░░░
___| | | |___
(_______| |_______)
"#;

";

pub fn print_intro_log() {
println!("\x1b[32m{INTRO}\x1b[0m");
}
}
14 changes: 14 additions & 0 deletions src/utils/read_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ pub fn parse_args() -> Result<CliArgs, CliError> {
let mut verify: bool = false;
let mut constructor_args: Option<Bytes> = None;
let mut keystore: bool = false;
let mut source_chain: Option<String> = None;
let mut chains: Vec<Chain> = Vec::with_capacity(Chain::COUNT);
let mut seen: ChainSet = ChainSet::new();
let mut parser: lexopt::Parser = lexopt::Parser::from_env();
Expand Down Expand Up @@ -205,6 +206,15 @@ pub fn parse_args() -> Result<CliArgs, CliError> {
Long("keystore") => {
keystore = true;
}
Long("source-chain") => {
let val: OsString = parser
.value()
.map_err(|e| CliError::ParseError(e.to_string()))?;
let val_str = val
.to_str()
.ok_or_else(|| CliError::ParseError("invalid UTF-8".to_string()))?;
source_chain = Some(val_str.to_string());
}
Long("constructor-args") => {
let val: OsString = parser
.value()
Expand Down Expand Up @@ -266,6 +276,7 @@ pub fn parse_args() -> Result<CliArgs, CliError> {
verify,
constructor_args,
keystore,
source_chain,
})
}

Expand All @@ -278,6 +289,9 @@ fn print_usage() {
eprintln!(" --address <hex> Contract address (hex, with or without 0x)");
eprintln!(" --verify Enable contract verification");
eprintln!(" --keystore Create and use an encrypted keystore");
eprintln!(
" --source-chain <chain> Chain with verified source (for cross-chain verification)"
);
eprintln!(
" --constructor-args <hex> ABI-encoded constructor arguments (hex, with or without 0x)"
);
Expand Down
Loading