-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add deployAndExecute
function in the factory/ registry
#62
Comments
deployAndExecute
functiondeployAndExecute
function in the factory/ registry
One additional user flow which should get implicitly unlocked with the addition of this method is that upon Proxy deployment the user can also install relevant plugins in the same transaction. |
Interesting use case! My first reaction was, "no, this ain't possible", but this could be done with a special target contract that has the same storage layout as the proxy. |
I just finished implementing this feature. @SolcAndMe let me know if the implementations match your expectations: prb-proxy/src/PRBProxyFactory.sol Lines 79 to 101 in aaaf577
And: prb-proxy/src/PRBProxyRegistry.sol Lines 93 to 112 in aaaf577
All functions have 100% test coverage: |
Why does it have to have the same storage layout? Couldn't this just be a target contract which calls into the plugin configuration methods - since the Factory still has ownership over the proxy at that point in time? |
Yes that's exactly what I had in mind! I don't have any further input on the implementation. |
Because of the DELEGATECALL. If you don't have the same storage layout, you will modify other storage properties. You can see an example for how this works in practice with the
No, unfortunately. By the time the target contract tries to access the
Totally doable! But, as explained above, it would have to be something like this: contract OnboardActions {
address public override owner;
uint256 public override minGasReserve;
mapping(bytes4 method => IPRBProxyPlugin plugin) internal plugins;
function setUpPlugins(address[] calldata pluginsToInstall) external {
for (uint256 i = 0; i < pluginsToInstall.length; ++i) {
bytes4[] memory methodList = pluginsToInstall[i].methodList();
for (uint256 j = 0; j < methodList.length; ++j) {
plugins[methodList[j]] = pluginsToInstall[i];
}
}
}
} Seeing how this is done in practice makes me wonder if there's much value in keeping the Removing the said functions would definitely save some gas on deployment.
Glad to hear! In terms of timeline, I will probably release a beta version later this week, and then I will wait a week or so before publishing the final V4 (just in case we find any last-minute issues). |
As the lead proponent of the plugin system, I wanted to ask you @cleanunicorn what you think of the idea above to not include the plugin installation functions in the proxy itself? |
Right, I blanked on the fact that this is an introspective change to the Proxy contract itself. Then it would make sense to provide a "Base" Target, Plugin / Setup contract to avoid user errors when users want to define their proxy setup strategies.
Awesome! |
Fantastic idea. I have just opened a separate issue for tracking - I 100% agree that this should be done.
A base target will not be needed if I implement a separate storage contract. |
I will close this issue since the |
As discussed in #25, it would be helpful to provide a
deployAndExecute
function that would deploy the proxy and immediately call a target contract in the same transaction.To quote @SolcAndMe:
The text was updated successfully, but these errors were encountered: