-
Notifications
You must be signed in to change notification settings - Fork 30
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 contract creation execution functions #61
Conversation
…ith gas reports too much
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.
Nice! Had a couple of questions and comments.
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.
Awesome! A few thoughts (don't feel particularly strongly about any of them):
- Do you think it's worth following the function signatures in https://github.com/safe-global/safe-smart-account/blob/main/contracts/libraries/CreateCall.sol for marginally easier compatibility with clients that already use Safes today?
- CreateCall also emits events. (as does https://github.com/pcaversaccio/createx). Is this worth doing for analytics? Or do we want to save gas?
- The examples above use a prefix, e.g.,
deployCreate2
orperformCreate2
. Is there an advantage to doing this? Perhaps makes for better grepability?
I'm not sure how compatibility with Safes will work-- as this is a feature built-in to the contract, but point 3 makes me want to modify the signatures anyway! With respect to events, my rationale is that contracts that need to be indexed can emit their own construction events without enforcing the cost. But, it would make for easier analytics, I'm open to including this as well. |
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!
Motivation
Currently, there isn't a way to deploy contracts directly from smart accounts. This PR addresses that by exposing two new top-level execution functions, one for
create
and one forcreate2
.Solution
Introduce two new functions
create(bytes calldata initCode, uint256 value)
andcreate2(bytes calldata initCode, bytes32 salt, uint256 value)
which create a contract withinitCode
using their respective deployment methods.These functions use the standard
onlyAuthorized
modifier.Why not use a deployer contract?
Although practical, a deployer contract has a few limitations:
create
deployments (due to the nonce not being known until execution).Note that this doesn't mean that using a deployer contract isn't possible-- it's still entirely possible to deploy via, for example, the
Create2Factory
contract, or any other factory contract via standard executions.