Skip to content

Commit f53ddec

Browse files
kumaryash90Krishang Nadgauda
andauthored
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 9 additions & 26 deletions
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

Lines changed: 3 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
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;

0 commit comments

Comments
 (0)