diff --git a/README.md b/README.md index 4bd56b8..5e90f19 100644 --- a/README.md +++ b/README.md @@ -23,4 +23,10 @@ npx hardhat ignition deploy ./ignition/modules/Lock.ts ## Deployments | Address | Tag | Chain | -|---------|-----|-------| \ No newline at end of file +|---------|-----|-------| + + +// Localhost +RUNNING network -> npx hardhat node +Remove ignition/deployments/chain-31337 +Deploy to localhost -> npx hardhat run ./scripts/deploy.ts --network localhost \ No newline at end of file diff --git a/ignition/modules/OIDPermissionManagerModule.ts b/ignition/modules/OIDPermissionManagerModule.ts index 211494e..9ddd8d2 100644 --- a/ignition/modules/OIDPermissionManagerModule.ts +++ b/ignition/modules/OIDPermissionManagerModule.ts @@ -1,8 +1,13 @@ import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; const OIDPermissionManager = buildModule("OIDPermissionManager", (m) => { - // const authority = m.getParameter("authority"); - const contract = m.contract("OIDPermissionManager", [], {}); + const initialAuthority = m.getParameter("initialAuthority"); + const initialEAS = m.getParameter("initialEAS"); + const contract = m.contract( + "OIDPermissionManager", + [initialAuthority, initialEAS], + {}, + ); return { contract }; }); diff --git a/scripts/deploy.ts b/scripts/deploy.ts index 0bc90f5..3d58ca7 100644 --- a/scripts/deploy.ts +++ b/scripts/deploy.ts @@ -8,7 +8,8 @@ import { deployEAS } from "../utils/deployEAS"; // const eas = "0xC2679fBD37d54388Ce493F1DB75320D236e1815e"; // Sepolia async function main() { - const [deployer] = await hre.viem.getWalletClients(); + const [deployer, appManagerWallet, attesterWallet, permissionManagerWallet] = + await hre.viem.getWalletClients(); const easContract = await deployEAS(deployer); const eas = easContract.eas.address; const { contract: authority } = await hre.ignition.deploy( @@ -30,27 +31,54 @@ async function main() { ); console.log(`ApplicationManager deployed to: ${appManager.address}`); - const { contract: permissionManager } = - await hre.ignition.deploy(OIDPermissionManager); + const { contract: permissionManager } = await hre.ignition.deploy( + OIDPermissionManager, + { + parameters: { + OIDPermissionManager: { + initialAuthority: authority.address, + initialEAS: eas, + }, + }, + }, + ); console.log(`PermissionManager deployed to: ${permissionManager.address}`); - const APP_MANAGER_ROLE = 1n; - const ATTESTER_ROLE = 2n; - - // await authority.write.labelRole([APP_MANAGER_ROLE, "APP_MANAGER_ROLE"]); - // console.log("Labeled APP_MANAGER_ROLE"); - // await authority.write.labelRole([ATTESTER_ROLE, "ATTESTER_ROLE"]); - // console.log("Labeled ATTESTER_ROLE"); - - // await authority.write.grantRole([ - // APP_MANAGER_ROLE, - // deployer.account.address, - // 0, - // ]); - // console.log(`Granted APP_MANAGER_ROLE to ${deployer.account.address}`); + const APP_MANAGER_ROLE = await authority.read.APPLICATION_MANAGER_ROLE(); + const ATTESTER_ROLE = await authority.read.ATTESTATION_MANAGER_ROLE(); + const PERMISSION_ROLE = await authority.read.PERMISSION_MANAGER_ROLE(); + + await authority.write.labelRole([APP_MANAGER_ROLE, "APP_MANAGER_ROLE"]); + console.log("Labeled APP_MANAGER_ROLE"); + await authority.write.labelRole([ATTESTER_ROLE, "ATTESTER_ROLE"]); + console.log("Labeled ATTESTER_ROLE"); + await authority.write.labelRole([PERMISSION_ROLE, "PERMISSION_ROLE"]); + console.log("Labeled PERMISSION_ROLE"); + + await authority.write.grantRole([ + APP_MANAGER_ROLE, + appManagerWallet.account.address, + 0, + ]); + console.log( + `Granted APP_MANAGER_ROLE to ${appManagerWallet.account.address}`, + ); - // await authority.write.grantRole([ATTESTER_ROLE, deployer.account.address, 0]); - // console.log(`Granted ATTESTER_ROLE to ${deployer.account.address}`); + await authority.write.grantRole([ + ATTESTER_ROLE, + attesterWallet.account.address, + 0, + ]); + console.log(`Granted ATTESTER_ROLE to ${attesterWallet.account.address}`); + + await authority.write.grantRole([ + PERMISSION_ROLE, + permissionManagerWallet.account.address, + 0, + ]); + console.log( + `Granted PERMISSION_ROLE to ${permissionManagerWallet.account.address}`, + ); const selectors = [ toFunctionSelector("createApplication((string, address))"), @@ -58,36 +86,36 @@ async function main() { toFunctionSelector("deleteApplication(uint256)"), ]; - // await authority.write.setTargetFunctionRole([ - // appManager.address, - // selectors, - // APP_MANAGER_ROLE, - // ]); - // console.log("Set target functions for app manager"); - - await hre.run("verify:verify", { - address: authority.address, - constructorArguments: [], - }); - console.log("AccessManager verified"); - - await hre.run("verify:verify", { - address: resolver.address, - constructorArguments: [eas], - }); - console.log("OIDResolver verified"); - - await hre.run("verify:verify", { - address: appManager.address, - constructorArguments: [authority.address], - }); - console.log("ApplicationManager verified"); - - await hre.run("verify:verify", { - address: permissionManager.address, - constructorArguments: [], - }); - console.log("PermissionManager verified"); + await authority.write.setTargetFunctionRole([ + appManager.address, + selectors, + APP_MANAGER_ROLE, + ]); + console.log("Set target functions for app manager"); + + // await hre.run("verify:verify", { + // address: authority.address, + // constructorArguments: [], + // }); + // console.log("AccessManager verified"); + + // await hre.run("verify:verify", { + // address: resolver.address, + // constructorArguments: [eas], + // }); + // console.log("OIDResolver verified"); + + // await hre.run("verify:verify", { + // address: appManager.address, + // constructorArguments: [authority.address], + // }); + // console.log("ApplicationManager verified"); + + // await hre.run("verify:verify", { + // address: permissionManager.address, + // constructorArguments: [], + // }); + // console.log("PermissionManager verified"); } main().catch(console.error);