Appearance
Solidity API
PropsDiamondFactory
Factory contract for creating new PropsDiamond instances with predictable addresses
Deploys new diamond contracts using CREATE2 for address predictability Supports metatransactions through ERC2771Context Provides functionality for diamond initialization and pre-approval operations
templateDiamond
solidity
address templateDiamondAddress of the template diamond contract to be cloned
Immutable value set during construction
diamondCutFacet
solidity
address diamondCutFacetAddress of the DiamondCutFacet contract
Immutable value set during construction, used for diamond initialization
DiamondCreated
solidity
event DiamondCreated(address diamondAddress)Emitted when a new diamond is created
Parameters
| Name | Type | Description |
|---|---|---|
| diamondAddress | address | The address of the newly created diamond |
constructor
solidity
constructor(address _templateDiamond, address _diamondCutFacet) publicConstructs the PropsDiamondFactory
Sets up the factory with template references and initializes the trusted forwarder
Parameters
| Name | Type | Description |
|---|---|---|
| _templateDiamond | address | Address of the template diamond contract |
| _diamondCutFacet | address | Address of the DiamondCutFacet contract |
createDiamond
solidity
function createDiamond(bytes32 _salt, struct IPropsInitCall.InitCall[] _initCalls, struct IPropsPreApprovalCall.PropsPreApprovalCall[] _preApprovalCalls) external returns (address)Creates a new diamond with initialization calls
Deploys a new diamond with CREATE2 and executes initialization calls
Parameters
| Name | Type | Description |
|---|---|---|
| _salt | bytes32 | Unique value to determine the contract address |
| _initCalls | struct IPropsInitCall.InitCall[] | Array of initialization calls to be executed on the new diamond |
| _preApprovalCalls | struct IPropsPreApprovalCall.PropsPreApprovalCall[] | Array of pre-approval calls to be executed before initialization |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | address | Address of the newly created diamond |
createDiamond
solidity
function createDiamond(bytes32 _salt, struct IDiamondCut.FacetCut[] _initialDiamondCuts, struct IPropsInitCall.InitCall[] _initCalls, struct IPropsPreApprovalCall.PropsPreApprovalCall[] _preApprovalCalls) external returns (address)Creates a new diamond with initial facet cuts and initialization calls
Deploys a new diamond with CREATE2, applies facet cuts, and executes initialization calls
Parameters
| Name | Type | Description |
|---|---|---|
| _salt | bytes32 | Unique value to determine the contract address |
| _initialDiamondCuts | struct IDiamondCut.FacetCut[] | Array of initial facet cuts to be applied to the new diamond |
| _initCalls | struct IPropsInitCall.InitCall[] | Array of initialization calls to be executed on the new diamond |
| _preApprovalCalls | struct IPropsPreApprovalCall.PropsPreApprovalCall[] | Array of pre-approval calls to be executed before initialization |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | address | Address of the newly created diamond |
_createDiamond
solidity
function _createDiamond(bytes32 _salt, struct IDiamondCut.FacetCut[] _initialDiamondCuts, struct IPropsInitCall.InitCall[] _initCalls, struct IPropsPreApprovalCall.PropsPreApprovalCall[] _preApprovalCalls) internal returns (address clone)Core function to create a diamond with all necessary initializations
Uses CREATE2 to deploy the diamond with a deterministic address Executes pre-approval calls and initializes the diamond
Parameters
| Name | Type | Description |
|---|---|---|
| _salt | bytes32 | Unique value to determine the contract address |
| _initialDiamondCuts | struct IDiamondCut.FacetCut[] | Array of initial facet cuts to be applied |
| _initCalls | struct IPropsInitCall.InitCall[] | Array of initialization calls to be executed |
| _preApprovalCalls | struct IPropsPreApprovalCall.PropsPreApprovalCall[] | Array of pre-approval calls to be executed |
Return Values
| Name | Type | Description |
|---|---|---|
| clone | address | Address of the newly created diamond |
_executePreApprovalCalls
solidity
function _executePreApprovalCalls(address _diamond, struct IPropsPreApprovalCall.PropsPreApprovalCall[] _preApprovalCalls) internalExecutes pre-approval calls before diamond initialization
Handles special cases where addresses are substituted with the diamond address Currently supports ERC20 permit operations
Parameters
| Name | Type | Description |
|---|---|---|
| _diamond | address | Address of the diamond being created |
| _preApprovalCalls | struct IPropsPreApprovalCall.PropsPreApprovalCall[] | Array of pre-approval calls to execute |
_msgSender
solidity
function _msgSender() internal view virtual returns (address sender)Internal function to get the sender of the current call
_Overrides ERC2771Context.msgSender() for meta-transaction support
Return Values
| Name | Type | Description |
|---|---|---|
| sender | address | The address of the sender (either the direct caller or the meta-tx originator) |
_msgData
solidity
function _msgData() internal view virtual returns (bytes)Internal function to get the calldata of the current call
_Overrides ERC2771Context.msgData() for meta-transaction support
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bytes | The calldata of the current call, potentially modified for meta-transactions |
getPropsDiamondCreationCode
solidity
function getPropsDiamondCreationCode() public view returns (bytes)Returns the creation code for PropsDiamond contract
Useful for client-side address prediction
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | bytes | The bytecode used to deploy new diamonds |
predictDiamondAddress
solidity
function predictDiamondAddress(address _sender, bytes32 _salt) public view returns (address)Predicts the address where a diamond will be deployed
Uses CREATE2 address calculation formula
Parameters
| Name | Type | Description |
|---|---|---|
| _sender | address | The address that will deploy the diamond |
| _salt | bytes32 | The salt to use for the deployment |
Return Values
| Name | Type | Description |
|---|---|---|
| [0] | address | The predicted address of the diamond |