Skip to content

Commit

Permalink
chore: update the deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Behzad-rabiei committed Nov 22, 2024
1 parent 324db51 commit b9eb820
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 52 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ npx hardhat ignition deploy ./ignition/modules/Lock.ts
## Deployments

| Address | Tag | Chain |
|---------|-----|-------|
|---------|-----|-------|


// Localhost
RUNNING network -> npx hardhat node
Remove ignition/deployments/chain-31337
Deploy to localhost -> npx hardhat run ./scripts/deploy.ts --network localhost
9 changes: 7 additions & 2 deletions ignition/modules/OIDPermissionManagerModule.ts
Original file line number Diff line number Diff line change
@@ -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 };
});

Expand Down
126 changes: 77 additions & 49 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -30,64 +31,91 @@ 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))"),
toFunctionSelector("updateApplication(uint256, (string, address))"),
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);

0 comments on commit b9eb820

Please sign in to comment.