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

Account factory: update constructor params #556

Merged
merged 2 commits into from
Oct 26, 2023
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
11 changes: 8 additions & 3 deletions contracts/prebuilts/account/dynamic/DynamicAccountFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@ import { DynamicAccount, IEntryPoint } from "./DynamicAccount.sol";
// \____/ \__| \__|\__|\__| \_______| \_____\____/ \_______|\_______/

contract DynamicAccountFactory is BaseAccountFactory, ContractMetadata, PermissionsEnumerable {
address public constant ENTRYPOINT_ADDRESS = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789;

/*///////////////////////////////////////////////////////////////
Constructor
//////////////////////////////////////////////////////////////*/

constructor(IEntryPoint _entrypoint, IExtension.Extension[] memory _defaultExtensions)
BaseAccountFactory(payable(address(new DynamicAccount(_entrypoint, _defaultExtensions))), address(_entrypoint))
constructor(address _defaultAdmin, IExtension.Extension[] memory _defaultExtensions)
BaseAccountFactory(
payable(address(new DynamicAccount(IEntryPoint(ENTRYPOINT_ADDRESS), _defaultExtensions))),
ENTRYPOINT_ADDRESS
)
{
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, _defaultAdmin);
}

/*///////////////////////////////////////////////////////////////
Expand Down
10 changes: 7 additions & 3 deletions contracts/prebuilts/account/managed/ManagedAccountFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ contract ManagedAccountFactory is BaseAccountFactory, ContractMetadata, Permissi
Constructor
//////////////////////////////////////////////////////////////*/

constructor(IEntryPoint _entrypoint, Extension[] memory _defaultExtensions)
constructor(
address _defaultAdmin,
IEntryPoint _entrypoint,
Extension[] memory _defaultExtensions
)
BaseRouter(_defaultExtensions)
BaseAccountFactory(payable(address(new ManagedAccount(_entrypoint, address(this)))), address(_entrypoint))
{
__BaseRouter_init();
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, _defaultAdmin);

bytes32 _extensionRole = keccak256("EXTENSION_ROLE");
_setupRole(_extensionRole, msg.sender);
_setupRole(_extensionRole, _defaultAdmin);
_setRoleAdmin(_extensionRole, _extensionRole);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ contract AccountFactory is BaseAccountFactory, ContractMetadata, PermissionsEnum
Constructor
//////////////////////////////////////////////////////////////*/

constructor(IEntryPoint _entrypoint)
constructor(address _defaultAdmin, IEntryPoint _entrypoint)
BaseAccountFactory(address(new Account(_entrypoint, address(this))), address(_entrypoint))
{
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(DEFAULT_ADMIN_ROLE, _defaultAdmin);
}

