Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "refactor: split account deployment into its own script" #64

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ via_ir = true
auto_detect_solc = false
auto_detect_remappings = false
deny_warnings = true
optimizer = true
optimizer_runs = 200

[fuzz]
runs = 1024
Expand Down
3 changes: 1 addition & 2 deletions script/000_ContractAddress.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ pragma solidity 0.8.24;
address constant ENTRY_POINT = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789;

// Use address(0) if unknown or deploying a new version of a contract.
address constant PLUGIN_MANAGER_ADDRESS = 0xc93D6559Fe4dB59742751A857d11a04861a50CCC;
address constant SINGLE_OWNER_MSCA_ADDRESS = address(0);
address constant PLUGIN_MANAGER_ADDRESS = 0x3169Ad878021B87C9CaA9b5CDA740ff3ca270Ce9;
address constant SINGLE_OWNER_MSCA_FACTORY_ADDRESS = 0xa233b124D7b9CFF2D38cB62319e1A3f79144B490;
address constant UPGRADABLE_MSCA_FACTORY_ADDRESS = 0x3e6b66A72B76850c372FBDf29f53268ad636B320;
address constant SINGLE_OWNER_PLUGIN_ADDRESS = 0x7af5E9DBe3e50F023a5b99f44002697cF8e1de2e;
Expand Down
49 changes: 0 additions & 49 deletions script/003.1_DeploySingleOwnerMSCA.s.sol

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@
pragma solidity 0.8.24;

import {SingleOwnerMSCAFactory} from "../src/msca/6900/v0.7/factories/semi/SingleOwnerMSCAFactory.sol";
import {SINGLE_OWNER_MSCA_ADDRESS, SINGLE_OWNER_MSCA_FACTORY_ADDRESS} from "./000_ContractAddress.sol";
import {ENTRY_POINT, PLUGIN_MANAGER_ADDRESS, SINGLE_OWNER_MSCA_FACTORY_ADDRESS} from "./000_ContractAddress.sol";
import {Script, console} from "forge-std/src/Script.sol";

