Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
howydev committed Jan 31, 2024
1 parent ee07537 commit b5545ff
Show file tree
Hide file tree
Showing 24 changed files with 84 additions and 82 deletions.
4 changes: 2 additions & 2 deletions .gasestimates.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ Generated via `bash utils/inspect.sh`.
| validateUserOp | 412 | 55506 | 61509 | 84413 | 76 |


| src/factory/MultiOwnerMAFactory.sol:MultiOwnerMAFactory contract | | | | | |
| src/factory/MultiOwnerModularAccountFactory.sol:MultiOwnerModularAccountFactory contract | | | | | |
|----------------------------------------------------------------------|-----------------|--------|--------|--------|---------|
| Deployment Cost | Deployment Size | | | | |
| 991201 | 5345 | | | | |
Expand Down Expand Up @@ -284,7 +284,7 @@ Generated via `bash utils/inspect.sh`.
| reverseAddressArray | 1513 | 1652 | 1513 | 1930 | 3 |


| test/factory/MultiOwnerMAFactoryTest.t.sol:MultiOwnerMAFactoryTest contract | | | | | |
| test/factory/MultiOwnerModularAccountFactoryTest.t.sol:MultiOwnerModularAccountFactoryTest contract | | | | | |
|---------------------------------------------------------------------------------|-----------------|-----|--------|-----|---------|
| Deployment Cost | Deployment Size | | | | |
| 14310646 | 70879 | | | | |
Expand Down
4 changes: 2 additions & 2 deletions .storagelayout.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ Generated via `bash utils/inspect.sh`.
| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

