Skip to content

Commit

Permalink
Merge branch 'main' into fix-token-gating
Browse files Browse the repository at this point in the history
  • Loading branch information
anajuliabit committed Jul 6, 2023
2 parents f286097 + f14d952 commit eb336b0
Show file tree
Hide file tree
Showing 135 changed files with 10,203 additions and 9,628 deletions.
14 changes: 6 additions & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"extends": [
"eslint:recommended",
"prettier"
],
"extends": ["eslint:recommended", "prettier"],
"env": {
"node": true,
"es6": true,
"es2020": true,
"commonjs": true,
"mocha": true
},
Expand All @@ -17,7 +14,8 @@
"no-empty": "off",
"no-only-tests/no-only-tests": "error"
},
"plugins": [
"no-only-tests"
]
"plugins": ["no-only-tests"],
"globals": {
"BigInt": true
}
}
4 changes: 2 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

find . -name '*.js' -not -path '*/node_modules/*' | xargs git diff --cached --name-only | xargs -r npx eslint --fix
find . -name '*.js' -not -path '*/node_modules/*' | xargs git diff --cached --name-only | xargs -r npx prettier --write
git diff --cached --name-only | grep -e contracts -e *.txt | xargs -r npx solhint --fix
git diff --cached --name-only | grep -e contracts -e *.txt | xargs -r npx prettier --write
git diff --cached --name-only | grep -e ^contracts -e sol$ | xargs -r npx solhint --fix
git diff --cached --name-only | grep -e ^contracts -e sol$ | xargs -r npx prettier --write
npm run natspec-interface-id:fix
6 changes: 4 additions & 2 deletions contracts/domain/BosonConstants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ string constant DIRECT_INITIALIZATION_NOT_ALLOWED = "Direct initializtion is not
string constant ACCESS_DENIED = "Access denied, caller doesn't have role";
string constant NOT_ASSISTANT = "Not seller's assistant";
string constant NOT_ADMIN = "Not admin";
string constant NOT_ASSISTANT_AND_CLERK = "Not assistant and clerk";
string constant NOT_ADMIN_ASSISTANT_AND_CLERK = "Not admin, assistant and clerk";
string constant CLERK_DEPRECATED = "Clerk is deprecated and must be set to address 0";
string constant NOT_ADMIN_AND_ASSISTANT = "Not admin and assistant";
string constant NOT_BUYER_OR_SELLER = "Not buyer or seller";
string constant NOT_VOUCHER_HOLDER = "Not current voucher holder";
string constant NOT_BUYER_WALLET = "Not buyer's wallet address";
Expand Down Expand Up @@ -120,6 +120,8 @@ string constant EXCHANGE_ALREADY_EXISTS = "Exchange already exists";
string constant INVALID_RANGE_LENGTH = "Range length is too large or zero";

