Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: default TransactionRequest #787

Merged
merged 2 commits into from
Dec 13, 2024
Merged
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
30 changes: 21 additions & 9 deletions crates/forge/bin/cmd/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub struct CreateArgs {
retry: RetryArgs,
}

#[derive(Debug, Default)]
/// Data used to deploy a contract on zksync
pub struct ZkSyncData {
#[allow(dead_code)]
Expand Down Expand Up @@ -1102,22 +1103,15 @@ where
Some(constructor) => constructor.abi_encode_input(&params).unwrap_or_default(),
};

let mut tx: alloy_zksync::network::transaction_request::TransactionRequest =
TransactionRequest::default()
.to(foundry_zksync_core::CONTRACT_DEPLOYER_ADDRESS.to_address())
.into();

tx = tx
let tx = alloy_zksync::network::transaction_request::TransactionRequest::default()
.with_to(foundry_zksync_core::CONTRACT_DEPLOYER_ADDRESS.to_address())
.with_create_params(
zk_data.bytecode.clone(),
constructor_args,
zk_data.factory_deps.clone(),
)
.map_err(|_| ContractDeploymentError::TransactionBuildError)?;

// NOTE(zk): We need to prepare the tx for submission to set the tx type to EIP712
tx.prep_for_submission();

Ok(ZkDeployer {
client: self.client.clone(),
abi: self.abi,
Expand Down Expand Up @@ -1156,6 +1150,8 @@ impl From<PendingTransactionError> for ContractDeploymentError {
mod tests {
use super::*;
use alloy_primitives::I256;
use alloy_zksync::network::tx_type::TxType;
use utils::get_provider_zksync;

#[test]
fn can_parse_create() {
Expand Down Expand Up @@ -1224,4 +1220,20 @@ mod tests {
let params = args.parse_constructor_args(&constructor, &args.constructor_args).unwrap();
assert_eq!(params, vec![DynSolValue::Int(I256::unchecked_from(-5), 256)]);
}

#[test]
fn test_zk_deployer_builds_eip712_transactions() {
let client = get_provider_zksync(&Default::default()).expect("failed creating client");
let factory =
DeploymentTxFactory::new_zk(Default::default(), Default::default(), client, 0);

let deployer = factory
.deploy_tokens_zk(
Default::default(),
&ZkSyncData { bytecode: [0u8; 32].into(), ..Default::default() },
)
.expect("failed deploying tokens");

assert_eq!(TxType::Eip712, deployer.tx.output_tx_type());
}
}
Loading