@artblocks/contracts 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +27 -2
  2. package/artifacts/contracts/archive/GenArt721CoreV0.sol/Address.json +10 -0
  3. package/artifacts/contracts/archive/GenArt721CoreV0.sol/Counters.json +10 -0
  4. package/artifacts/contracts/archive/GenArt721CoreV0.sol/CustomERC721Metadata.json +425 -0
  5. package/artifacts/contracts/archive/GenArt721CoreV0.sol/ERC165.json +38 -0
  6. package/artifacts/contracts/archive/GenArt721CoreV0.sol/ERC721.json +322 -0
  7. package/artifacts/contracts/archive/GenArt721CoreV0.sol/ERC721Enumerable.json +384 -0
  8. package/artifacts/contracts/archive/GenArt721CoreV0.sol/ERC721ReceiverMock.json +101 -0
  9. package/artifacts/contracts/archive/GenArt721CoreV0.sol/GenArt721.json +1528 -0
  10. package/artifacts/contracts/archive/GenArt721CoreV0.sol/IERC165.json +32 -0
  11. package/artifacts/contracts/archive/GenArt721CoreV0.sol/IERC721.json +316 -0
  12. package/artifacts/contracts/archive/GenArt721CoreV0.sol/IERC721Enumerable.json +378 -0
  13. package/artifacts/contracts/archive/GenArt721CoreV0.sol/IERC721Receiver.json +47 -0
  14. package/artifacts/contracts/archive/GenArt721CoreV0.sol/SafeMath.json +10 -0
  15. package/artifacts/contracts/archive/GenArt721CoreV0.sol/Strings.json +10 -0
  16. package/artifacts/contracts/archive/GenArt721CoreV1.sol/Address.json +10 -0
  17. package/artifacts/contracts/archive/GenArt721CoreV1.sol/Counters.json +10 -0
  18. package/artifacts/contracts/archive/GenArt721CoreV1.sol/CustomERC721Metadata.json +425 -0
  19. package/artifacts/contracts/archive/GenArt721CoreV1.sol/ERC165.json +38 -0
  20. package/artifacts/contracts/archive/GenArt721CoreV1.sol/ERC721.json +322 -0
  21. package/artifacts/contracts/archive/GenArt721CoreV1.sol/ERC721Enumerable.json +384 -0
  22. package/artifacts/contracts/archive/GenArt721CoreV1.sol/GenArt721Core.json +1773 -0
  23. package/artifacts/contracts/archive/GenArt721CoreV1.sol/IERC165.json +32 -0
  24. package/artifacts/contracts/archive/GenArt721CoreV1.sol/IERC721.json +316 -0
  25. package/artifacts/contracts/archive/GenArt721CoreV1.sol/IERC721Enumerable.json +378 -0
  26. package/artifacts/contracts/archive/GenArt721CoreV1.sol/IERC721Receiver.json +47 -0
  27. package/artifacts/contracts/archive/GenArt721CoreV1.sol/Randomizer.json +26 -0
  28. package/artifacts/contracts/archive/GenArt721CoreV1.sol/SafeMath.json +10 -0
  29. package/artifacts/contracts/archive/GenArt721CoreV1.sol/Strings.json +10 -0
  30. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV0.sol/MinterDAExpV0.json +575 -0
  31. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV1.sol/MinterDAExpV1.json +463 -0
  32. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExp/MinterDAExpV2.sol/MinterDAExpV2.json +3 -3
  33. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExp/MinterDAExpV3.sol/MinterDAExpV3.json +3 -3
  34. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol/MinterDAExpSettlementV0.json +15 -15
  35. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV0.sol/MinterDALinV0.json +551 -0
  36. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV1.sol/MinterDALinV1.json +439 -0
  37. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDALin/MinterDALinV2.sol/MinterDALinV2.json +3 -3
  38. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDALin/MinterDALinV3.sol/MinterDALinV3.json +3 -3
  39. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV0.sol/MinterHolderV0.json +622 -0
  40. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV1.sol/MinterHolderV1.json +719 -0
  41. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV2.sol/MinterHolderV2.json +794 -0
  42. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterHolder/MinterHolderV3.sol/MinterHolderV3.json +3 -3
  43. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV0.sol/MinterMerkleV0.json +873 -0
  44. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV1.sol/MinterMerkleV1.json +932 -0
  45. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV2.sol/MinterMerkleV2.json +984 -0
  46. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterMerkle/MinterMerkleV3.sol/MinterMerkleV3.json +3 -3
  47. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterMerkle/MinterMerkleV4.sol/MinterMerkleV4.json +3 -3
  48. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV0.sol/MinterSetPriceV0.json +400 -0
  49. package/artifacts/contracts/{minter-suite/Minters/MinterSetPrice/deprecated → archive/minter-suite/Minters/MinterSetPrice}/MinterSetPriceV1.sol/MinterSetPriceV1.json +3 -3
  50. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPrice/MinterSetPriceV2.sol/MinterSetPriceV2.json +3 -3
  51. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPrice/MinterSetPriceV3.sol/MinterSetPriceV3.json +3 -3
  52. package/artifacts/contracts/{minter-suite/Minters/MinterSetPriceERC20/deprecated → archive/minter-suite/Minters/MinterSetPriceERC20}/MinterSetPriceERC20V0.sol/MinterSetPriceERC20V0.json +3 -3
  53. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V1.sol/MinterSetPriceERC20V1.json +349 -0
  54. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol/MinterSetPriceERC20V2.json +3 -3
  55. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol/MinterSetPriceERC20V3.json +3 -3
  56. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV0.sol/IFilteredMinterDAExpSettlementV0.json +12 -12
  57. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlement_Mixin.sol/IFilteredMinterDAExpSettlement_Mixin.json +161 -0
  58. package/artifacts/contracts/interfaces/0.8.x/IMinterBaseV0.sol/IMinterBaseV0.json +24 -0
  59. package/artifacts/contracts/interfaces/0.8.x/IMintingAPICoreV0.sol/IMintingAPICoreV0.json +185 -0
  60. package/artifacts/contracts/interfaces/0.8.x/IMintingAPIMinterV0.sol/IMintingAPIMinterV0.json +88 -0
  61. package/artifacts/contracts/minter-suite/Minters/MinterBase_v0_1_1.sol/MinterBase.json +24 -0
  62. package/artifacts/contracts/minter-suite/Minters/MinterDAExpSettlementV1.sol/MinterDAExpSettlementV1.json +1066 -0
  63. package/artifacts/contracts/minter-suite/Minters/MinterDAExpV4.sol/MinterDAExpV4.json +869 -0
  64. package/artifacts/contracts/minter-suite/Minters/MinterDALinV4.sol/MinterDALinV4.json +845 -0
  65. package/artifacts/contracts/minter-suite/Minters/MinterHolderV4.sol/MinterHolderV4.json +1113 -0
  66. package/artifacts/contracts/minter-suite/Minters/MinterMerkleV5.sol/MinterMerkleV5.json +1052 -0
  67. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20V4.sol/MinterSetPriceERC20V4.json +755 -0
  68. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceV4.sol/MinterSetPriceV4.json +684 -0
  69. package/artifacts/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol/GenArt721CoreV3_Engine_IncorrectCoreType.json +1817 -0
  70. package/contracts/archive/GenArt721CoreV0.sol +1621 -0
  71. package/contracts/archive/GenArt721CoreV1.sol +1577 -0
  72. package/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV0.sol +503 -0
  73. package/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV1.sol +442 -0
  74. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExp/MinterDAExpV2.sol +3 -3
  75. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExp/MinterDAExpV3.sol +3 -3
  76. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol +3 -3
  77. package/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV0.sol +450 -0
  78. package/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV1.sol +406 -0
  79. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDALin/MinterDALinV2.sol +3 -3
  80. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDALin/MinterDALinV3.sol +3 -3
  81. package/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV0.sol +540 -0
  82. package/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV1.sol +648 -0
  83. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterHolder/MinterHolderV2.sol +6 -6
  84. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterHolder/MinterHolderV3.sol +4 -4
  85. package/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV0.sol +523 -0
  86. package/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV1.sol +602 -0
  87. package/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV2.sol +679 -0
  88. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterMerkle/MinterMerkleV3.sol +4 -4
  89. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterMerkle/MinterMerkleV4.sol +4 -4
  90. package/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV0.sol +333 -0
  91. package/contracts/{minter-suite/Minters/MinterSetPrice/deprecated → archive/minter-suite/Minters/MinterSetPrice}/MinterSetPriceV1.sol +0 -0
  92. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPrice/MinterSetPriceV2.sol +3 -3
  93. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPrice/MinterSetPriceV3.sol +3 -3
  94. package/contracts/{minter-suite/Minters/MinterSetPriceERC20/deprecated → archive/minter-suite/Minters/MinterSetPriceERC20}/MinterSetPriceERC20V0.sol +0 -0
  95. package/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V1.sol +411 -0
  96. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol +3 -3
  97. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol +3 -3
  98. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV0.sol +4 -53
  99. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlement_Mixin.sol +62 -0
  100. package/contracts/interfaces/0.8.x/IMinterBaseV0.sol +20 -0
  101. package/contracts/interfaces/0.8.x/IMintingAPICoreV0.sol +62 -0
  102. package/contracts/interfaces/0.8.x/IMintingAPIMinterV0.sol +31 -0
  103. package/contracts/minter-suite/Minters/MinterBase_v0_1_1.sol +293 -0
  104. package/contracts/minter-suite/Minters/MinterDAExpSettlementV1.sol +1026 -0
  105. package/contracts/minter-suite/Minters/MinterDAExpV4.sol +572 -0
  106. package/contracts/minter-suite/Minters/MinterDALinV4.sol +525 -0
  107. package/contracts/minter-suite/Minters/MinterHolderV4.sol +752 -0
  108. package/contracts/minter-suite/Minters/MinterMerkleV5.sol +688 -0
  109. package/contracts/minter-suite/Minters/MinterSetPriceERC20V4.sol +451 -0
  110. package/contracts/minter-suite/Minters/MinterSetPriceV4.sol +352 -0
  111. package/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol +1979 -0
  112. package/package.json +1 -1
  113. package/artifacts/contracts/minter-suite/Minters/MinterHolder/MinterHolderV2.sol/MinterHolderV2.json +0 -794
