-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/update deployment logic using factory (#52)
* Add ZKSyncCreate2Factory, EmailAccountRecovery test casees split by function. * Failed: update integration testing with foundry-zksync. * Update integration testing command with foundry-zksync. * Failed: update integration testing with foundry. * Add DeployEmailAuthWithCreate2.s.sol. * Disable DeployEmailAuthWIthCreate2.s.sol. * Fix integration test for foundry * Fail: integration testing for foundry zksync. * Fix integration testing for foundry zksync * Tweak README.md * Add EmailAccountRecoveryZkSync * Uncomment some contracts which are used for foundry zksync * make deployEmailAuthProxy as internal function * Update yarn build, yarn test * Remove specific foundry version * Update foundry version * chore: git rm --cached * chore: Update after git rm --cached * chore: git rm --cached * chore: Update after git rm --cached * Fix build-test-fmt on github action * Rename DeployEmailAuthWIthCreate2 * Update deployment files in docs
- Loading branch information
Showing
50 changed files
with
3,642 additions
and
1,052 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ jobs: | |
- name: Install Foundry | ||
uses: foundry-rs/[email protected] | ||
with: | ||
version: nightly-cafc2606a2187a42b236df4aa65f4e8cdfcea970 | ||
version: nightly-0079a1146b79a4aeda58b0258215bedb1f92700b | ||
|
||
- name: Run tests | ||
working-directory: packages/contracts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,3 +82,4 @@ book | |
|
||
# For zksync | ||
zkout | ||
.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
packages/contracts/script/DeployEmailAuthWithCreate2ZKSync.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.