-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
174 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ cache/ | |
.env | ||
|
||
broadcast/**/run-latest.json | ||
broadcast/**/dry-run/**/* | ||
broadcast/**/dry-run/**/* | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.19; | ||
|
||
import "forge-std/Script.sol"; | ||
|
||
import {IEntryPoint} from "account-abstraction/interfaces/IEntryPoint.sol"; | ||
|
||
import {MultiOwnerLightAccountFactory} from "../src/MultiOwnerLightAccountFactory.sol"; | ||
|
||
// @notice Deploys MultiOwnerLightAccountFactory | ||
// @dev To run: `forge script script/Deploy_MultiOwnerLightAccountFactory.s.sol:Deploy_MultiOwnerLightAccountFactory --broadcast --rpc-url ${RPC_URL} --verify -vvvv` | ||
contract Deploy_MultiOwnerLightAccountFactory is Script { | ||
// Load entrypoint from env | ||
address public entryPointAddr = vm.envAddress("ENTRYPOINT"); | ||
IEntryPoint public entryPoint = IEntryPoint(payable(entryPointAddr)); | ||
|
||
// Load factory owner from env | ||
address public owner = vm.envAddress("OWNER"); | ||
|
||
error InitCodeHashMismatch(bytes32 initCodeHash); | ||
error DeployedAddressMismatch(address deployed); | ||
|
||
function run() public { | ||
vm.startBroadcast(); | ||
|
||
// Init code hash check | ||
bytes32 initCodeHash = | ||
keccak256(abi.encodePacked(type(MultiOwnerLightAccountFactory).creationCode, abi.encode(owner, entryPoint))); | ||
|
||
if (initCodeHash != 0x69e0f4a2942425638860e9982bd32f08941a082681e53208de970099f18252cc) { | ||
revert InitCodeHashMismatch(initCodeHash); | ||
} | ||
|
||
console.log("********************************"); | ||
console.log("******** Deploy Inputs *********"); | ||
console.log("********************************"); | ||
console.log("Owner:", owner); | ||
console.log("Entrypoint:", address(entryPoint)); | ||
console.log(); | ||
console.log("********************************"); | ||
console.log("******** Deploying.... *********"); | ||
console.log("********************************"); | ||
|
||
MultiOwnerLightAccountFactory factory = new MultiOwnerLightAccountFactory{ | ||
salt: 0x0000000000000000000000000000000000000000bb3ab048b3f4ef2620ea0163 | ||
}(owner, entryPoint); | ||
|
||
// Deployed address check | ||
if (address(factory) != 0x000000000019d2Ee9F2729A65AfE20bb0020AefC) { | ||
revert DeployedAddressMismatch(address(factory)); | ||
} | ||
|
||
_addStakeForFactory(address(factory)); | ||
|
||
console.log("MultiOwnerLightAccountFactory:", address(factory)); | ||
console.log("MultiOwnerLightAccount:", address(factory.ACCOUNT_IMPLEMENTATION())); | ||
console.log(); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
|
||
function _addStakeForFactory(address factoryAddr) internal { | ||
uint32 unstakeDelaySec = uint32(vm.envOr("UNSTAKE_DELAY_SEC", uint32(86400))); | ||
uint256 requiredStakeAmount = vm.envUint("REQUIRED_STAKE_AMOUNT"); | ||
uint256 currentStakedAmount = entryPoint.getDepositInfo(factoryAddr).stake; | ||
uint256 stakeAmount = requiredStakeAmount - currentStakedAmount; | ||
MultiOwnerLightAccountFactory(payable(factoryAddr)).addStake{value: stakeAmount}(unstakeDelaySec, stakeAmount); | ||
console.log("******** Add Stake Verify *********"); | ||
console.log("Staked factory: ", factoryAddr); | ||
console.log("Stake amount: ", entryPoint.getDepositInfo(factoryAddr).stake); | ||
console.log("Unstake delay: ", entryPoint.getDepositInfo(factoryAddr).unstakeDelaySec); | ||
console.log("******** Stake Verify Done *********"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.23; | ||
|
||
import {Script} from "forge-std/Script.sol"; | ||
import {console} from "forge-std/Test.sol"; | ||
|
||
import {IEntryPoint} from "account-abstraction/interfaces/IEntryPoint.sol"; | ||
|
||
import {LightAccountFactory} from "../src/LightAccountFactory.sol"; | ||
import {MultiOwnerLightAccountFactory} from "../src/MultiOwnerLightAccountFactory.sol"; | ||
|
||
contract GetInitCodeHash is Script { | ||
// Load entrypoint from env | ||
address public entryPointAddr = vm.envAddress("ENTRYPOINT"); | ||
IEntryPoint public entryPoint = IEntryPoint(payable(entryPointAddr)); | ||
|
||
// Load factory owner from env | ||
address public owner = vm.envAddress("OWNER"); | ||
|
||
function run() public view { | ||
console.log("******** Calculating Init Code Hashes *********"); | ||
console.log("Chain: ", block.chainid); | ||
console.log("EP: ", entryPointAddr); | ||
console.log("Factory owner: ", owner); | ||
|
||
bytes memory lightAccountFactoryInitCode = | ||
abi.encodePacked(type(LightAccountFactory).creationCode, abi.encode(owner, entryPoint)); | ||
|
||
bytes32 lightAccountFactoryInitCodeHash = keccak256(lightAccountFactoryInitCode); | ||
|
||
console.log("LightAccountFactory init code hash:"); | ||
console.logBytes32(lightAccountFactoryInitCodeHash); | ||
|
||
bytes memory multiOwnerLightAccountFactoryInitCode = | ||
abi.encodePacked(type(MultiOwnerLightAccountFactory).creationCode, abi.encode(owner, entryPoint)); | ||
|
||
bytes32 multiOwnerLightAccountFactoryInitCodeHash = keccak256(multiOwnerLightAccountFactoryInitCode); | ||
|
||
console.log("MultiOwnerLightAccountFactory init code hash:"); | ||
console.logBytes32(multiOwnerLightAccountFactoryInitCodeHash); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters