@@ -11,12 +11,53 @@ import { deployContractViaCREATE2 } from './contract';
1111async function step4 ( ) : Promise < EnvironmentInfo > {
1212 const env = loadEnvironmentInfo ( hre . network . name ) ;
1313 const { network } = env ;
14- const factoryAddress = '0x8Fa5088dF65855E0DaF87FA6591659893b24871d' ;
15- const startupWalletImplAddress = '0x8FD900677aabcbB368e0a27566cCd0C7435F1926' ;
14+
15+ // Load addresses from previous steps
16+ const stepDir = network === 'base_sepolia' ? 'scripts/steps/base_sepolia' : 'scripts/steps' ;
17+
18+ // Load step1 data for factory address
19+ const step1Path = `${ stepDir } /step1.json` ;
20+ if ( ! fs . existsSync ( step1Path ) ) {
21+ throw new Error ( `Step 1 not found at ${ step1Path } . Please run step 1 first.` ) ;
22+ }
23+ const step1Data = JSON . parse ( fs . readFileSync ( step1Path , 'utf8' ) ) ;
24+ const factoryAddress = step1Data . factory ;
25+
26+ // Load step3 data for startupWalletImpl address
27+ const step3Path = `${ stepDir } /step3.json` ;
28+ if ( ! fs . existsSync ( step3Path ) ) {
29+ throw new Error ( `Step 3 not found at ${ step3Path } . Please run step 3 first.` ) ;
30+ }
31+ const step3Data = JSON . parse ( fs . readFileSync ( step3Path , 'utf8' ) ) ;
32+ const startupWalletImplAddress = step3Data . startupWalletImpl ;
33+
34+ // Load step0 data for deployer address
35+ const step0Path = `${ stepDir } /step0.json` ;
36+ if ( ! fs . existsSync ( step0Path ) ) {
37+ throw new Error ( `Step 0 not found at ${ step0Path } . Please run step 0 first.` ) ;
38+ }
39+ const step0Data = JSON . parse ( fs . readFileSync ( step0Path , 'utf8' ) ) ;
40+ const deployerContractAddress = step0Data . create2DeployerAddress ;
41+
42+ // Load step5 data for ImmutableSigner address
43+ const step5Path = `${ stepDir } /step5.json` ;
44+ if ( ! fs . existsSync ( step5Path ) ) {
45+ throw new Error ( `Step 5 not found at ${ step5Path } . Please run step 5 first.` ) ;
46+ }
47+ const step5Data = JSON . parse ( fs . readFileSync ( step5Path , 'utf8' ) ) ;
48+ const immutableSignerAddress = step5Data . immutableSigner ;
49+
50+ // Use Biconomy EntryPoint address from environment
51+ const entryPointAddress = process . env . BICONOMY_ENTRYPOINT_ADDRESS || '0x0000000071727De22E5E9d8BAf0edAc6f37da032' ;
52+
53+ // Update env with correct deployer address
54+ env . deployerContractAddress = deployerContractAddress ;
1655
1756 console . log ( `[${ network } ] Starting deployment...` ) ;
1857 console . log ( `[${ network } ] Factory address ${ factoryAddress } ` ) ;
1958 console . log ( `[${ network } ] StartupWalletImpl address ${ startupWalletImplAddress } ` ) ;
59+ console . log ( `[${ network } ] EntryPoint address ${ entryPointAddress } ` ) ;
60+ console . log ( `[${ network } ] ImmutableSigner address ${ immutableSignerAddress } ` ) ;
2061
2162 await waitForInput ( ) ;
2263
@@ -25,9 +66,17 @@ async function step4(): Promise<EnvironmentInfo> {
2566
2667 // --- Step 4: Deployed using CREATE2 Factory.
2768 // Deploy main module dynamic auth (CFC)
28- const mainModuleDynamicAuth = await deployContractViaCREATE2 ( env , wallets , 'MainModuleDynamicAuth' , [ factoryAddress , startupWalletImplAddress ] ) ;
69+ // Constructor parameters: (address _factory, address _startup)
70+ const mainModuleDynamicAuth = await deployContractViaCREATE2 ( env , wallets , 'MainModuleDynamicAuth' , [
71+ factoryAddress , // Factory address
72+ startupWalletImplAddress // Startup wallet implementation
73+ ] ) ;
2974
30- fs . writeFileSync ( 'step4.json' , JSON . stringify ( {
75+ // Save to network-specific directory
76+ if ( ! fs . existsSync ( stepDir ) ) {
77+ fs . mkdirSync ( stepDir , { recursive : true } ) ;
78+ }
79+ fs . writeFileSync ( `${ stepDir } /step4.json` , JSON . stringify ( {
3180 factoryAddress : factoryAddress ,
3281 startupWalletImplAddress : startupWalletImplAddress ,
3382 mainModuleDynamicAuth : mainModuleDynamicAuth . address ,
0 commit comments