Deterministic Deployment Helper functions
Related to https://github.com/gnosis/zodiac-safe-app/issues/94.
This contract contains helper functions that can be used to deploy the RealityModule to a deterministic address even though the template ID is unknown at the deployment time.
This is needed because if a new template is added in the same transaction and where the module is deployed, the template ID is unknown until the transaction executes.
This is unnecessary if the template ID is already known (the template has been created in an earlier transaction).
This functionality is helpful if the template will be created and the RealityModule deployed in the same transaction.
The contracts consist of multiple deployment and configuration functions that each have their pros and cons. The reason to provide multiple alternatives is that different circumstances will favor different versions.
Usage of the createTemplate function via delegatecall:
In this scenario, we deploy the module as normal (just set the templateId to 0). Then create a subsequent delegated call from the safe to createTemplate function. This will create a new template and set the new templateId in one transaction. Kind of like createTemplateAndChangeOwner but without the need to change the owner (the safe will already be the owner) and call via delegated call:
Pros:
The init parameters (for the modules setup function) are required to be customized in the following way:
The owner of the module must be set to the address of the DeterministicDeploymentHelper contract.
The templateId must be set to 0.
The createTemplateAndChangeOwner function must be called in the same transaction (for instance, via a multisend contract) as the deployment of the module. If not, somebody else could take over ownership of the module.
Usage of the deployWithEncodedParams function directly:
Pros:
The deployment of the module and createTemplateAndChangeOwner functionality are bundled together. There is no risk that the deployment and configuration do not happen in the same transaction.
Cons:
The init parameters (for the modules setup function) are required to be customized in the following way:
The owner of the module must be set to the address of the DeterministicDeploymentHelper contract.
The templateId must be set to 0.
The default deployAndSetUpModule function can NOT be used.
Usage of the deployWithTemplate function directly:
Pros:
The deployment of the module and createTemplateAndChangeOwner functionality are bundled together. There is no risk that the deployment and configuration do not happen in the same transaction.
The input parameters are used as expected, there is no need to customize the deployment parameters in any special way.
Cons:
The default deployAndSetUpModule function can NOT be used.
Deterministic Deployment Helper functions Related to https://github.com/gnosis/zodiac-safe-app/issues/94. This contract contains helper functions that can be used to deploy the RealityModule to a deterministic address even though the template ID is unknown at the deployment time.
The contracts consist of multiple deployment and configuration functions that each have their pros and cons. The reason to provide multiple alternatives is that different circumstances will favor different versions.
Usage of the
createTemplate
function via delegatecall: In this scenario, we deploy the module as normal (just set thetemplateId
to0
). Then create a subsequent delegated call from the safe tocreateTemplate
function. This will create a new template and set the new templateId in one transaction. Kind of likecreateTemplateAndChangeOwner
but without the need to change the owner (the safe will already be the owner) and call via delegated call: Pros:deployAndSetUpModule
function can be used (https://github.com/gnosis/zodiac/blob/dbe820aa8c9ee9d55e938b7fbdc1800dc89702db/src/factory/factory.ts#L7).Cons:
setup
function) are required to be customized in the following way:The templateId must be set to
0
.Usage of the
createTemplateAndChangeOwner
function directly: Pros:deployAndSetUpModule
function can be used (https://github.com/gnosis/zodiac/blob/dbe820aa8c9ee9d55e938b7fbdc1800dc89702db/src/factory/factory.ts#L7).Cons:
setup
function) are required to be customized in the following way:0
.The
createTemplateAndChangeOwner
function must be called in the same transaction (for instance, via a multisend contract) as the deployment of the module. If not, somebody else could take over ownership of the module.Usage of the
deployWithEncodedParams
function directly: Pros:createTemplateAndChangeOwner
functionality are bundled together. There is no risk that the deployment and configuration do not happen in the same transaction.Cons:
setup
function) are required to be customized in the following way:0
.The default
deployAndSetUpModule
function can NOT be used.Usage of the
deployWithTemplate
function directly: Pros:createTemplateAndChangeOwner
functionality are bundled together. There is no risk that the deployment and configuration do not happen in the same transaction.Cons:
deployAndSetUpModule
function can NOT be used.