@@ -32,17 +32,22 @@ contract Deploy_LightAccountFactory is Script {
3232 console.log ("******** Deploying.... ********* " );
3333 console.log ("******************************** " );
3434
35- LightAccountFactory factory = new LightAccountFactory {salt: factorySalt}(owner, entryPoint);
36-
37- // Deployed address check
38- if (address (factory) != expectedFactoryAddress) {
39- revert DeployedAddressMismatch (address (factory));
35+ if (expectedFactoryAddress.code.length == 0 ) {
36+ address factory = address (new LightAccountFactory {salt: factorySalt}(owner, entryPoint));
37+ // Deployed address check
38+ if (factory != expectedFactoryAddress) {
39+ revert DeployedAddressMismatch (factory);
40+ }
41+ } else {
42+ console.log ("Factory already deployed at: " , expectedFactoryAddress);
4043 }
4144
42- _addStakeForFactory (address (factory) );
45+ _addStakeForFactory (expectedFactoryAddress );
4346
44- console.log ("LightAccountFactory: " , address (factory));
45- console.log ("LightAccount: " , address (factory.ACCOUNT_IMPLEMENTATION ()));
47+ console.log ("LightAccountFactory: " , address (expectedFactoryAddress));
48+ console.log (
49+ "LightAccount: " , address (LightAccountFactory (payable (expectedFactoryAddress)).ACCOUNT_IMPLEMENTATION ())
50+ );
4651 console.log ();
4752
4853 vm.stopBroadcast ();
@@ -53,11 +58,16 @@ contract Deploy_LightAccountFactory is Script {
5358 uint256 requiredStakeAmount = vm.envUint ("REQUIRED_STAKE_AMOUNT " );
5459 uint256 currentStakedAmount = entryPoint.getDepositInfo (factoryAddr).stake;
5560 uint256 stakeAmount = requiredStakeAmount - currentStakedAmount;
56- LightAccountFactory (payable (factoryAddr)).addStake {value: stakeAmount}(unstakeDelaySec, stakeAmount);
57- console.log ("******** Add Stake Verify ********* " );
58- console.log ("Staked factory: " , factoryAddr);
59- console.log ("Stake amount: " , entryPoint.getDepositInfo (factoryAddr).stake);
60- console.log ("Unstake delay: " , entryPoint.getDepositInfo (factoryAddr).unstakeDelaySec);
61- console.log ("******** Stake Verify Done ********* " );
61+
62+ if (stakeAmount > 0 ) {
63+ LightAccountFactory (payable (factoryAddr)).addStake {value: stakeAmount}(unstakeDelaySec, stakeAmount);
64+ console.log ("******** Add Stake Verify ********* " );
65+ console.log ("Staked factory: " , factoryAddr);
66+ console.log ("Stake amount: " , entryPoint.getDepositInfo (factoryAddr).stake);
67+ console.log ("Unstake delay: " , entryPoint.getDepositInfo (factoryAddr).unstakeDelaySec);
68+ console.log ("******** Stake Verify Done ********* " );
69+ } else {
70+ console.log ("Factory already staked " );
71+ }
6272 }
6373}
0 commit comments