Skip to content

Commit 9a0c7b3

Browse files
kumaryash90Krishang Nadgauda
and
Krishang Nadgauda
authored
Sigdrop size additional (#193)
* use string revert statements * revert back from custom errors to regular reverts * run prettier * update tests * expose totalMinted; size down contract accordingly * public functions for contract type and version; reduce revert strings Co-authored-by: Krishang Nadgauda <[email protected]>
1 parent f53ddec commit 9a0c7b3

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

contracts/feature/DropSinglePhase.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ abstract contract DropSinglePhase is IDropSinglePhase {
111111
}
112112

113113
if (supplyClaimedAlready > _condition.maxClaimableSupply) {
114-
revert("max supply claimed already");
114+
revert("max supply claimed");
115115
}
116116

117117
claimCondition = ClaimCondition({

contracts/feature/LazyMint.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ abstract contract LazyMint is ILazyMint {
4040
}
4141
}
4242

43-
revert("No batchId for token");
43+
revert("Invalid tokenId");
4444
}
4545

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

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

contracts/signature-drop/SignatureDrop.sol

+12-7
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ contract SignatureDrop is
4949
State variables
5050
//////////////////////////////////////////////////////////////*/
5151

52-
bytes32 public contractType = bytes32("SignatureDrop");
53-
uint256 public contractVersion = 2;
54-
5552
/// @dev Only transfers to or from TRANSFER_ROLE holders are valid, when transfers are restricted.
5653
bytes32 private transferRole;
5754
/// @dev Only MINTER_ROLE holders can sign off on `MintRequest`s and lazy mint tokens.
@@ -138,6 +135,14 @@ contract SignatureDrop is
138135
}
139136
}
140137

138+
function contractType() public pure returns (bytes32) {
139+
return bytes32("SignatureDrop");
140+
}
141+
142+
function contractVersion() public pure returns (uint256) {
143+
return 2;
144+
}
145+
141146
/*///////////////////////////////////////////////////////////////
142147
Lazy minting + delayed-reveal logic
143148
//////////////////////////////////////////////////////////////*/
@@ -152,7 +157,7 @@ contract SignatureDrop is
152157
bytes calldata _encryptedBaseURI
153158
) external onlyRole(minterRole) returns (uint256 batchId) {
154159
if (_amount == 0) {
155-
revert("Minting zero amount");
160+
revert("Zero amt");
156161
}
157162

158163
uint256 startId = nextTokenIdToMint;
@@ -192,7 +197,7 @@ contract SignatureDrop is
192197
returns (address signer)
193198
{
194199
if (_req.quantity == 0) {
195-
revert("Minting zero amount");
200+
revert("Zero qty");
196201
}
197202

198203
uint256 tokenIdToMint = _currentIndex;
@@ -236,7 +241,7 @@ contract SignatureDrop is
236241
) internal view override {
237242
require(isTrustedForwarder(msg.sender) || _msgSender() == tx.origin, "BOT");
238243
if (_currentIndex + _quantity > nextTokenIdToMint) {
239-
revert("Not enough minted tokens.");
244+
revert("Not enough minted tokens");
240245
}
241246
}
242247

@@ -257,7 +262,7 @@ contract SignatureDrop is
257262

258263
if (_currency == CurrencyTransferLib.NATIVE_TOKEN) {
259264
if (msg.value != totalPrice) {
260-
revert("Must send total price.");
265+
revert("Must send total price");
261266
}
262267
}
263268

docs/SignatureDrop.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ function contractURI() external view returns (string)
164164
### contractVersion
165165

166166
```solidity
167-
function contractVersion() external view returns (uint256)
167+
function contractVersion() external pure returns (uint256)
168168
```
169169

170170

src/test/SignatureDrop.t.sol

+4-4
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ contract SignatureDropTest is BaseTest {
344344

345345
sigdrop.lazyMint(100, "ipfs://", "");
346346

347-
vm.expectRevert("No batchId for token");
347+
vm.expectRevert("Invalid tokenId");
348348
sigdrop.tokenURI(100);
349349

350350
vm.stopPrank();
@@ -744,7 +744,7 @@ contract SignatureDropTest is BaseTest {
744744
bytes memory signature = signMintRequest(mintrequest, privateKey);
745745
vm.startPrank(address(deployerSigner));
746746
vm.warp(mintrequest.validityStartTimestamp);
747-
vm.expectRevert("Must send total price.");
747+
vm.expectRevert("Must send total price");
748748
sigdrop.mintWithSignature{ value: 2 }(mintrequest, signature);
749749
vm.stopPrank();
750750
}
@@ -903,7 +903,7 @@ contract SignatureDropTest is BaseTest {
903903
vm.prank(deployerSigner);
904904
sigdrop.setClaimConditions(conditions[0], false);
905905

906-
vm.expectRevert("Not enough minted tokens.");
906+
vm.expectRevert("Not enough minted tokens");
907907
vm.prank(getActor(6), getActor(6));
908908
sigdrop.claim(receiver, 101, address(0), 0, alp, "");
909909
}
@@ -1082,7 +1082,7 @@ contract SignatureDropTest is BaseTest {
10821082
assertEq(uri, string(abi.encodePacked("ipfs://", "1")));
10831083

10841084
bytes memory newEncryptedURI = sigdrop.encryptDecrypt("ipfs://secret", "key");
1085-
vm.expectRevert("Minting zero amount");
1085+
vm.expectRevert("Zero amt");
10861086
sigdrop.lazyMint(0, "", newEncryptedURI);
10871087

10881088
vm.stopPrank();

0 commit comments

Comments
 (0)