IBosonOfferHandler
View Source: contracts/interfaces/handlers/IBosonOfferHandler.sol
↗ Extends: IBosonOfferEvents
IBosonOfferHandler
Handles creation, voiding, and querying of offers within the protocol.
The ERC-165 identifier for this interface is: 0xa1e3b91c
Functions
- createOffer(struct BosonTypes.Offer _offer, struct BosonTypes.OfferDates _offerDates, struct BosonTypes.OfferDurations _offerDurations, uint256 _disputeResolverId, uint256 _agentId)
- createOfferBatch(struct BosonTypes.Offer[] _offers, struct BosonTypes.OfferDates[] _offerDates, struct BosonTypes.OfferDurations[] _offerDurations, uint256[] _disputeResolverIds, uint256[] _agentIds)
- reserveRange(uint256 _offerId, uint256 _length, address _to)
- voidOffer(uint256 _offerId)
- voidOfferBatch(uint256[] _offerIds)
- extendOffer(uint256 _offerId, uint256 _validUntilDate)
- extendOfferBatch(uint256[] _offerIds, uint256 _validUntilDate)
- getOffer(uint256 _offerId)
- getNextOfferId()
- isOfferVoided(uint256 _offerId)
- getAgentIdByOffer(uint256 _offerId)
createOffer
Creates an offer.
Emits an OfferCreated event if successful.
Reverts if:
- The offers region of protocol is paused
- Caller is not an assistant
- Valid from date is greater than valid until date
- Valid until date is not in the future
- Both voucher expiration date and voucher expiration period are defined
- Neither of voucher expiration date and voucher expiration period are defined
- Voucher redeemable period is fixed, but it ends before it starts
- Voucher redeemable period is fixed, but it ends before offer expires
- Dispute period is less than minimum dispute period
- Resolution period is not between the minimum and the maximum resolution period
- Voided is set to true
- Available quantity is set to zero
- Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver
- Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver
- Seller is not on dispute resolver's seller allow list
- Dispute resolver does not accept fees in the exchange token
- Buyer cancel penalty is greater than price
- Collection does not exist
- When agent id is non zero:
- If Agent does not exist
- If the sum of agent fee amount and protocol fee amount is greater than the offer fee limit
function createOffer(struct BosonTypes.Offer _offer,
struct BosonTypes.OfferDates _offerDates,
struct BosonTypes.OfferDurations _offerDurations,
uint256 _disputeResolverId,
uint256 _agentId)
external
Arguments
Name | Type | Description |
---|---|---|
_offer | BosonTypes.Offer | the fully populated struct with offer id set to 0x0 and voided set to false |
_offerDates | BosonTypes.OfferDates | the fully populated offer dates struct |
_offerDurations | BosonTypes.OfferDurations | the fully populated offer durations struct |
_disputeResolverId | uint256 | the id of chosen dispute resolver (can be 0) |
_agentId | uint256 | the id of agent |
createOfferBatch
Creates a batch of offers.
Emits an OfferCreated event for every offer if successful.
Reverts if:
- The offers region of protocol is paused
- Number of elements in offers, offerDates and offerDurations do not match
- For any offer:
- Caller is not an assistant
- Valid from date is greater than valid until date
- Valid until date is not in the future
- Both voucher expiration date and voucher expiration period are defined
- Neither of voucher expiration date and voucher expiration period are defined
- Voucher redeemable period is fixed, but it ends before it starts
- Voucher redeemable period is fixed, but it ends before offer expires
- Dispute period is less than minimum dispute period
- Resolution period is not between the minimum and the maximum resolution period
- Voided is set to true
- Available quantity is set to zero
- Dispute resolver wallet is not registered, except for absolute zero offers with unspecified dispute resolver
- Dispute resolver is not active, except for absolute zero offers with unspecified dispute resolver
- Seller is not on dispute resolver's seller allow list
- Dispute resolver does not accept fees in the exchange token
- Buyer cancel penalty is greater than price
- Collection does not exist
- When agent ids are non zero:
- If Agent does not exist
- If the sum of agent fee amount and protocol fee amount is greater than the offer fee limit
function createOfferBatch(struct BosonTypes.Offer[] _offers,
struct BosonTypes.OfferDates[] _offerDates,
struct BosonTypes.OfferDurations[] _offerDurations,
uint256[] _disputeResolverIds,
uint256[] _agentIds)
external
Arguments
Name | Type | Description |
---|---|---|
_offers | BosonTypes.Offer[] | the array of fully populated Offer structs with offer id set to 0x0 and voided set to false |
_offerDates | BosonTypes.OfferDates[] | the array of fully populated offer dates structs |
_offerDurations | BosonTypes.OfferDurations[] | the array of fully populated offer durations structs |
_disputeResolverIds | uint256[] | the array of ids of chosen dispute resolvers (can be 0) |
_agentIds | uint256[] | the array of ids of agents |
reserveRange
Reserves a range of vouchers to be associated with an offer
Reverts if:
- The offers region of protocol is paused
- The exchanges region of protocol is paused
- Offer does not exist
- Offer already voided
- Caller is not the seller
- Range length is zero
- Range length is greater than quantity available
- Range length is greater than maximum allowed range length
- Call to BosonVoucher.reserveRange() reverts
- _to is not the BosonVoucher contract address or the BosonVoucher contract owner
function reserveRange(uint256 _offerId,
uint256 _length,
address _to)
external
Arguments
Name | Type | Description |
---|---|---|
_offerId | uint256 | the id of the offer |
_length | uint256 | the length of the range |
_to | address | the address to send the pre-minted vouchers to (contract address or contract owner) |
voidOffer
Voids a given offer.
Existing exchanges are not affected.
No further vouchers can be issued against a voided offer.
Emits an OfferVoided event if successful.
Reverts if:
- The offers region of protocol is paused
- Offer id is invalid
- Caller is not the assistant of the offer
- Offer has already been voided
function voidOffer(uint256 _offerId)
external
Arguments
Name | Type | Description |
---|---|---|
_offerId | uint256 | the id of the offer to void |
voidOfferBatch
Voids a batch of offers.
Existing exchanges are not affected.
No further vouchers can be issued against a voided offer.
Emits an OfferVoided event for every offer if successful.
Reverts if, for any offer:
- The offers region of protocol is paused
- Offer id is invalid
- Caller is not the assistant of the offer
- Offer has already been voided
function voidOfferBatch(uint256[] _offerIds)
external
Arguments
Name | Type | Description |
---|---|---|
_offerIds | uint256[] | list of ids of offers to void |
extendOffer
Sets new valid until date.
Emits an OfferExtended event if successful.
Reverts if:
- The offers region of protocol is paused
- Offer does not exist
- Caller is not the assistant of the offer
- New valid until date is before existing valid until dates
- Offer has voucherRedeemableUntil set and new valid until date is greater than that
function extendOffer(uint256 _offerId,
uint256 _validUntilDate)
external
Arguments
Name | Type | Description |
---|---|---|
_offerId | uint256 | the id of the offer to extend |
_validUntilDate | uint256 | new valid until date |
extendOfferBatch
Sets new valid until date for a batch of offers.
Emits an OfferExtended event for every offer if successful.
Reverts if:
- The offers region of protocol is paused
- For any of the offers:
- Offer does not exist
- Caller is not the assistant of the offer
- New valid until date is before existing valid until dates
- Offer has voucherRedeemableUntil set and new valid until date is greater than that
function extendOfferBatch(uint256[] _offerIds,
uint256 _validUntilDate)
external
Arguments
Name | Type | Description |
---|---|---|
_offerIds | uint256[] | list of ids of the offers to extend |
_validUntilDate | uint256 | new valid until date |
getOffer
Gets the details about a given offer.
function getOffer(uint256 _offerId)
external
view
returns(bool exists,
BosonTypes.Offer memory offer,
BosonTypes.OfferDates memory offerDates,
BosonTypes.OfferDurations memory offerDurations,
BosonTypes.DisputeResolutionTerms memory disputeResolutionTerms,
BosonTypes.OfferFees memory offerFees)
Arguments
Name | Type | Description |
---|---|---|
_offerId | uint256 | the id of the offer to retrieve |
Returns
Name | Type | Description |
---|---|---|
exists | bool | the offer was found |
offer | BosonTypes.Offer | the offer details. See {BosonTypes.Offer} |
offerDates | BosonTypes.OfferDates | the offer dates details. See {BosonTypes.OfferDates} |
offerDurations | BosonTypes.OfferDurations | the offer durations details. See {BosonTypes.OfferDurations} |
disputeResolutionTerms | BosonTypes.DisputeResolutionTerms | the details about the dispute resolution terms. See {BosonTypes.DisputeResolutionTerms} |
offerFees | BosonTypes.OfferFees | the offer fees details. See {BosonTypes.OfferFees} |
getNextOfferId
Gets the next offer id.Does not increment the counter.
function getNextOfferId()
external
view
returns(uint256 nextOfferId)
Returns
Name | Type | Description |
---|---|---|
nextOfferId | uint256 | the next offer id |
isOfferVoided
Checks if offer is voided or not.
function isOfferVoided(uint256 _offerId)
external
view
returns(bool exists, bool offerVoided)
Arguments
Name | Type | Description |
---|---|---|
_offerId | uint256 | the id of the offer to check |
Returns
Name | Type | Description |
---|---|---|
exists | bool | the offer was found |
offerVoided | bool | true if voided, false otherwise |
getAgentIdByOffer
Gets the agent id for a given offer id.
function getAgentIdByOffer(uint256 _offerId)
external
view
returns(bool exists, uint256 agentId)
Arguments
Name | Type | Description |
---|---|---|
_offerId | uint256 | the offer id |
Returns
Name | Type | Description |
---|---|---|
exists | bool | whether the agent id exists |
agentId | uint256 | the agent id |