Skip to content

Commit f53ddec

Browse files
kumaryash90Krishang Nadgauda
and
Krishang Nadgauda
authored
Sigdrop size (#192)
* use string revert statements * revert back from custom errors to regular reverts * run prettier * update tests * expose totalMinted; size down contract accordingly * optimize totalMinted * run prettier Co-authored-by: Krishang Nadgauda <[email protected]>
1 parent 83b0e77 commit f53ddec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+99
-3165
lines changed

contracts/feature/ContractMetadata.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ abstract contract ContractMetadata is IContractMetadata {
1717
/// @dev Lets a contract admin set the URI for contract-level metadata.
1818
function setContractURI(string memory _uri) external override {
1919
if (!_canSetContractURI()) {
20-
revert ContractMetadata__NotAuthorized();
20+
revert("Not authorized");
2121
}
2222

2323
_setupContractURI(_uri);

contracts/feature/DelayedReveal.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ abstract contract DelayedReveal is IDelayedReveal {
2121
function getRevealURI(uint256 _batchId, bytes calldata _key) public view returns (string memory revealedURI) {
2222
bytes memory encryptedURI = encryptedBaseURI[_batchId];
2323
if (encryptedURI.length == 0) {
24-
revert DelayedReveal__NothingToReveal(_batchId);
24+
revert("Nothing to reveal");
2525
}
2626

2727
revealedURI = string(encryptDecrypt(encryptedURI, _key));

contracts/feature/DropSinglePhase.sol

+9-26
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ abstract contract DropSinglePhase is IDropSinglePhase {
3434
*/
3535
mapping(bytes32 => TWBitMaps.BitMap) private usedAllowlistSpot;
3636

37-
/*///////////////////////////////////////////////////////////////
38-
Errors
39-
//////////////////////////////////////////////////////////////*/
40-
4137
/*///////////////////////////////////////////////////////////////
4238
Drop logic
4339
//////////////////////////////////////////////////////////////*/
@@ -103,7 +99,7 @@ abstract contract DropSinglePhase is IDropSinglePhase {
10399
/// @dev Lets a contract admin set claim conditions.
104100
function setClaimConditions(ClaimCondition calldata _condition, bool _resetClaimEligibility) external override {
105101
if (!_canSetClaimConditions()) {
106-
revert DropSinglePhase__NotAuthorized();
102+
revert("Not authorized");
107103
}
108104

109105
bytes32 targetConditionId = conditionId;
@@ -115,7 +111,7 @@ abstract contract DropSinglePhase is IDropSinglePhase {
115111
}
116112

117113
if (supplyClaimedAlready > _condition.maxClaimableSupply) {
118-
revert DropSinglePhase__MaxSupplyClaimedAlready(supplyClaimedAlready);
114+
revert("max supply claimed already");
119115
}
120116

121117
claimCondition = ClaimCondition({
@@ -144,40 +140,27 @@ abstract contract DropSinglePhase is IDropSinglePhase {
144140
ClaimCondition memory currentClaimPhase = claimCondition;
145141

146142
if (_currency != currentClaimPhase.currency || _pricePerToken != currentClaimPhase.pricePerToken) {
147-
revert DropSinglePhase__InvalidCurrencyOrPrice(
148-
_currency,
149-
currentClaimPhase.currency,
150-
_pricePerToken,
151-
currentClaimPhase.pricePerToken
152-
);
143+
revert("Invalid price or currency");
153144
}
154145

155146
// If we're checking for an allowlist quantity restriction, ignore the general quantity restriction.
156147
if (
157148
_quantity == 0 ||
158149
(verifyMaxQuantityPerTransaction && _quantity > currentClaimPhase.quantityLimitPerTransaction)
159150
) {
160-
revert DropSinglePhase__InvalidQuantity();
151+
revert("Invalid quantity");
161152
}
162153

163154
if (currentClaimPhase.supplyClaimed + _quantity > currentClaimPhase.maxClaimableSupply) {
164-
revert DropSinglePhase__ExceedMaxClaimableSupply(
165-
currentClaimPhase.supplyClaimed,
166-
currentClaimPhase.maxClaimableSupply
167-
);
155+
revert("exceeds max supply");
168156
}
169157

170158
(uint256 lastClaimedAt, uint256 nextValidClaimTimestamp) = getClaimTimestamp(_claimer);
171159
if (
172160
currentClaimPhase.startTimestamp > block.timestamp ||
173161
(lastClaimedAt != 0 && block.timestamp < nextValidClaimTimestamp)
174162
) {
175-
revert DropSinglePhase__CannotClaimYet(
176-
block.timestamp,
177-
currentClaimPhase.startTimestamp,
178-
lastClaimedAt,
179-
nextValidClaimTimestamp
180-
);
163+
revert("cant claim yet");
181164
}
182165
}
183166

@@ -196,15 +179,15 @@ abstract contract DropSinglePhase is IDropSinglePhase {
196179
keccak256(abi.encodePacked(_claimer, _allowlistProof.maxQuantityInAllowlist))
197180
);
198181
if (!validMerkleProof) {
199-
revert DropSinglePhase__NotInWhitelist();
182+
revert("not in allowlist");
200183
}
201184

202185
if (usedAllowlistSpot[conditionId].get(merkleProofIndex)) {
203-
revert DropSinglePhase__ProofClaimed();
186+
revert("proof claimed");
204187
}
205188

206189
if (_allowlistProof.maxQuantityInAllowlist != 0 && _quantity > _allowlistProof.maxQuantityInAllowlist) {
207-
revert DropSinglePhase__InvalidQuantityProof(_allowlistProof.maxQuantityInAllowlist);
190+
revert("Invalid qty proof");
208191
}
209192
}
210193
}

contracts/feature/LazyMint.sol

+3-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ abstract contract LazyMint is ILazyMint {
2424
/// @dev Returns the id for the batch of tokens the given tokenId belongs to.
2525
function getBatchIdAtIndex(uint256 _index) public view returns (uint256) {
2626
if (_index >= getBaseURICount()) {
27-
revert LazyMint__InvalidIndex(_index);
27+
revert("Invalid index");
2828
}
2929
return batchIds[_index];
3030
}
@@ -40,7 +40,7 @@ abstract contract LazyMint is ILazyMint {
4040
}
4141
}
4242

43-
revert LazyMint__NoBatchIDForToken(_tokenId);
43+
revert("No batchId for token");
4444
}
4545

4646
/// @dev Returns the baseURI for a token. The intended metadata URI for the token is baseURI + tokenId.
@@ -53,8 +53,7 @@ abstract contract LazyMint is ILazyMint {
5353
return baseURI[indices[i]];
5454
}
5555
}
56-
57-
revert LazyMint__NoBaseURIForToken(_tokenId);
56+
revert("No baseURI for token");
5857
}
5958

6059
/// @dev Sets the base URI for the batch of tokens with the given batchId.

contracts/feature/Ownable.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ abstract contract Ownable is IOwnable {
1616
/// @dev Reverts if caller is not the owner.
1717
modifier onlyOwner() {
1818
if (msg.sender != _owner) {
19-
revert Ownable__NotAuthorized();
19+
revert("Not authorized");
2020
}
2121
_;
2222
}
@@ -29,7 +29,7 @@ abstract contract Ownable is IOwnable {
2929
/// @dev Lets a contract admin set a new owner for the contract. The new owner must be a contract admin.
3030
function setOwner(address _newOwner) external override {
3131
if (!_canSetOwner()) {
32-
revert Ownable__NotAuthorized();
32+
revert("Not authorized");
3333
}
3434
_setupOwner(_newOwner);
3535
}

contracts/feature/Permissions.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ contract Permissions is IPermissions {
3434
function grantRole(bytes32 role, address account) public virtual override {
3535
_checkRole(_getRoleAdmin[role], msg.sender);
3636
if (_hasRole[role][account]) {
37-
revert Permissions__CanOnlyGrantToNonHolders(account);
37+
revert("Can only grant to non holders");
3838
}
3939
_setupRole(role, account);
4040
}
@@ -46,7 +46,7 @@ contract Permissions is IPermissions {
4646

4747
function renounceRole(bytes32 role, address account) public virtual override {
4848
if (msg.sender != account) {
49-
revert Permissions__CanOnlyRenounceForSelf(msg.sender, account);
49+
revert("Can only renounce for self");
5050
}
5151
_revokeRole(role, account);
5252
}

contracts/feature/PlatformFee.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ abstract contract PlatformFee is IPlatformFee {
2424
/// @dev Lets a contract admin update the platform fee recipient and bps
2525
function setPlatformFeeInfo(address _platformFeeRecipient, uint256 _platformFeeBps) external override {
2626
if (!_canSetPlatformFeeInfo()) {
27-
revert PlatformFee__NotAuthorized();
27+
revert("Not authorized");
2828
}
2929
_setupPlatformFeeInfo(_platformFeeRecipient, _platformFeeBps);
3030
}
3131

3232
/// @dev Lets a contract admin update the platform fee recipient and bps
3333
function _setupPlatformFeeInfo(address _platformFeeRecipient, uint256 _platformFeeBps) internal {
3434
if (_platformFeeBps > 10_000) {
35-
revert PlatformFee__ExceedsMaxBps(_platformFeeBps);
35+
revert("Exceeds max bps");
3636
}
3737

3838
platformFeeBps = uint16(_platformFeeBps);

contracts/feature/PrimarySale.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ abstract contract PrimarySale is IPrimarySale {
2020
/// @dev Lets a contract admin set the recipient for all primary sales.
2121
function setPrimarySaleRecipient(address _saleRecipient) external override {
2222
if (!_canSetPrimarySaleRecipient()) {
23-
revert PrimarySale__NotAuthorized();
23+
revert("Not authorized");
2424
}
2525
_setupPrimarySaleRecipient(_saleRecipient);
2626
}

contracts/feature/Royalty.sol

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ abstract contract Royalty is IRoyalty {
5252
/// @dev Lets a contract admin update the default royalty recipient and bps.
5353
function setDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) external override {
5454
if (!_canSetRoyaltyInfo()) {
55-
revert Royalty__NotAuthorized();
55+
revert("Not authorized");
5656
}
5757

5858
_setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps);
@@ -61,7 +61,7 @@ abstract contract Royalty is IRoyalty {
6161
/// @dev Lets a contract admin update the default royalty recipient and bps.
6262
function _setupDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) internal {
6363
if (_royaltyBps > 10_000) {
64-
revert Royalty__ExceedsMaxBps(_royaltyBps);
64+
revert("Exceeds max bps");
6565
}
6666

6767
royaltyRecipient = _royaltyRecipient;
@@ -77,7 +77,7 @@ abstract contract Royalty is IRoyalty {
7777
uint256 _bps
7878
) external override {
7979
if (!_canSetRoyaltyInfo()) {
80-
revert Royalty__NotAuthorized();
80+
revert("Not authorized");
8181
}
8282

8383
_setupRoyaltyInfoForToken(_tokenId, _recipient, _bps);
@@ -90,7 +90,7 @@ abstract contract Royalty is IRoyalty {
9090
uint256 _bps
9191
) internal {
9292
if (_bps > 10_000) {
93-
revert Royalty__ExceedsMaxBps(_bps);
93+
revert("Exceeds max bps");
9494
}
9595

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

contracts/feature/SignatureMintERC721.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ abstract contract SignatureMintERC721 is EIP712, ISignatureMintERC721 {
3939
(success, signer) = verify(_req, _signature);
4040

4141
if (!success) {
42-
revert SignatureMintERC721__InvalidRequest();
42+
revert("Invalid req");
4343
}
4444

4545
if (_req.validityStartTimestamp > block.timestamp || block.timestamp > _req.validityEndTimestamp) {
46-
revert SignatureMintERC721__RequestExpired(block.timestamp);
46+
revert("Req expired");
4747
}
4848

4949
minted[_req.uid] = true;

contracts/feature/SignatureMintERC721Upgradeable.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ abstract contract SignatureMintERC721Upgradeable is Initializable, EIP712Upgrade
4343
(success, signer) = verify(_req, _signature);
4444

4545
if (!success) {
46-
revert SignatureMintERC721__InvalidRequest();
46+
revert("Invalid req");
4747
}
4848

4949
if (_req.validityStartTimestamp > block.timestamp || block.timestamp > _req.validityEndTimestamp) {
50-
revert SignatureMintERC721__RequestExpired(block.timestamp);
50+
revert("Req expired");
5151
}
5252

5353
minted[_req.uid] = true;

contracts/feature/interface/IContractMetadata.sol

-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,4 @@ interface IContractMetadata {
2020

2121
/// @dev Emitted when the contract URI is updated.
2222
event ContractURIUpdated(string prevURI, string newURI);
23-
24-
/// @dev Emitted when an unauthorized caller tries to set the contract metadata URI.
25-
error ContractMetadata__NotAuthorized();
2623
}

contracts/feature/interface/IDelayedReveal.sol

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ pragma solidity ^0.8.0;
77
*/
88

99
interface IDelayedReveal {
10-
/// @notice Emitted when encrypted URI for a given batch is empty.
11-
error DelayedReveal__NothingToReveal(uint256 batchId);
12-
1310
/**
1411
* @notice Reveals a batch of delayed reveal NFTs.
1512
*

contracts/feature/interface/IDropSinglePhase.sol

-37
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,6 @@ interface IDropSinglePhase is IClaimCondition {
99
uint256 maxQuantityInAllowlist;
1010
}
1111

12-
/// @dev Emitted when an unauthorized caller tries to set claim conditions.
13-
error DropSinglePhase__NotAuthorized();
14-
15-
/// @notice Emitted when given currency or price is invalid.
16-
error DropSinglePhase__InvalidCurrencyOrPrice(
17-
address givenCurrency,
18-
address requiredCurrency,
19-
uint256 givenPricePerToken,
20-
uint256 requiredPricePerToken
21-
);
22-
23-
/// @notice Emitted when claiming invalid quantity of tokens.
24-
error DropSinglePhase__InvalidQuantity();
25-
26-
/// @notice Emitted when claiming given quantity will exceed max claimable supply.
27-
error DropSinglePhase__ExceedMaxClaimableSupply(uint256 supplyClaimed, uint256 maxClaimableSupply);
28-
29-
/// @notice Emitted when the current timestamp is invalid for claim.
30-
error DropSinglePhase__CannotClaimYet(
31-
uint256 blockTimestamp,
32-
uint256 startTimestamp,
33-
uint256 lastClaimedAt,
34-
uint256 nextValidClaimTimestamp
35-
);
36-
37-
/// @notice Emitted when given allowlist proof is invalid.
38-
error DropSinglePhase__NotInWhitelist();
39-
40-
/// @notice Emitted when allowlist spot is already used.
41-
error DropSinglePhase__ProofClaimed();
42-
43-
/// @notice Emitted when claiming more than allowed quantity in allowlist.
44-
error DropSinglePhase__InvalidQuantityProof(uint256 maxQuantityInAllowlist);
45-
46-
/// @notice Emitted when max claimable supply in given condition is less than supply claimed already.
47-
error DropSinglePhase__MaxSupplyClaimedAlready(uint256 supplyClaimedAlready);
48-
4912
/// @dev Emitted when tokens are claimed via `claim`.
5013
event TokensClaimed(
5114
address indexed claimer,

contracts/feature/interface/ILazyMint.sol

-9
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@ pragma solidity ^0.8.0;
88
*/
99

1010
interface ILazyMint {
11-
/// @notice Emitted when the given index is equal to or higher than total number of batches.
12-
error LazyMint__InvalidIndex(uint256 index);
13-
14-
/// @notice Emitted when the given token ID doesn't belong to any batch.
15-
error LazyMint__NoBatchIDForToken(uint256 tokenId);
16-
17-
/// @notice Emitted when there's no Base URI set for the given token ID.
18-
error LazyMint__NoBaseURIForToken(uint256 tokenId);
19-
2011
/**
2112
* @notice Lazy mints a given amount of NFTs.
2213
*

contracts/feature/interface/IOwnable.sol

-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,4 @@ interface IOwnable {
1616

1717
/// @dev Emitted when a new Owner is set.
1818
event OwnerUpdated(address indexed prevOwner, address indexed newOwner);
19-
20-
/// @dev Emitted when an unauthorized caller tries to set the owner.
21-
error Ownable__NotAuthorized();
2219
}

contracts/feature/interface/IPermissions.sol

-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ pragma solidity ^0.8.0;
55
* @dev External interface of AccessControl declared to support ERC165 detection.
66
*/
77
interface IPermissions {
8-
/// @notice Emitted when calling address is different from the specified account.
9-
error Permissions__CanOnlyRenounceForSelf(address caller, address account);
10-
11-
/// @notice Emitted when specified account already has the role.
12-
error Permissions__CanOnlyGrantToNonHolders(address account);
13-
148
/**
159
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
1610
*

contracts/feature/interface/IPlatformFee.sol

-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ pragma solidity ^0.8.0;
88
*/
99

1010
interface IPlatformFee {
11-
/// @notice Emitted when given platform-fee bps exceeds max bps.
12-
error PlatformFee__ExceedsMaxBps(uint256 platformFeeBps);
13-
1411
/// @dev Returns the platform fee bps and recipient.
1512
function getPlatformFeeInfo() external view returns (address, uint16);
1613

@@ -19,7 +16,4 @@ interface IPlatformFee {
1916

2017
/// @dev Emitted when fee on primary sales is updated.
2118
event PlatformFeeInfoUpdated(address indexed platformFeeRecipient, uint256 platformFeeBps);
22-
23-
/// @dev Emitted when an unauthorized caller tries to set platform fee details.
24-
error PlatformFee__NotAuthorized();
2519
}

contracts/feature/interface/IPrimarySale.sol

-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,4 @@ interface IPrimarySale {
1616

1717
/// @dev Emitted when a new sale recipient is set.
1818
event PrimarySaleRecipientUpdated(address indexed recipient);
19-
20-
/// @dev Emitted when an unauthorized caller tries to set primary sales details.
21-
error PrimarySale__NotAuthorized();
2219
}

0 commit comments

Comments
 (0)