Skip to content

Commit

Permalink
Rename DeployEmailAuthWIthCreate2
Browse files Browse the repository at this point in the history
  • Loading branch information
wshino committed Sep 10, 2024
1 parent 618ed4f commit 14f0626
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 56 deletions.
56 changes: 0 additions & 56 deletions packages/contracts/script/DeployEmailAuthWithCreate2.s.sol

This file was deleted.

56 changes: 56 additions & 0 deletions packages/contracts/script/DeployEmailAuthWithCreate2ZKSync.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "forge-std/Script.sol";

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import "../src/EmailAuth.sol";
import {ZKSyncCreate2Factory} from "../src/utils/ZKSyncCreate2Factory.sol";

contract Deploy is Script {
using ECDSA for *;

function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
if (deployerPrivateKey == 0) {
console.log("PRIVATE_KEY env var not set");
return;
}

vm.startBroadcast(deployerPrivateKey);

EmailAuth emailAuth = new EmailAuth();

address recoveredAccount = address(0x1);
bytes32 accountSalt = 0x0;

ERC1967Proxy proxy = new ERC1967Proxy(
address(emailAuth),
abi.encodeCall(emailAuth.initialize, (recoveredAccount, accountSalt, address(this)))
);
console.log("normal deployed proxyAddress %s", address(proxy));

ZKSyncCreate2Factory factory = new ZKSyncCreate2Factory();
string memory artifact = vm.readFile("zkout/ERC1967Proxy.sol/ERC1967Proxy.json");
bytes32 bytecodeHash = vm.parseJsonBytes32(artifact, ".hash");
console.log("bytecodeHash");
console.logBytes32(bytes32(bytecodeHash));

bytes memory emailAuthInit = abi.encode(
address(emailAuth), abi.encodeCall(EmailAuth.initialize, (recoveredAccount, accountSalt, address(this)))
);

address computedAddress = factory.computeAddress(accountSalt, bytecodeHash, emailAuthInit);
console.log("computedAddress", computedAddress);

(bool success, bytes memory returnData) = factory.deploy(accountSalt, bytecodeHash, emailAuthInit);

address payable proxyAddress = abi.decode(returnData, (address));
console.log("proxyAddress %s", proxyAddress);

EmailAuth emailAuthProxy = EmailAuth(proxyAddress);
console.log("emailAuthProxy.controller() %s", emailAuthProxy.controller());
vm.stopBroadcast();
}
}

0 comments on commit 14f0626

Please sign in to comment.