Skip to content

Commit

Permalink
refactor: rename UpgradeableModularAccount to ReferenceModularAccount (
Browse files Browse the repository at this point in the history
  • Loading branch information
adamegyed authored Aug 23, 2024
1 parent 094605e commit ff62f45
Show file tree
Hide file tree
Showing 26 changed files with 128 additions and 137 deletions.
8 changes: 4 additions & 4 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";

import {AccountFactory} from "../src/account/AccountFactory.sol";

import {ReferenceModularAccount} from "../src/account/ReferenceModularAccount.sol";
import {SemiModularAccount} from "../src/account/SemiModularAccount.sol";
import {UpgradeableModularAccount} from "../src/account/UpgradeableModularAccount.sol";
import {SingleSignerValidationModule} from "../src/modules/validation/SingleSignerValidationModule.sol";

contract DeployScript is Script {
Expand Down Expand Up @@ -51,7 +51,7 @@ contract DeployScript is Script {

address addr = Create2.computeAddress(
salt,
keccak256(abi.encodePacked(type(UpgradeableModularAccount).creationCode, abi.encode(entryPoint))),
keccak256(abi.encodePacked(type(ReferenceModularAccount).creationCode, abi.encode(entryPoint))),
CREATE2_FACTORY
);
if (addr != expected) {
Expand All @@ -63,7 +63,7 @@ contract DeployScript is Script {

if (addr.code.length == 0) {
console.log("No code found at expected address, deploying...");
UpgradeableModularAccount deployed = new UpgradeableModularAccount{salt: salt}(entryPoint);
ReferenceModularAccount deployed = new ReferenceModularAccount{salt: salt}(entryPoint);

if (address(deployed) != expected) {
console.log("Deployed address mismatch");
Expand Down Expand Up @@ -166,7 +166,7 @@ contract DeployScript is Script {
console.log("No code found at expected address, deploying...");
AccountFactory deployed = new AccountFactory{salt: salt}(
entryPoint,
UpgradeableModularAccount(payable(accountImpl)),
ReferenceModularAccount(payable(accountImpl)),
SemiModularAccount(payable(semiModularAccountImpl)),
singleSignerValidationModule,
owner
Expand Down
12 changes: 6 additions & 6 deletions src/account/AccountFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";

import {ReferenceModularAccount} from "../account/ReferenceModularAccount.sol";
import {SemiModularAccount} from "../account/SemiModularAccount.sol";
import {UpgradeableModularAccount} from "../account/UpgradeableModularAccount.sol";
import {ValidationConfigLib} from "../helpers/ValidationConfigLib.sol";

import {LibClone} from "solady/utils/LibClone.sol";

contract AccountFactory is Ownable {
UpgradeableModularAccount public immutable ACCOUNT_IMPL;
ReferenceModularAccount public immutable ACCOUNT_IMPL;
SemiModularAccount public immutable SEMI_MODULAR_ACCOUNT_IMPL;
bytes32 private immutable _PROXY_BYTECODE_HASH;
IEntryPoint public immutable ENTRY_POINT;
Expand All @@ -25,7 +25,7 @@ contract AccountFactory is Ownable {

constructor(
IEntryPoint _entryPoint,
UpgradeableModularAccount _accountImpl,
ReferenceModularAccount _accountImpl,
SemiModularAccount _semiModularImpl,
address _singleSignerValidationModule,
address owner
Expand All @@ -47,7 +47,7 @@ contract AccountFactory is Ownable {
*/
function createAccount(address owner, uint256 salt, uint32 entityId)
external
returns (UpgradeableModularAccount)
returns (ReferenceModularAccount)
{
bytes32 combinedSalt = getSalt(owner, salt, entityId);
address addr = Create2.computeAddress(combinedSalt, _PROXY_BYTECODE_HASH);
Expand All @@ -58,7 +58,7 @@ contract AccountFactory is Ownable {
// not necessary to check return addr since next call will fail if so
new ERC1967Proxy{salt: combinedSalt}(address(ACCOUNT_IMPL), "");
// point proxy to actual implementation and init plugins
UpgradeableModularAccount(payable(addr)).initializeWithValidation(
ReferenceModularAccount(payable(addr)).initializeWithValidation(
ValidationConfigLib.pack(SINGLE_SIGNER_VALIDATION_MODULE, entityId, true, true),
new bytes4[](0),
pluginInstallData,
Expand All @@ -67,7 +67,7 @@ contract AccountFactory is Ownable {
emit ModularAccountDeployed(addr, owner, salt);
}

return UpgradeableModularAccount(payable(addr));
return ReferenceModularAccount(payable(addr));
}

function createSemiModularAccount(address owner, uint256 salt) external returns (SemiModularAccount) {
Expand Down
4 changes: 2 additions & 2 deletions src/account/AccountStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet

import {HookConfig, ModuleEntity} from "../interfaces/IModularAccount.sol";

// bytes = keccak256("ERC6900.UpgradeableModularAccount.Storage")
bytes32 constant _ACCOUNT_STORAGE_SLOT = 0x9f09680beaa4e5c9f38841db2460c401499164f368baef687948c315d9073e40;
// bytes = keccak256("ERC6900.ReferenceModularAccount.Storage")
bytes32 constant _ACCOUNT_STORAGE_SLOT = 0xc531f081ecdb5a90f38c197521797881a6e5c752a7d451780f325a95f8b91f45;

// Represents data associated with a specifc function selector.
struct ExecutionData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {AccountStorage, getAccountStorage, toHookConfig, toSetValue} from "./Acc
import {AccountStorageInitializable} from "./AccountStorageInitializable.sol";
import {ModuleManagerInternals} from "./ModuleManagerInternals.sol";

contract UpgradeableModularAccount is
contract ReferenceModularAccount is
IModularAccount,
AccountExecutor,
AccountLoupe,
Expand Down
6 changes: 3 additions & 3 deletions src/account/SemiModularAccount.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.25;

import {UpgradeableModularAccount} from "./UpgradeableModularAccount.sol";
import {ReferenceModularAccount} from "./ReferenceModularAccount.sol";
import {IEntryPoint} from "@eth-infinitism/account-abstraction/interfaces/IEntryPoint.sol";
import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interfaces/PackedUserOperation.sol";

Expand All @@ -13,7 +13,7 @@ import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/Messa
import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import {LibClone} from "solady/utils/LibClone.sol";

contract SemiModularAccount is UpgradeableModularAccount {
contract SemiModularAccount is ReferenceModularAccount {
using MessageHashUtils for bytes32;
using ModuleEntityLib for ModuleEntity;

Expand Down Expand Up @@ -46,7 +46,7 @@ contract SemiModularAccount is UpgradeableModularAccount {
error FallbackSignerDisabled();
error InitializerDisabled();

constructor(IEntryPoint anEntryPoint) UpgradeableModularAccount(anEntryPoint) {}
constructor(IEntryPoint anEntryPoint) ReferenceModularAccount(anEntryPoint) {}

/// @notice Updates the fallback signer address in storage.
/// @dev This function causes the fallback signer getter to ignore the bytecode signer if it is nonzero. It can
Expand Down
14 changes: 7 additions & 7 deletions test/account/AccountFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ pragma solidity ^0.8.19;

import {AccountFactory} from "../../src/account/AccountFactory.sol";

import {ReferenceModularAccount} from "../../src/account/ReferenceModularAccount.sol";
import {SemiModularAccount} from "../../src/account/SemiModularAccount.sol";
import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {AccountTestBase} from "../utils/AccountTestBase.sol";

contract AccountFactoryTest is AccountTestBase {
AccountFactory internal _factory;
UpgradeableModularAccount internal _account;
ReferenceModularAccount internal _account;
SemiModularAccount internal _semiModularAccount;

function setUp() public {
_account = new UpgradeableModularAccount(entryPoint);
_account = new ReferenceModularAccount(entryPoint);
_semiModularAccount = new SemiModularAccount(entryPoint);

_factory = new AccountFactory(
Expand All @@ -22,23 +22,23 @@ contract AccountFactoryTest is AccountTestBase {
}

function test_createAccount() public {
UpgradeableModularAccount account = _factory.createAccount(address(this), 100, 0);
ReferenceModularAccount account = _factory.createAccount(address(this), 100, 0);

assertEq(address(account.entryPoint()), address(entryPoint));
}

function test_createAccountAndGetAddress() public {
UpgradeableModularAccount account = _factory.createAccount(address(this), 100, 0);
ReferenceModularAccount account = _factory.createAccount(address(this), 100, 0);

assertEq(address(account), address(_factory.createAccount(address(this), 100, 0)));
}

function test_multipleDeploy() public {
UpgradeableModularAccount account = _factory.createAccount(address(this), 100, 0);
ReferenceModularAccount account = _factory.createAccount(address(this), 100, 0);

uint256 startGas = gasleft();

UpgradeableModularAccount account2 = _factory.createAccount(address(this), 100, 0);
ReferenceModularAccount account2 = _factory.createAccount(address(this), 100, 0);

// Assert that the 2nd deployment call cost less than 1 sstore
// Implies that no deployment was done on the second calls
Expand Down
4 changes: 2 additions & 2 deletions test/account/DirectCallsFromModule.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {ReferenceModularAccount} from "../../src/account/ReferenceModularAccount.sol";

import {HookConfigLib} from "../../src/helpers/HookConfigLib.sol";
import {ModuleEntity, ModuleEntityLib} from "../../src/helpers/ModuleEntityLib.sol";
Expand Down Expand Up @@ -155,6 +155,6 @@ contract DirectCallsFromModuleTest is AccountTestBase {
}

function _buildDirectCallDisallowedError(bytes4 selector) internal pure returns (bytes memory) {
return abi.encodeWithSelector(UpgradeableModularAccount.ValidationFunctionMissing.selector, selector);
return abi.encodeWithSelector(ReferenceModularAccount.ValidationFunctionMissing.selector, selector);
}
}
10 changes: 5 additions & 5 deletions test/account/GlobalValidationTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.25;
import {PackedUserOperation} from "@eth-infinitism/account-abstraction/interfaces/PackedUserOperation.sol";
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";

import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {ReferenceModularAccount} from "../../src/account/ReferenceModularAccount.sol";
import {ModuleEntityLib} from "../../src/helpers/ModuleEntityLib.sol";

import {AccountTestBase} from "../utils/AccountTestBase.sol";
Expand All @@ -17,13 +17,13 @@ contract GlobalValidationTest is AccountTestBase {
// A separate account and owner that isn't deployed yet, used to test initcode
address public owner2;
uint256 public owner2Key;
UpgradeableModularAccount public account2;
ReferenceModularAccount public account2;

function setUp() public {
(owner2, owner2Key) = makeAddrAndKey("owner2");

// Compute counterfactual address
account2 = UpgradeableModularAccount(payable(factory.getAddress(owner2, 0)));
account2 = ReferenceModularAccount(payable(factory.getAddress(owner2, 0)));
vm.deal(address(account2), 100 ether);

_signerValidation =
Expand All @@ -38,7 +38,7 @@ contract GlobalValidationTest is AccountTestBase {
sender: address(account2),
nonce: 0,
initCode: abi.encodePacked(address(factory), abi.encodeCall(factory.createAccount, (owner2, 0))),
callData: abi.encodeCall(UpgradeableModularAccount.execute, (ethRecipient, 1 wei, "")),
callData: abi.encodeCall(ReferenceModularAccount.execute, (ethRecipient, 1 wei, "")),
accountGasLimits: _encodeGas(VERIFICATION_GAS_LIMIT, CALL_GAS_LIMIT),
preVerificationGas: 0,
gasFees: _encodeGas(1, 1),
Expand All @@ -65,7 +65,7 @@ contract GlobalValidationTest is AccountTestBase {

vm.prank(owner2);
account2.executeWithAuthorization(
abi.encodeCall(UpgradeableModularAccount.execute, (ethRecipient, 1 wei, "")),
abi.encodeCall(ReferenceModularAccount.execute, (ethRecipient, 1 wei, "")),
_encodeSignature(_signerValidation, GLOBAL_VALIDATION, "")
);

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

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

import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {ReferenceModularAccount} from "../../src/account/ReferenceModularAccount.sol";

import {ModuleEntityLib} from "../../src/helpers/ModuleEntityLib.sol";
import {ValidationConfigLib} from "../../src/helpers/ValidationConfigLib.sol";
Expand Down Expand Up @@ -62,7 +62,7 @@ contract MultiValidationTest is AccountTestBase {
vm.prank(owner1);
vm.expectRevert(
abi.encodeWithSelector(
UpgradeableModularAccount.RuntimeValidationFunctionReverted.selector,
ReferenceModularAccount.RuntimeValidationFunctionReverted.selector,
address(validator2),
TEST_DEFAULT_VALIDATION_ENTITY_ID,
abi.encodeWithSignature("NotAuthorized()")
Expand Down Expand Up @@ -93,7 +93,7 @@ contract MultiValidationTest is AccountTestBase {
sender: address(account1),
nonce: 0,
initCode: "",
callData: abi.encodeCall(UpgradeableModularAccount.execute, (address(0), 0, "")),
callData: abi.encodeCall(ReferenceModularAccount.execute, (address(0), 0, "")),
accountGasLimits: _encodeGas(VERIFICATION_GAS_LIMIT, CALL_GAS_LIMIT),
preVerificationGas: 0,
gasFees: _encodeGas(1, 1),
Expand Down
Loading

0 comments on commit ff62f45

Please sign in to comment.