Skip to content

Commit 9f61af5

Browse files
Expose IClaimable interfaces from ERCXLazyMint bases (#245)
1 parent 849e186 commit 9f61af5

File tree

4 files changed

+105
-3
lines changed

4 files changed

+105
-3
lines changed

contracts/base/ERC1155LazyMint.sol

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import "../extension/Ownable.sol";
99
import "../extension/Royalty.sol";
1010
import "../extension/BatchMintMetadata.sol";
1111
import "../extension/LazyMint.sol";
12+
import "../extension/interface/IClaimableERC1155.sol";
1213

1314
import "../lib/TWStrings.sol";
1415

@@ -44,7 +45,16 @@ import "../lib/TWStrings.sol";
4445
*
4546
*/
4647

47-
contract ERC1155LazyMint is ERC1155, ContractMetadata, Ownable, Royalty, Multicall, BatchMintMetadata, LazyMint {
48+
contract ERC1155LazyMint is
49+
ERC1155,
50+
ContractMetadata,
51+
Ownable,
52+
Royalty,
53+
Multicall,
54+
BatchMintMetadata,
55+
LazyMint,
56+
IClaimableERC1155
57+
{
4858
using TWStrings for uint256;
4959

5060
/*//////////////////////////////////////////////////////////////
@@ -106,6 +116,7 @@ contract ERC1155LazyMint is ERC1155, ContractMetadata, Ownable, Royalty, Multica
106116
require(_tokenId < nextTokenIdToMint(), "invalid id");
107117

108118
_mint(_receiver, _tokenId, _quantity, "");
119+
emit TokensClaimed(msg.sender, _receiver, _tokenId, _quantity);
109120
}
110121

111122
/**

contracts/base/ERC721LazyMint.sol

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import "../extension/Ownable.sol";
99
import "../extension/Royalty.sol";
1010
import "../extension/BatchMintMetadata.sol";
1111
import "../extension/LazyMint.sol";
12+
import "../extension/interface/IClaimableERC721.sol";
1213

1314
import "../lib/TWStrings.sol";
1415

@@ -38,7 +39,16 @@ import "../lib/TWStrings.sol";
3839
* without paying the gas cost for actually minting the NFTs.
3940
*/
4041

41-
contract ERC721LazyMint is ERC721A, ContractMetadata, Multicall, Ownable, Royalty, BatchMintMetadata, LazyMint {
42+
contract ERC721LazyMint is
43+
ERC721A,
44+
ContractMetadata,
45+
Multicall,
46+
Ownable,
47+
Royalty,
48+
BatchMintMetadata,
49+
LazyMint,
50+
IClaimableERC721
51+
{
4252
using TWStrings for uint256;
4353

4454
/*//////////////////////////////////////////////////////////////
@@ -99,9 +109,10 @@ contract ERC721LazyMint is ERC721A, ContractMetadata, Multicall, Ownable, Royalt
99109
*/
100110
function claim(address _receiver, uint256 _quantity) public payable virtual {
101111
verifyClaim(msg.sender, _quantity); // add your claim verification logic by overriding this function
102-
112+
uint256 startTokenId = _currentIndex;
103113
require(_currentIndex + _quantity <= nextTokenIdToLazyMint, "Not enough lazy minted tokens.");
104114
_safeMint(_receiver, _quantity, "");
115+
emit TokensClaimed(msg.sender, _receiver, startTokenId, _quantity);
105116
}
106117

107118
/**
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.0;
3+
4+
interface IClaimableERC1155 {
5+
/// @dev Emitted when tokens are claimed
6+
event TokensClaimed(
7+
address indexed claimer,
8+
address indexed receiver,
9+
uint256 indexed tokenId,
10+
uint256 quantityClaimed
11+
);
12+
13+
/**
14+
* @notice Lets an address claim multiple lazy minted NFTs at once to a recipient.
15+
* Contract creators should override this function to create custom logic for claiming,
16+
* for e.g. price collection, allowlist, max quantity, etc.
17+
*
18+
* @dev The logic in the `verifyClaim` function determines whether the caller is authorized to mint NFTs.
19+
*
20+
* @param _receiver The recipient of the tokens to mint.
21+
* @param _tokenId The tokenId of the lazy minted NFT to mint.
22+
* @param _quantity The number of tokens to mint.
23+
*/
24+
function claim(
25+
address _receiver,
26+
uint256 _tokenId,
27+
uint256 _quantity
28+
) external payable;
29+
30+
/**
31+
* @notice Override this function to add logic for claim verification, based on conditions
32+
* such as allowlist, price, max quantity etc.
33+
*
34+
* @dev Checks a request to claim NFTs against a custom condition.
35+
*
36+
* @param _claimer Caller of the claim function.
37+
* @param _tokenId The tokenId of the lazy minted NFT to mint.
38+
* @param _quantity The number of NFTs being claimed.
39+
*/
40+
function verifyClaim(
41+
address _claimer,
42+
uint256 _tokenId,
43+
uint256 _quantity
44+
) external view;
45+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.0;
3+
4+
interface IClaimableERC721 {
5+
/// @dev Emitted when tokens are claimed
6+
event TokensClaimed(
7+
address indexed claimer,
8+
address indexed receiver,
9+
uint256 indexed startTokenId,
10+
uint256 quantityClaimed
11+
);
12+
13+
/**
14+
* @notice Lets an address claim multiple lazy minted NFTs at once to a recipient.
15+
* Contract creators should override this function to create custom logic for claiming,
16+
* for e.g. price collection, allowlist, max quantity, etc.
17+
*
18+
* @dev The logic in the `verifyClaim` function determines whether the caller is authorized to mint NFTs.
19+
*
20+
* @param _receiver The recipient of the NFT to mint.
21+
* @param _quantity The number of NFTs to mint.
22+
*/
23+
function claim(address _receiver, uint256 _quantity) external payable;
24+
25+
/**
26+
* @notice Override this function to add logic for claim verification, based on conditions
27+
* such as allowlist, price, max quantity etc.
28+
*
29+
* @dev Checks a request to claim NFTs against a custom condition.
30+
*
31+
* @param _claimer Caller of the claim function.
32+
* @param _quantity The number of NFTs being claimed.
33+
*/
34+
function verifyClaim(address _claimer, uint256 _quantity) external view;
35+
}

0 commit comments

Comments
 (0)