PurchaseToReceiveRoleApprovalFacetStorage
This library handles the storage and logic for the PurchaseToReceiveRoleApprovalFacet
connector facet.
_Connectors intervene at predetermined intermediate state(s) and progress campaigns to predetermined destination state(s). when applicable.
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).
UnauthorizedStateChange
Thrown when attempting to approve a campaign's transition to the receive state without authorization.
PurchasePhaseNotFinished
Thrown when attempting to transition the campaign's state before the purchase phase has finished.
PurchaseAmountNotReached
Thrown when attempting to transition the campaign's state but its funding target has not been reached.
STORAGE_SLOT
Unique identifier for the storage slot where the Layout struct is stored. Derived from the ERC7201 formula. STORAGE_SLOT: 0x150972faaabc779b9c84a34484fdc1807c65066d87a76c9f9e0b1a365e815d00
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.
initPurchaseToReceiveConnector
Initializes the PurchaseToReceiveRoleApprovalFacetStorage
by registering the intermediate state (PURCHASE
) and
the destination state (RECEIVE
) 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 PurchaseToReceiveRoleApprovalFacetStorage.Layout | A reference to the Layout struct in storage. |
initPurchaseToReceiveConnectorData | bytes | The ABI-encoded data containing: - eligibleRoles : bytes32[] containing the role(s) eligible for validating (approving purchase completion). - intermediateState : uint256 representing the PURCHASE state for any campaign. - destinationState : uint256 representing the RECEIVE state for any campaign. |
approvePurchaseCompletion
Transitions the specified campaign from its PURCHASE
state to its RECEIVE
state.
This function can only be called by eligible validators (see initCreateToPurchaseConnector()
),
and can only be executed if the current state of campaignId
is PURCHASE
and the purchase phase
time window has elapsed, with the campaign meeting its funding target.
Parameters
Name | Type | Description |
---|---|---|
l | struct PurchaseToReceiveRoleApprovalFacetStorage.Layout | A reference to the Layout struct in storage. |
campaignId | uint256 | The unique identifier of the targeted campaign. |