From d31bb35e9e2a65e403e97c4171c16cdb93ca53c2 Mon Sep 17 00:00:00 2001 From: wshino Date: Sun, 13 Oct 2024 01:07:42 +0900 Subject: [PATCH] Add Deploy_jwtVerifier.s.sol --- packages/contracts/README.md | 3 ++- .../contracts/script/Deploy_jwtVerifier.s.sol | 21 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/contracts/README.md b/packages/contracts/README.md index 0f3d556..0b9520b 100644 --- a/packages/contracts/README.md +++ b/packages/contracts/README.md @@ -12,7 +12,8 @@ Here is the sample verified deployed addresses on Sepolia: ``` JWTRegistry: 0x983A7B6a8b5657319078D858a303830C99761108 DKIMRegistry: 0xf3B70Dc348C7820b3026564500A7eBAc6cC4cC33 -JWTVerifier: 0xac82c745AAdA7489786ed689bcc1138F27833cD7 +JWTVerifier implementation: 0xF462839975B5e1844dD32cb301aFE65D0Dbe66Dd +JWTVerifier proxy: 0x63E990e29317Bf54a6c4F5Fb26e33342D3DE6Fd3 ``` ## Errors diff --git a/packages/contracts/script/Deploy_jwtVerifier.s.sol b/packages/contracts/script/Deploy_jwtVerifier.s.sol index f1c9ace..77d081b 100644 --- a/packages/contracts/script/Deploy_jwtVerifier.s.sol +++ b/packages/contracts/script/Deploy_jwtVerifier.s.sol @@ -4,20 +4,37 @@ pragma solidity ^0.8.12; import "forge-std/Script.sol"; import "../src/utils/JwtVerifier.sol"; +import "../src/utils/JwtGroth16Verifier.sol"; +import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; // 1. `source .env` // 2. `forge script script/Deploy_jwtVerifier.s.sol:DeployScript --rpc-url $RPC_URL --verify --etherscan-api-key $ETHERSCAN_API_KEY --broadcast -vvvv` contract DeployScript is Script { function run() external { uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY"); + address deployer = vm.addr(deployerPrivateKey); + address initialOwner = deployer; bytes32 salt = keccak256(abi.encodePacked(vm.envString("DEPLOY_SALT"))); vm.startBroadcast(deployerPrivateKey); // Deploy the contract using CREATE2 - JwtVerifier jwtVerifier = new JwtVerifier{salt: salt}(); + JwtVerifier jwtVerifierImpl = new JwtVerifier(); + console.log( + "JWTVerifier implementation deployed at: %s", + address(jwtVerifierImpl) + ); + JwtGroth16Verifier groth16Verifier = new JwtGroth16Verifier(); + ERC1967Proxy jwtVerifierProxy = new ERC1967Proxy{salt: salt}( + address(jwtVerifierImpl), + abi.encodeCall( + jwtVerifierImpl.initialize, + (initialOwner, address(groth16Verifier)) + ) + ); - console.log("Contract deployed to:", address(jwtVerifier)); + JwtVerifier jwtVerifier = JwtVerifier(address(jwtVerifierProxy)); + console.log("JWTVerifier proxy deployed to:", address(jwtVerifier)); vm.stopBroadcast(); }