anvil_zksync_common/utils/
predeploys.rs1use alloy::primitives::{hex, Address};
2use alloy::{sol, sol_types::SolCall};
3use eyre::{eyre, Result};
4use once_cell::sync::Lazy;
5use serde::Deserialize;
6
7pub static PREDEPLOYS: Lazy<Vec<Predeploy>> = Lazy::new(|| {
9 const RAW: &str = include_str!("../data/predeploys.json");
10 serde_json::from_str(RAW).expect("invalid predeploys.json")
11});
12
13#[derive(Debug, Deserialize)]
14pub struct Predeploy {
15 pub address: Address,
16 pub constructor_input: String,
17}
18
19sol! {
20 function deployPredeployedContract(
22 address contractAddress,
23 bytes constructorInput
24 ) external;
25}
26
27impl Predeploy {
28 pub fn encode_manager_call(&self) -> Result<Vec<u8>> {
29 let ctor_bytes =
30 hex::decode(self.constructor_input.trim_start_matches("0x")).map_err(|e| {
31 eyre!(
32 "invalid hex in constructor_input for {}: {}",
33 self.address,
34 e
35 )
36 })?;
37
38 let call = deployPredeployedContractCall {
39 contractAddress: self.address,
40 constructorInput: ctor_bytes.into(),
41 };
42
43 Ok(call.abi_encode())
44 }
45}