/*///////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/test/benchmark/AccountBenchmark.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ contract AccountBenchmarkTest is BaseTest {
// Setup contracts
entrypoint = new EntryPoint();
// deploy account factory
accountFactory = new AccountFactory(IEntryPoint(payable(address(entrypoint))));
accountFactory = new AccountFactory(deployer, IEntryPoint(payable(address(entrypoint))));
// deploy dummy contract
numberContract = new Number();
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/smart-wallet/Account.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ contract SimpleAccountTest is BaseTest {
// Setup contracts
entrypoint = new EntryPoint();
// deploy account factory
accountFactory = new AccountFactory(IEntryPoint(payable(address(entrypoint))));
accountFactory = new AccountFactory(deployer, IEntryPoint(payable(address(entrypoint))));
// deploy dummy contract
numberContract = new Number();
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/smart-wallet/AccountVulnPOC.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ contract SimpleAccountVulnPOCTest is BaseTest {
// Setup contracts
entrypoint = new EntryPoint();
// deploy account factory
accountFactory = new AccountFactory(IEntryPoint(payable(address(entrypoint))));
accountFactory = new AccountFactory(deployer, IEntryPoint(payable(address(entrypoint))));
// deploy dummy contract
numberContract = new Number();
}
Expand Down
12 changes: 5 additions & 7 deletions src/test/smart-wallet/DynamicAccount.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ contract NFTRejector {

contract DynamicAccountTest is BaseTest {
// Target contracts
EntryPoint private entrypoint;
EntryPoint private constant entrypoint = EntryPoint(payable(0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789));
DynamicAccountFactory private accountFactory;

// Mocks
Expand Down Expand Up @@ -202,7 +202,8 @@ contract DynamicAccountTest is BaseTest {
nonSigner = vm.addr(nonSignerPKey);

// Setup contracts
entrypoint = new EntryPoint();
address _deployedEntrypoint = address(new EntryPoint());
vm.etch(address(entrypoint), bytes(_deployedEntrypoint.code));

// Setting up default extension.
IExtension.Extension memory defaultExtension;
Expand Down Expand Up @@ -248,7 +249,7 @@ contract DynamicAccountTest is BaseTest {
extensions[0] = defaultExtension;

// deploy account factory
accountFactory = new DynamicAccountFactory(IEntryPoint(payable(address(entrypoint))), extensions);
accountFactory = new DynamicAccountFactory(deployer, extensions);
// deploy dummy contract
numberContract = new Number();
}
Expand Down Expand Up @@ -303,10 +304,7 @@ contract DynamicAccountTest is BaseTest {
extensions[0] = defaultExtension;

// deploy account factory
DynamicAccountFactory factory = new DynamicAccountFactory(
IEntryPoint(payable(address(entrypoint))),
extensions
);
DynamicAccountFactory factory = new DynamicAccountFactory(deployer, extensions);
}

/// @dev Create an account by directly calling the factory.
Expand Down
7 changes: 6 additions & 1 deletion src/test/smart-wallet/ManagedAccount.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,11 @@ contract ManagedAccountTest is BaseTest {

// deploy account factory
vm.prank(factoryDeployer);
accountFactory = new ManagedAccountFactory(IEntryPoint(payable(address(entrypoint))), extensions);
accountFactory = new ManagedAccountFactory(
factoryDeployer,
IEntryPoint(payable(address(entrypoint))),
extensions
);
// deploy dummy contract
numberContract = new Number();
}
Expand Down Expand Up @@ -303,6 +307,7 @@ contract ManagedAccountTest is BaseTest {
// deploy account factory
vm.prank(factoryDeployer);
ManagedAccountFactory factory = new ManagedAccountFactory(
factoryDeployer,
IEntryPoint(payable(address(entrypoint))),
extensions
);
Expand Down
2 changes: 1 addition & 1 deletion src/test/smart-wallet/account-core/isValidSigner.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ contract AccountCoreTest_isValidSigner is BaseTest {
IExtension.Extension[] memory extensions;

// deploy account factory
accountFactory = new DynamicAccountFactory(IEntryPoint(payable(address(entrypoint))), extensions);
accountFactory = new DynamicAccountFactory(deployer, extensions);
// deploy dummy contract
numberContract = new Number();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ contract AccountPermissionsTest_setPermissionsForSigner is BaseTest {
);

// Target contracts
EntryPoint private entrypoint;
EntryPoint private constant entrypoint = EntryPoint(payable(0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789));
DynamicAccountFactory private accountFactory;

// Mocks
Expand Down Expand Up @@ -220,7 +220,8 @@ contract AccountPermissionsTest_setPermissionsForSigner is BaseTest {
nonSigner = vm.addr(nonSignerPKey);

// Setup contracts
entrypoint = new EntryPoint();
address _deployedEntrypoint = address(new EntryPoint());
vm.etch(address(entrypoint), bytes(_deployedEntrypoint.code));

// Setting up default extension.
IExtension.Extension memory defaultExtension;
Expand Down Expand Up @@ -266,7 +267,7 @@ contract AccountPermissionsTest_setPermissionsForSigner is BaseTest {
extensions[0] = defaultExtension;

// deploy account factory
accountFactory = new DynamicAccountFactory(IEntryPoint(payable(address(entrypoint))), extensions);
accountFactory = new DynamicAccountFactory(deployer, extensions);
// deploy dummy contract
numberContract = new Number();
}
Expand Down
Loading