DiamondFactory
Factory for creating and configuring Tokenizer Platform instances based on the EIP-2535 diamond architecture.
This process involves deploying a diamond proxy instance (see FractionalizationDiamond.sol
), adding appropriate facets
via the diamondCut operation, and initializing the associated storage of the diamond proxy.
_This contract supports Meta Transactions (see EIP-2771).
NOTE:
- This factory can also be used to create and configure Staking Platforms._
factoryOwner
The owner of this contract.
InvalidZeroAddress
Thrown when the zero address is provided as input.
NotFactoryOwner
Thrown when the caller is not the owner of this contract.
CannotUpdateToSameForwarder
Thrown when the provided address for Forwarder is the same as the current one in changeTrustedForwarder()
.
ArrayLengthMismatch
Thrown when the lengths of initSelectors
and initData
do not match in _deployAndInitializeDiamond()
.
TrustedForwarderChanged
Emitted at changeTrustedForwarder()
.
FactoryOwnershipTransferred
Emitted at transferFactoryOwnership()
.
DiamondDeployedAndInitialized
Emitted at deployAndInitializeDiamond()
and deployAndInitializeDiamondWithOwnershipTransfer()
.
constructor
Constructor.
Emits a {FactoryOwnershipTransferred} and a {TrustedForwarderChanged} event.
Parameters
Name | Type | Description |
---|---|---|
owner_ | address | The address to be granted ownership of this contract (i.e., DiamondFactory.sol ). |
trustedForwarder_ | address | The address to set as the designated trusted Forwarder (see EIP-2771). |
changeTrustedForwarder
Replaces the current trusted Forwarder with a new one.
_See EIP-2771.
Emits a {TrustedForwarderChanged} event._
Parameters
Name | Type | Description |
---|---|---|
newTrustedForwarder | address | The address of the new trusted Forwarder. |
transferFactoryOwnership
Transfers ownership of this contract to newFactoryOwner
.
Emits a {FactoryOwnershipTransferred} event.
Parameters
Name | Type | Description |
---|---|---|
newFactoryOwner | address | The address to be granted ownership of this contract. |
deployAndInitializeDiamond
Creates and configures a Tokenizer Platform instance.
_This function deploys a FractionalizationDiamond.sol
instance, adds the specified facets (facetCuts
),
initializes the diamond's associated storage using the provided initSelectors
and initData
, and assigns
admin
as the administrator of the newly created Tokenizer Platform.
Emits the following events:
- {DiamondDeployedAndInitialized}
- {DiamondCut} (see
DiamondWritableInternal.sol
) - {AccessControlInitialized} and {AdminChanged} (see
AccessControlFacet.sol
) - {OwnershipTransferred} (see Diamond
OwnableInternal.sol
)
IMPORTANT:
- The owner of the deployed Diamond is this contract (
DiamondFactory.sol
). - The admin of a Tokenizer Platform is distinct from the owner of the associated
FractionalizationDiamond.sol
(diamond proxy) and does not have the same privileges. For details, seeSolidStateDiamond.sol
andSafeOwnable.sol
. - Do not provide the initialization selector of
AccessControlFacet
ininitSelectors
. - Do not provide the initialization data for init function of
AccessControlFacet
ininitData
._
Parameters
Name | Type | Description |
---|---|---|
facetCuts | struct IERC2535DiamondCutInternal.FacetCut[] | See IERC2535DiamondCutInternal.FacetCut (The targeted Facets to add). |
initSelectors | bytes4[] | Selectors of init functions of Facets (exclude the init selector of AccessControlFacet ). |
initData | bytes[] | Encoded data for initialization (exclude the init data for init function of AccessControlFacet ). |
admin | address | The account to be assigned as the administrator of the created Tokenizer Platform. |
Return Values
Name | Type | Description |
---|---|---|
diamondAddr | address | The address of the deployed diamond proxy. |
deployAndInitializeDiamondWithOwnershipTransfer
Creates and configures a Tokenizer Platform instance and transfers ownership to the specified owner
.
_This function deploys a FractionalizationDiamond.sol
instance, adds the specified facets (facetCuts
),
initializes the diamond's associated storage using the provided initSelectors
and initData
, assigns
admin
as the administrator of the newly created Tokenizer Platform and transfers ownership of the diamond proxy
to owner
.
Emits the following events:
- {DiamondDeployedAndInitialized}
- {DiamondCut} (see
DiamondWritableInternal.sol
) - {AccessControlInitialized} and {AdminChanged} (see
AccessControlFacet.sol
) - {OwnershipTransferred} (see Diamond
OwnableInternal.sol
)
IMPORTANT:
- The owner of the deployed Diamond will be the
newOwner
account. - The admin of a Tokenizer Platform is distinct from the owner of the associated
FractionalizationDiamond.sol
(diamond proxy) and does not have the same privileges. For details, seeSolidStateDiamond.sol
andSafeOwnable.sol
. - The
admin
andnewOwner
can be the same account. - Do not provide the initialization selector of
AccessControlFacet
ininitSelectors
. - Do not provide the initialization data for init function of
AccessControlFacet
ininitData
._
Parameters
Name | Type | Description |
---|---|---|
facetCuts | struct IERC2535DiamondCutInternal.FacetCut[] | See IERC2535DiamondCutInternal.FacetCut (The targeted Facets to add). |
initSelectors | bytes4[] | Selectors of init functions of Facets (exclude the init selector of AccessControlFacet ). |
initData | bytes[] | Encoded data for initialization (exclude the init data for init function of AccessControlFacet ). |
admin | address | The account to be assigned as the administrator of the created Tokenizer Platform. |
newOwner | address | The account to be granted ownership of the deployed diamond proxy. |
Return Values
Name | Type | Description |
---|---|---|
diamondAddr | address | The address of the deployed diamond proxy. |
_deployAndInitializeDiamond
Internal version of deployAndInitializeDiamond()
.
Called by deployAndInitializeDiamond()
and deployAndInitializeDiamondWithOwnershipTransfer()
.
Parameters
Name | Type | Description |
---|---|---|
facetCuts | struct IERC2535DiamondCutInternal.FacetCut[] | See IERC2535DiamondCutInternal.FacetCut . |
initSelectors | bytes4[] | Selectors of init functions of Facets. |
initData | bytes[] | Encoded data for initialization. |
admin | address | The account to be assigned as the administrator of the created Tokenizer Platform. |
Return Values
Name | Type | Description |
---|---|---|
diamondAddr | address | The address of the deployed diamond proxy. |