FractionsAddressApprovalFacetStorage
This library handles the storage and logic for the FractionsAddressApprovalFacet
connector facet.
_Connectors intervene at predetermined intermediate state(s) and progress campaigns to predetermined destination state(s). when applicable.
IMPORTANT:
- This implementation features an allowlist of addresses for campaign validator(s) instead of a role-based schema.
NOTE:
- We do not use the
custom:storage-location
annotation because the Layout struct is defined in a library, which, as of now, does not support automated storage layout validation. However, the implementation adheres to the ERC-7201 structure in spirit by ensuring unique and collision-free storage slots using the ERC-7201 formula._
AlreadyInitialized
Thrown when attempting to re-initialize.
WrongInitializationData
Thrown when passing invalid initialization data (e.g., setting states to zero).
UnauthorizedApproval
Thrown when attempting to approve a campaign's transition to the purchase phase without authorization.
UnauthorizedRejection
Thrown when attempting to reject a campaign without authorization.
STORAGE_SLOT
Unique identifier for the storage slot where the Layout struct is stored. Derived from the ERC7201 formula. STORAGE_SLOT: 0x9c3a91c94ed5783f3fb1e75483294e2666446879763a2216d089aebad07bda00
Layout
Struct containing the configuration information of the connector.
layout
Retrieves a reference to the Layout struct stored at the slot specified by STORAGE_SLOT
unique identifier.
initCreateToPurchaseConnector
Initializes the FractionsRoleApprovalFacetStorage
by registering the eligible validator role(s), as well as the
intermediate state (CREATED
), and the destination states (PURCHASE
and REJECTED
) for this connector.
Campaign states in a TMI-Fraction Platform are represented as uint256
values and are configured during the
initialization of the generic StateFacet
(see StateFacet.sol
). Extra care should be taken to ensure consistency
with the value schema used for the states, as defined in the StateFacet
configuration (e.g., using enums).
Parameters
Name | Type | Description |
---|---|---|
l | struct FractionsAddressApprovalFacetStorage.Layout | A reference to the Layout struct in storage. |
initCreateToPurchaseConnectorData | bytes | The ABI-encoded data containing: - eligibleAddresses : address[] containing the addresses of eligible validators (can approve or reject campaigns). - interferenceState : uint256 representing the CREATED state for any campaign. - approveState : uint256 representing the PURCHASE state for any campaign. - rejectState : uint256 representing the REJECTED state for any campaign. |
approveFractions
Transitions the specified campaign from its CREATED
state to its PURCHASE
state.
This function can only be called by eligible validators (see initCreateToPurchaseConnector()
),
and can only be executed if the current state of campaignId
is CREATED
.
Parameters
Name | Type | Description |
---|---|---|
l | struct FractionsAddressApprovalFacetStorage.Layout | A reference to the Layout struct in storage. |
campaignId | uint256 | The unique identifier of the targeted campaign. |
rejectFractions
Transitions the specified campaign from its CREATED
state to its REJECTED
state.
_This function can only be called by eligible validators (see initCreateToPurchaseConnector()
),
and can only be executed if the current state of campaignId
is CREATED
.
IMPORTANT:
- All the wrapped assets of the
campaignId
are forcibly unlocked and transferred to the campaign's creator._
Parameters
Name | Type | Description |
---|---|---|
l | struct FractionsAddressApprovalFacetStorage.Layout | A reference to the Layout struct in storage. |
campaignId | uint256 | The unique identifier of the targeted campaign. |