@@ -0,0 +1,602 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Created By: Art Blocks Inc.
3
+
4
+ import "../../../../interfaces/0.8.x/IGenArt721CoreContractV3.sol";
5
+ import "../../../../interfaces/0.8.x/IMinterFilterV0.sol";
6
+ import "../../../../interfaces/0.8.x/IFilteredMinterMerkleV0.sol";
7
+
8
+ import "@openzeppelin-4.7/contracts/utils/cryptography/MerkleProof.sol";
9
+ import "@openzeppelin-4.7/contracts/token/ERC20/IERC20.sol";
10
+ import "@openzeppelin-4.7/contracts/security/ReentrancyGuard.sol";
11
+
12
+ pragma solidity 0.8.17;
13
+
14
+ /**
15
+ * @title Filtered Minter contract that allows tokens to be minted with ETH
16
+ * for addresses in a Merkle allowlist.
17
+ * This is designed to be used with IGenArt721CoreContractV3 contracts.
18
+ * @author Art Blocks Inc.
19
+ * @notice Privileged Roles and Ownership:
20
+ * This contract is designed to be managed, with limited powers.
21
+ * Privileged roles and abilities are controlled by the project's artist, which
22
+ * can be modified by the core contract's Admin ACL contract. Both of these
23
+ * roles hold extensive power and can modify minter details.
24
+ * Care must be taken to ensure that the admin ACL contract and artist
25
+ * addresses are secure behind a multi-sig or other access control mechanism.
26
+ * ----------------------------------------------------------------------------
27
+ * The following functions are restricted to a project's artist:
28
+ * - updateMerkleRoot
29
+ * - updatePricePerTokenInWei
30
+ * - setProjectInvocationsPerAddress
31
+ * ----------------------------------------------------------------------------
32
+ * Additional admin and artist privileged roles may be described on other
33
+ * contracts that this minter integrates with.
34
+ */
35
+ contract MinterMerkleV1 is ReentrancyGuard, IFilteredMinterMerkleV0 {
36
+ using MerkleProof for bytes32[];
37
+
38
+ /// Core contract address this minter interacts with
39
+ address public immutable genArt721CoreAddress;
40
+
41
+ /// This contract handles cores with interface IV3
42
+ IGenArt721CoreContractV3 private immutable genArtCoreContract;
43
+
44
+ /// Minter filter address this minter interacts with
45
+ address public immutable minterFilterAddress;
46
+
47
+ /// Minter filter this minter may interact with.
48
+ IMinterFilterV0 private immutable minterFilter;
49
+
50
+ /// minterType for this minter
51
+ string public constant minterType = "MinterMerkleV1";
52
+
53
+ /// project minter configuration keys used by this minter
54
+ bytes32 private constant CONFIG_MERKLE_ROOT = "merkleRoot";
55
+ bytes32 private constant CONFIG_USE_MAX_INVOCATIONS_PER_ADDRESS_OVERRIDE =
56
+ "useMaxMintsPerAddrOverride"; // shortened to fit in 32 bytes
57
+ bytes32 private constant CONFIG_MAX_INVOCATIONS_OVERRIDE =
58
+ "maxMintsPerAddrOverride"; // shortened to match format of previous key
59
+
60
+ uint256 constant ONE_MILLION = 1_000_000;
61
+
62
+ uint256 public constant DEFAULT_MAX_INVOCATIONS_PER_ADDRESS = 1;
63
+
64
+ struct ProjectConfig {
65
+ bool maxHasBeenInvoked;
66
+ bool priceIsConfigured;
67
+ // initial value is false, so by default, projects limit allowlisted
68
+ // addresses to a mint qty of `DEFAULT_MAX_INVOCATIONS_PER_ADDRESS`
69
+ bool useMaxInvocationsPerAddressOverride;
70
+ // a value of 0 means no limit
71
+ // (only used if `useMaxInvocationsPerAddressOverride` is true)
72
+ uint24 maxInvocationsPerAddressOverride;
73
+ uint24 maxInvocations;
74
+ uint256 pricePerTokenInWei;
75
+ }
76
+
77
+ mapping(uint256 => ProjectConfig) public projectConfig;
78
+
79
+ /// projectId => merkle root
80
+ mapping(uint256 => bytes32) public projectMerkleRoot;
81
+
82
+ /// projectId => purchaser address => qty of mints purchased for project
83
+ mapping(uint256 => mapping(address => uint256))
84
+ public projectUserMintInvocations;
85
+
86
+ modifier onlyArtist(uint256 _projectId) {
87
+ require(
88
+ msg.sender ==
89
+ genArtCoreContract.projectIdToArtistAddress(_projectId),
90
+ "Only Artist"
91
+ );
92
+ _;
93
+ }
94
+
95
+ /**
96
+ * @notice Initializes contract to be a Filtered Minter for
97
+ * `_minterFilter`, integrated with Art Blocks core contract
98
+ * at address `_genArt721Address`.
99
+ * @param _genArt721Address Art Blocks core contract address for
100
+ * which this contract will be a minter.
101
+ * @param _minterFilter Minter filter for which this will be a
102
+ * filtered minter.
103
+ */
104
+ constructor(
105
+ address _genArt721Address,
106
+ address _minterFilter
107
+ ) ReentrancyGuard() {
108
+ genArt721CoreAddress = _genArt721Address;
109
+ genArtCoreContract = IGenArt721CoreContractV3(_genArt721Address);
110
+ minterFilterAddress = _minterFilter;
111
+ minterFilter = IMinterFilterV0(_minterFilter);
112
+ require(
113
+ minterFilter.genArt721CoreAddress() == _genArt721Address,
114
+ "Illegal contract pairing"
115
+ );
116
+ // broadcast default max invocations per address for this minter
117
+ emit DefaultMaxInvocationsPerAddress(
118
+ DEFAULT_MAX_INVOCATIONS_PER_ADDRESS
119
+ );
120
+ }
121
+
122
+ /**
123
+ * @notice Update the Merkle root for project `_projectId`.
124
+ * @param _projectId Project ID to be updated.
125
+ * @param _root root of Merkle tree defining addresses allowed to mint
126
+ * on project `_projectId`.
127
+ */
128
+ function updateMerkleRoot(
129
+ uint256 _projectId,
130
+ bytes32 _root
131
+ ) external onlyArtist(_projectId) {
132
+ require(_root != bytes32(0), "Root must be provided");
133
+ projectMerkleRoot[_projectId] = _root;
134
+ emit ConfigValueSet(_projectId, CONFIG_MERKLE_ROOT, _root);
135
+ }
136
+
137
+ /**
138
+ * @notice Returns hashed address (to be used as merkle tree leaf).
139
+ * Included as a public function to enable users to calculate their hashed
140
+ * address in Solidity when generating proofs off-chain.
141
+ * @param _address address to be hashed
142
+ * @return bytes32 hashed address, via keccak256 (using encodePacked)
143
+ */
144
+ function hashAddress(address _address) public pure returns (bytes32) {
145
+ return keccak256(abi.encodePacked(_address));
146
+ }
147
+
148
+ /**
149
+ * @notice Verify if address is allowed to mint on project `_projectId`.
150
+ * @param _projectId Project ID to be checked.
151
+ * @param _proof Merkle proof for address.
152
+ * @param _address Address to check.
153
+ * @return inAllowlist true only if address is allowed to mint and valid
154
+ * Merkle proof was provided
155
+ */
156
+ function verifyAddress(
157
+ uint256 _projectId,
158
+ bytes32[] calldata _proof,
159
+ address _address
160
+ ) public view returns (bool) {
161
+ return
162
+ _proof.verifyCalldata(
163
+ projectMerkleRoot[_projectId],
164
+ hashAddress(_address)
165
+ );
166
+ }
167
+
168
+ /**
169
+ * @notice Sets maximum allowed invocations per allowlisted address for
170
+ * project `_project` to `limit`. If `limit` is set to 0, allowlisted
171
+ * addresses will be able to mint as many times as desired, until the
172
+ * project reaches its maximum invocations.
173
+ * Default is a value of 1 if never configured by artist.
174
+ * @param _projectId Project ID to toggle the mint limit.
175
+ * @param _maxInvocationsPerAddress Maximum allowed invocations per
176
+ * allowlisted address.
177
+ * @dev default value stated above must be updated if the value of
178
+ * CONFIG_USE_MAX_INVOCATIONS_PER_ADDRESS_OVERRIDE is changed.
179
+ */
180
+ function setProjectInvocationsPerAddress(
181
+ uint256 _projectId,
182
+ uint24 _maxInvocationsPerAddress
183
+ ) external onlyArtist(_projectId) {
184
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
185
+ // use override value instead of the contract's default
186
+ // @dev this never changes from true to false; default value is only
187
+ // used if artist has never configured project invocations per address
188
+ _projectConfig.useMaxInvocationsPerAddressOverride = true;
189
+ // update the override value
190
+ _projectConfig
191
+ .maxInvocationsPerAddressOverride = _maxInvocationsPerAddress;
192
+ // generic events
193
+ emit ConfigValueSet(
194
+ _projectId,
195
+ CONFIG_USE_MAX_INVOCATIONS_PER_ADDRESS_OVERRIDE,
196
+ true
197
+ );
198
+ emit ConfigValueSet(
199
+ _projectId,
200
+ CONFIG_MAX_INVOCATIONS_OVERRIDE,
201
+ uint256(_maxInvocationsPerAddress)
202
+ );
203
+ }
204
+
205
+ /**
206
+ * @notice Syncs local maximum invocations of project `_projectId` based on
207
+ * the value currently defined in the core contract. Only used for gas
208
+ * optimization of mints after maxInvocations has been reached.
209
+ * @param _projectId Project ID to set the maximum invocations for.
210
+ * @dev this enables gas reduction after maxInvocations have been reached -
211
+ * core contracts shall still enforce a maxInvocation check during mint.
212
+ * @dev function is intentionally not gated to any specific access control;
213
+ * it only syncs a local state variable to the core contract's state.
214
+ */
215
+ function setProjectMaxInvocations(uint256 _projectId) external {
216
+ uint256 maxInvocations;
217
+ (, maxInvocations, , , , ) = genArtCoreContract.projectStateData(
218
+ _projectId
219
+ );
220
+ // update storage with results
221
+ projectConfig[_projectId].maxInvocations = uint24(maxInvocations);
222
+ }
223
+
224
+ /**
225
+ * @notice Warning: Disabling purchaseTo is not supported on this minter.
226
+ * This method exists purely for interface-conformance purposes.
227
+ */
228
+ function togglePurchaseToDisabled(
229
+ uint256 _projectId
230
+ ) external view onlyArtist(_projectId) {
231
+ revert("Action not supported");
232
+ }
233
+
234
+ /**
235
+ * @notice projectId => has project reached its maximum number of
236
+ * invocations? Note that this returns a local cache of the core contract's
237
+ * state, and may be out of sync with the core contract. This is
238
+ * intentional, as it only enables gas optimization of mints after a
239
+ * project's maximum invocations has been reached. A false negative will
240
+ * only result in a gas cost increase, since the core contract will still
241
+ * enforce a maxInvocation check during minting. A false positive is not
242
+ * possible because the V3 core contract only allows maximum invocations
243
+ * to be reduced, not increased. Based on this rationale, we intentionally
244
+ * do not do input validation in this method as to whether or not the input
245
+ * `_projectId` is an existing project ID.
246
+ */
247
+ function projectMaxHasBeenInvoked(
248
+ uint256 _projectId
249
+ ) external view returns (bool) {
250
+ return projectConfig[_projectId].maxHasBeenInvoked;
251
+ }
252
+
253
+ /**
254
+ * @notice projectId => project's maximum number of invocations.
255
+ * Optionally synced with core contract value, for gas optimization.
256
+ * Note that this returns a local cache of the core contract's
257
+ * state, and may be out of sync with the core contract. This is
258
+ * intentional, as it only enables gas optimization of mints after a
259
+ * project's maximum invocations has been reached.
260
+ * @dev A number greater than the core contract's project max invocations
261
+ * will only result in a gas cost increase, since the core contract will
262
+ * still enforce a maxInvocation check during minting. A number less than
263
+ * the core contract's project max invocations is only possible when the
264
+ * project's max invocations have not been synced on this minter, since the
265
+ * V3 core contract only allows maximum invocations to be reduced, not
266
+ * increased. When this happens, the minter will enable minting, allowing
267
+ * the core contract to enforce the max invocations check. Based on this
268
+ * rationale, we intentionally do not do input validation in this method as
269
+ * to whether or not the input `_projectId` is an existing project ID.
270
+ */
271
+ function projectMaxInvocations(
272
+ uint256 _projectId
273
+ ) external view returns (uint256) {
274
+ return uint256(projectConfig[_projectId].maxInvocations);
275
+ }
276
+
277
+ /**
278
+ * @notice Updates this minter's price per token of project `_projectId`
279
+ * to be '_pricePerTokenInWei`, in Wei.
280
+ * This price supersedes any legacy core contract price per token value.
281
+ * @dev Note that it is intentionally supported here that the configured
282
+ * price may be explicitly set to `0`.
283
+ */
284
+ function updatePricePerTokenInWei(
285
+ uint256 _projectId,
286
+ uint256 _pricePerTokenInWei
287
+ ) external onlyArtist(_projectId) {
288
+ projectConfig[_projectId].pricePerTokenInWei = _pricePerTokenInWei;
289
+ projectConfig[_projectId].priceIsConfigured = true;
290
+ emit PricePerTokenInWeiUpdated(_projectId, _pricePerTokenInWei);
291
+ }
292
+
293
+ /**
294
+ * @notice Inactive function - requires Merkle proof to purchase.
295
+ */
296
+ function purchase(uint256) external payable returns (uint256) {
297
+ revert("Must provide Merkle proof");
298
+ }
299
+
300
+ /**
301
+ * @notice Inactive function - requires Merkle proof to purchase.
302
+ */
303
+ function purchaseTo(address, uint256) public payable returns (uint256) {
304
+ revert("Must provide Merkle proof");
305
+ }
306
+
307
+ /**
308
+ * @notice Purchases a token from project `_projectId`.
309
+ * @param _projectId Project ID to mint a token on.
310
+ * @param _proof Merkle proof.
311
+ * @return tokenId Token ID of minted token
312
+ */
313
+ function purchase(
314
+ uint256 _projectId,
315
+ bytes32[] calldata _proof
316
+ ) external payable returns (uint256 tokenId) {
317
+ tokenId = purchaseTo_K1L(msg.sender, _projectId, _proof);
318
+ return tokenId;
319
+ }
320
+
321
+ /**
322
+ * @notice gas-optimized version of purchase(uint256,bytes32[]).
323
+ */
324
+ function purchase_gD5(
325
+ uint256 _projectId,
326
+ bytes32[] calldata _proof
327
+ ) external payable returns (uint256 tokenId) {
328
+ tokenId = purchaseTo_K1L(msg.sender, _projectId, _proof);
329
+ return tokenId;
330
+ }
331
+
332
+ /**
333
+ * @notice Purchases a token from project `_projectId` and sets
334
+ * the token's owner to `_to`.
335
+ * @param _to Address to be the new token's owner.
336
+ * @param _projectId Project ID to mint a token on.
337
+ * @param _proof Merkle proof.
338
+ * @return tokenId Token ID of minted token
339
+ */
340
+ function purchaseTo(
341
+ address _to,
342
+ uint256 _projectId,
343
+ bytes32[] calldata _proof
344
+ ) external payable returns (uint256 tokenId) {
345
+ return purchaseTo_K1L(_to, _projectId, _proof);
346
+ }
347
+
348
+ /**
349
+ * @notice gas-optimized version of purchaseTo(address,uint256,bytes32[]).
350
+ */
351
+ function purchaseTo_K1L(
352
+ address _to,
353
+ uint256 _projectId,
354
+ bytes32[] calldata _proof
355
+ ) public payable nonReentrant returns (uint256 tokenId) {
356
+ // CHECKS
357
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
358
+
359
+ // Note that `maxHasBeenInvoked` is only checked here to reduce gas
360
+ // consumption after a project has been fully minted.
361
+ // `_projectConfig.maxHasBeenInvoked` is locally cached to reduce
362
+ // gas consumption, but if not in sync with the core contract's value,
363
+ // the core contract also enforces its own max invocation check during
364
+ // minting.
365
+ require(
366
+ !_projectConfig.maxHasBeenInvoked,
367
+ "Maximum number of invocations reached"
368
+ );
369
+
370
+ // load price of token into memory
371
+ uint256 _pricePerTokenInWei = _projectConfig.pricePerTokenInWei;
372
+
373
+ require(
374
+ msg.value >= _pricePerTokenInWei,
375
+ "Must send minimum value to mint!"
376
+ );
377
+
378
+ // require artist to have configured price of token on this minter
379
+ require(_projectConfig.priceIsConfigured, "Price not configured");
380
+
381
+ // no contract filter since Merkle tree controls allowed addresses
382
+
383
+ // require valid Merkle proof
384
+ require(
385
+ verifyAddress(_projectId, _proof, msg.sender),
386
+ "Invalid Merkle proof"
387
+ );
388
+
389
+ // limit mints per address by project
390
+ uint256 _maxProjectInvocationsPerAddress = _projectConfig
391
+ .useMaxInvocationsPerAddressOverride
392
+ ? _projectConfig.maxInvocationsPerAddressOverride
393
+ : DEFAULT_MAX_INVOCATIONS_PER_ADDRESS;
394
+
395
+ require(
396
+ projectUserMintInvocations[_projectId][msg.sender] <
397
+ _maxProjectInvocationsPerAddress ||
398
+ _maxProjectInvocationsPerAddress == 0,
399
+ "Maximum number of invocations per address reached"
400
+ );
401
+
402
+ // EFFECTS
403
+ // increment user's invocations for this project
404
+ unchecked {
405
+ // this will never overflow since user's invocations on a project
406
+ // are limited by the project's max invocations
407
+ projectUserMintInvocations[_projectId][msg.sender]++;
408
+ }
409
+
410
+ // mint token
411
+ tokenId = minterFilter.mint(_to, _projectId, msg.sender);
412
+
413
+ // okay if this underflows because if statement will always eval false.
414
+ // this is only for gas optimization (core enforces maxInvocations).
415
+ unchecked {
416
+ if (tokenId % ONE_MILLION == _projectConfig.maxInvocations - 1) {
417
+ _projectConfig.maxHasBeenInvoked = true;
418
+ }
419
+ }
420
+
421
+ // INTERACTIONS
422
+ _splitFundsETH(_projectId, _pricePerTokenInWei);
423
+
424
+ return tokenId;
425
+ }
426
+
427
+ /**
428
+ * @dev splits ETH funds between sender (if refund), foundation,
429
+ * artist, and artist's additional payee for a token purchased on
430
+ * project `_projectId`.
431
+ * @dev possible DoS during splits is acknowledged, and mitigated by
432
+ * business practices, including end-to-end testing on mainnet, and
433
+ * admin-accepted artist payment addresses.
434
+ */
435
+ function _splitFundsETH(
436
+ uint256 _projectId,
437
+ uint256 _pricePerTokenInWei
438
+ ) internal {
439
+ if (msg.value > 0) {
440
+ bool success_;
441
+ // send refund to sender
442
+ uint256 refund = msg.value - _pricePerTokenInWei;
443
+ if (refund > 0) {
444
+ (success_, ) = msg.sender.call{value: refund}("");
445
+ require(success_, "Refund failed");
446
+ }
447
+ // split remaining funds between foundation, artist, and artist's
448
+ // additional payee
449
+ (
450
+ uint256 artblocksRevenue_,
451
+ address payable artblocksAddress_,
452
+ uint256 artistRevenue_,
453
+ address payable artistAddress_,
454
+ uint256 additionalPayeePrimaryRevenue_,
455
+ address payable additionalPayeePrimaryAddress_
456
+ ) = genArtCoreContract.getPrimaryRevenueSplits(
457
+ _projectId,
458
+ _pricePerTokenInWei
459
+ );
460
+ // Art Blocks payment
461
+ if (artblocksRevenue_ > 0) {
462
+ (success_, ) = artblocksAddress_.call{value: artblocksRevenue_}(
463
+ ""
464
+ );
465
+ require(success_, "Art Blocks payment failed");
466
+ }
467
+ // artist payment
468
+ if (artistRevenue_ > 0) {
469
+ (success_, ) = artistAddress_.call{value: artistRevenue_}("");
470
+ require(success_, "Artist payment failed");
471
+ }
472
+ // additional payee payment
473
+ if (additionalPayeePrimaryRevenue_ > 0) {
474
+ (success_, ) = additionalPayeePrimaryAddress_.call{
475
+ value: additionalPayeePrimaryRevenue_
476
+ }("");
477
+ require(success_, "Additional Payee payment failed");
478
+ }
479
+ }
480
+ }
481
+
482
+ /**
483
+ * @notice projectId => maximum invocations per allowlisted address. If a
484
+ * a value of 0 is returned, there is no limit on the number of mints per
485
+ * allowlisted address.
486
+ * Default behavior is limit 1 mint per address.
487
+ * This value can be changed at any time by the artist.
488
+ * @dev default value stated above must be updated if the value of
489
+ * CONFIG_USE_MAX_INVOCATIONS_PER_ADDRESS_OVERRIDE is changed.
490
+ */
491
+ function projectMaxInvocationsPerAddress(
492
+ uint256 _projectId
493
+ ) public view returns (uint256) {
494
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
495
+ if (_projectConfig.useMaxInvocationsPerAddressOverride) {
496
+ return uint256(_projectConfig.maxInvocationsPerAddressOverride);
497
+ } else {
498
+ return DEFAULT_MAX_INVOCATIONS_PER_ADDRESS;
499
+ }
500
+ }
501
+
502
+ /**
503
+ * @notice Returns remaining invocations for a given address.
504
+ * If `projectLimitsMintInvocationsPerAddress` is false, individual
505
+ * addresses are only limited by the project's maximum invocations, and a
506
+ * dummy value of zero is returned for `mintInvocationsRemaining`.
507
+ * If `projectLimitsMintInvocationsPerAddress` is true, the quantity of
508
+ * remaining mint invocations for address `_address` is returned as
509
+ * `mintInvocationsRemaining`.
510
+ * Note that mint invocations per address can be changed at any time by the
511
+ * artist of a project.
512
+ * Also note that all mint invocations are limited by a project's maximum
513
+ * invocations as defined on the core contract. This function may return
514
+ * a value greater than the project's remaining invocations.
515
+ */
516
+ function projectRemainingInvocationsForAddress(
517
+ uint256 _projectId,
518
+ address _address
519
+ )
520
+ external
521
+ view
522
+ returns (
523
+ bool projectLimitsMintInvocationsPerAddress,
524
+ uint256 mintInvocationsRemaining
525
+ )
526
+ {
527
+ uint256 maxInvocationsPerAddress = projectMaxInvocationsPerAddress(
528
+ _projectId
529
+ );
530
+ if (maxInvocationsPerAddress == 0) {
531
+ // project does not limit mint invocations per address, so leave
532
+ // `projectLimitsMintInvocationsPerAddress` at solidity initial
533
+ // value of false. Also leave `mintInvocationsRemaining` at
534
+ // solidity initial value of zero, as indicated in this function's
535
+ // documentation.
536
+ } else {
537
+ projectLimitsMintInvocationsPerAddress = true;
538
+ uint256 userMintInvocations = projectUserMintInvocations[
539
+ _projectId
540
+ ][_address];
541
+ // if user has not reached max invocations per address, return
542
+ // remaining invocations
543
+ if (maxInvocationsPerAddress > userMintInvocations) {
544
+ unchecked {
545
+ // will never underflow due to the check above
546
+ mintInvocationsRemaining =
547
+ maxInvocationsPerAddress -
548
+ userMintInvocations;
549
+ }
550
+ }
551
+ // else user has reached their maximum invocations, so leave
552
+ // `mintInvocationsRemaining` at solidity initial value of zero
553
+ }
554
+ }
555
+
556
+ /**
557
+ * @notice Process proof for an address. Returns Merkle root. Included to
558
+ * enable users to easily verify a proof's validity.
559
+ * @param _proof Merkle proof for address.
560
+ * @param _address Address to process.
561
+ * @return merkleRoot Merkle root for `_address` and `_proof`
562
+ */
563
+ function processProofForAddress(
564
+ bytes32[] calldata _proof,
565
+ address _address
566
+ ) external pure returns (bytes32) {
567
+ return _proof.processProofCalldata(hashAddress(_address));
568
+ }
569
+
570
+ /**
571
+ * @notice Gets if price of token is configured, price of minting a
572
+ * token on project `_projectId`, and currency symbol and address to be
573
+ * used as payment. Supersedes any core contract price information.
574
+ * @param _projectId Project ID to get price information for.
575
+ * @return isConfigured true only if token price has been configured on
576
+ * this minter
577
+ * @return tokenPriceInWei current price of token on this minter - invalid
578
+ * if price has not yet been configured
579
+ * @return currencySymbol currency symbol for purchases of project on this
580
+ * minter. This minter always returns "ETH"
581
+ * @return currencyAddress currency address for purchases of project on
582
+ * this minter. This minter always returns null address, reserved for ether
583
+ */
584
+ function getPriceInfo(
585
+ uint256 _projectId
586
+ )
587
+ external
588
+ view
589
+ returns (
590
+ bool isConfigured,
591
+ uint256 tokenPriceInWei,
592
+ string memory currencySymbol,
593
+ address currencyAddress
594
+ )
595
+ {
596
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
597
+ isConfigured = _projectConfig.priceIsConfigured;
598
+ tokenPriceInWei = _projectConfig.pricePerTokenInWei;
599
+ currencySymbol = "ETH";
600
+ currencyAddress = address(0);
601
+ }
602
+ }