Skip to content

Commit 7203e26

Browse files
committed
fix(deploy): skip stake call if required amount is 0
1 parent 59d744d commit 7203e26

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

script/Deploy_LightAccountFactory.s.sol

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,16 @@ contract Deploy_LightAccountFactory is Script {
5353
uint256 requiredStakeAmount = vm.envUint("REQUIRED_STAKE_AMOUNT");
5454
uint256 currentStakedAmount = entryPoint.getDepositInfo(factoryAddr).stake;
5555
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 *********");
56+
57+
if (stakeAmount > 0) {
58+
LightAccountFactory(payable(factoryAddr)).addStake{value: stakeAmount}(unstakeDelaySec, stakeAmount);
59+
console.log("******** Add Stake Verify *********");
60+
console.log("Staked factory: ", factoryAddr);
61+
console.log("Stake amount: ", entryPoint.getDepositInfo(factoryAddr).stake);
62+
console.log("Unstake delay: ", entryPoint.getDepositInfo(factoryAddr).unstakeDelaySec);
63+
console.log("******** Stake Verify Done! *********");
64+
} else {
65+
console.log("No stake needed for factory");
66+
}
6267
}
6368
}

script/Deploy_MultiOwnerLightAccountFactory.s.sol

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,18 @@ contract Deploy_MultiOwnerLightAccountFactory is Script {
5353
uint256 requiredStakeAmount = vm.envUint("REQUIRED_STAKE_AMOUNT");
5454
uint256 currentStakedAmount = entryPoint.getDepositInfo(factoryAddr).stake;
5555
uint256 stakeAmount = requiredStakeAmount - currentStakedAmount;
56-
MultiOwnerLightAccountFactory(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 *********");
56+
57+
if (stakeAmount > 0) {
58+
MultiOwnerLightAccountFactory(payable(factoryAddr)).addStake{value: stakeAmount}(
59+
unstakeDelaySec, stakeAmount
60+
);
61+
console.log("******** Add Stake Verify *********");
62+
console.log("Staked factory: ", factoryAddr);
63+
console.log("Stake amount: ", entryPoint.getDepositInfo(factoryAddr).stake);
64+
console.log("Unstake delay: ", entryPoint.getDepositInfo(factoryAddr).unstakeDelaySec);
65+
console.log("******** Stake Verify Done! *********");
66+
} else {
67+
console.log("No stake needed for factory");
68+
}
6269
}
6370
}

0 commit comments

Comments
 (0)