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

feat: add account factory #105

Merged
merged 7 commits into from
Jul 23, 2024
Merged

feat: add account factory #105

merged 7 commits into from
Jul 23, 2024

Conversation

howydev
Copy link
Collaborator

@howydev howydev commented Jul 18, 2024

No description provided.

function createAccount(
address owner,
uint256 salt,
uint32 entityId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could opt to always use an entityId of 0 on the factory by default, to make it simpler on the SDK

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this shouldn't be in the SDK right? I think we could always have the SDK default to 0 too, but allow flexibility in the contracts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would the flexibility be needed for, though? Even if it were necessary to do something else, that could just be set after deployment.

@howydev
Copy link
Collaborator Author

howydev commented Jul 19, 2024

Will also make another change, adding the sig validator addr into the counterfactual. Else I think it might be possible for a malicious party to take over another persons counterfactual

import {SingleSignerValidation} from "../../src/plugins/validation/SingleSignerValidation.sol";

contract AccountFactory is Ownable {
UpgradeableModularAccount public accountImplementation;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make this immutable and just deploy new factories for new versions, this way deployment saves an SLOAD, wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump, if we don't support upgrading this, we should make it immutable

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, missed it, just made the change

UpgradeableModularAccount public accountImplementation;
bytes32 private immutable _PROXY_BYTECODE_HASH;
uint32 public constant UNSTAKE_DELAY = 1 weeks;
IEntryPoint public entryPoint;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as acountImplementation, might benefit from being an immutable, though ofc this depends if we want this factory to be used in prod or not

@howydev howydev force-pushed the howy/add-factory branch from afc5f27 to 4b9b766 Compare July 19, 2024 20:08
@howydev howydev force-pushed the howy/add-factory branch from 485e0c5 to b2e06d0 Compare July 19, 2024 20:14
@howydev howydev requested review from adamegyed and Zer0dot July 19, 2024 22:05
import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol";
import {AccountTestBase} from "../utils/AccountTestBase.sol";

contract AccountFactoryTest is AccountTestBase {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: rename file to AccountFactory.t.sol

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch


// Assert the return addresses are the same
assertEq(address(account), address(account2));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a test that verifies the address returned by getAddress() and the account created & returned by createAccount are the same?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

import {SingleSignerValidation} from "../../src/plugins/validation/SingleSignerValidation.sol";

contract AccountFactory is Ownable {
UpgradeableModularAccount public accountImplementation;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump, if we don't support upgrading this, we should make it immutable

@howydev howydev requested a review from adamegyed July 22, 2024 20:45
Copy link
Contributor

@adamegyed adamegyed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@howydev howydev merged commit 4278acf into v0.8-develop Jul 23, 2024
3 checks passed
@howydev howydev deleted the howy/add-factory branch July 23, 2024 18:33
adamegyed pushed a commit that referenced this pull request Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants