@@ -34,6 +34,10 @@ async function main() {
3434 console . error ( "Missing MNEMONIC or PRIVATE_KEY. Aborting.." ) ;
3535 return null ;
3636 }
37+ if ( ! process . env . ADDRESS_FILE ) {
38+ console . error ( "Missing ADDRESS_FILE. Aborting.." ) ;
39+ return null ;
40+ }
3741 owner = wallet . connect ( provider ) ;
3842 let gasLimit = 3000000 ;
3943 let gasPrice = null ;
@@ -46,8 +50,8 @@ async function main() {
4650 networkName = "mainnet" ;
4751 OPFOwner = "0x0d27cd67c4A3fd3Eb9C7C757582f59089F058167" ;
4852 RouterAddress = "0x8149276f275EEFAc110D74AFE8AFECEaeC7d1593" ;
49- gasLimit = 15000000
50- gasPrice = ethers . utils . parseUnits ( '0.4 ' , 'gwei' )
53+ gasLimit = 5000000
54+ gasPrice = ethers . utils . parseUnits ( '1.2 ' , 'gwei' )
5155 break ;
5256 case 10 :
5357 networkName = "optimism" ;
@@ -67,11 +71,11 @@ async function main() {
6771 networkName = "base" ;
6872 OPFOwner = '0x4169e846f1524Cf0ac02Bd4B04fa33242709Cf64' ;
6973 RouterAddress = "0xEF62FB495266C72a5212A11Dce8baa79Ec0ABeB1" ;
70- gasPrice = ethers . utils . parseUnits ( '0.009260 ' , 'gwei' )
71- gasLimit = 28000000
74+ gasPrice = ethers . utils . parseUnits ( '0.022999855 ' , 'gwei' )
75+ gasLimit = 5000000
7276 break ;
7377 case 23294 :
74- networkName = "oasis_saphire " ;
78+ networkName = "oasis_sapphire " ;
7579 OPFOwner = '0x086E7F0588755af5AF5f8194542Fd8328238F3C1'
7680 RouterAddress = "0xd8992Ed72C445c35Cb4A2be468568Ed1079357c8" ;
7781 gasPrice = ethers . utils . parseUnits ( '100' , 'gwei' )
@@ -88,8 +92,8 @@ async function main() {
8892 networkName = "sepolia" ;
8993 OPFOwner = '0xC7EC1970B09224B317c52d92f37F5e1E4fF6B687' ;
9094 RouterAddress = "0x2112Eb973af1DBf83a4f11eda82f7a7527D7Fde5" ;
91- gasPrice = ethers . utils . parseUnits ( '1 ' , 'gwei' )
92- gasLimit = 28000000
95+ gasPrice = ethers . utils . parseUnits ( '0.001000011 ' , 'gwei' )
96+ gasLimit = 5000000
9397 break ;
9498 case 11155420 :
9599 networkName = "optimism_sepolia" ;
@@ -114,15 +118,36 @@ async function main() {
114118 else {
115119 options = { gasLimit }
116120 }
117-
121+ console . log ( "Network:" + networkName )
122+ const addressFile = process . env . ADDRESS_FILE ;
123+ let oldAddresses ;
124+ if ( addressFile ) {
125+ try {
126+ oldAddresses = JSON . parse ( fs . readFileSync ( addressFile ) ) ;
127+ } catch ( e ) {
128+ console . log ( e ) ;
129+ oldAddresses = { } ;
130+ }
131+ if ( ! oldAddresses [ networkName ] ) oldAddresses [ networkName ] = { } ;
132+ addresses = oldAddresses [ networkName ] ;
133+ }
134+ if ( logging )
135+ console . info (
136+ "Use existing addresses:" + JSON . stringify ( addresses , null , 2 )
137+ ) ;
138+ if ( ! addresses . Router ) {
139+ console . error ( "Missing RouterAddress address. Aborting.." ) ;
140+ return null ;
141+ }
142+ RouterAddress = addresses . Router
118143 if ( ! OPFOwner || ! RouterAddress ) {
119144 console . error ( "Missing OPFOwner or Router. Aborting.." ) ;
120145 return null ;
121146 }
122147 console . log ( "Deployer nonce:" , await owner . getTransactionCount ( ) ) ;
123-
124- if ( logging ) console . info ( "Deploying Compute Collector" ) ;
125- const NewCollector = await ethers . getContractFactory ( "OPFCommunityFeeCollector" ,
148+ if ( ! addresses . OPFCommunityFeeCollectorCompute ) {
149+ if ( logging ) console . info ( "Deploying Compute Collector" ) ;
150+ const NewCollector = await ethers . getContractFactory ( "OPFCommunityFeeCollector" ,
126151 owner
127152 ) ;
128153
@@ -133,22 +158,42 @@ async function main() {
133158 console . log ( "\tnpx hardhat verify --network " + networkName + " " + deployNewCollector . address + " " + OPFOwner + " " + OPFOwner )
134159
135160 }
161+ addresses . OPFCommunityFeeCollectorCompute = deployNewCollector . address
162+ }
136163 if ( logging ) console . info ( "Deploying Escrow" ) ;
137164 const Escrow = await ethers . getContractFactory (
138165 "Escrow" ,
139166 owner
140167 ) ;
141168
142- const deployEscrow = await Escrow . connect ( owner ) . deploy ( RouterAddress , deployNewCollector . address , options )
169+ const deployEscrow = await Escrow . connect ( owner ) . deploy ( RouterAddress , addresses . OPFCommunityFeeCollectorCompute , options )
143170 await deployEscrow . deployTransaction . wait ( ) ;
144171 if ( show_verify ) {
145172 console . log ( "\tRun the following to verify on etherscan" ) ;
146- console . log ( "\tnpx hardhat verify --network " + networkName + " " + deployEscrow . address + " " + RouterAddress + " " + deployNewCollector . address )
173+ console . log ( "\tnpx hardhat verify --network " + networkName + " " + deployEscrow . address + " " + RouterAddress + " " + addresses . OPFCommunityFeeCollectorCompute )
147174
148175 }
149176 console . log ( "\r\n\r\n" )
150- console . log ( "\"OPFCommunityFeeCollectorCompute\":\"" + deployNewCollector . address + "\"" )
177+ console . log ( "\"OPFCommunityFeeCollectorCompute\":\"" + addresses . OPFCommunityFeeCollectorCompute + "\"" )
151178 console . log ( "\"Escrow\":\"" + deployEscrow . address + "\"" )
179+ addresses . Escrow = deployEscrow . address
180+
181+ if ( addressFile ) {
182+ // write address.json if needed
183+ oldAddresses [ networkName ] = addresses ;
184+ //if (logging)
185+ // console.info(
186+ // "writing to " +
187+ // addressFile +
188+ // "\r\n" +
189+ // JSON.stringify(oldAddresses, null, 2)
190+ //);
191+ try {
192+ fs . writeFileSync ( addressFile , JSON . stringify ( oldAddresses , null , 2 ) ) ;
193+ } catch ( e ) {
194+ console . error ( e ) ;
195+ }
196+ }
152197}
153198
154199
0 commit comments