Skip to content

Commit

Permalink
fix: use zksync_deploy method to set correct tx params
Browse files Browse the repository at this point in the history
  • Loading branch information
elfedy committed Nov 22, 2024
1 parent f75d7bf commit 9c60954
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions crates/forge/bin/cmd/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ pub struct CreateArgs {
pub struct ZkSyncData {
#[allow(dead_code)]
bytecode: Vec<u8>,
bytecode_hash: H256,
factory_deps: Vec<Vec<u8>>,
paymaster_params: Option<PaymasterParams>,
}
Expand Down Expand Up @@ -256,7 +255,7 @@ impl CreateArgs {
visited_bytecodes.insert(bytecode.clone());
visited_bytecodes.into_iter().collect()
};
let zk_data = ZkSyncData { bytecode, bytecode_hash, factory_deps, paymaster_params };
let zk_data = ZkSyncData { bytecode, factory_deps, paymaster_params };

return if self.unlocked {
// Deploy with unlocked account
Expand Down Expand Up @@ -661,6 +660,8 @@ impl CreateArgs {
self.verify_preflight_check(constructor_args.clone(), chain).await?;
}

println!("{:?}", deployer.tx);

// Deploy the actual contract
let (deployed_contract, receipt) = deployer.send_with_receipt().await?;

Expand Down Expand Up @@ -1077,21 +1078,16 @@ where
None => Default::default(),
Some(constructor) => constructor.abi_encode_input(&params).unwrap_or_default(),
};
let data: Bytes = foundry_zksync_core::encode_create_params(
&forge::revm::primitives::CreateScheme::Create,
zk_data.bytecode_hash,
constructor_args,
)
.into();

// create the tx object. Since we're deploying a contract, `to` is
// `CONTRACT_DEPLOYER_ADDRESS`
let tx: alloy_zksync::network::transaction_request::TransactionRequest =
let mut tx: alloy_zksync::network::transaction_request::TransactionRequest =
TransactionRequest::default()
.to(foundry_zksync_core::CONTRACT_DEPLOYER_ADDRESS.to_address())
.input(data.into())
.into();

tx = tx
.zksync_deploy(zk_data.bytecode.clone(), constructor_args, zk_data.factory_deps.clone())
.map_err(|_| ContractDeploymentError::TransactionBuildError)?;

Ok(ZkDeployer {
client: self.client.clone(),
abi: self.abi,
Expand All @@ -1116,6 +1112,8 @@ pub enum ContractDeploymentError {
ContractNotDeployed,
#[error(transparent)]
RpcError(#[from] TransportError),
#[error("failed building transaction")]
TransactionBuildError,
}

impl From<PendingTransactionError> for ContractDeploymentError {
Expand Down

0 comments on commit 9c60954

Please sign in to comment.