/
DummyERC1155RoundsUpgradeable.sol
136 lines (125 loc) · 4.36 KB
/
DummyERC1155RoundsUpgradeable.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "../ERC1155RoundsUpgradeable.sol";
/**
* @dev Dummy contract test the management of mint rounds with {ERC1155RoundsUpgradeable}
* @author Interplanetary Lab <contact@interplanetary-lab.io>
*/
contract DummyERC1155RoundsUpgradeable is
ERC1155RoundsUpgradeable,
OwnableUpgradeable,
UUPSUpgradeable
{
/// Maximum supply of all contract
uint256 public constant MAX_SUPPLY = 11_111;
/// Number of tokens that a wallet can mint in a public round
uint256 public maxMintsPerWallet;
/**
* CONSTRUCTOR
*
* @custom:oz-upgrades-unsafe-allow constructor
*/
constructor() {
_disableInitializers();
}
/**
* @notice Initialize the contract
*/
function initialize() public initializer {
__ERC1155_init("uri");
__Ownable_init();
__UUPSUpgradeable_init();
maxMintsPerWallet = 3;
}
/**
* @notice Mint the `amount` of tokens in a public round.
*
* @dev Call {ERC721RoundsUpgradeable-_publicRoundMint}.
* @dev Requirements:
* - Total minted for the user during this round must be less than `maxMintsPerWallet`
* - View {ERC721RoundsUpgradeable-_publicRoundMint} requirements
*
* @param roundId The mint round index
* @param amount The number of tokens to mint
*/
function mint(uint256 roundId, uint256 amount) external payable virtual {
require(
totalMintedBy(msg.sender, roundId) + amount <= maxMintsPerWallet,
"Max allowed"
);
_publicRoundMint(msg.sender, roundId, amount);
}
/**
* @notice Mint the `amount` of tokens with the signature of the round validator.
*
* @dev Call {ERC721RoundsUpgradeable-_privateRoundMint}.
* @dev Requirements:
* - View {ERC721RoundsUpgradeable-_privateRoundMint} requirements
*
* @param roundId The mint round index
* @param amount The number of tokens to mint
* @param maxMint The maximum token that the user is allowed to mint in the round (verified in `sig`)
* @param payloadExpiration The maximum timestamp before the signature is considered invalid (verified in `sig`)
* @param sig The EC signature generated by the wave validator
*/
function privateMint(
uint256 roundId,
uint256 amount,
uint256 maxMint,
uint256 payloadExpiration,
bytes memory sig
) external payable virtual {
_privateRoundMint(
msg.sender,
roundId,
amount,
maxMint,
payloadExpiration,
sig
);
}
/**
* @dev Create or edit a round
*
* @dev Call {ERC721RoundsUpgradeable-_setupRound}.
* @dev Requirements:
* - msg.sender is owner of the contract
* - View {ERC721RoundsUpgradeable-_setupRound} requirements
*
* @param roundId The round identifier
* @param tokenId The token index
* @param supply Number of tokens that can be minted in this round. Can be 0 for no supply control.
* @param startTime The start date of the round in seconds
* @param duration The duration of the round in seconds. Can be 0 for no time limitation
* @param validator The address of the whitelist validator. Can be 'address(0)' for no whitelist
* @param price The price of the round in ETH (can be 0)
*/
function setupRound(
uint256 roundId,
uint256 tokenId,
uint32 supply,
uint64 startTime,
uint64 duration,
address validator,
uint256 price
) external virtual onlyOwner {
_setupRound(roundId, tokenId, supply, startTime, duration, validator, price);
}
/**
* @notice Check the max supply before the mint
*
* @param to The wallet to transfer new tokens
* @param amount The number of tokens to mint
*/
function _beforeMint(address to, uint256 tokenId, uint256 amount) internal virtual override {
require(_totalMinted[tokenId] + amount <= MAX_SUPPLY, "Supply exceeded");
super._beforeMint(to, tokenId, amount);
}
function _authorizeUpgrade(address newImplementation)
internal
override
onlyOwner
{}
}