Skip to content

Commit 68fcb7d

Browse files
authored
fix: default TransactionRequest (#787)
* fix default TransactionRequest * add unit test
1 parent e7390e0 commit 68fcb7d

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

crates/forge/bin/cmd/create.rs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ pub struct CreateArgs {
108108
retry: RetryArgs,
109109
}
110110

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

1105-
let mut tx: alloy_zksync::network::transaction_request::TransactionRequest =
1106-
TransactionRequest::default()
1107-
.to(foundry_zksync_core::CONTRACT_DEPLOYER_ADDRESS.to_address())
1108-
.into();
1109-
1110-
tx = tx
1106+
let tx = alloy_zksync::network::transaction_request::TransactionRequest::default()
1107+
.with_to(foundry_zksync_core::CONTRACT_DEPLOYER_ADDRESS.to_address())
11111108
.with_create_params(
11121109
zk_data.bytecode.clone(),
11131110
constructor_args,
11141111
zk_data.factory_deps.clone(),
11151112
)
11161113
.map_err(|_| ContractDeploymentError::TransactionBuildError)?;
11171114

1118-
// NOTE(zk): We need to prepare the tx for submission to set the tx type to EIP712
1119-
tx.prep_for_submission();
1120-
11211115
Ok(ZkDeployer {
11221116
client: self.client.clone(),
11231117
abi: self.abi,
@@ -1156,6 +1150,8 @@ impl From<PendingTransactionError> for ContractDeploymentError {
11561150
mod tests {
11571151
use super::*;
11581152
use alloy_primitives::I256;
1153+
use alloy_zksync::network::tx_type::TxType;
1154+
use utils::get_provider_zksync;
11591155

11601156
#[test]
11611157
fn can_parse_create() {
@@ -1224,4 +1220,20 @@ mod tests {
12241220
let params = args.parse_constructor_args(&constructor, &args.constructor_args).unwrap();
12251221
assert_eq!(params, vec![DynSolValue::Int(I256::unchecked_from(-5), 256)]);
12261222
}
1223+
1224+
#[test]
1225+
fn test_zk_deployer_builds_eip712_transactions() {
1226+
let client = get_provider_zksync(&Default::default()).expect("failed creating client");
1227+
let factory =
1228+
DeploymentTxFactory::new_zk(Default::default(), Default::default(), client, 0);
1229+
1230+
let deployer = factory
1231+
.deploy_tokens_zk(
1232+
Default::default(),
1233+
&ZkSyncData { bytecode: [0u8; 32].into(), ..Default::default() },
1234+
)
1235+
.expect("failed deploying tokens");
1236+
1237+
assert_eq!(TxType::Eip712, deployer.tx.output_tx_type());
1238+
}
12271239
}

0 commit comments

Comments
 (0)