Skip to content

Commit b93a720

Browse files
committed
trim require message
1 parent 8ea438c commit b93a720

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

contracts/drop/DropERC721.sol

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -392,13 +392,10 @@ contract DropERC721 is
392392

393393
uint256 lastConditionStartTimestamp;
394394
for (uint256 i = 0; i < _phases.length; i++) {
395-
require(
396-
i == 0 || lastConditionStartTimestamp < _phases[i].startTimestamp,
397-
"startTimestamp must be in ascending order."
398-
);
395+
require(i == 0 || lastConditionStartTimestamp < _phases[i].startTimestamp, "ST");
399396

400397
uint256 supplyClaimedAlready = claimCondition.phases[newStartIndex + i].supplyClaimed;
401-
require(supplyClaimedAlready < _phases[i].maxClaimableSupply, "max supply claimed already");
398+
require(supplyClaimedAlready < _phases[i].maxClaimableSupply, "MS");
402399

403400
claimCondition.phases[newStartIndex + i] = _phases[i];
404401
claimCondition.phases[newStartIndex + i].supplyClaimed = supplyClaimedAlready;
@@ -630,7 +627,7 @@ contract DropERC721 is
630627

631628
/// @dev Lets a contract admin set the global maximum supply for collection's NFTs.
632629
function setMaxTotalSupply(uint256 _maxTotalSupply) external onlyRole(DEFAULT_ADMIN_ROLE) {
633-
require(_maxTotalSupply < nextTokenIdToMint, "already minted more than desired max supply");
630+
require(_maxTotalSupply < nextTokenIdToMint, "MAX");
634631
maxTotalSupply = _maxTotalSupply;
635632
emit MaxTotalSupplyUpdated(_maxTotalSupply);
636633
}
@@ -646,7 +643,7 @@ contract DropERC721 is
646643
external
647644
onlyRole(DEFAULT_ADMIN_ROLE)
648645
{
649-
require(_royaltyBps <= MAX_BPS, "exceed royalty bps");
646+
require(_royaltyBps <= MAX_BPS, "MAX_BPS");
650647

651648
royaltyRecipient = _royaltyRecipient;
652649
royaltyBps = uint16(_royaltyBps);
@@ -660,7 +657,7 @@ contract DropERC721 is
660657
address _recipient,
661658
uint256 _bps
662659
) external onlyRole(DEFAULT_ADMIN_ROLE) {
663-
require(_bps <= MAX_BPS, "exceed royalty bps");
660+
require(_bps <= MAX_BPS, "MAX_BPS");
664661

665662
royaltyInfoForToken[_tokenId] = RoyaltyInfo({ recipient: _recipient, bps: _bps });
666663

@@ -682,7 +679,7 @@ contract DropERC721 is
682679

683680
/// @dev Lets a contract admin set a new owner for the contract. The new owner must be a contract admin.
684681
function setOwner(address _newOwner) external onlyRole(DEFAULT_ADMIN_ROLE) {
685-
require(hasRole(DEFAULT_ADMIN_ROLE, _newOwner), "new owner not contract admin.");
682+
require(hasRole(DEFAULT_ADMIN_ROLE, _newOwner), "!ADMIN");
686683
address _prevOwner = _owner;
687684
_owner = _newOwner;
688685

@@ -715,7 +712,7 @@ contract DropERC721 is
715712

716713
// if transfer is restricted on the contract, we still want to allow burning and minting
717714
if (!hasRole(TRANSFER_ROLE, address(0)) && from != address(0) && to != address(0)) {
718-
require(hasRole(TRANSFER_ROLE, from) || hasRole(TRANSFER_ROLE, to), "restricted to TRANSFER_ROLE holders");
715+
require(hasRole(TRANSFER_ROLE, from) || hasRole(TRANSFER_ROLE, to), "!TRANSFER_ROLE");
719716
}
720717
}
721718

contracts/marketplace/Marketplace.sol

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ contract Marketplace is
9999

100100
/// @dev Checks whether caller is a listing creator.
101101
modifier onlyListingCreator(uint256 _listingId) {
102-
require(listings[_listingId].tokenOwner == _msgSender(), "caller != listing owner");
102+
require(listings[_listingId].tokenOwner == _msgSender(), "!OWNER");
103103
_;
104104
}
105105

106106
/// @dev Checks whether a listing exists.
107107
modifier onlyExistingListing(uint256 _listingId) {
108-
require(listings[_listingId].assetContract != address(0), "listing DNE");
108+
require(listings[_listingId].assetContract != address(0), "DNE");
109109
_;
110110
}
111111

@@ -338,7 +338,7 @@ contract Marketplace is
338338
function cancelDirectListing(uint256 _listingId) external onlyListingCreator(_listingId) {
339339
Listing memory targetListing = listings[_listingId];
340340

341-
require(targetListing.listingType == ListingType.Direct, "not direct listing");
341+
require(targetListing.listingType == ListingType.Direct, "!DIRECT");
342342

343343
delete listings[_listingId];
344344

@@ -363,7 +363,7 @@ contract Marketplace is
363363
// Check whether the settled total price and currency to use are correct.
364364
require(
365365
_currency == targetListing.currency && _totalPrice == (targetListing.buyoutPricePerToken * _quantityToBuy),
366-
"invalid currency or price"
366+
"!PRICE"
367367
);
368368

369369
executeSale(
@@ -386,11 +386,8 @@ contract Marketplace is
386386
Offer memory targetOffer = offers[_listingId][_offeror];
387387
Listing memory targetListing = listings[_listingId];
388388

389-
require(
390-
_currency == targetOffer.currency && _pricePerToken == targetOffer.pricePerToken,
391-
"invalid currency or price"
392-
);
393-
require(targetOffer.expirationTimestamp > block.timestamp, "offer expired");
389+
require(_currency == targetOffer.currency && _pricePerToken == targetOffer.pricePerToken, "!PRICE");
390+
require(targetOffer.expirationTimestamp > block.timestamp, "EXPIRED");
394391

395392
delete offers[_listingId][_offeror];
396393

0 commit comments

Comments
 (0)