@@ -7,7 +7,7 @@ import {DelegateRegistry} from "../src/DelegateRegistry.sol";
77import {Singlesig} from "../src/singlesig/Singlesig.sol " ;
88
99import {Create2Factory} from "era-contracts/system-contracts/contracts/Create2Factory.sol " ;
10- import {ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT} from "era-contracts/system-contracts/contracts/Constants.sol " ;
10+ import {ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT, CREATE2_PREFIX } from "era-contracts/system-contracts/contracts/Constants.sol " ;
1111
1212interface ImmutableCreate2Factory {
1313 function safeCreate2 (bytes32 salt , bytes calldata initCode ) external payable returns (address deploymentAddress );
@@ -26,21 +26,37 @@ interface ZksyncCreate2Factory {
2626}
2727
2828contract Deploy is Script {
29+ address immutable firstOwner = 0x6Ed7D526b020780f694f3c10Dfb25E1b134D3215 ;
30+
2931 // ZksyncCreate2Factory immutable zksyncCreateFactory = ZksyncCreate2Factory(0x0000000000000000000000000000000000010000);
3032 Create2Factory immutable zksyncCreateFactory = Create2Factory (0x0000000000000000000000000000000000010000 );
3133 ZksyncCreate2Factory immutable zksyncContractDeployer = ZksyncCreate2Factory (0x0000000000000000000000000000000000008006 );
3234
3335 ImmutableCreate2Factory immutable factory = ImmutableCreate2Factory (0x0000000000FFe8B47B3e2130213B802212439497 );
3436 bytes initCode = type (DelegateRegistry).creationCode;
3537 // bytes32 singlesigSalt = 0x0000000000000000000000000000000000000000fbe49ecfc3decb1164228b89;
36- bytes32 registrySalt = 0x00000000000000000000000000000000000000002bbc593dd77cb93fbb932d5f ;
38+ // bytes32 registrySalt = 0x00000000000000000000000000000000000000002bbc593dd77cb93fbb932d5f;
39+
40+ bytes32 zkSinglesigSalt = 0x0000000000000000000000000000000000000000b46d2eb2b23e8ae404000006 ;
41+ // bytes32 registrySalt = bytes32(0);
42+ bytes32 registrySalt = 0x0000000000000000000000000000000000000000dc73d3e78582b023010000a0 ;
3743
3844 // bytes initCode = abi.encodePacked(type(Singlesig).creationCode, abi.encode(address(0x6Ed7D526b020780f694f3c10Dfb25E1b134D3215)));
3945 // bytes32 salt = 0x000000000000000000000000000000000000000016c7768a8c7a2824b846321d;
4046
4147 function run () external {
4248 vm.startBroadcast ();
4349
50+ Singlesig predeploySinglesig = new Singlesig {salt: zkSinglesigSalt}(firstOwner);
51+ bytes32 singlesigZKBytecodeHash = ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT.getRawCodeHash (address (predeploySinglesig));
52+ bytes32 constructorHash = keccak256 (abi.encode (firstOwner));
53+ console2.log (address (predeploySinglesig));
54+ console2.logBytes (abi.encode (firstOwner));
55+ console2.logBytes32 (singlesigZKBytecodeHash);
56+ console2.logBytes32 (constructorHash);
57+ bytes memory preimage = bytes .concat (CREATE2_PREFIX, bytes32 (uint256 (uint160 (address (zksyncCreateFactory)))), zkSinglesigSalt, singlesigZKBytecodeHash, constructorHash);
58+ console2.logBytes (preimage);
59+
4460 // address singlesigAddress = factory.safeCreate2(singlesigSalt, initCode);
4561 // Singlesig singlesig = Singlesig(payable(singlesigAddress));
4662 // console2.log(address(singlesig));
@@ -49,21 +65,28 @@ contract Deploy is Script {
4965 // bytes32[] memory hashes = existing.getOutgoingDelegationHashes(0x86362a4C99d900D72d787Ef1BddA38Fd318aa5E9);
5066 // console2.logBytes32(hashes[0]);
5167
52- DelegateRegistry saltDeploy = new DelegateRegistry {salt: registrySalt}();
53- console2.log (address (saltDeploy));
54-
55- DelegateRegistry predeploy = new DelegateRegistry ();
56-
57- bytes32 bytecodeHash = keccak256 (initCode);
58- bytes32 zkBytecodeHash = ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT.getRawCodeHash (address (predeploy));
59-
60- console2.logBytes32 (bytecodeHash);
61- console2.logBytes32 (zkBytecodeHash);
62- console2.log (address (predeploy));
63- console2.log (msg .sender );
64- console2.logBytes32 (registrySalt);
65- address registryAddress = zksyncContractDeployer.getNewAddressCreate2 (address (zksyncCreateFactory), zkBytecodeHash, registrySalt, "" );
66- console2.log (registryAddress);
68+ // DelegateRegistry saltDeploy = new DelegateRegistry{salt: registrySalt}();
69+ // console2.logBytes32(keccak256(""));
70+ // console2.log(address(saltDeploy));
71+
72+ // DelegateRegistry predeploy = new DelegateRegistry();
73+
74+ // bytes32 bytecodeHash = keccak256(initCode);
75+ // bytes32 zkBytecodeHash = ACCOUNT_CODE_STORAGE_SYSTEM_CONTRACT.getRawCodeHash(address(predeploy));
76+
77+ // console2.logBytes32(bytecodeHash);
78+ // console2.logBytes32(zkBytecodeHash);
79+ // console2.log(address(predeploy));
80+ // console2.log(msg.sender);
81+ // console2.logBytes32(registrySalt);
82+ // bytes memory preimage = bytes.concat(CREATE2_PREFIX, bytes32(uint256(uint160(address(zksyncCreateFactory)))), registrySalt, zkBytecodeHash, keccak256(""));
83+ // console2.logBytes(preimage);
84+ // address localRegistryAddress = address(uint160(uint256(keccak256(
85+ // bytes.concat(CREATE2_PREFIX, bytes32(uint256(uint160(address(zksyncCreateFactory)))), registrySalt, zkBytecodeHash, keccak256(""))
86+ // ))));
87+ // console2.log(localRegistryAddress);
88+ // address registryAddress = zksyncContractDeployer.getNewAddressCreate2(address(zksyncCreateFactory), zkBytecodeHash, registrySalt, "");
89+ // console2.log(registryAddress);
6790
6891 // zksyncCreateFactory.create2(registrySalt, zkBytecodeHash, "");
6992
0 commit comments