Skip to main content

GroupHandlerFacet

View Source: contracts/protocol/facets/GroupHandlerFacet.sol

↗ Extends: IBosonGroupHandler, GroupBase

GroupHandlerFacet

Handles grouping of offers and conditions.

Functions

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

NameTypeDescription
_groupBosonTypes.Groupthe fully populated struct with group id set to 0x0
_conditionBosonTypes.Conditionthe 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

NameTypeDescription
_groupIduint256the id of the group to be updated
_offerIdsuint256[]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

NameTypeDescription
_groupIduint256the id of the group to be updated
_offerIdsuint256[]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

NameTypeDescription
_groupIduint256the id of the group whose condition will be set
_conditionBosonTypes.Conditionfully 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

NameTypeDescription
_groupIduint256the id of the group to check

Returns

NameTypeDescription
existsboolthe group was found
groupBosonTypes.Groupthe group details. See {BosonTypes.Group}
conditionBosonTypes.Conditionthe 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

NameTypeDescription
nextGroupIduint256the next group id