Skip to content

Commit

Permalink
Price discovery offers must have 0 initial price (#909)
Browse files Browse the repository at this point in the history
* Update solidity code

* Unit tests
  • Loading branch information
zajck authored Feb 16, 2024
1 parent e2319f1 commit ed67b23
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 0 deletions.
2 changes: 2 additions & 0 deletions contracts/domain/BosonErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ interface BosonErrors {
error InvalidRoyaltyInfo();
// Trying to change the default recipient address (treasury)
error WrongDefaultRecipient();
// Price discovery offer has non zero price
error InvalidPriceDiscoveryPrice();

// Group related
// Group does not exist
Expand Down
2 changes: 2 additions & 0 deletions contracts/interfaces/handlers/IBosonOfferHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface IBosonOfferHandler is BosonErrors, IBosonOfferEvents {
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -81,6 +82,7 @@ interface IBosonOfferHandler is BosonErrors, IBosonOfferEvents {
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down
16 changes: 16 additions & 0 deletions contracts/interfaces/handlers/IBosonOrchestrationHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ interface IBosonOrchestrationHandler is
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -170,6 +171,7 @@ interface IBosonOrchestrationHandler is
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -232,6 +234,7 @@ interface IBosonOrchestrationHandler is
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -290,6 +293,7 @@ interface IBosonOrchestrationHandler is
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -349,6 +353,7 @@ interface IBosonOrchestrationHandler is
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -409,6 +414,7 @@ interface IBosonOrchestrationHandler is
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -471,6 +477,7 @@ interface IBosonOrchestrationHandler is
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -537,6 +544,7 @@ interface IBosonOrchestrationHandler is
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -606,6 +614,7 @@ interface IBosonOrchestrationHandler is
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -677,6 +686,7 @@ interface IBosonOrchestrationHandler is
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -767,6 +777,7 @@ interface IBosonOrchestrationHandler is
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -852,6 +863,7 @@ interface IBosonOrchestrationHandler is
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -939,6 +951,7 @@ interface IBosonOrchestrationHandler is
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -1032,6 +1045,7 @@ interface IBosonOrchestrationHandler is
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -1127,6 +1141,7 @@ interface IBosonOrchestrationHandler is
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -1225,6 +1240,7 @@ interface IBosonOrchestrationHandler is
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down
5 changes: 5 additions & 0 deletions contracts/protocol/bases/OfferBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ contract OfferBase is ProtocolBase, IBosonOfferEvents {
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -96,6 +97,7 @@ contract OfferBase is ProtocolBase, IBosonOfferEvents {
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -147,6 +149,9 @@ contract OfferBase is ProtocolBase, IBosonOfferEvents {
// quantity must be greater than zero
if (_offer.quantityAvailable == 0) revert InvalidQuantityAvailable();

// If offer is of the discovery type, price must be zero
if (_offer.priceType == PriceType.Discovery && _offer.price != 0) revert InvalidPriceDiscoveryPrice();

DisputeResolutionTerms memory disputeResolutionTerms;
OfferFees storage offerFees = fetchOfferFees(_offer.id);
{
Expand Down
2 changes: 2 additions & 0 deletions contracts/protocol/facets/OfferHandlerFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ contract OfferHandlerFacet is IBosonOfferHandler, OfferBase {
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down Expand Up @@ -90,6 +91,7 @@ contract OfferHandlerFacet is IBosonOfferHandler, OfferBase {
* - Resolution period is not between the minimum and the maximum resolution period
* - Voided is set to true
* - Available quantity is set to zero
* - Offer type is discovery and the price is not 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
Expand Down
Loading

0 comments on commit ed67b23

Please sign in to comment.