diff --git a/packages/contracts/package.json b/packages/contracts/package.json index e136ad12..3fc1d004 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -1,6 +1,6 @@ { "name": "@zk-email/ether-email-auth-contracts", - "version": "0.0.1-preview", + "version": "0.0.2-preview", "license": "MIT", "scripts": { "build": "forge build --skip '*ZKSync*'", diff --git a/packages/contracts/src/EmailAccountRecoveryZKSync.sol b/packages/contracts/src/EmailAccountRecoveryZKSync.sol index 963418e1..95ec720b 100644 --- a/packages/contracts/src/EmailAccountRecoveryZKSync.sol +++ b/packages/contracts/src/EmailAccountRecoveryZKSync.sol @@ -9,14 +9,14 @@ import {ZKSyncCreate2Factory} from "./utils/ZKSyncCreate2Factory.sol"; /// @notice Provides mechanisms for email-based account recovery, leveraging guardians and template-based email verification. /// @dev This contract is abstract and requires implementation of several methods for configuring a new guardian and recovering an account contract. abstract contract EmailAccountRecoveryZKSync is EmailAccountRecovery { - // This is the address of the zkSync factory contract address public factoryAddr; // The bytecodeHash is hardcoded here because type(ERC1967Proxy).creationCode doesn't work on eraVM currently // If you failed some test cases, check the bytecodeHash by yourself // see, test/ComputeCreate2Address.t.sol - bytes32 public constant proxyBytecodeHash = 0x010000835b32e9a15f4b6353ad649fa33f4fbe4f5139126c07205e738b9f758e; - + bytes32 public constant proxyBytecodeHash = + 0x010000835b32e9a15f4b6353ad649fa33f4fbe4f5139126c07205e738b9f758e; + /// @notice Returns the address of the zkSyncfactory contract. /// @dev This function is virtual and can be overridden by inheriting contracts. /// @return address The address of the zkSync factory contract. @@ -34,19 +34,20 @@ abstract contract EmailAccountRecoveryZKSync is EmailAccountRecovery { function computeEmailAuthAddress( address recoveredAccount, bytes32 accountSalt - ) public view override returns (address) { + ) public view virtual override returns (address) { // If on zksync, we use another logic to calculate create2 address. - return ZKSyncCreate2Factory(factory()).computeAddress( - accountSalt, - proxyBytecodeHash, - abi.encode( - emailAuthImplementation(), - abi.encodeCall( - EmailAuth.initialize, - (recoveredAccount, accountSalt, address(this)) + return + ZKSyncCreate2Factory(factory()).computeAddress( + accountSalt, + proxyBytecodeHash, + abi.encode( + emailAuthImplementation(), + abi.encodeCall( + EmailAuth.initialize, + (recoveredAccount, accountSalt, address(this)) + ) ) - ) - ); + ); } /// @notice Deploys a proxy contract for email authentication using the CREATE2 opcode. @@ -57,25 +58,23 @@ abstract contract EmailAccountRecoveryZKSync is EmailAccountRecovery { /// @param accountSalt A bytes32 salt value defined as a hash of the guardian's email address and an account code. This is assumed to be unique to a pair of the guardian's email address and the wallet address to be recovered. /// @return address The address of the deployed proxy contract. function deployEmailAuthProxy( - address recoveredAccount, + address recoveredAccount, bytes32 accountSalt - ) internal override returns (address) { - (bool success, bytes memory returnData) = ZKSyncCreate2Factory(factory()).deploy( - accountSalt, - proxyBytecodeHash, - abi.encode( - emailAuthImplementation(), - abi.encodeCall( - EmailAuth.initialize, - ( - recoveredAccount, - accountSalt, - address(this) + ) internal virtual override returns (address) { + (bool success, bytes memory returnData) = ZKSyncCreate2Factory( + factory() + ).deploy( + accountSalt, + proxyBytecodeHash, + abi.encode( + emailAuthImplementation(), + abi.encodeCall( + EmailAuth.initialize, + (recoveredAccount, accountSalt, address(this)) ) ) - ) - ); + ); address payable proxyAddress = abi.decode(returnData, (address)); return proxyAddress; } -} \ No newline at end of file +}