Skip to content

Commit cc90e21

Browse files
committed
scripts/deploy-election-db: add electionDB as admin of candidateDB and voterDB
Signed-off-by: John Titor <[email protected]>
1 parent 276dd57 commit cc90e21

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

scripts/deploy-election-db.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,23 @@ async function main() {
6262
throw new Error("ElectionDatabase address is missing");
6363
}
6464

65+
try {
66+
const voterDatabaseContract = await hre.viem.getContractAt(
67+
"VoterDatabase",
68+
voterDatabaseAddress
69+
);
70+
const candidateDatabaseContract = await hre.viem.getContractAt(
71+
"CandidateDatabase",
72+
candidateDatabaseAddress
73+
);
74+
75+
await voterDatabaseContract.write.addAdmin([electionDatabaseAddress]);
76+
await candidateDatabaseContract.write.addAdmin([electionDatabaseAddress]);
77+
} catch (error) {
78+
console.error(error);
79+
throw error;
80+
}
81+
6582
if (
6683
hre.network.config.chainId === sepolia.id &&
6784
process.env.ETHERSCAN_API_KEY
@@ -84,6 +101,7 @@ main()
84101
process.exit(0);
85102
})
86103
.catch((error) => {
104+
console.log("Something went wrong! See the logs for more information.");
87105
console.error(error);
88106
process.exit(1);
89107
});

0 commit comments

Comments
 (0)