`forge inspect --pretty src/factory/MultiOwnerMAFactory.sol:MultiOwnerMAFactory storage-layout`
`forge inspect --pretty src/factory/MultiOwnerModularAccountFactory.sol:MultiOwnerModularAccountFactory storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
|--------|---------|------|--------|-------|-------------------------------------------------------------|
| _owner | address | 0 | 0 | 20 | src/factory/MultiOwnerMAFactory.sol:MultiOwnerMAFactory |
| _owner | address | 0 | 0 | 20 | src/factory/MultiOwnerModularAccountFactory.sol:MultiOwnerModularAccountFactory |

`forge inspect --pretty src/libraries/AccountStorageV1.sol:AccountStorageV1 storage-layout`
| Name | Type | Slot | Offset | Bytes | Contract |
Expand Down
25 changes: 15 additions & 10 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pragma solidity ^0.8.22;
import {Script} from "forge-std/Script.sol";
import {console} from "forge-std/Test.sol";

import {IEntryPoint as I4337EntryPoint} from "@eth-infinitism/account-abstraction/interfaces/IEntryPoint.sol";

import {UpgradeableModularAccount} from "../src/account/UpgradeableModularAccount.sol";
import {MultiOwnerModularAccountFactory} from "../src/factory/MultiOwnerModularAccountFactory.sol";
import {IEntryPoint} from "../src/interfaces/erc4337/IEntryPoint.sol";
Expand All @@ -38,7 +40,7 @@ contract Deploy is Script {
// Load core contract, if not in env, deploy new contract
address public maImpl = vm.envOr("MA_IMPL", address(0));
address public ownerFactoryAddr = vm.envOr("OWNER_FACTORY", address(0));
MultiOwnerMAFactory ownerFactory;
MultiOwnerModularAccountFactory ownerFactory;

// Load plugins contract, if not in env, deploy new contract
address public multiOwnerPlugin = vm.envOr("OWNER_PLUGIN", address(0));
Expand Down Expand Up @@ -73,16 +75,17 @@ contract Deploy is Script {
}
multiOwnerPluginManifestHash = keccak256(abi.encode(BasePlugin(multiOwnerPlugin).pluginManifest()));

// Deploy MultiOwnerMAFactory, and add stake with EP
// Deploy MultiOwnerModularAccountFactory, and add stake with EP

if (ownerFactoryAddr == address(0)) {
ownerFactory =
new MultiOwnerMAFactory(owner, multiOwnerPlugin, maImpl, multiOwnerPluginManifestHash, entryPoint);
ownerFactory = new MultiOwnerModularAccountFactory(
owner, multiOwnerPlugin, maImpl, multiOwnerPluginManifestHash, entryPoint
);

ownerFactoryAddr = address(ownerFactory);
console.log("New MultiOwnerMAFactory: ", ownerFactoryAddr);
console.log("New MultiOwnerModularAccountFactory: ", ownerFactoryAddr);
} else {
console.log("Exist MultiOwnerMAFactory: ", ownerFactoryAddr);
console.log("Exist MultiOwnerModularAccountFactory: ", ownerFactoryAddr);
}
_addStakeForFactory(ownerFactoryAddr, entryPoint);

Expand All @@ -102,16 +105,18 @@ contract Deploy is Script {
function _addStakeForFactory(address factoryAddr, IEntryPoint anEntryPoint) internal {
uint32 unstakeDelaySec = uint32(vm.envOr("UNSTAKE_DELAY_SEC", uint32(60)));
uint256 requiredStakeAmount = vm.envUint("REQUIRED_STAKE_AMOUNT") * 1 ether;
uint256 currentStakedAmount = IEntryPoint(address(anEntryPoint)).getDepositInfo(factoryAddr).stake;
uint256 currentStakedAmount = I4337EntryPoint(address(anEntryPoint)).getDepositInfo(factoryAddr).stake;
uint256 stakeAmount = requiredStakeAmount - currentStakedAmount;
// since all factory share the same addStake method, it does not matter which contract we use to cast the
// address
MultiOwnerMAFactory(payable(factoryAddr)).addStake{value: stakeAmount}(unstakeDelaySec, stakeAmount);
MultiOwnerModularAccountFactory(payable(factoryAddr)).addStake{value: stakeAmount}(
unstakeDelaySec, stakeAmount
);
console.log("******** Add Stake Verify *********");
console.log("Staked factory: ", factoryAddr);
console.log("Stake amount: ", IEntryPoint(address(anEntryPoint)).getDepositInfo(factoryAddr).stake);
console.log("Stake amount: ", I4337EntryPoint(address(anEntryPoint)).getDepositInfo(factoryAddr).stake);
console.log(
"Unstake delay: ", IEntryPoint(address(anEntryPoint)).getDepositInfo(factoryAddr).unstakeDelaySec
"Unstake delay: ", I4337EntryPoint(address(anEntryPoint)).getDepositInfo(factoryAddr).unstakeDelaySec
);
console.log("******** Stake Verify Done *********");
}
Expand Down
1 change: 0 additions & 1 deletion src/plugins/owner/IMultiOwnerPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ interface IMultiOwnerPlugin {
enum FunctionId {
RUNTIME_VALIDATION_OWNER_OR_SELF, // require owner or self access
USER_OP_VALIDATION_OWNER // require owner access

}

/// @notice This event is emitted when owners of the account are updated.
Expand Down
4 changes: 1 addition & 3 deletions src/plugins/session/ISessionKeyPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import {UserOperation} from "../../interfaces/erc4337/UserOperation.sol";
import {Call} from "../../interfaces/IStandardExecutor.sol";

interface ISessionKeyPlugin {
enum FunctionId {
USER_OP_VALIDATION_SESSION_KEY
}
enum FunctionId {USER_OP_VALIDATION_SESSION_KEY}

// Valid access control types for contract access control lists.
enum ContractAccessControlType {
Expand Down
6 changes: 3 additions & 3 deletions test/account/AccountExecHooks.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol";
import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {MultiOwnerMAFactory} from "../../src/factory/MultiOwnerMAFactory.sol";
import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol";
import {FunctionReferenceLib} from "../../src/helpers/FunctionReferenceLib.sol";
import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol";
import {
Expand All @@ -44,7 +44,7 @@ contract UpgradeableModularAccountExecHooksTest is Test {

IEntryPoint public entryPoint;
MultiOwnerPlugin public multiOwnerPlugin;
MultiOwnerMAFactory public factory;
MultiOwnerModularAccountFactory public factory;
MockPlugin public mockPlugin1;
MockPlugin public mockPlugin2;
bytes32 public manifestHash1;
Expand Down Expand Up @@ -73,7 +73,7 @@ contract UpgradeableModularAccountExecHooksTest is Test {
(owner1, owner1Key) = makeAddrAndKey("owner1");
address impl = address(new UpgradeableModularAccount(IEntryPoint(address(entryPoint))));

factory = new MultiOwnerMAFactory(
factory = new MultiOwnerModularAccountFactory(
address(this),
address(multiOwnerPlugin),
impl,
Expand Down
6 changes: 3 additions & 3 deletions test/account/AccountLoupe.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.so
import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";

import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {MultiOwnerMAFactory} from "../../src/factory/MultiOwnerMAFactory.sol";
import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol";
import {FunctionReferenceLib} from "../../src/helpers/FunctionReferenceLib.sol";
import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol";
import {IAccountLoupe} from "../../src/interfaces/IAccountLoupe.sol";
Expand All @@ -43,7 +43,7 @@ import {ComprehensivePlugin} from "../mocks/plugins/ComprehensivePlugin.sol";
contract AccountLoupeTest is Test {
IEntryPoint public entryPoint;
MultiOwnerPlugin public multiOwnerPlugin;
MultiOwnerMAFactory public factory;
MultiOwnerModularAccountFactory public factory;
ComprehensivePlugin public comprehensivePlugin;

UpgradeableModularAccount public account1;
Expand All @@ -58,7 +58,7 @@ contract AccountLoupeTest is Test {

multiOwnerPlugin = new MultiOwnerPlugin();
address impl = address(new UpgradeableModularAccount(entryPoint));
factory = new MultiOwnerMAFactory(
factory = new MultiOwnerModularAccountFactory(
address(this),
address(multiOwnerPlugin),
impl,
Expand Down
6 changes: 3 additions & 3 deletions test/account/AccountPreValidationHooks.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol";
import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {MultiOwnerMAFactory} from "../../src/factory/MultiOwnerMAFactory.sol";
import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol";
import {FunctionReferenceLib} from "../../src/helpers/FunctionReferenceLib.sol";
import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol";
import {UserOperation} from "../../src/interfaces/erc4337/UserOperation.sol";
Expand All @@ -46,7 +46,7 @@ contract UpgradeableModularAccountPreValidationHooksTest is Test {
IEntryPoint public entryPoint;
address payable public beneficiary;
MultiOwnerPlugin public multiOwnerPlugin;
MultiOwnerMAFactory public factory;
MultiOwnerModularAccountFactory public factory;
MockPlugin public mockPlugin1;
MockPlugin public mockPlugin2;
bytes32 public manifestHash1;
Expand Down Expand Up @@ -77,7 +77,7 @@ contract UpgradeableModularAccountPreValidationHooksTest is Test {

address impl = address(new UpgradeableModularAccount(entryPoint));

factory = new MultiOwnerMAFactory(
factory = new MultiOwnerModularAccountFactory(
address(this),
address(multiOwnerPlugin),
impl,
Expand Down
6 changes: 3 additions & 3 deletions test/account/AccountReturnData.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {Test} from "forge-std/Test.sol";
import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol";

import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {MultiOwnerMAFactory} from "../../src/factory/MultiOwnerMAFactory.sol";
import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol";
import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol";
import {FunctionReference} from "../../src/interfaces/IPluginManager.sol";
import {Call} from "../../src/interfaces/IStandardExecutor.sol";
Expand All @@ -37,7 +37,7 @@ import {
contract AccountReturnDataTest is Test {
IEntryPoint public entryPoint; // Just to be able to construct the factory
MultiOwnerPlugin public multiOwnerPlugin;
MultiOwnerMAFactory public factory;
MultiOwnerModularAccountFactory public factory;

RegularResultContract public regularResultContract;
ResultCreatorPlugin public resultCreatorPlugin;
Expand All @@ -50,7 +50,7 @@ contract AccountReturnDataTest is Test {
multiOwnerPlugin = new MultiOwnerPlugin();
address impl = address(new UpgradeableModularAccount(entryPoint));

factory = new MultiOwnerMAFactory(
factory = new MultiOwnerModularAccountFactory(
address(this),
address(multiOwnerPlugin),
impl,
Expand Down
6 changes: 3 additions & 3 deletions test/account/ExecuteFromPluginPermissions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {Test, console} from "forge-std/Test.sol";
import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol";

import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {MultiOwnerMAFactory} from "../../src/factory/MultiOwnerMAFactory.sol";
import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol";
import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol";
import {IPlugin} from "../../src/interfaces/IPlugin.sol";
import {FunctionReference} from "../../src/interfaces/IPluginManager.sol";
Expand All @@ -44,7 +44,7 @@ contract ExecuteFromPluginPermissionsTest is Test {

IEntryPoint public entryPoint; // Just to be able to construct the factory
MultiOwnerPlugin public multiOwnerPlugin;
MultiOwnerMAFactory public factory;
MultiOwnerModularAccountFactory public factory;
UpgradeableModularAccount public account;

EFPCallerPlugin public efpCallerPlugin;
Expand All @@ -64,7 +64,7 @@ contract ExecuteFromPluginPermissionsTest is Test {
multiOwnerPlugin = new MultiOwnerPlugin();
address impl = address(new UpgradeableModularAccount(entryPoint));

factory = new MultiOwnerMAFactory(
factory = new MultiOwnerModularAccountFactory(
address(this),
address(multiOwnerPlugin),
impl,
Expand Down
6 changes: 3 additions & 3 deletions test/account/ManifestValidity.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.so

import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol";
import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {MultiOwnerMAFactory} from "../../src/factory/MultiOwnerMAFactory.sol";
import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol";
import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol";
import {FunctionReference} from "../../src/interfaces/IPluginManager.sol";
import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol";
Expand All @@ -41,7 +41,7 @@ import {
contract ManifestValidityTest is Test {
IEntryPoint public entryPoint; // Just to be able to construct the factory
MultiOwnerPlugin public multiOwnerPlugin;
MultiOwnerMAFactory public factory;
MultiOwnerModularAccountFactory public factory;

UpgradeableModularAccount public account;

Expand All @@ -50,7 +50,7 @@ contract ManifestValidityTest is Test {
multiOwnerPlugin = new MultiOwnerPlugin();
address impl = address(new UpgradeableModularAccount(entryPoint));

factory = new MultiOwnerMAFactory(
factory = new MultiOwnerModularAccountFactory(
address(this),
address(multiOwnerPlugin),
impl,
Expand Down
6 changes: 3 additions & 3 deletions test/account/TokenReceiver.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Recei
import {IERC777Recipient} from "@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol";

import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {MultiOwnerMAFactory} from "../../src/factory/MultiOwnerMAFactory.sol";
import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol";
import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol";
import {
IPlugin,
Expand All @@ -49,7 +49,7 @@ contract TokenReceiverTest is Test, IERC1155Receiver {
MockERC777 public t1;
MockERC1155 public t2;
MockPlugin public mockPlugin;
MultiOwnerMAFactory public factory;
MultiOwnerModularAccountFactory public factory;
MultiOwnerPlugin public multiOwnerPlugin;
IEntryPoint public entryPoint;

Expand All @@ -69,7 +69,7 @@ contract TokenReceiverTest is Test, IERC1155Receiver {
function setUp() public {
entryPoint = IEntryPoint(address(new EntryPoint()));
multiOwnerPlugin = new MultiOwnerPlugin();
factory = new MultiOwnerMAFactory(
factory = new MultiOwnerModularAccountFactory(
address(this),
address(multiOwnerPlugin),
address(new UpgradeableModularAccount(entryPoint)),
Expand Down
6 changes: 3 additions & 3 deletions test/account/UpgradeableModularAccount.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.so
import {AccountExecutor} from "../../src/account/AccountExecutor.sol";
import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol";
import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {MultiOwnerMAFactory} from "../../src/factory/MultiOwnerMAFactory.sol";
import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol";
import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol";
import {UserOperation} from "../../src/interfaces/erc4337/UserOperation.sol";
import {IAccountInitializable} from "../../src/interfaces/IAccountInitializable.sol";
Expand All @@ -46,7 +46,7 @@ contract UpgradeableModularAccountTest is Test {
address payable public beneficiary;
MultiOwnerPlugin public multiOwnerPlugin;
SessionKeyPlugin public sessionKeyPlugin;
MultiOwnerMAFactory public factory;
MultiOwnerModularAccountFactory public factory;
address public accountImplementation;

address public owner1;
Expand Down Expand Up @@ -77,7 +77,7 @@ contract UpgradeableModularAccountTest is Test {
sessionKeyPlugin = new SessionKeyPlugin();
accountImplementation = address(new UpgradeableModularAccount(entryPoint));
bytes32 manifestHash = keccak256(abi.encode(multiOwnerPlugin.pluginManifest()));
factory = new MultiOwnerMAFactory(
factory = new MultiOwnerModularAccountFactory(
address(this), address(multiOwnerPlugin), accountImplementation, manifestHash, entryPoint
);

Expand Down
6 changes: 3 additions & 3 deletions test/account/UpgradeableModularAccountPluginManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol";
import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {MultiOwnerMAFactory} from "../../src/factory/MultiOwnerMAFactory.sol";
import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol";
import {FunctionReferenceLib} from "../../src/helpers/FunctionReferenceLib.sol";
import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol";
import {IAccountLoupe} from "../../src/interfaces/IAccountLoupe.sol";
Expand All @@ -52,7 +52,7 @@ contract UpgradeableModularAccountPluginManagerTest is Test {
address payable public beneficiary;
MultiOwnerPlugin public multiOwnerPlugin;
SessionKeyPlugin public sessionKeyPlugin;
MultiOwnerMAFactory public factory;
MultiOwnerModularAccountFactory public factory;
address public implementation;

address public owner1;
Expand Down Expand Up @@ -87,7 +87,7 @@ contract UpgradeableModularAccountPluginManagerTest is Test {
sessionKeyPlugin = new SessionKeyPlugin();
implementation = address(new UpgradeableModularAccount(entryPoint));
bytes32 manifestHash = keccak256(abi.encode(multiOwnerPlugin.pluginManifest()));
factory = new MultiOwnerMAFactory(
factory = new MultiOwnerModularAccountFactory(
address(this), address(multiOwnerPlugin), implementation, manifestHash, entryPoint
);

Expand Down
Loading

0 comments on commit b5545ff

Please sign in to comment.