GroupHandlerFacet
View Source: contracts/protocol/facets/GroupHandlerFacet.sol
↗ Extends: IBosonGroupHandler, GroupBase
GroupHandlerFacet
Handles grouping of offers and conditions.
Functions
- initialize()
- createGroup(struct BosonTypes.Group _group, struct BosonTypes.Condition _condition)
- addOffersToGroup(uint256 _groupId, uint256[] _offerIds)
- removeOffersFromGroup(uint256 _groupId, uint256[] _offerIds)
- setGroupCondition(uint256 _groupId, struct BosonTypes.Condition _condition)
- getGroup(uint256 _groupId)
- getNextGroupId()
initialize
Facet Initializer
This function is callable only once.
function initialize()
public
onlyUnInitialized
createGroup
Creates a group.
Emits a GroupCreated event if successful.
Reverts if:
- Caller is not an operator
- Any of offers belongs to different seller
- Any of offers does not exist
- Offer exists in a different group
- Number of offers exceeds maximum allowed number per group
function createGroup(struct BosonTypes.Group _group,
struct BosonTypes.Condition _condition)
external
groupsNotPaused nonReentrant
Arguments
Name | Type | Description |
---|---|---|
_group | BosonTypes.Group | the fully populated struct with group id set to 0x0 |
_condition | BosonTypes.Condition | the fully populated condition struct |
addOffersToGroup
Adds offers to an existing group.
Emits a GroupUpdated event if successful.
Reverts if:
- Caller is not the seller
- Offer ids param is an empty list
- Current number of offers plus number of offers added exceeds maximum allowed number per group
- Group does not exist
- Any of offers belongs to different seller
- Any of offers does not exist
- Offer exists in a different group
- Offer ids param contains duplicated offers
function addOffersToGroup(uint256 _groupId,
uint256[] _offerIds)
external
groupsNotPaused nonReentrant
Arguments
Name | Type | Description |
---|---|---|
_groupId | uint256 | the id of the group to be updated |
_offerIds | uint256[] | array of offer ids to be added to the group |
removeOffersFromGroup
Removes offers from an existing group.
Emits a GroupUpdated event if successful.
Reverts if:
- The groups region of protocol is paused
- Caller is not the seller
- Offer ids param is an empty list
- Number of offers exceeds maximum allowed number per group
- Group does not exist
- Any offer is not part of the group
function removeOffersFromGroup(uint256 _groupId,
uint256[] _offerIds)
external
groupsNotPaused nonReentrant
Arguments
Name | Type | Description |
---|---|---|
_groupId | uint256 | the id of the group to be updated |
_offerIds | uint256[] | array of offer ids to be removed from the group |
setGroupCondition
Sets the condition of an existing group.
Emits a GroupUpdated event if successful.
Reverts if:
- The groups region of protocol is paused
- Condition includes invalid combination of fields
- Seller does not match caller
- Group does not exist
function setGroupCondition(uint256 _groupId,
struct BosonTypes.Condition _condition)
external
groupsNotPaused nonReentrant
Arguments
Name | Type | Description |
---|---|---|
_groupId | uint256 | the id of the group whose condition will be set |
_condition | BosonTypes.Condition | fully populated condition struct |
getGroup
Gets the details about a given group.
function getGroup(uint256 _groupId)
external
view
returns(bool exists,
Group memory group,
Condition memory condition)
Arguments
Name | Type | Description |
---|---|---|
_groupId | uint256 | the id of the group to check |
Returns
Name | Type | Description |
---|---|---|
exists | bool | the group was found |
group | BosonTypes.Group | the group details. See {BosonTypes.Group} |
condition | BosonTypes.Condition | the group's condition details. See {BosonTypes.Condition} |
getNextGroupId
Gets the next group id.Does not increment the counter.
function getNextGroupId()
public
view
returns(uint256 nextGroupId)
Returns
Name | Type | Description |
---|---|---|
nextGroupId | uint256 | the next group id |