Factory
Provides functionality for creating and managing execution environments for DApps within the Atlas Protocol.
This contract uses deterministic deployment to generate and manage Execution Environment instances based on
predefined templates.
EXECUTION_ENV_TEMPLATE
address EXECUTION_ENV_TEMPLATE
_FACTORY_BASE_SALT
bytes32 _FACTORY_BASE_SALT
constructor
constructor(address executionTemplate) internal
Initializes a new Factory contract instance by setting the immutable salt for deterministic deployment
of Execution Environments and storing the execution template address.
The Execution Environment Template must be separately deployed using the same calculated salt.
Parameters
Name | Type | Description |
---|
executionTemplate | address | Address of the pre-deployed execution template contract for creating Execution Environment instances. |
createExecutionEnvironment
function createExecutionEnvironment(address control) external returns (address executionEnvironment)
Creates a new Execution Environment for the caller, given a DAppControl contract address.
Parameters
Name | Type | Description |
---|
control | address | The address of the DAppControl contract for which the execution environment is being created. |
Return Values
Name | Type | Description |
---|
executionEnvironment | address | The address of the newly created Execution Environment instance. |
getExecutionEnvironment
function getExecutionEnvironment(address user, address control) external view returns (address executionEnvironment, uint32 callConfig, bool exists)
Retrieves the address and configuration of an existing execution environment for a given user and DApp
control contract.
Parameters
Name | Type | Description |
---|
user | address | The address of the user for whom the execution environment is being queried. |
control | address | The address of the DAppControl contract associated with the execution environment. |
Return Values
Name | Type | Description |
---|
executionEnvironment | address | The address of the queried execution environment. |
callConfig | uint32 | The call configuration used by the execution environment, retrieved from the DAppControl contract. |
exists | bool | A boolean indicating whether the execution environment already exists (true) or not (false). |
_getOrCreateExecutionEnvironment
function _getOrCreateExecutionEnvironment(struct UserOperation userOp) internal returns (address executionEnvironment, struct DAppConfig dConfig)
Gets an existing execution environment or creates a new one if it does not exist for the specified user
operation.
Parameters
Name | Type | Description |
---|
userOp | struct UserOperation | The user operation containing details about the user and the DAppControl contract. |
Return Values
Name | Type | Description |
---|
executionEnvironment | address | The address of the execution environment that was found or created. |
dConfig | struct DAppConfig | The DAppConfig for the execution environment, specifying how operations should be handled. |
_getOrCreateExecutionEnvironment
function _getOrCreateExecutionEnvironment(address user, address control, uint32 callConfig) internal returns (address executionEnvironment)
Deploys a new execution environment or retrieves the address of an existing one based on the DApp
control, user, and configuration.
Uses the create2
opcode for deterministic deployment, allowing the calculation of the execution
environment's address before deployment. The deployment uses a combination of the DAppControl address, user
address, call configuration, and a unique salt to ensure the uniqueness and predictability of the environment's
address.
Parameters
Name | Type | Description |
---|
user | address | The address of the user for whom the execution environment is being set. |
control | address | The address of the DAppControl contract providing the operational context. |
callConfig | uint32 | CallConfig settings of the DAppControl contract. |
Return Values
Name | Type | Description |
---|
executionEnvironment | address | The address of the newly created or already existing execution environment. |
_getExecutionEnvironmentCustom
function _getExecutionEnvironmentCustom(address user, address control, uint32 callConfig) internal view returns (address executionEnvironment)
Generates the address of a user's execution environment affected by deprecated callConfig changes in the
DAppControl.
Calculates the deterministic address of the execution environment based on the user, control,
callConfig, and controlCodeHash, ensuring consistency across changes in callConfig.
Parameters
Name | Type | Description |
---|
user | address | The address of the user for whom the execution environment's address is being generated. |
control | address | The address of the DAppControl contract associated with the execution environment. |
callConfig | uint32 | The configuration flags defining the behavior of the execution environment. |
Return Values
Name | Type | Description |
---|
executionEnvironment | address | The address of the user's execution environment. |
_computeSalt
function _computeSalt(address user, address control, uint32 callConfig) internal view returns (bytes32)
_getMimicCreationCode
function _getMimicCreationCode(address user, address control, uint32 callConfig) internal view returns (bytes creationCode)
Generates the creation code for the execution environment contract.
Parameters
Name | Type | Description |
---|
user | address | The address of the user for whom the execution environment is being created, contributing to the uniqueness of the creation code. |
control | address | The address of the DAppControl contract associated with the execution environment. |
callConfig | uint32 | The configuration flags defining the behavior of the execution environment. |
Return Values
Name | Type | Description |
---|
creationCode | bytes | The bytecode representing the creation code of the execution environment contract. |