Fraction ProtocolskeletonFacetsconnectorscreateToPurchaseConnectorsfractionsRoleApproval

FractionsRoleApprovalFacetStorage

This library handles the storage and logic for the FractionsRoleApprovalFacet connector facet.

_Connectors intervene at predetermined intermediate state(s) and progress campaigns to predetermined destination state(s). when applicable.

IMPORTANT:

  • This implementation features role-based access control for the campaign validator(s) (see AccessControl.sol).

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

error AlreadyInitialized()

Thrown when attempting to re-initialize.

WrongInitializationData

error WrongInitializationData()

Thrown when passing invalid initialization data (e.g., setting states to zero).

UnauthorizedApproval

error UnauthorizedApproval(uint256 campaignId, address account)

Thrown when attempting to approve a campaign's transition to the purchase phase without authorization.

UnauthorizedRejection

error UnauthorizedRejection(uint256 campaignId, address account)

Thrown when attempting to reject a campaign without authorization.

STORAGE_SLOT

bytes32 STORAGE_SLOT

Unique identifier for the storage slot where the Layout struct is stored. Derived from the ERC7201 formula. STORAGE_SLOT: 0x2957d1ea22bafe0f23595598fff9e39b2ee7dc53fe89c23575e6aa6196fa2100

Layout

Struct containing the configuration information of the connector.

struct Layout {
  uint256 interferenceState;
  uint256 approveState;
  uint256 rejectState;
  bytes32[] eligibleRoles;
}

layout

function layout() internal pure returns (struct FractionsRoleApprovalFacetStorage.Layout l)

Retrieves a reference to the Layout struct stored at the slot specified by STORAGE_SLOT unique identifier.

initCreateToPurchaseConnector

function initCreateToPurchaseConnector(struct FractionsRoleApprovalFacetStorage.Layout l, bytes initCreateToPurchaseConnectorData) internal

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

NameTypeDescription
lstruct FractionsRoleApprovalFacetStorage.LayoutA reference to the Layout struct in storage.
initCreateToPurchaseConnectorDatabytesThe ABI-encoded data containing: - eligibleRoles: A bytes32 array containing the role(s) eligible for validating (approving or rejecting campaigns). - interferenceState: A uint256 representing the CREATED state for any campaign. - approveState: A uint256 representing the PURCHASE state for any campaign. - rejectState: A uint256 representing the REJECTED state for any campaign.

approveFractions

function approveFractions(struct FractionsRoleApprovalFacetStorage.Layout l, uint256 campaignId) internal

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 successfully if the current state of campaignId is CREATED.

Parameters

NameTypeDescription
lstruct FractionsRoleApprovalFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted campaign.

rejectFractions

function rejectFractions(struct FractionsRoleApprovalFacetStorage.Layout l, uint256 campaignId) internal

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 successfully 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

NameTypeDescription
lstruct FractionsRoleApprovalFacetStorage.LayoutA reference to the Layout struct in storage.
campaignIduint256The unique identifier of the targeted campaign.

On this page