GroupBase
View Source: contracts/protocol/bases/GroupBase.sol
↗ Extends: ProtocolBase, IBosonGroupEvents ↘ Derived Contracts: GroupHandlerFacet, OrchestrationHandlerFacet
GroupBase
Provides methods for group creation that can be shared across facets
Functions
- createGroupInternal(struct BosonTypes.Group _group, struct BosonTypes.Condition _condition)
- storeCondition(uint256 _groupId, struct BosonTypes.Condition _condition)
- validateCondition(struct BosonTypes.Condition _condition)
- addOffersToGroupInternal(uint256 _groupId, uint256[] _offerIds)
- preUpdateChecks(uint256 _groupId, uint256[] _offerIds)
createGroupInternal
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 createGroupInternal(struct BosonTypes.Group _group,
struct BosonTypes.Condition _condition)
internal
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 |
storeCondition
Store a condition struct associated with a given group id.
function storeCondition(uint256 _groupId,
struct BosonTypes.Condition _condition)
internal
Arguments
Name | Type | Description |
---|---|---|
_groupId | uint256 | the group id |
_condition | BosonTypes.Condition | the condition |
validateCondition
Validates that condition parameters make sense.
Reverts if:
- EvaluationMethod.None and has fields different from 0
- EvaluationMethod.Threshold and token address or maxCommits is zero
- EvaluationMethod.SpecificToken and token address or maxCommits is zero
function validateCondition(struct BosonTypes.Condition _condition)
internal
pure
returns(bool valid)
Arguments
Name | Type | Description |
---|---|---|
_condition | BosonTypes.Condition | fully populated condition struct |
Returns
Name | Type | Description |
---|---|---|
valid | bool | validity of condition |
addOffersToGroupInternal
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 addOffersToGroupInternal(uint256 _groupId,
uint256[] _offerIds)
internal
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 |
preUpdateChecks
Checks that update can be done before performing an update
and returns seller id and group storage pointer for further use.
Reverts if:
- 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
function preUpdateChecks(uint256 _groupId,
uint256[] _offerIds)
internal
view
returns(uint256 sellerId, Group storage group)
Arguments
Name | Type | Description |
---|---|---|
_groupId | uint256 | the id of the group to be updated |
_offerIds | uint256[] | array of offer ids to be added to or removed from the group |
Returns
Name | Type | Description |
---|---|---|
sellerId | uint256 | the seller id |
group | BosonTypes.Group | the group details |