CampaignCreationSkeletonNID
Implementation of CampaignCreationSkeleton with NID gating integration. This facet is a core component (skeleton) of a staking platform, providing functionality to create staking campaigns with configurable setter functions for campaign parameters. The creation process includes both mandatory and optional configuration steps, allowing flexibility while enforcing essential requirements.
The registered setter functions must be defined in contracts that are added as facets to the staking diamond. These setter functions are categorized as required or optional and are executed during the campaign creation process based on the input provided. The execution order and data structure are critical for successfully setting up and creating campaigns.
OnlyAdminCanInitialize
Thrown when a non-admin account attempts to call restricted initialization functions.
AlreadyInitialized
Thrown when attempting to re-initialize.
NoRequiredSelectorsSpecifiedAtInitialize
Thrown when no required selectors are specified during initialization.
RequiredSelectorNotDiamondRegistered
Thrown when a selector specified as required during initialization is not registered in the diamond.
OptionalSelectorNotDiamondRegistered
Thrown when a selector specified as optional during initialization is not registered in the diamond.
InvalidCampaignCreationInput
Thrown when the number of required and optional selectors does not match the provided calldata.
RequiredSetterExecutionFailed
Thrown when a required setter function execution fails during a campaign's creation process.
OptionalSetterExecutionFailed
Thrown when a supported optional setter function execution fails during a campaign's creation process.
UnsupportedOptionalSelector
Thrown when an selector specified as optional is not supported for the campaign creation process.
NidCampaignCreationSkeletonInitialized
Emitted at initCampaignCreation()
.
StakingCampaignCreated
Emitted at createCampaign()
.
CampaignAssetManagersDeployed
Emitted at createCampaign()
.
initCampaignCreation
Initializes the CampaignCreationStorage
by registering the required and optional setter functions.
Also initializes the TxAuthDataVerifierFacetStorage
by registering the address of the dedicated signer.
_If multiple facets of the staking platform (diamond) integrate NID along with this facet,
TxAuthDataVerifierFacetStorage
must be initialized through this facet.
The selectors of the targeted setter functions must belong to the facets added to the diamond.
Setter functions corresponding to required selectors are executed mandatorily when a campaign is created.
In contrast, setter functions corresponding to optional selectors are executed only if the creator of the
campaign chooses to do so (see createCampaign()
).
This function can only be called by the Admin (see AccessControlStakingFacet.sol
).
Emits a {NidCampaignCreationSkeletonInitialized}
event._
Parameters
Name | Type | Description |
---|---|---|
initCampaignCreationData | bytes | The ABI-encoded data containing the following: - signer The address of the designated off-chain service that signs the msgHash of the txAuthData struct (see NID TxAuthDataVerifierFacet.sol ) - requiredSelectors An array of mandatory setter function selectors (bytes4). - optionalSelectors An array of optional setter function selectors (bytes4). |
createCampaign
Creates a new staking campaign by deploying a dedicated CampaignAssetManager
for the campaign's input
and another for its output. It then executes required setter functions, as well as any optional setter functions
specified by the provided optional selectors. The ID assigned to the newly created campaign is calculated by
incrementing the totalCampaigns
counter defined in the general storage.
_The required and optional setter functions are registered in the storage via the initCampaignCreation()
and are identified by their function selectors.
The dataToExecute
array is divided into two parts:
-
First Part: Contains the ABI-encoded input data for the required setter functions that are executed mandatorily.
The order of this data must exactly match the order of the required selectors specified during the execution of
initCampaignCreation()
. For example, if the required selectors are registered as [selectorA, selectorB, selectorC], then the first part ofdataToExecute
must be [dataForFunctionA, dataForFunctionB, dataForFunctionC, ..secondPart
..]. Any mismatch in order will lead to misconfigurations or likely cause a revert. -
Second Part: Contains the ABI-encoded input data for the specified optional setter functions (if any) to be executed.
Users are gated by requireTxDataAuth
modifier (see NID TxAuthDataVerifierFacet
) to create campaigns.
Emits a {CampaignAssetManagersDeployed}
and {StakingCampaignCreated}
event._
Parameters
Name | Type | Description |
---|---|---|
campaignCreationData | bytes | The ABI-encoded data containing the following: - optionalSelectorsToExecute An array of optional setter function selectors (bytes4) to be executed. - dataToExecute An array with the ABI-encoded input data for the respective required and optional setter functions. |