-
Notifications
You must be signed in to change notification settings - Fork 26
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
Conversation
src/account/AccountFactory.sol
Outdated
function createAccount( | ||
address owner, | ||
uint256 salt, | ||
uint32 entityId, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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 |
src/account/AccountFactory.sol
Outdated
import {SingleSignerValidation} from "../../src/plugins/validation/SingleSignerValidation.sol"; | ||
|
||
contract AccountFactory is Ownable { | ||
UpgradeableModularAccount public accountImplementation; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
src/account/AccountFactory.sol
Outdated
UpgradeableModularAccount public accountImplementation; | ||
bytes32 private immutable _PROXY_BYTECODE_HASH; | ||
uint32 public constant UNSTAKE_DELAY = 1 weeks; | ||
IEntryPoint public entryPoint; |
There was a problem hiding this comment.
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
afc5f27
to
4b9b766
Compare
485e0c5
to
b2e06d0
Compare
test/account/AccountFactory.sol
Outdated
import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; | ||
import {AccountTestBase} from "../utils/AccountTestBase.sol"; | ||
|
||
contract AccountFactoryTest is AccountTestBase { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
test/account/AccountFactory.sol
Outdated
|
||
// Assert the return addresses are the same | ||
assertEq(address(account), address(account2)); | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/account/AccountFactory.sol
Outdated
import {SingleSignerValidation} from "../../src/plugins/validation/SingleSignerValidation.sol"; | ||
|
||
contract AccountFactory is Ownable { | ||
UpgradeableModularAccount public accountImplementation; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
No description provided.