Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update deployment scripts #39

Merged
merged 3 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 39 additions & 8 deletions script/AggregationDeployBase.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,57 @@ import "forge-std/Script.sol";
import "forge-std/StdJson.sol";
import { Strings } from "openzeppelin-contracts/contracts/utils/Strings.sol";

import { V1Claim2Verifier } from "../src/verifiers/v1/V1Claim2Verifier.sol";
import { V1Claim16Verifier } from "../src/verifiers/v1/V1Claim16Verifier.sol";
import { V1Claim32Verifier } from "../src/verifiers/v1/V1Claim32Verifier.sol";
import { V1Claim64Verifier } from "../src/verifiers/v1/V1Claim64Verifier.sol";
import { V1Claim128Verifier } from "../src/verifiers/v1/V1Claim128Verifier.sol";
import { V1Claim256Verifier } from "../src/verifiers/v1/V1Claim256Verifier.sol";


import { V2Claim2Verifier } from "../src/verifiers/v2/V2Claim2Verifier.sol";
import { V2Claim16Verifier } from "../src/verifiers/v2/V2Claim16Verifier.sol";
import { V2Claim32Verifier } from "../src/verifiers/v2/V2Claim32Verifier.sol";
import { V2Claim64Verifier } from "../src/verifiers/v2/V2Claim64Verifier.sol";
import { V2Claim128Verifier } from "../src/verifiers/v2/V2Claim128Verifier.sol";
import { V2Claim8192Verifier } from "../src/verifiers/v2/V2Claim8192Verifier.sol";


string constant DEPLOYED_ADDRESS_FILE = "script/config/deployed.json";
string constant QUERY_SCHEMA_FILE = "script/config/querySchema.json";

abstract contract AggregationDeployBase is Script {
function _getDeployedAddresses()
internal
view
returns (address queryAddress, address wldToken, address rootValidator, address grant)
returns (address wldToken, address rootValidator, address grant)
{
string memory deployedAddressesFile = vm.readFile(DEPLOYED_ADDRESS_FILE);
queryAddress = abi.decode(vm.parseJson(deployedAddressesFile, ".queryAddress"), (address));
wldToken = abi.decode(vm.parseJson(deployedAddressesFile, ".wldToken"), (address));
rootValidator = abi.decode(vm.parseJson(deployedAddressesFile, ".rootValidator"), (address));
grant = abi.decode(vm.parseJson(deployedAddressesFile, ".grant"), (address));
}

function _getQuerySchema(string memory version, uint256 maxNumClaims) internal view returns (bytes32 querySchema) {
string memory querySchemaFile = vm.readFile(QUERY_SCHEMA_FILE);
string memory path =
string.concat(string.concat(".", version), string.concat(".", Strings.toString(maxNumClaims)));
querySchema = abi.decode(vm.parseJson(querySchemaFile, path), (bytes32));
function _deployVerifier(string memory version, uint256 maxNumClaims) internal returns (address verifier) {
bytes32 versionHash = keccak256(abi.encodePacked(version));

if (versionHash == keccak256(abi.encodePacked("v1"))) {
if (maxNumClaims == 2) verifier = address(new V1Claim2Verifier());
else if (maxNumClaims == 16) verifier = address(new V1Claim16Verifier());
else if (maxNumClaims == 32) verifier = address(new V1Claim32Verifier());
else if (maxNumClaims == 64) verifier = address(new V1Claim64Verifier());
else if (maxNumClaims == 128) verifier = address(new V1Claim128Verifier());
else if (maxNumClaims == 256) verifier = address(new V1Claim256Verifier());
else revert("Invalid numClaims value");
} else if (versionHash == keccak256(abi.encodePacked("v2"))) {
if (maxNumClaims == 2) verifier = address(new V2Claim2Verifier());
else if (maxNumClaims == 16) verifier = address(new V2Claim16Verifier());
else if (maxNumClaims == 32) verifier = address(new V2Claim32Verifier());
else if (maxNumClaims == 64) verifier = address(new V2Claim64Verifier());
else if (maxNumClaims == 128) verifier = address(new V2Claim128Verifier());
else if (maxNumClaims == 8192) verifier = address(new V2Claim8192Verifier());
else revert("Invalid numClaims value");
} else {
revert("Invalid version");
}
}
}
7 changes: 4 additions & 3 deletions script/DeployAggregationV1.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pragma solidity 0.8.19;

import { WorldcoinAggregationV1 } from "../src/WorldcoinAggregationV1.sol";
import { IERC20 } from "../src/interfaces/IERC20.sol";
import { V1Claim2Verifier } from "../src/verifiers/V1Claim2Verifier.sol";

import { AggregationDeployBase } from "./AggregationDeployBase.s.sol";

Expand All @@ -16,10 +15,12 @@ contract DeployAggregationV1 is AggregationDeployBase {

bytes32 vKeyHash = 0x46e72119ce99272ddff09e0780b472fdc612ca799c245eea223b27e57a5f9cec;

(, address wldToken, address rootValidator, address grant) = _getDeployedAddresses();
(address wldToken, address rootValidator, address grant) = _getDeployedAddresses();

address verifier = _deployVerifier("v1", maxNumClaims);

WorldcoinAggregationV1 worldcoinAggV1 = new WorldcoinAggregationV1(
vKeyHash, maxNumClaims, wldToken, rootValidator, grant, address(new V1Claim2Verifier()), address(0)
vKeyHash, maxNumClaims, wldToken, rootValidator, grant, verifier, address(0)
);

IERC20 wldTokenContract = IERC20(wldToken);
Expand Down
19 changes: 9 additions & 10 deletions script/DeployAggregationV2.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,20 @@ contract DeployAggregationV2 is AggregationDeployBase {
function run(uint256 logMaxNumClaims) external {
vm.startBroadcast();

// uint64 sourceChainId = 11_155_111;
// bytes32 vKeyHash = 0x46e72119ce99272ddff09e0780b472fdc612ca799c245eea223b27e57a5f9cec;
bytes32 vKeyHash = 0x46e72119ce99272ddff09e0780b472fdc612ca799c245eea223b27e57a5f9cec;

// uint256 maxNumClaims = 2 ** logMaxNumClaims;
uint256 maxNumClaims = 2 ** logMaxNumClaims;

// bytes32 querySchema = _getQuerySchema("v2", maxNumClaims);
(address wldToken, address rootValidator, address grant) = _getDeployedAddresses();

// (address queryAddress, address wldToken, address rootValidator, address grant) = _getDeployedAddresses();
address verifier = _deployVerifier("v2", maxNumClaims);

// WorldcoinAggregationV2 worldcoinAggV2 =
// new WorldcoinAggregationV2(vKeyHash, logMaxNumClaims, wldToken, rootValidator, grant);
WorldcoinAggregationV2 worldcoinAggV2 =
new WorldcoinAggregationV2(vKeyHash, logMaxNumClaims, wldToken, rootValidator, grant, verifier, address(0));

// IERC20 wldTokenContract = IERC20(wldToken);
// uint256 transferAmount = 100_000 * 10 ** 18;
// wldTokenContract.transfer(address(worldcoinAggV2), transferAmount);
IERC20 wldTokenContract = IERC20(wldToken);
uint256 transferAmount = 100_000 * 10 ** 18;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Could be easier to write 100_000e18

wldTokenContract.transfer(address(worldcoinAggV2), transferAmount);

vm.stopBroadcast();
}
Expand Down
1 change: 0 additions & 1 deletion script/config/deployed.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"queryAddress": "0x9C9CF878f9Ba4422BDD73B55554F0A796411D5ed",
"wldToken": "0xe93D97b0Bd30bD61a9D02B0A471DbB329D5d1fd8",
"rootValidator": "0x9c06c3F1deecb530857127009EBE7d112ecd0E3F",
"grant": "0x5d1F6aDfff773A2146f1f3c947Ddad1945103DaC"
Expand Down
10 changes: 5 additions & 5 deletions script/config/v2client.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"8": "0x051e0aB85c4Dfb90270FD45c93628c7F0b7551e7",
"16": "0x3f88b9dc416ceadc36092673097ba456ba878cfb",
"32": "0x18c98598e77dBF52e897966b3b1980EB9195D496",
"64": "0x7400fA7E1da16D995EC5F8F717a61D974C02BfAc",
"128": "0x0CBb51Fd7fbfc36A342C3D35316B814C825EA552"
"16": "0x94ad8F0eCe486C49978cc5Ae2557f202f3396a4a",
"32": "0xef0e3752037583b46E4cF7813064d093830b864B",
"64": "0x3AA0F154e13C6bf4024349076c87bf5F9D85CefF",
"128": "0x3B688859e6610Caa0729C8458d539d2b7F809F63",
"8192": "0x14dafE7C9981cc5295c1883Fe55155BABb30eAcC"
}
Loading
Loading