@@ -51,40 +51,46 @@ async function main() {
5151 console . log ( "----------------------------------------------------" ) ;
5252 await delay ( 3000 ) ;
5353
54- // Step 4: Set up admin permissions
55- console . log ( "Setting up admin permissions..." ) ;
56- const voterDatabaseContract = await hre . viem . getContractAt (
57- "VoterDatabase" ,
58- voterDatabaseAddress
59- ) ;
60- const candidateDatabaseContract = await hre . viem . getContractAt (
61- "CandidateDatabase" ,
62- candidateDatabaseAddress
63- ) ;
54+ // Step 4: Set up admin permissions (skip if SKIP_CONFIGURE=1)
55+ if ( process . env . SKIP_CONFIGURE !== "1" ) {
56+ console . log ( "Setting up admin permissions..." ) ;
57+ const voterDatabaseContract = await hre . viem . getContractAt (
58+ "VoterDatabase" ,
59+ voterDatabaseAddress
60+ ) ;
61+ const candidateDatabaseContract = await hre . viem . getContractAt (
62+ "CandidateDatabase" ,
63+ candidateDatabaseAddress
64+ ) ;
6465
65- const publicClient = await hre . viem . getPublicClient ( ) ;
66+ const publicClient = await hre . viem . getPublicClient ( ) ;
6667
67- console . log ( "Granting ElectionDatabase admin access in VoterDatabase..." ) ;
68- const hash1 = await voterDatabaseContract . write . addAdmin ( [
69- getAddress ( electionDatabaseAddress ) ,
70- ] ) ;
71- await publicClient . waitForTransactionReceipt ( { hash : hash1 } ) ;
68+ console . log ( "Granting ElectionDatabase admin access in VoterDatabase..." ) ;
69+ const hash1 = await voterDatabaseContract . write . addAdmin ( [
70+ getAddress ( electionDatabaseAddress ) ,
71+ ] ) ;
72+ await publicClient . waitForTransactionReceipt ( { hash : hash1 } ) ;
7273
73- console . log (
74- "Granting ElectionDatabase admin access in CandidateDatabase..."
75- ) ;
76- const hash2 = await candidateDatabaseContract . write . addAdmin ( [
77- getAddress ( electionDatabaseAddress ) ,
78- ] ) ;
79- await publicClient . waitForTransactionReceipt ( { hash : hash2 } ) ;
74+ console . log (
75+ "Granting ElectionDatabase admin access in CandidateDatabase..."
76+ ) ;
77+ const hash2 = await candidateDatabaseContract . write . addAdmin ( [
78+ getAddress ( electionDatabaseAddress ) ,
79+ ] ) ;
80+ await publicClient . waitForTransactionReceipt ( { hash : hash2 } ) ;
8081
81- console . log ( "Admin permissions setup successfully!" ) ;
82- console . log ( "----------------------------------------------------" ) ;
82+ console . log ( "Admin permissions setup successfully!" ) ;
83+ console . log ( "----------------------------------------------------" ) ;
84+ } else {
85+ console . log ( "Skipping admin permissions setup (SKIP_CONFIGURE=1)" ) ;
86+ console . log ( "----------------------------------------------------" ) ;
87+ }
8388
8489 // Step 5: Verify contracts on Sepolia if applicable
8590 if (
8691 hre . network . config . chainId === sepolia . id &&
87- process . env . ETHERSCAN_API_KEY
92+ process . env . ETHERSCAN_API_KEY &&
93+ process . env . SKIP_VERIFY !== "1"
8894 ) {
8995 console . log ( "Waiting before contract verification..." ) ;
9096 await delay ( 7000 ) ;
@@ -98,6 +104,11 @@ async function main() {
98104 ] ) ;
99105 console . log ( "Contracts verified successfully!" ) ;
100106 console . log ( "----------------------------------------------------" ) ;
107+ } else {
108+ console . log (
109+ "Skipping contract verification... Either SKIP_VERIFY=1 provided or ETHERSCAN_API_KEY is missing or chain is unsupported"
110+ ) ;
111+ console . log ( "----------------------------------------------------" ) ;
101112 }
102113 } catch ( error ) {
103114 console . error ( "Deployment failed:" , error ) ;
0 commit comments