// Revert Reasons: Twin related
uint256 constant SINGLE_TWIN_RESERVED_GAS = 140000;
uint256 constant MINIMAL_RESIDUAL_GAS = 180000;
string constant NO_SUCH_TWIN = "No such twin";
string constant NO_TRANSFER_APPROVED = "No transfer approved";
string constant TWIN_TRANSFER_FAILED = "Twin could not be transferred";
Expand Down
8 changes: 4 additions & 4 deletions contracts/domain/BosonTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ contract BosonTypes {
enum SellerUpdateFields {
Admin,
Assistant,
Clerk,
Clerk, // Deprecated.
AuthToken
}

enum DisputeResolverUpdateFields {
Admin,
Assistant,
Clerk
Clerk // Deprecated.
}

struct AuthToken {
Expand All @@ -92,7 +92,7 @@ contract BosonTypes {
uint256 id;
address assistant;
address admin;
address clerk;
address clerk; // Deprecated. Kept for backwards compatibility.
address payable treasury;
bool active;
string metadataUri;
Expand All @@ -109,7 +109,7 @@ contract BosonTypes {
uint256 escalationResponsePeriod;
address assistant;
address admin;
address clerk;
address clerk; // Deprecated. Kept for backwards compatibility.
address payable treasury;
string metadataUri;
bool active;
Expand Down
3 changes: 2 additions & 1 deletion contracts/interfaces/clients/IBosonVoucher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ interface IBosonVoucher is IERC721Upgradeable, IERC721MetadataUpgradeable, IERC7
*
* @param _to - address of the contract to call
* @param _data - data to pass to the external contract
* @return result - result of the call
*/
function callExternalContract(address _to, bytes memory _data) external payable;
function callExternalContract(address _to, bytes memory _data) external payable returns (bytes memory);

/** @notice Set approval for all to the vouchers owned by this contract
*
Expand Down
1 change: 1 addition & 0 deletions contracts/interfaces/events/IBosonConfigEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface IBosonConfigEvents {
);
event MaxTotalOfferFeePercentageChanged(uint16 maxTotalOfferFeePercentage, address indexed executedBy);
event MaxRoyaltyPercentageChanged(uint16 maxRoyaltyPecentage, address indexed executedBy);
event MinResolutionPeriodChanged(uint256 minResolutionPeriod, address indexed executedBy);
event MaxResolutionPeriodChanged(uint256 maxResolutionPeriod, address indexed executedBy);
event MinDisputePeriodChanged(uint256 minDisputePeriod, address indexed executedBy);
event MaxPremintedVouchersChanged(uint256 maxPremintedVouchers, address indexed executedBy);
Expand Down
30 changes: 18 additions & 12 deletions contracts/interfaces/handlers/IBosonAccountHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ interface IBosonAccountHandler is IBosonAccountEvents {
*
* Reverts if:
* - Caller is not the supplied admin or does not own supplied auth token
* - Caller is not the supplied assistant and clerk
* - Caller is not the supplied assistant
* - Supplied clerk is not a zero address
* - The sellers region of protocol is paused
* - Address values are zero address
* - Addresses are not unique to this seller
Expand Down Expand Up @@ -59,7 +60,8 @@ interface IBosonAccountHandler is IBosonAccountEvents {
* Emits a DisputeResolverCreated event if successful.
*
* Reverts if:
* - Caller is not the supplied admin, assistant and clerk
* - Caller is not the supplied admin and assistant
* - Supplied clerk is not a zero address
* - The dispute resolvers region of protocol is paused
* - Any address is zero address
* - Any address is not unique to this dispute resolver
Expand Down Expand Up @@ -98,18 +100,19 @@ interface IBosonAccountHandler is IBosonAccountEvents {
function createAgent(BosonTypes.Agent memory _agent) external;

/**
* @notice Updates treasury address, if changed. Puts admin, assistant, clerk and AuthToken in pending queue, if changed.
* @notice Updates treasury address, if changed. Puts admin, assistant and AuthToken in pending queue, if changed.
* Pending updates can be completed by calling the optInToSellerUpdate function.
* @dev Active flag passed in by caller will be ignored. The value from storage will be used.
*
* Emits a SellerUpdateApplied event if the seller has changed the treasury.
* Emits a SellerUpdatePending event if the seller has requested an update for admin, clerk, assistant, or auth token.
* Holder of new auth token and/or owner(s) of new addresses for admin, clerk, assistant must opt-in to the update.
* Emits a SellerUpdatePending event if the seller has requested an update for admin, assistant, or auth token.
* Holder of new auth token and/or owner(s) of new addresses for admin, assistant must opt-in to the update.
*
* Reverts if:
* - The sellers region of protocol is paused
* - Address values are zero address
* - Addresses are not unique to this seller
* - Supplied clerk is not a zero address
* - Caller address is not the admin address of the stored seller with no AuthToken
* - Caller is not the owner of the seller's stored AuthToken
* - Seller does not exist
Expand All @@ -135,6 +138,7 @@ interface IBosonAccountHandler is IBosonAccountEvents {
* - Caller is not the owner of the pending AuthToken being updated
* - No pending update exists for this seller
* - AuthTokenType is not unique to this seller
* - Seller tries to update the clerk
*
* @param _sellerId - seller id
* @param _fieldsToUpdate - fields to update, see SellerUpdateFields enum
Expand All @@ -161,7 +165,7 @@ interface IBosonAccountHandler is IBosonAccountEvents {
function updateBuyer(BosonTypes.Buyer memory _buyer) external;

/**
* @notice Updates treasury address, escalationResponsePeriod or metadataUri if changed. Puts admin, assistant and clerk in pending queue, if changed.
* @notice Updates treasury address, escalationResponsePeriod or metadataUri if changed. Puts admin and assistant in pending queue, if changed.
* Pending updates can be completed by calling the optInToDisputeResolverUpdate function.
*
* Update doesn't include DisputeResolverFees, allowed seller list or active flag.
Expand All @@ -172,13 +176,14 @@ interface IBosonAccountHandler is IBosonAccountEvents {
* @dev Active flag passed in by caller will be ignored. The value from storage will be used.
*
* Emits a DisputeResolverUpdated event if successful.
* Emits a DisputeResolverUpdatePending event if the dispute resolver has requested an update for admin, clerk or assistant.
* Owner(s) of new addresses for admin, clerk, assistant must opt-in to the update.
* Emits a DisputeResolverUpdatePending event if the dispute resolver has requested an update for admin or assistant.
* Owner(s) of new addresses for admin, assistant must opt-in to the update.
*
* Reverts if:
* - The dispute resolvers region of protocol is paused
* - Caller is not the admin address of the stored dispute resolver
* - Any address is not unique to this dispute resolver
* - Supplied clerk is not a zero address
* - Dispute resolver does not exist
* - EscalationResponsePeriod is invalid
* - No field has been updated or requested to be updated
Expand All @@ -197,6 +202,7 @@ interface IBosonAccountHandler is IBosonAccountEvents {
* - Addresses are not unique to this dispute resolver
* - Caller address is not pending update for the field being updated
* - No pending update exists for this dispute resolver
* - Dispute resolver tries to update the clerk
*
* @param _disputeResolverId - disputeResolver id
* @param _fieldsToUpdate - fields to update, see DisputeResolverUpdateFields enum
Expand Down Expand Up @@ -317,11 +323,11 @@ interface IBosonAccountHandler is IBosonAccountEvents {
) external view returns (bool exists, BosonTypes.Seller memory seller, BosonTypes.AuthToken memory authToken);

/**
* @notice Gets the details about a seller by an address associated with that seller: assistant, admin, or clerk address.
* @notice Gets the details about a seller by an address associated with that seller: assistant, or admin address.
* A seller will have either an admin address or an auth token.
* If seller's admin uses NFT Auth the seller should call `getSellerByAuthToken` instead.
*
* @param _associatedAddress - the address associated with the seller. Must be an assistant, admin, or clerk address.
* @param _associatedAddress - the address associated with the seller. Must be an assistant, or admin address.
* @return exists - the seller was found
* @return seller - the seller details. See {BosonTypes.Seller}
* @return authToken - optional AuthToken struct that specifies an AuthToken type and tokenId that the seller can use to do admin functions
Expand Down Expand Up @@ -378,9 +384,9 @@ interface IBosonAccountHandler is IBosonAccountEvents {
);

/**
* @notice Gets the details about a dispute resolver by an address associated with that dispute resolver: assistant, admin, or clerk address.
* @notice Gets the details about a dispute resolver by an address associated with that dispute resolver: assistant, or admin address.
*
* @param _associatedAddress - the address associated with the dispute resolver. Must be an assistant, admin, or clerk address.
* @param _associatedAddress - the address associated with the dispute resolver. Must be an assistant, or admin address.
* @return exists - the dispute resolver was found
* @return disputeResolver - the dispute resolver details. See {BosonTypes.DisputeResolver}
* @return disputeResolverFees - list of fees dispute resolver charges per token type. Zero address is native currency. See {BosonTypes.DisputeResolverFee}
Expand Down
22 changes: 21 additions & 1 deletion contracts/interfaces/handlers/IBosonConfigHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { IBosonConfigEvents } from "../events/IBosonConfigEvents.sol";
*
* @notice Handles management of configuration within the protocol.
*
* The ERC-165 identifier for this interface is: 0xe393ad01
* The ERC-165 identifier for this interface is: 0x25616ef5
*/
interface IBosonConfigHandler is IBosonConfigEvents {
/**
Expand Down Expand Up @@ -429,6 +429,26 @@ interface IBosonConfigHandler is IBosonConfigEvents {
*/
function getMaxRoyaltyPecentage() external view returns (uint16);

/**
* @notice Sets the minimum resolution period a seller can specify.
*
* Emits a MinResolutionPeriodChanged event.
*
* Reverts if _minResolutionPeriod is zero.
*
* @dev Caller must have ADMIN role.
*
* @param _minResolutionPeriod - the minimum resolution period that a {BosonTypes.Seller} can specify
*/
function setMinResolutionPeriod(uint256 _minResolutionPeriod) external;

/**
* @notice Gets the minimum resolution period a seller can specify.
*
* @return the minimum resolution period that a {BosonTypes.Seller} can specify
*/
function getMinResolutionPeriod() external view returns (uint256);

/**
* @notice Sets the maximum resolution period a seller can specify.
*
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/handlers/IBosonOfferHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface IBosonOfferHandler is IBosonOfferEvents {
* - 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 set to zero or above the maximum resolution 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
Expand Down Expand Up @@ -71,7 +71,7 @@ interface IBosonOfferHandler is IBosonOfferEvents {
* - 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 set to zero or above the maximum resolution 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
Expand Down
Loading

0 comments on commit eb336b0

Please sign in to comment.