contract DeploySingleOwnerMSCAFactoryScript is Script {
address internal constant PLUGIN_MANAGER = PLUGIN_MANAGER_ADDRESS;
address payable internal constant EXPECTED_FACTORY_ADDRESS = payable(SINGLE_OWNER_MSCA_FACTORY_ADDRESS);

function run() public {
address entryPoint = ENTRY_POINT;
uint256 key = vm.envUint("DEPLOYER_PRIVATE_KEY");
vm.startBroadcast(key);
SingleOwnerMSCAFactory factory;
if (EXPECTED_FACTORY_ADDRESS.code.length == 0) {
factory = new SingleOwnerMSCAFactory{salt: 0}(SINGLE_OWNER_MSCA_ADDRESS);
factory = new SingleOwnerMSCAFactory{salt: 0}(entryPoint, PLUGIN_MANAGER);
console.log("New single owner MSCA factory address: %s", address(factory));
} else {
factory = SingleOwnerMSCAFactory(EXPECTED_FACTORY_ADDRESS);
Expand Down
13 changes: 9 additions & 4 deletions src/msca/6900/v0.7/factories/semi/SingleOwnerMSCAFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pragma solidity 0.8.24;

import {Create2FailedDeployment, InvalidInitializationInput} from "../../../shared/common/Errors.sol";
import {SingleOwnerMSCA} from "../../account/semi/SingleOwnerMSCA.sol";
import {PluginManager} from "../../managers/PluginManager.sol";
import {IEntryPoint} from "@account-abstraction/contracts/interfaces/IEntryPoint.sol";
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";

Expand All @@ -30,8 +32,9 @@ import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
contract SingleOwnerMSCAFactory {
// logic implementation
SingleOwnerMSCA public immutable ACCOUNT_IMPLEMENTATION;
IEntryPoint public immutable ENTRY_POINT;

event FactoryDeployed(address indexed factory, address accountImplementation);
event FactoryDeployed(address indexed factory, address accountImplementation, address entryPoint);
event AccountCreated(address indexed proxy, address sender, bytes32 salt);

/**
Expand All @@ -42,9 +45,11 @@ contract SingleOwnerMSCAFactory {
* during the deployment. No hooks can be injected during the account deployment, so for a future installation
* of more complicated plugins, please call installPlugin via a separate tx/userOp after account deployment.
*/
constructor(address _singleOwnerMSCAImplAddr) {
ACCOUNT_IMPLEMENTATION = SingleOwnerMSCA(payable(_singleOwnerMSCAImplAddr));
emit FactoryDeployed(address(this), address(ACCOUNT_IMPLEMENTATION));
constructor(address _entryPointAddr, address _pluginManagerAddr) {
ENTRY_POINT = IEntryPoint(_entryPointAddr);
PluginManager _pluginManager = PluginManager(_pluginManagerAddr);
ACCOUNT_IMPLEMENTATION = new SingleOwnerMSCA(ENTRY_POINT, _pluginManager);
emit FactoryDeployed(address(this), address(ACCOUNT_IMPLEMENTATION), _entryPointAddr);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions test/WalletMigration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ contract WalletMigrationTest is TestUtils {
testERC1155 = new TestERC1155("getrich.com");
testERC721 = new TestERC721("getrich", "$$$");
testERC20 = new TestLiquidityPool("getrich", "$$$");
SingleOwnerMSCA singleOwnerMSCA = new SingleOwnerMSCA(entryPoint, pluginManager);
singleOwnerMSCAFactory = new SingleOwnerMSCAFactory(address(singleOwnerMSCA));
singleOwnerMSCAFactory = new SingleOwnerMSCAFactory(address(entryPoint), address(pluginManager));
ecdsaAccountFactory = new ECDSAAccountFactory(entryPoint);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ pragma solidity 0.8.24;

import {FunctionReference} from "../../../../../../src/msca/6900/v0.7/common/Structs.sol";

import {SingleOwnerMSCA} from "../../../../../../src/msca/6900/v0.7/account/semi/SingleOwnerMSCA.sol";
import {SingleOwnerMSCAFactory} from "../../../../../../src/msca/6900/v0.7/factories/semi/SingleOwnerMSCAFactory.sol";
import {PluginManager} from "../../../../../../src/msca/6900/v0.7/managers/PluginManager.sol";
import {
PluginManager,
SingleOwnerMSCA,
SingleOwnerMSCAFactory
} from "../../../../../../src/msca/6900/v0.7/factories/semi/SingleOwnerMSCAFactory.sol";
import {SingleOwnerPlugin} from "../../../../../../src/msca/6900/v0.7/plugins/v1_0_0/acl/SingleOwnerPlugin.sol";
import {PluginGasProfileBaseTest, UserOperation} from "../../../../PluginGasProfileBase.t.sol";

Expand Down Expand Up @@ -54,7 +56,7 @@ contract SingleOwnerMSCAWithSingleOwnerPluginTest is PluginGasProfileBaseTest {
function setUp() public override {
super.setUp();
accountAndPluginType = "SingleOwnerMSCAWithSingleOwnerPlugin";
factory = new SingleOwnerMSCAFactory(address(new SingleOwnerMSCA(entryPoint, pluginManager)));
factory = new SingleOwnerMSCAFactory(address(entryPoint), address(pluginManager));
singleOwnerPlugin = new SingleOwnerPlugin();
singleOwnerPluginAddr = address(singleOwnerPlugin);
}
Expand Down
2 changes: 1 addition & 1 deletion test/msca/6900/v0.7/SingleOwnerMSCA.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ contract SingleOwnerMSCATest is TestUtils {
testERC1155 = new TestERC1155("getrich.com");
testERC721 = new TestERC721("getrich", "$$$");
testLiquidityPool = new TestLiquidityPool("getrich", "$$$");
factory = new SingleOwnerMSCAFactory(address(new SingleOwnerMSCA(entryPoint, pluginManager)));
factory = new SingleOwnerMSCAFactory(address(entryPoint), address(pluginManager));
// mock ERC1820Registry contract, could also use etch though, but I'm implementing a simplified registry
erc1820Registry = new MockERC1820Registry();
testERC777 = new TestERC777(erc1820Registry);
Expand Down
2 changes: 1 addition & 1 deletion test/msca/6900/v0.7/SingleOwnerMSCAFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ contract SingleOwnerMSCAFactoryTest is TestUtils {
address payable private beneficiary; // e.g. bundler

function setUp() public {
factory = new SingleOwnerMSCAFactory(address(new SingleOwnerMSCA(entryPoint, pluginManager)));
factory = new SingleOwnerMSCAFactory(address(entryPoint), address(pluginManager));
testLiquidityPool = new TestLiquidityPool("getrich", "$$$");
beneficiary = payable(address(makeAddr("bundler")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ contract ColdStorageAddressBookPluginWithSemiMSCATest is TestUtils {

function setUp() public {
beneficiary = payable(address(makeAddr("bundler")));
factory = new SingleOwnerMSCAFactory(address(new SingleOwnerMSCA(entryPoint, pluginManager)));
factory = new SingleOwnerMSCAFactory(address(entryPoint), address(pluginManager));
addressBookPlugin = new ColdStorageAddressBookPlugin();

(ownerAddr, eoaPrivateKey) = makeAddrAndKey("ColdStorageAddressBookPluginWithSemiMSCATest");
Expand Down
Loading