IFactory

Git Source

Inherits: IMigratable

Functions

initialize

Initializes the contract.

function initialize() external;

deployImplementation

Deploys an implementation contract.

function deployImplementation(bytes memory bytecode_) external returns (address implementation_);

Parameters

NameTypeDescription
bytecode_bytesThe bytecode of the implementation to deploy (including appended constructor data).

Returns

NameTypeDescription
implementation_addressThe address of the deployed implementation.

deployProxy

Deploys a proxy contract.

function deployProxy(address implementation_, bytes32 salt_, bytes calldata initializeCallData_)
    external
    returns (address proxy_);

Parameters

NameTypeDescription
implementation_addressThe address of the implementation the proxy should proxy.
salt_bytes32A salt defined by the sender.
initializeCallData_bytesThe call data used to initialize the proxy.

Returns

NameTypeDescription
proxy_addressThe address of the deployed proxy.

pausedParameterKey

The parameter registry key used to fetch the paused status.

function pausedParameterKey() external pure returns (string memory key_);

migratorParameterKey

The parameter registry key used to fetch the migrator.

function migratorParameterKey() external pure returns (string memory key_);

paused

The pause status.

function paused() external view returns (bool paused_);

parameterRegistry

The address of the parameter registry.

function parameterRegistry() external view returns (address parameterRegistry_);

initializableImplementation

The address of the first temporary implementation that proxies will proxy.

*This contract is the first proxied implementation of any proxy, and allows the factory to then set the proxy's actual implementation, and initialize it with respect to that actual implementation. This ensures that:

  • The address of a proxy is only defined by the nonce, and not by the implementation it will proxy.
  • No contracts are deployed that are not used.
  • The proxy can be easily initialized with respect to the actual implementation, atomically.*
function initializableImplementation() external view returns (address initializableImplementation_);

computeImplementationAddress

Computes the address of an implementation contract that would be deployed from a given bytecode.

The address is determined only by the bytecode, and so the same bytecode results in the same address.

function computeImplementationAddress(bytes calldata bytecode_) external view returns (address implementation_);

Parameters

NameTypeDescription
bytecode_bytesThe bytecode of the implementation to deploy (including appended constructor data).

Returns

NameTypeDescription
implementation_addressThe address of the implementation that would be deployed.

computeProxyAddress

Computes the address of a proxy contract that would be deployed from given a caller and salt.

The actual salt used to deploy the proxy via create2 is keccak256(abi.encodePacked(caller_, salt_)).

function computeProxyAddress(address caller_, bytes32 salt_) external view returns (address proxy_);

Parameters

NameTypeDescription
caller_addressThe address of the caller that would request the proxy deployment.
salt_bytes32The salt defined by the caller.

Returns

NameTypeDescription
proxy_addressThe address of the proxy that would be deployed.

Events

InitializableImplementationDeployed

Emitted when the "initializable implementation" is deployed.

This contract is only deployed once, when the factory itself is deployed.

event InitializableImplementationDeployed(address indexed implementation);

Parameters

NameTypeDescription
implementationaddressThe address of the deployed "initializable implementation".

ImplementationDeployed

Emitted when an implementation is deployed.

event ImplementationDeployed(address indexed implementation, bytes32 indexed bytecodeHash);

Parameters

NameTypeDescription
implementationaddressThe address of the deployed implementation.
bytecodeHashbytes32The hash of the bytecode of the deployed implementation.

ProxyDeployed

Emitted when a proxy is deployed.

The actual salt used to deploy the proxy via create2 is keccak256(abi.encodePacked(sender, salt)).

event ProxyDeployed(
    address indexed proxy,
    address indexed implementation,
    address indexed sender,
    bytes32 salt,
    bytes initializeCallData
);

Parameters

NameTypeDescription
proxyaddressThe address of the deployed proxy.
implementationaddressThe address of the implementation the proxy proxies.
senderaddressThe address of the sender that triggered the proxy deployment.
saltbytes32The salt defined by the sender.
initializeCallDatabytesThe call data used to initialize the proxy.

Errors

ZeroParameterRegistry

Thrown when the parameter registry is the zero address.

error ZeroParameterRegistry();

InvalidImplementation

Thrown when the implementation is the zero address.

error InvalidImplementation();

EmptyBytecode

Thrown when the bytecode is empty (i.e. of the implementation to deploy).

error EmptyBytecode();

DeployFailed

Thrown when the deployment of a contract (e.g. an implementation or proxy) fails.

error DeployFailed();

Paused

Thrown when any pausable function is called when the contract is paused.

error Paused();