@@ -7,6 +7,8 @@ import {Script, console} from "forge-std/Script.sol";
77import {Create2} from "@openzeppelin/contracts/utils/Create2.sol " ;
88
99import {AccountFactory} from "../src/account/AccountFactory.sol " ;
10+
11+ import {SemiModularAccount} from "../src/account/SemiModularAccount.sol " ;
1012import {UpgradeableModularAccount} from "../src/account/UpgradeableModularAccount.sol " ;
1113import {SingleSignerValidation} from "../src/modules/validation/SingleSignerValidation.sol " ;
1214
@@ -16,10 +18,12 @@ contract DeployScript is Script {
1618 address public owner = vm.envAddress ("OWNER " );
1719
1820 address public accountImpl = vm.envOr ("ACCOUNT_IMPL " , address (0 ));
21+ address public semiModularAccountImpl = vm.envOr ("SMA_IMPL " , address (0 ));
1922 address public factory = vm.envOr ("FACTORY " , address (0 ));
2023 address public singleSignerValidation = vm.envOr ("SINGLE_SIGNER_VALIDATION " , address (0 ));
2124
2225 bytes32 public accountImplSalt = bytes32 (vm.envOr ("ACCOUNT_IMPL_SALT " , uint256 (0 )));
26+ bytes32 public semiModularAccountImplSalt = bytes32 (vm.envOr ("SMA_IMPL_SALT " , uint256 (0 )));
2327 bytes32 public factorySalt = bytes32 (vm.envOr ("FACTORY_SALT " , uint256 (0 )));
2428 bytes32 public singleSignerValidationSalt = bytes32 (vm.envOr ("SINGLE_SIGNER_VALIDATION_SALT " , uint256 (0 )));
2529
@@ -34,6 +38,7 @@ contract DeployScript is Script {
3438
3539 vm.startBroadcast ();
3640 _deployAccountImpl (accountImplSalt, accountImpl);
41+ _deploySemiModularAccountImpl (semiModularAccountImplSalt, semiModularAccountImpl);
3742 _deploySingleSignerValidation (singleSignerValidationSalt, singleSignerValidation);
3843 _deployAccountFactory (factorySalt, factory);
3944 _addStakeForFactory (uint32 (requiredUnstakeDelay), requiredStakeAmount);
@@ -72,6 +77,38 @@ contract DeployScript is Script {
7277 }
7378 }
7479
80+ function _deploySemiModularAccountImpl (bytes32 salt , address expected ) internal {
81+ console.log (string .concat ("Deploying SemiModularAccountImpl with salt: " , vm.toString (salt)));
82+
83+ address addr = Create2.computeAddress (
84+ salt,
85+ keccak256 (abi.encodePacked (type (SemiModularAccount).creationCode, abi.encode (entryPoint))),
86+ CREATE2_FACTORY
87+ );
88+ if (addr != expected) {
89+ console.log ("Expected address mismatch " );
90+ console.log ("Expected: " , expected);
91+ console.log ("Actual: " , addr);
92+ revert ();
93+ }
94+
95+ if (addr.code.length == 0 ) {
96+ console.log ("No code found at expected address, deploying... " );
97+ SemiModularAccount deployed = new SemiModularAccount {salt: salt}(entryPoint);
98+
99+ if (address (deployed) != expected) {
100+ console.log ("Deployed address mismatch " );
101+ console.log ("Expected: " , expected);
102+ console.log ("Deployed: " , address (deployed));
103+ revert ();
104+ }
105+
106+ console.log ("Deployed SemiModularAccount at: " , address (deployed));
107+ } else {
108+ console.log ("Code found at expected address, skipping deployment " );
109+ }
110+ }
111+
75112 function _deploySingleSignerValidation (bytes32 salt , address expected ) internal {
76113 console.log (string .concat ("Deploying SingleSignerValidation with salt: " , vm.toString (salt)));
77114
@@ -110,7 +147,7 @@ contract DeployScript is Script {
110147 keccak256 (
111148 abi.encodePacked (
112149 type (AccountFactory).creationCode,
113- abi.encode (entryPoint, accountImpl, singleSignerValidation, owner)
150+ abi.encode (entryPoint, accountImpl, semiModularAccountImpl, singleSignerValidation, owner)
114151 )
115152 ),
116153 CREATE2_FACTORY
@@ -124,8 +161,13 @@ contract DeployScript is Script {
124161
125162 if (addr.code.length == 0 ) {
126163 console.log ("No code found at expected address, deploying... " );
164+ // Patched
127165 AccountFactory deployed = new AccountFactory {salt: salt}(
128- entryPoint, UpgradeableModularAccount (payable (accountImpl)), singleSignerValidation, owner
166+ entryPoint,
167+ UpgradeableModularAccount (payable (accountImpl)),
168+ SemiModularAccount (payable (semiModularAccountImpl)),
169+ singleSignerValidation,
170+ owner
129171 );
130172
131173 if (address (deployed) != expected) {
0 commit comments