Configuring PlatformGeneric FacetsState Facet

State Facets Types

When initializing each Internal and SubInternal state facet, you must assign at least one uint256 value to it (e.g. 1, 2), which corresponds to the state(s) where the associated Skeleton and/or Subskeleton facets operate within a campaign.

The initialization process of the state facets for a platform can be divided into three separate steps:

  1. Initialize the storage for Internal and SubInternal state facets (e.g. SingleStateBuybackFacetStorage):

The initialization can take various forms and may include one or more uint256 arguments for a facet, depending on the implementation type.

TypeDescription
Single StateSets a specific state for a function of the respective skeleton, allowing it to be called only in that state. For example, the purchase() function can be called only in a specific state.
Multiple StateSets multiple possible states for a function of the respective skeleton. As a result, the function can be called only when the campaign is in one of the specified states. For example, receive() can be called in both the DONE (2) and PURCHASE (1) states. A real-world example: People have purchased some fractions, and during the purchase phase, the issuer can call the receive() function to collect the funds gathered from those purchases. Later, if the campaign moves to the DONE state - meaning the purchase phase has ended - the issuer can still call the receive() function to retrieve the collected funds. Therefore, a campaign may go through different states in which certain functions become callable.
Restricted StateSimilar to Multiple States, but works in reverse: instead of defining the states in which a function can be called, the developer specifies the states (e.g., 0, 3, 5) in which the function cannot be called.
  1. Initialize connectors.

  2. Initialize the StateFacetStorage.

Initialization Order

It is mandatory to initialize the AccessControlFacetStorage first, before any other initialization.

The order in which all state facets are initialized can be arbitrary, but developers must ensure that state transitions follow a logical progression.

A developer can initialize SingleStateBuybackFacetStorage with state value 2 and SingleStatePurchaseStorage with value 3, allowing campaigns to progress to the purchase phase - provided the necessary configurations are in place (e.g., a createToPurchase connector with interferenceState = 1 and destinationState = 3).

In other words, assigning specific values to internal or subinternal state facet storage does not, on its own, disrupt the campaign's logic. What determines the flow is how connectors and transitions are configured.

Only state values 0 and 1 are reserved as default codes for campaigns; all other values can be used freely.

The diagram below illustrates a set of initialized internal facets along with their corresponding uint256 initialization values:

image

On this page