@artblocks/contracts 1.0.0 → 1.0.1

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 (68) hide show
  1. package/README.md +3 -9
  2. package/artifacts/contracts/AdminACLV1.sol/AdminACLV1.json +2 -2
  3. package/artifacts/contracts/BasicPolyptychRandomizerV0.sol/BasicPolyptychRandomizerV0.json +229 -0
  4. package/artifacts/contracts/BasicRandomizerV2.sol/BasicRandomizerV2.json +3 -3
  5. package/artifacts/contracts/GenArt721CoreV3.sol/GenArt721CoreV3.json +2 -2
  6. package/artifacts/contracts/GenArt721CoreV3_Engine.sol/GenArt721CoreV3_Engine.json +2 -2
  7. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV0.sol/MinterDAExpV0.json +2 -2
  8. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV1.sol/MinterDAExpV1.json +2 -2
  9. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV2.sol/MinterDAExpV2.json +2 -2
  10. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV3.sol/MinterDAExpV3.json +2 -2
  11. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol/MinterDAExpSettlementV0.json +2 -2
  12. package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterDAExpSettlement}/MinterDAExpSettlementV1.sol/MinterDAExpSettlementV1.json +3 -3
  13. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV0.sol/MinterDALinV0.json +2 -2
  14. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV1.sol/MinterDALinV1.json +2 -2
  15. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV2.sol/MinterDALinV2.json +2 -2
  16. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV3.sol/MinterDALinV3.json +2 -2
  17. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV0.sol/MinterHolderV0.json +2 -2
  18. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV1.sol/MinterHolderV1.json +2 -2
  19. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV2.sol/MinterHolderV2.json +2 -2
  20. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV3.sol/MinterHolderV3.json +2 -2
  21. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV0.sol/MinterMerkleV0.json +2 -2
  22. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV1.sol/MinterMerkleV1.json +2 -2
  23. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV2.sol/MinterMerkleV2.json +2 -2
  24. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV3.sol/MinterMerkleV3.json +2 -2
  25. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV4.sol/MinterMerkleV4.json +2 -2
  26. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV0.sol/MinterSetPriceV0.json +2 -2
  27. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV1.sol/MinterSetPriceV1.json +2 -2
  28. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV2.sol/MinterSetPriceV2.json +2 -2
  29. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV3.sol/MinterSetPriceV3.json +2 -2
  30. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V0.sol/MinterSetPriceERC20V0.json +2 -2
  31. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V1.sol/MinterSetPriceERC20V1.json +2 -2
  32. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol/MinterSetPriceERC20V2.json +2 -2
  33. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol/MinterSetPriceERC20V3.json +2 -2
  34. package/artifacts/contracts/explorations/GenArt721CoreV3_Explorations.sol/GenArt721CoreV3_Explorations.json +2 -2
  35. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV1.sol/IFilteredMinterDAExpSettlementV1.json +767 -0
  36. package/artifacts/contracts/interfaces/0.8.x/IMinterFilterV0.sol/IMinterFilterV0.json +6 -0
  37. package/artifacts/contracts/interfaces/0.8.x/IRandomizerPolyptychV0.sol/IRandomizerPolyptychV0.json +87 -0
  38. package/artifacts/contracts/interfaces/0.8.x/IRandomizerV2.sol/IRandomizerV2.json +1 -1
  39. package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV0.sol/MinterFilterV0.json +8 -2
  40. package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV1.sol/MinterFilterV1.json +34 -2
  41. package/artifacts/contracts/minter-suite/Minters/MinterDAExpSettlementV2.sol/MinterDAExpSettlementV2.json +1127 -0
  42. package/artifacts/contracts/minter-suite/Minters/MinterDAExpV4.sol/MinterDAExpV4.json +15 -2
  43. package/artifacts/contracts/minter-suite/Minters/MinterDALinV4.sol/MinterDALinV4.json +15 -2
  44. package/artifacts/contracts/minter-suite/Minters/MinterHolderV4.sol/MinterHolderV4.json +15 -2
  45. package/artifacts/contracts/minter-suite/Minters/MinterMerkleV5.sol/MinterMerkleV5.json +15 -2
  46. package/artifacts/contracts/minter-suite/Minters/MinterPolyptychV0.sol/IGenArt721CoreContractV3WithRandomizer.json +662 -0
  47. package/artifacts/contracts/minter-suite/Minters/MinterPolyptychV0.sol/MinterPolyptychV0.json +1268 -0
  48. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20V4.sol/MinterSetPriceERC20V4.json +15 -2
  49. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceV4.sol/MinterSetPriceV4.json +15 -2
  50. package/artifacts/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol/GenArt721CoreV3_Engine_IncorrectCoreType.json +2 -2
  51. package/artifacts/contracts/mock/RandomizerV2_NoAssignMock.sol/RandomizerV2_NoAssignMock.json +3 -3
  52. package/contracts/BasicPolyptychRandomizerV0.sol +126 -0
  53. package/contracts/BasicRandomizerV2.sol +3 -3
  54. package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterDAExpSettlement}/MinterDAExpSettlementV1.sol +4 -4
  55. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV1.sol +21 -0
  56. package/contracts/interfaces/0.8.x/IMinterFilterV0.sol +6 -0
  57. package/contracts/interfaces/0.8.x/IRandomizerPolyptychV0.sol +31 -0
  58. package/contracts/interfaces/0.8.x/IRandomizerV2.sol +5 -2
  59. package/contracts/minter-suite/MinterFilter/MinterFilterV1.sol +18 -0
  60. package/contracts/minter-suite/Minters/MinterDAExpSettlementV2.sol +1312 -0
  61. package/contracts/minter-suite/Minters/MinterDAExpV4.sol +32 -4
  62. package/contracts/minter-suite/Minters/MinterDALinV4.sol +32 -5
  63. package/contracts/minter-suite/Minters/MinterHolderV4.sol +35 -6
  64. package/contracts/minter-suite/Minters/MinterMerkleV5.sol +35 -6
  65. package/contracts/minter-suite/Minters/MinterPolyptychV0.sol +998 -0
  66. package/contracts/minter-suite/Minters/MinterSetPriceERC20V4.sol +35 -6
  67. package/contracts/minter-suite/Minters/MinterSetPriceV4.sol +32 -4
  68. package/package.json +8 -2
@@ -0,0 +1,998 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Created By: Art Blocks Inc.
3
+
4
+ import "../../interfaces/0.8.x/IGenArt721CoreContractV3_Engine.sol";
5
+ import "../../interfaces/0.8.x/IMinterFilterV0.sol";
6
+ import "../../interfaces/0.8.x/IFilteredMinterHolderV2.sol";
7
+ import "../../interfaces/0.8.x/IRandomizerPolyptychV0.sol";
8
+ import "../../interfaces/0.8.x/IDelegationRegistry.sol";
9
+ import "./MinterBase_v0_1_1.sol";
10
+
11
+ import "@openzeppelin-4.5/contracts/token/ERC721/IERC721.sol";
12
+ import "@openzeppelin-4.5/contracts/security/ReentrancyGuard.sol";
13
+ import "@openzeppelin-4.5/contracts/utils/structs/EnumerableSet.sol";
14
+
15
+ pragma solidity 0.8.17;
16
+
17
+ /**
18
+ * @title Core contract interface for accessing the randomizer from the minter
19
+ * @notice This interface provides the minter with access to the randomizer, allowing the
20
+ * token hash seed for a newly-minted token to be assigned by the minter if the artist
21
+ * has enabled the project as a polyptych. Polytptych projects must use the V3 engine
22
+ * core contract, polyptych minter, and polyptych randomizer - this interface allows the
23
+ * minter to access the randomizer.
24
+ */
25
+ interface IGenArt721CoreContractV3WithRandomizer is
26
+ IGenArt721CoreContractV3_Engine
27
+ {
28
+ /// current randomizer contract
29
+ function randomizerContract() external returns (IRandomizerPolyptychV0);
30
+ }
31
+
32
+ /**
33
+ * @title Filtered Minter contract that allows tokens to be minted with ETH or ERC20 tokens
34
+ * when purchaser owns an allowlisted ERC-721 NFT. This contract must be used with
35
+ * an accompanying randomizer contract that is configured to copy the token hash seed
36
+ * from the allowlisted token to a corresponding newly-minted token.
37
+ * The source token may only be used to mint one additional polyptych "panel" if the token
38
+ * has not yet been used to mint a panel with the currently configured panel ID. To add
39
+ * an additional panel to a project, the panel ID may be incremented for the project
40
+ * using the `incrementPolyptychProjectPanelId` function. Panel IDs for a project may only
41
+ * be incremented such that panels must be minted in the order of their panel ID. Tokens
42
+ * of the same project and panel ID may be minted in any order.
43
+ * This is designed to be used with IGenArt721CoreContractV3_Engine contracts with an
44
+ * active IPolyptychRandomizerV0 randomizer available for this minter to use.
45
+ * This minter requires both a properly configured engine core contract and polyptych
46
+ * randomizer in order to mint polyptych tokens.
47
+ * @author Art Blocks Inc.
48
+ * @notice Privileged Roles and Ownership:
49
+ * This contract is designed to be managed, with limited powers.
50
+ * Privileged roles and abilities are controlled by the core contract's Admin
51
+ * ACL contract and a project's artist. Both of these roles hold extensive
52
+ * power and can modify minter details.
53
+ * Care must be taken to ensure that the admin ACL contract and artist
54
+ * addresses are secure behind a multi-sig or other access control mechanism.
55
+ * ----------------------------------------------------------------------------
56
+ * The following functions are restricted to the core contract's Admin ACL
57
+ * contract:
58
+ * - registerNFTAddress
59
+ * - unregisterNFTAddress
60
+ * ----------------------------------------------------------------------------
61
+ * The following functions are restricted to a project's artist:
62
+ * - allowHoldersOfProjects
63
+ * - removeHoldersOfProjects
64
+ * - allowRemoveHoldersOfProjects
65
+ * - updatePricePerTokenInWei
66
+ * - updateProjectCurrencyInfo
67
+ * - setProjectMaxInvocations
68
+ * - manuallyLimitProjectMaxInvocations
69
+ * ----------------------------------------------------------------------------
70
+ * Additional admin and artist privileged roles may be described on other
71
+ * contracts that this minter integrates with.
72
+ * ----------------------------------------------------------------------------
73
+ * This contract allows gated minting with support for vaults to delegate minting
74
+ * privileges via an external delegation registry. This means a vault holding an
75
+ * allowed token can delegate minting privileges to a wallet that is not holding an
76
+ * allowed token, enabling the vault to remain air-gapped while still allowing minting.
77
+ * The delegation registry contract is responsible for managing these delegations,
78
+ * and is available at the address returned by the public immutable
79
+ * `delegationRegistryAddress`. At the time of writing, the delegation
80
+ * registry enables easy delegation configuring at https://delegate.cash/.
81
+ * Art Blocks does not guarentee the security of the delegation registry, and
82
+ * users should take care to ensure that the delegation registry is secure.
83
+ * Delegations must be configured by the vault owner prior to purchase. Supported
84
+ * delegation types include token-level, contract-level (via genArt721CoreAddress), or
85
+ * wallet-level delegation. Contract-level delegations must be configured for the core
86
+ * token contract as returned by the owned token's core contract address.
87
+ */
88
+ contract MinterPolyptychV0 is
89
+ ReentrancyGuard,
90
+ MinterBase,
91
+ IFilteredMinterHolderV2
92
+ {
93
+ // add Enumerable Set methods
94
+ using EnumerableSet for EnumerableSet.AddressSet;
95
+
96
+ /// Delegation registry address
97
+ address public immutable delegationRegistryAddress;
98
+
99
+ /// Delegation registry address
100
+ IDelegationRegistry private immutable delegationRegistryContract;
101
+
102
+ /// Core contract address this minter interacts with
103
+ address public immutable genArt721CoreAddress;
104
+
105
+ /// This contract handles cores with interface IV3
106
+ IGenArt721CoreContractV3WithRandomizer private immutable genArtCoreContract;
107
+
108
+ /// Minter filter address this minter interacts with
109
+ address public immutable minterFilterAddress;
110
+
111
+ /// Minter filter this minter may interact with.
112
+ IMinterFilterV0 private immutable minterFilter;
113
+
114
+ // Stores whether a panel with an ID has been minted for a given token hash seed
115
+ // panelId => hashSeed => panelIsMinted
116
+ mapping(uint256 => mapping(bytes12 => bool))
117
+ public polyptychPanelHashSeedIsMinted;
118
+
119
+ /// minterType for this minter
120
+ string public constant minterType = "MinterPolyptychV0";
121
+
122
+ /// minter version for this minter
123
+ string public constant minterVersion = "v0.1.0";
124
+
125
+ uint256 constant ONE_MILLION = 1_000_000;
126
+
127
+ struct ProjectConfig {
128
+ bool maxHasBeenInvoked;
129
+ bool priceIsConfigured;
130
+ uint24 maxInvocations;
131
+ uint24 polyptychPanelId;
132
+ address currencyAddress;
133
+ uint256 pricePerTokenInWei;
134
+ string currencySymbol;
135
+ }
136
+
137
+ mapping(uint256 => ProjectConfig) public projectConfig;
138
+
139
+ /// Set of core contracts allowed to be queried for token holders
140
+ EnumerableSet.AddressSet private _registeredNFTAddresses;
141
+
142
+ /**
143
+ * projectId => ownedNFTAddress => ownedNFTProjectIds => bool
144
+ * projects whose holders are allowed to purchase a token on `projectId`
145
+ */
146
+ mapping(uint256 => mapping(address => mapping(uint256 => bool)))
147
+ public allowedProjectHolders;
148
+
149
+ // modifier to restrict access to only AdminACL allowed calls
150
+ // @dev defers which ACL contract is used to the core contract
151
+ modifier onlyCoreAdminACL(bytes4 _selector) {
152
+ require(
153
+ genArtCoreContract.adminACLAllowed(
154
+ msg.sender,
155
+ address(this),
156
+ _selector
157
+ ),
158
+ "Only Core AdminACL allowed"
159
+ );
160
+ _;
161
+ }
162
+
163
+ modifier onlyArtist(uint256 _projectId) {
164
+ require(
165
+ msg.sender ==
166
+ genArtCoreContract.projectIdToArtistAddress(_projectId),
167
+ "Only Artist"
168
+ );
169
+ _;
170
+ }
171
+
172
+ /**
173
+ * @notice Initializes contract to be a Filtered Minter for
174
+ * `_minterFilter`, integrated with Art Blocks core contract
175
+ * at address `_genArt721Address`.
176
+ * @param _genArt721Address Art Blocks core contract for which this
177
+ * contract will be a minter.
178
+ * @param _minterFilter Minter filter for which
179
+ * this will a filtered minter.
180
+ * @param _delegationRegistryAddress Delegation registry contract address.
181
+ */
182
+ constructor(
183
+ address _genArt721Address,
184
+ address _minterFilter,
185
+ address _delegationRegistryAddress
186
+ ) ReentrancyGuard() MinterBase(_genArt721Address) {
187
+ genArt721CoreAddress = _genArt721Address;
188
+ genArtCoreContract = IGenArt721CoreContractV3WithRandomizer(
189
+ _genArt721Address
190
+ );
191
+ delegationRegistryAddress = _delegationRegistryAddress;
192
+ emit DelegationRegistryUpdated(_delegationRegistryAddress);
193
+ delegationRegistryContract = IDelegationRegistry(
194
+ _delegationRegistryAddress
195
+ );
196
+ minterFilterAddress = _minterFilter;
197
+ minterFilter = IMinterFilterV0(_minterFilter);
198
+ require(
199
+ minterFilter.genArt721CoreAddress() == _genArt721Address,
200
+ "Illegal contract pairing"
201
+ );
202
+ // currently, this minter only supports Engine V3 core contracts
203
+ require(MinterBase.isEngine, "Only supports V3 Engine core");
204
+ }
205
+
206
+ /**
207
+ * @notice Return whether or not a token has been used to mint a polyptych panel with the given ID
208
+ * @param _panelId The ID of the polyptych panel being checked
209
+ * @param _ownedNFTAddress ERC-721 NFT address holding the project token
210
+ * owned by msg.sender being used to prove right to purchase
211
+ * @param _ownedNFTTokenId ERC-721 NFT token ID owned by msg.sender being used
212
+ * to prove right to purchase
213
+ */
214
+ function polyptychPanelMintedWithToken(
215
+ uint24 _panelId,
216
+ address _ownedNFTAddress,
217
+ uint256 _ownedNFTTokenId
218
+ ) external view returns (bool panelMinted) {
219
+ bytes12 _tokenHash = IGenArt721CoreContractV3_Engine(_ownedNFTAddress)
220
+ .tokenIdToHashSeed(_ownedNFTTokenId);
221
+ require(_tokenHash != bytes32(0), "Invalid token hash seed");
222
+ return polyptychPanelHashSeedIsMinted[_panelId][_tokenHash];
223
+ }
224
+
225
+ /**
226
+ *
227
+ * @notice Registers holders of NFTs at address `_NFTAddress` to be
228
+ * considered for minting. New core address is assumed to follow syntax of:
229
+ * `projectId = tokenId / 1_000_000`
230
+ * @param _NFTAddress NFT core address to be registered.
231
+ */
232
+ function registerNFTAddress(
233
+ address _NFTAddress
234
+ ) external onlyCoreAdminACL(this.registerNFTAddress.selector) {
235
+ // check that core contract implements the `tokenIdToHashSeed` function
236
+ IGenArt721CoreContractV3WithRandomizer(_NFTAddress).tokenIdToHashSeed(
237
+ 0
238
+ );
239
+ _registeredNFTAddresses.add(_NFTAddress);
240
+ emit RegisteredNFTAddress(_NFTAddress);
241
+ }
242
+
243
+ /**
244
+ *
245
+ * @notice Unregisters holders of NFTs at address `_NFTAddress` to be
246
+ * considered for adding to future allowlists.
247
+ * @param _NFTAddress NFT core address to be unregistered.
248
+ */
249
+ function unregisterNFTAddress(
250
+ address _NFTAddress
251
+ ) external onlyCoreAdminACL(this.unregisterNFTAddress.selector) {
252
+ _registeredNFTAddresses.remove(_NFTAddress);
253
+ emit UnregisteredNFTAddress(_NFTAddress);
254
+ }
255
+
256
+ /**
257
+ * @notice Allows holders of NFTs at addresses `_ownedNFTAddressesAdd`,
258
+ * project IDs `_ownedNFTProjectIdsAdd` to mint on project `_projectId`.
259
+ * Also removes holders of NFTs at addresses `_ownedNFTAddressesRemove`,
260
+ * project IDs `_ownedNFTProjectIdsRemove` from minting on project
261
+ * `_projectId`.
262
+ * `_ownedNFTAddressesAdd` assumed to be aligned with
263
+ * `_ownedNFTProjectIdsAdd`.
264
+ * e.g. Allows holders of project `_ownedNFTProjectIdsAdd[0]` on token
265
+ * contract `_ownedNFTAddressesAdd[0]` to mint `_projectId`.
266
+ * `_ownedNFTAddressesRemove` also assumed to be aligned with
267
+ * `_ownedNFTProjectIdsRemove`.
268
+ * @param _projectId Project ID to enable minting on.
269
+ * @param _ownedNFTAddressesAdd NFT core addresses of projects to be
270
+ * allowlisted. Indexes must align with `_ownedNFTProjectIdsAdd`.
271
+ * @param _ownedNFTProjectIdsAdd Project IDs on `_ownedNFTAddressesAdd`
272
+ * whose holders shall be allowlisted to mint project `_projectId`. Indexes
273
+ * must align with `_ownedNFTAddressesAdd`.
274
+ * @param _ownedNFTAddressesRemove NFT core addresses of projects to be
275
+ * removed from allowlist. Indexes must align with
276
+ * `_ownedNFTProjectIdsRemove`.
277
+ * @param _ownedNFTProjectIdsRemove Project IDs on
278
+ * `_ownedNFTAddressesRemove` whose holders will be removed from allowlist
279
+ * to mint project `_projectId`. Indexes must align with
280
+ * `_ownedNFTAddressesRemove`.
281
+ * @dev if a project is included in both add and remove arrays, it will be
282
+ * removed.
283
+ */
284
+ function allowRemoveHoldersOfProjects(
285
+ uint256 _projectId,
286
+ address[] memory _ownedNFTAddressesAdd,
287
+ uint256[] memory _ownedNFTProjectIdsAdd,
288
+ address[] memory _ownedNFTAddressesRemove,
289
+ uint256[] memory _ownedNFTProjectIdsRemove
290
+ ) external onlyArtist(_projectId) {
291
+ allowHoldersOfProjects(
292
+ _projectId,
293
+ _ownedNFTAddressesAdd,
294
+ _ownedNFTProjectIdsAdd
295
+ );
296
+ removeHoldersOfProjects(
297
+ _projectId,
298
+ _ownedNFTAddressesRemove,
299
+ _ownedNFTProjectIdsRemove
300
+ );
301
+ }
302
+
303
+ /**
304
+ * @notice Syncs local maximum invocations of project `_projectId` based on
305
+ * the value currently defined in the core contract.
306
+ * @param _projectId Project ID to set the maximum invocations for.
307
+ * @dev this enables gas reduction after maxInvocations have been reached -
308
+ * core contracts shall still enforce a maxInvocation check during mint.
309
+ */
310
+ function setProjectMaxInvocations(uint256 _projectId) public {
311
+ uint256 maxInvocations;
312
+ uint256 invocations;
313
+ (invocations, maxInvocations, , , , ) = genArtCoreContract
314
+ .projectStateData(_projectId);
315
+ // update storage with results
316
+ projectConfig[_projectId].maxInvocations = uint24(maxInvocations);
317
+
318
+ // We need to ensure maxHasBeenInvoked is correctly set after manually syncing the
319
+ // local maxInvocations value with the core contract's maxInvocations value.
320
+ // This synced value of maxInvocations from the core contract will always be greater
321
+ // than or equal to the previous value of maxInvocations stored locally.
322
+ projectConfig[_projectId].maxHasBeenInvoked =
323
+ invocations == maxInvocations;
324
+
325
+ emit ProjectMaxInvocationsLimitUpdated(_projectId, maxInvocations);
326
+ }
327
+
328
+ /**
329
+ * @notice Manually sets the local maximum invocations of project `_projectId`
330
+ * with the provided `_maxInvocations`, checking that `_maxInvocations` is less
331
+ * than or equal to the value of project `_project_id`'s maximum invocations that is
332
+ * set on the core contract.
333
+ * @dev Note that a `_maxInvocations` of 0 can only be set if the current `invocations`
334
+ * value is also 0 and this would also set `maxHasBeenInvoked` to true, correctly short-circuiting
335
+ * this minter's purchase function, avoiding extra gas costs from the core contract's maxInvocations check.
336
+ * @param _projectId Project ID to set the maximum invocations for.
337
+ * @param _maxInvocations Maximum invocations to set for the project.
338
+ */
339
+ function manuallyLimitProjectMaxInvocations(
340
+ uint256 _projectId,
341
+ uint256 _maxInvocations
342
+ ) external onlyArtist(_projectId) {
343
+ // CHECKS
344
+ // ensure that the manually set maxInvocations is not greater than what is set on the core contract
345
+ uint256 maxInvocations;
346
+ uint256 invocations;
347
+ (invocations, maxInvocations, , , , ) = genArtCoreContract
348
+ .projectStateData(_projectId);
349
+ require(
350
+ _maxInvocations <= maxInvocations,
351
+ "Cannot increase project max invocations above core contract set project max invocations"
352
+ );
353
+ require(
354
+ _maxInvocations >= invocations,
355
+ "Cannot set project max invocations to less than current invocations"
356
+ );
357
+
358
+ // EFFECTS
359
+ // update storage with results
360
+ projectConfig[_projectId].maxInvocations = uint24(_maxInvocations);
361
+ // We need to ensure maxHasBeenInvoked is correctly set after manually setting the
362
+ // local maxInvocations value.
363
+ projectConfig[_projectId].maxHasBeenInvoked =
364
+ invocations == _maxInvocations;
365
+
366
+ emit ProjectMaxInvocationsLimitUpdated(_projectId, _maxInvocations);
367
+ }
368
+
369
+ /**
370
+ * @notice Updates this minter's price per token of project `_projectId`
371
+ * to be '_pricePerTokenInWei`, in Wei.
372
+ * This price supersedes any legacy core contract price per token value.
373
+ * @dev Note that it is intentionally supported here that the configured
374
+ * price may be explicitly set to `0`.
375
+ */
376
+ function updatePricePerTokenInWei(
377
+ uint256 _projectId,
378
+ uint256 _pricePerTokenInWei
379
+ ) external onlyArtist(_projectId) {
380
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
381
+ _projectConfig.pricePerTokenInWei = _pricePerTokenInWei;
382
+ _projectConfig.priceIsConfigured = true;
383
+ emit PricePerTokenInWeiUpdated(_projectId, _pricePerTokenInWei);
384
+
385
+ // sync local max invocations if not initially populated
386
+ // @dev if local max invocations and maxHasBeenInvoked are both
387
+ // initial values, we know they have not been populated.
388
+ if (
389
+ _projectConfig.maxInvocations == 0 &&
390
+ _projectConfig.maxHasBeenInvoked == false
391
+ ) {
392
+ setProjectMaxInvocations(_projectId);
393
+ }
394
+ }
395
+
396
+ /**
397
+ * @notice Updates payment currency of project `_projectId` to be
398
+ * `_currencySymbol` at address `_currencyAddress`.
399
+ * @param _projectId Project ID to update.
400
+ * @param _currencySymbol Currency symbol.
401
+ * @param _currencyAddress Currency address.
402
+ */
403
+ function updateProjectCurrencyInfo(
404
+ uint256 _projectId,
405
+ string memory _currencySymbol,
406
+ address _currencyAddress
407
+ ) external onlyArtist(_projectId) {
408
+ // require null address if symbol is "ETH"
409
+ require(
410
+ (keccak256(abi.encodePacked(_currencySymbol)) ==
411
+ keccak256(abi.encodePacked("ETH"))) ==
412
+ (_currencyAddress == address(0)),
413
+ "ETH is only null address"
414
+ );
415
+ projectConfig[_projectId].currencySymbol = _currencySymbol;
416
+ projectConfig[_projectId].currencyAddress = _currencyAddress;
417
+ emit ProjectCurrencyInfoUpdated(
418
+ _projectId,
419
+ _currencyAddress,
420
+ _currencySymbol
421
+ );
422
+ }
423
+
424
+ /**
425
+ * @notice Purchases a token from project `_projectId`.
426
+ * @param _projectId Project ID to mint a token on.
427
+ * @param _ownedNFTAddress ERC-721 NFT address holding the project token
428
+ * owned by msg.sender being used to prove right to purchase.
429
+ * @param _ownedNFTTokenId ERC-721 NFT token ID owned by msg.sender being used
430
+ * to prove right to purchase.
431
+ * @return tokenId Token ID of minted token
432
+ */
433
+ function purchase(
434
+ uint256 _projectId,
435
+ address _ownedNFTAddress,
436
+ uint256 _ownedNFTTokenId
437
+ ) external payable returns (uint256 tokenId) {
438
+ tokenId = purchaseTo_dlc(
439
+ msg.sender,
440
+ _projectId,
441
+ _ownedNFTAddress,
442
+ _ownedNFTTokenId,
443
+ address(0)
444
+ );
445
+ return tokenId;
446
+ }
447
+
448
+ /**
449
+ * @notice gas-optimized version of purchase(uint256,address,uint256).
450
+ */
451
+ function purchase_nnf(
452
+ uint256 _projectId,
453
+ address _ownedNFTAddress,
454
+ uint256 _ownedNFTTokenId
455
+ ) external payable returns (uint256 tokenId) {
456
+ tokenId = purchaseTo_dlc(
457
+ msg.sender,
458
+ _projectId,
459
+ _ownedNFTAddress,
460
+ _ownedNFTTokenId,
461
+ address(0)
462
+ );
463
+ return tokenId;
464
+ }
465
+
466
+ /**
467
+ * @notice Purchases a token from project `_projectId` and sets
468
+ * the token's owner to `_to`.
469
+ * @param _to Address to be the new token's owner.
470
+ * @param _projectId Project ID to mint a token on.
471
+ * @param _ownedNFTAddress ERC-721 NFT holding the project token owned by
472
+ * msg.sender being used to claim right to purchase.
473
+ * @param _ownedNFTTokenId ERC-721 NFT token ID owned by msg.sender being used
474
+ * to claim right to purchase.
475
+ * @return tokenId Token ID of minted token
476
+ */
477
+ function purchaseTo(
478
+ address _to,
479
+ uint256 _projectId,
480
+ address _ownedNFTAddress,
481
+ uint256 _ownedNFTTokenId
482
+ ) external payable returns (uint256 tokenId) {
483
+ return
484
+ purchaseTo_dlc(
485
+ _to,
486
+ _projectId,
487
+ _ownedNFTAddress,
488
+ _ownedNFTTokenId,
489
+ address(0)
490
+ );
491
+ }
492
+
493
+ /**
494
+ * @notice Purchases a token from project `_projectId` and sets
495
+ * the token's owner to `_to`, as a delegate, (the `msg.sender`)
496
+ * on behalf of an explicitly defined vault.
497
+ * @param _to Address to be the new token's owner.
498
+ * @param _projectId Project ID to mint a token on.
499
+ * @param _ownedNFTAddress ERC-721 NFT address holding the project token owned by
500
+ * _vault (or msg.sender if no _vault is provided) being used to claim right to purchase.
501
+ * @param _ownedNFTTokenId ERC-721 NFT token ID owned by _vault (or msg.sender if
502
+ * no _vault is provided) being used to claim right to purchase.
503
+ * @param _vault Vault being purchased on behalf of. Acceptable to be `address(0)` if no vault.
504
+ * @return tokenId Token ID of minted token
505
+ */
506
+ function purchaseTo(
507
+ address _to,
508
+ uint256 _projectId,
509
+ address _ownedNFTAddress,
510
+ uint256 _ownedNFTTokenId,
511
+ address _vault
512
+ ) external payable returns (uint256 tokenId) {
513
+ return
514
+ purchaseTo_dlc(
515
+ _to,
516
+ _projectId,
517
+ _ownedNFTAddress,
518
+ _ownedNFTTokenId,
519
+ _vault
520
+ );
521
+ }
522
+
523
+ /**
524
+ * @notice Inactive function - requires NFT ownership to purchase.
525
+ */
526
+ function purchase(uint256) external payable returns (uint256) {
527
+ revert("Must claim NFT ownership");
528
+ }
529
+
530
+ /**
531
+ * @notice Warning: Disabling purchaseTo is not supported on this minter.
532
+ * This method exists purely for interface-conformance purposes.
533
+ */
534
+ function togglePurchaseToDisabled(
535
+ uint256 _projectId
536
+ ) external view onlyArtist(_projectId) {
537
+ revert("Action not supported");
538
+ }
539
+
540
+ /**
541
+ * @notice projectId => has project reached its maximum number of
542
+ * invocations? Note that this returns a local cache of the core contract's
543
+ * state, and may be out of sync with the core contract. This is
544
+ * intentional, as it only enables gas optimization of mints after a
545
+ * project's maximum invocations has been reached. A false negative will
546
+ * only result in a gas cost increase, since the core contract will still
547
+ * enforce a maxInvocation check during minting. A false positive is not
548
+ * possible because the V3 core contract only allows maximum invocations
549
+ * to be reduced, not increased. Based on this rationale, we intentionally
550
+ * do not do input validation in this method as to whether or not the input
551
+ * `_projectId` is an existing project ID.
552
+ */
553
+ function projectMaxHasBeenInvoked(
554
+ uint256 _projectId
555
+ ) external view returns (bool) {
556
+ return projectConfig[_projectId].maxHasBeenInvoked;
557
+ }
558
+
559
+ /**
560
+ * @notice projectId => project's maximum number of invocations.
561
+ * Optionally synced with core contract value, for gas optimization.
562
+ * Note that this returns a local cache of the core contract's
563
+ * state, and may be out of sync with the core contract. This is
564
+ * intentional, as it only enables gas optimization of mints after a
565
+ * project's maximum invocations has been reached.
566
+ * @dev A number greater than the core contract's project max invocations
567
+ * will only result in a gas cost increase, since the core contract will
568
+ * still enforce a maxInvocation check during minting. A number less than
569
+ * the core contract's project max invocations is only possible when the
570
+ * project's max invocations have not been synced on this minter, since the
571
+ * V3 core contract only allows maximum invocations to be reduced, not
572
+ * increased. When this happens, the minter will enable minting, allowing
573
+ * the core contract to enforce the max invocations check. Based on this
574
+ * rationale, we intentionally do not do input validation in this method as
575
+ * to whether or not the input `_projectId` is an existing project ID.
576
+ */
577
+ function projectMaxInvocations(
578
+ uint256 _projectId
579
+ ) external view returns (uint256) {
580
+ return uint256(projectConfig[_projectId].maxInvocations);
581
+ }
582
+
583
+ /**
584
+ * @notice Gets your balance of the ERC-20 token currently set
585
+ * as the payment currency for project `_projectId`.
586
+ * @param _projectId Project ID to be queried.
587
+ * @return balance Balance of ERC-20
588
+ */
589
+ function getYourBalanceOfProjectERC20(
590
+ uint256 _projectId
591
+ ) external view returns (uint256 balance) {
592
+ balance = IERC20(projectConfig[_projectId].currencyAddress).balanceOf(
593
+ msg.sender
594
+ );
595
+ return balance;
596
+ }
597
+
598
+ /**
599
+ * @notice Gets your allowance for this minter of the ERC-20
600
+ * token currently set as the payment currency for project
601
+ * `_projectId`.
602
+ * @param _projectId Project ID to be queried.
603
+ * @return remaining Remaining allowance of ERC-20
604
+ */
605
+ function checkYourAllowanceOfProjectERC20(
606
+ uint256 _projectId
607
+ ) external view returns (uint256 remaining) {
608
+ remaining = IERC20(projectConfig[_projectId].currencyAddress).allowance(
609
+ msg.sender,
610
+ address(this)
611
+ );
612
+ return remaining;
613
+ }
614
+
615
+ /**
616
+ * @notice Gets quantity of NFT addresses registered on this minter.
617
+ * @return uint256 quantity of NFT addresses registered
618
+ */
619
+ function getNumRegisteredNFTAddresses() external view returns (uint256) {
620
+ return _registeredNFTAddresses.length();
621
+ }
622
+
623
+ /**
624
+ * @notice Get registered NFT core contract address at index `_index` of
625
+ * enumerable set.
626
+ * @param _index enumerable set index to query.
627
+ * @return NFTAddress NFT core contract address at index `_index`
628
+ * @dev index must be < quantity of registered NFT addresses
629
+ */
630
+ function getRegisteredNFTAddressAt(
631
+ uint256 _index
632
+ ) external view returns (address NFTAddress) {
633
+ return _registeredNFTAddresses.at(_index);
634
+ }
635
+
636
+ /**
637
+ * @notice Gets if price of token is configured, price of minting a
638
+ * token on project `_projectId`, and currency symbol and address to be
639
+ * used as payment. Supersedes any core contract price information.
640
+ * @param _projectId Project ID to get price information for.
641
+ * @return isConfigured true only if token price has been configured on
642
+ * this minter
643
+ * @return tokenPriceInWei current price of token on this minter - invalid
644
+ * if price has not yet been configured
645
+ * @return currencySymbol currency symbol for purchases of project on this
646
+ * minter. This minter always returns "ETH"
647
+ * @return currencyAddress currency address for purchases of project on
648
+ * this minter. This minter always returns null address, reserved for ether
649
+ */
650
+ function getPriceInfo(
651
+ uint256 _projectId
652
+ )
653
+ external
654
+ view
655
+ returns (
656
+ bool isConfigured,
657
+ uint256 tokenPriceInWei,
658
+ string memory currencySymbol,
659
+ address currencyAddress
660
+ )
661
+ {
662
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
663
+ isConfigured = _projectConfig.priceIsConfigured;
664
+ tokenPriceInWei = _projectConfig.pricePerTokenInWei;
665
+ currencyAddress = _projectConfig.currencyAddress;
666
+ if (currencyAddress == address(0)) {
667
+ // defaults to ETH
668
+ currencySymbol = "ETH";
669
+ } else {
670
+ currencySymbol = _projectConfig.currencySymbol;
671
+ }
672
+ }
673
+
674
+ /**
675
+ * @notice Inactive function - requires NFT ownership to purchase.
676
+ */
677
+ function purchaseTo(address, uint256) public payable returns (uint256) {
678
+ revert("Must claim NFT ownership");
679
+ }
680
+
681
+ /**
682
+ * @notice gas-optimized version of purchaseTo(address,uint256,address,uint256,address).
683
+ * @param _to Address to be the new token's owner.
684
+ * @param _projectId Project ID to mint a token on.
685
+ * @param _ownedNFTAddress ERC-721 NFT address holding the project token owned by _vault
686
+ * (or msg.sender if no _vault is provided) being used to claim right to purchase.
687
+ * @param _ownedNFTTokenId ERC-721 NFT token ID owned by _vault (or msg.sender if
688
+ * no _vault is provided) being used to claim right to purchase.
689
+ * @param _vault Vault being purchased on behalf of. Acceptable to be `address(0)` if no vault.
690
+ * @return tokenId Token ID of minted token
691
+ */
692
+ function purchaseTo_dlc(
693
+ address _to,
694
+ uint256 _projectId,
695
+ address _ownedNFTAddress,
696
+ uint256 _ownedNFTTokenId,
697
+ address _vault
698
+ ) public payable nonReentrant returns (uint256 tokenId) {
699
+ // CHECKS
700
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
701
+
702
+ // Note that `maxHasBeenInvoked` is only checked here to reduce gas
703
+ // consumption after a project has been fully minted.
704
+ // `_projectConfig.maxHasBeenInvoked` is locally cached to reduce
705
+ // gas consumption, but if not in sync with the core contract's value,
706
+ // the core contract also enforces its own max invocation check during
707
+ // minting.
708
+ require(
709
+ !_projectConfig.maxHasBeenInvoked,
710
+ "Maximum number of invocations reached"
711
+ );
712
+
713
+ // require artist to have configured price of token on this minter
714
+ require(_projectConfig.priceIsConfigured, "Price not configured");
715
+
716
+ // require token used to claim to be in set of allowlisted NFTs
717
+ require(
718
+ isAllowlistedNFT(_projectId, _ownedNFTAddress, _ownedNFTTokenId),
719
+ "Only allowlisted NFTs"
720
+ );
721
+
722
+ // NOTE: delegate-vault handling **begins here**.
723
+
724
+ // handle that the vault may be either the `msg.sender` in the case
725
+ // that there is not a true vault, or may be `_vault` if one is
726
+ // provided explicitly (and it is valid).
727
+ address vault = msg.sender;
728
+ if (_vault != address(0)) {
729
+ // If a vault is provided, it must be valid, otherwise throw rather
730
+ // than optimistically-minting with original `msg.sender`.
731
+ // Note, we do not check `checkDelegateForAll` or `checkDelegateForContract` as well,
732
+ // as they are known to be implicitly checked by calling `checkDelegateForToken`.
733
+ bool isValidVault = delegationRegistryContract
734
+ .checkDelegateForToken(
735
+ msg.sender, // delegate
736
+ _vault, // vault
737
+ _ownedNFTAddress, // contract
738
+ _ownedNFTTokenId // tokenId
739
+ );
740
+ require(isValidVault, "Invalid delegate-vault pairing");
741
+ vault = _vault;
742
+ }
743
+
744
+ // we need the new token ID in advance of the randomizer setting a token hash
745
+ (uint256 _invocations, , , , , ) = genArtCoreContract.projectStateData(
746
+ _projectId
747
+ );
748
+
749
+ address _artist = genArtCoreContract.projectIdToArtistAddress(
750
+ _projectId
751
+ );
752
+
753
+ uint256 _newTokenId = (_projectId * ONE_MILLION) + _invocations;
754
+
755
+ // EFFECTS
756
+
757
+ // we need to store the new token ID before it is minted so the randomizer can query it
758
+ IGenArt721CoreContractV3WithRandomizer _ownedNFTCoreContract = IGenArt721CoreContractV3WithRandomizer(
759
+ _ownedNFTAddress
760
+ );
761
+ bytes12 _targetHashSeed = _ownedNFTCoreContract.tokenIdToHashSeed(
762
+ _ownedNFTTokenId
763
+ );
764
+
765
+ _requireCurrentPanelIsMintedOnce(_projectId, _targetHashSeed);
766
+
767
+ genArtCoreContract.randomizerContract().setPolyptychHashSeed(
768
+ _newTokenId,
769
+ _targetHashSeed
770
+ );
771
+
772
+ // once mint() is called, the polyptych randomizer will either:
773
+ // 1) assign a random token hash
774
+ // 2) if configured, obtain the token hash from the `polyptychSeedHashes` mapping
775
+ tokenId = minterFilter.mint(_to, _projectId, vault);
776
+
777
+ // NOTE: delegate-vault handling **ends here**.
778
+
779
+ // redundant check against reentrancy
780
+ bytes12 _assignedHashSeed = genArtCoreContract.tokenIdToHashSeed(
781
+ tokenId
782
+ );
783
+ require(
784
+ _assignedHashSeed == _targetHashSeed,
785
+ "Unexpected token hash seed"
786
+ );
787
+
788
+ // invocation is token number plus one, and will never overflow due to
789
+ // limit of 1e6 invocations per project. block scope for gas efficiency
790
+ // (i.e. avoid an unnecessary var initialization to 0).
791
+ unchecked {
792
+ uint256 tokenInvocation = (tokenId % ONE_MILLION) + 1;
793
+ uint256 localMaxInvocations = _projectConfig.maxInvocations;
794
+ // handle the case where the token invocation == minter local max
795
+ // invocations occurred on a different minter, and we have a stale
796
+ // local maxHasBeenInvoked value returning a false negative.
797
+ // @dev this is a CHECK after EFFECTS, so security was considered
798
+ // in detail here.
799
+ require(
800
+ tokenInvocation <= localMaxInvocations,
801
+ "Maximum invocations reached"
802
+ );
803
+ // in typical case, update the local maxHasBeenInvoked value
804
+ // to true if the token invocation == minter local max invocations
805
+ // (enables gas efficient reverts after sellout)
806
+ if (tokenInvocation == localMaxInvocations) {
807
+ _projectConfig.maxHasBeenInvoked = true;
808
+ }
809
+ }
810
+
811
+ // INTERACTIONS
812
+ // require sender to own NFT used to redeem
813
+ /**
814
+ * @dev Considered an interaction because calling ownerOf on an NFT
815
+ * contract. Plan is to only register AB/PBAB NFTs on the minter, but
816
+ * in case other NFTs are registered, better to check here. Also,
817
+ * function is non-reentrant, so being extra cautious.
818
+ */
819
+ if (msg.sender == _artist) {
820
+ require(
821
+ IERC721(_ownedNFTAddress).ownerOf(_ownedNFTTokenId) == _to,
822
+ "Only owner of NFT"
823
+ );
824
+ } else {
825
+ require(
826
+ IERC721(_ownedNFTAddress).ownerOf(_ownedNFTTokenId) == vault,
827
+ "Only owner of NFT"
828
+ );
829
+ }
830
+
831
+ // split funds
832
+ uint256 pricePerTokenInWei = _projectConfig.pricePerTokenInWei;
833
+ address currencyAddress = _projectConfig.currencyAddress;
834
+ if (currencyAddress != address(0)) {
835
+ require(
836
+ msg.value == 0,
837
+ "this project accepts a different currency and cannot accept ETH"
838
+ );
839
+ require(
840
+ IERC20(currencyAddress).allowance(msg.sender, address(this)) >=
841
+ pricePerTokenInWei,
842
+ "Insufficient Funds Approved for TX"
843
+ );
844
+ require(
845
+ IERC20(currencyAddress).balanceOf(msg.sender) >=
846
+ pricePerTokenInWei,
847
+ "Insufficient balance."
848
+ );
849
+ splitFundsERC20(
850
+ _projectId,
851
+ pricePerTokenInWei,
852
+ currencyAddress,
853
+ genArt721CoreAddress
854
+ );
855
+ } else {
856
+ require(
857
+ msg.value >= pricePerTokenInWei,
858
+ "Must send minimum value to mint!"
859
+ );
860
+ splitFundsETH(_projectId, pricePerTokenInWei, genArt721CoreAddress);
861
+ }
862
+
863
+ return tokenId;
864
+ }
865
+
866
+ /**
867
+ * @notice Allows holders of NFTs at addresses `_ownedNFTAddresses`,
868
+ * project IDs `_ownedNFTProjectIds` to mint on project `_projectId`.
869
+ * `_ownedNFTAddresses` assumed to be aligned with `_ownedNFTProjectIds`.
870
+ * e.g. Allows holders of project `_ownedNFTProjectIds[0]` on token
871
+ * contract `_ownedNFTAddresses[0]` to mint `_projectId`.
872
+ * @param _projectId Project ID to enable minting on.
873
+ * @param _ownedNFTAddresses NFT core addresses of projects to be
874
+ * allowlisted. Indexes must align with `_ownedNFTProjectIds`.
875
+ * @param _ownedNFTProjectIds Project IDs on `_ownedNFTAddresses` whose
876
+ * holders shall be allowlisted to mint project `_projectId`. Indexes must
877
+ * align with `_ownedNFTAddresses`.
878
+ */
879
+ function allowHoldersOfProjects(
880
+ uint256 _projectId,
881
+ address[] memory _ownedNFTAddresses,
882
+ uint256[] memory _ownedNFTProjectIds
883
+ ) public onlyArtist(_projectId) {
884
+ // require same length arrays
885
+ require(
886
+ _ownedNFTAddresses.length == _ownedNFTProjectIds.length,
887
+ "Length of add arrays must match"
888
+ );
889
+ // for each approved project
890
+ for (uint256 i = 0; i < _ownedNFTAddresses.length; i++) {
891
+ // ensure registered address
892
+ require(
893
+ _registeredNFTAddresses.contains(_ownedNFTAddresses[i]),
894
+ "Only Registered NFT Addresses"
895
+ );
896
+ // approve
897
+ allowedProjectHolders[_projectId][_ownedNFTAddresses[i]][
898
+ _ownedNFTProjectIds[i]
899
+ ] = true;
900
+ }
901
+ // emit approve event
902
+ emit AllowedHoldersOfProjects(
903
+ _projectId,
904
+ _ownedNFTAddresses,
905
+ _ownedNFTProjectIds
906
+ );
907
+ }
908
+
909
+ /**
910
+ * @notice Removes holders of NFTs at addresses `_ownedNFTAddresses`,
911
+ * project IDs `_ownedNFTProjectIds` to mint on project `_projectId`. If
912
+ * other projects owned by a holder are still allowed to mint, holder will
913
+ * maintain ability to purchase.
914
+ * `_ownedNFTAddresses` assumed to be aligned with `_ownedNFTProjectIds`.
915
+ * e.g. Removes holders of project `_ownedNFTProjectIds[0]` on token
916
+ * contract `_ownedNFTAddresses[0]` from mint allowlist of `_projectId`.
917
+ * @param _projectId Project ID to enable minting on.
918
+ * @param _ownedNFTAddresses NFT core addresses of projects to be removed
919
+ * from allowlist. Indexes must align with `_ownedNFTProjectIds`.
920
+ * @param _ownedNFTProjectIds Project IDs on `_ownedNFTAddresses` whose
921
+ * holders will be removed from allowlist to mint project `_projectId`.
922
+ * Indexes must align with `_ownedNFTAddresses`.
923
+ */
924
+ function removeHoldersOfProjects(
925
+ uint256 _projectId,
926
+ address[] memory _ownedNFTAddresses,
927
+ uint256[] memory _ownedNFTProjectIds
928
+ ) public onlyArtist(_projectId) {
929
+ // require same length arrays
930
+ require(
931
+ _ownedNFTAddresses.length == _ownedNFTProjectIds.length,
932
+ "Length of remove arrays must match"
933
+ );
934
+ // for each removed project
935
+ for (uint256 i = 0; i < _ownedNFTAddresses.length; i++) {
936
+ // revoke
937
+ allowedProjectHolders[_projectId][_ownedNFTAddresses[i]][
938
+ _ownedNFTProjectIds[i]
939
+ ] = false;
940
+ }
941
+ // emit removed event
942
+ emit RemovedHoldersOfProjects(
943
+ _projectId,
944
+ _ownedNFTAddresses,
945
+ _ownedNFTProjectIds
946
+ );
947
+ }
948
+
949
+ /**
950
+ * @notice Allows the artist to increment the minter to the next polyptych panel
951
+ * @param _projectId Project ID to increment to its next polyptych panel
952
+ */
953
+ function incrementPolyptychProjectPanelId(
954
+ uint256 _projectId
955
+ ) public onlyArtist(_projectId) {
956
+ projectConfig[_projectId].polyptychPanelId++;
957
+ }
958
+
959
+ /**
960
+ * @notice Returns if token is an allowlisted NFT for project `_projectId`.
961
+ * @param _projectId Project ID to be checked.
962
+ * @param _ownedNFTAddress ERC-721 NFT token address to be checked.
963
+ * @param _ownedNFTTokenId ERC-721 NFT token ID to be checked.
964
+ * @return bool Token is allowlisted
965
+ * @dev does not check if token has been used to purchase
966
+ * @dev assumes project ID can be derived from tokenId / 1_000_000
967
+ */
968
+ function isAllowlistedNFT(
969
+ uint256 _projectId,
970
+ address _ownedNFTAddress,
971
+ uint256 _ownedNFTTokenId
972
+ ) public view returns (bool) {
973
+ uint256 ownedNFTProjectId = _ownedNFTTokenId / ONE_MILLION;
974
+ return
975
+ allowedProjectHolders[_projectId][_ownedNFTAddress][
976
+ ownedNFTProjectId
977
+ ];
978
+ }
979
+
980
+ function _requireCurrentPanelIsMintedOnce(
981
+ uint256 _projectId,
982
+ bytes12 _tokenHashSeed
983
+ ) private {
984
+ // mark the polyptych panel as minted so the same panel cannot be minted twice
985
+ uint256 _panelId = projectConfig[_projectId].polyptychPanelId;
986
+
987
+ require(
988
+ _tokenHashSeed != bytes12(0),
989
+ "Cannot have an empty hash seed to copy."
990
+ );
991
+
992
+ require(
993
+ !polyptychPanelHashSeedIsMinted[_panelId][_tokenHashSeed],
994
+ "Panel already minted"
995
+ );
996
+ polyptychPanelHashSeedIsMinted[_panelId][_tokenHashSeed] = true;
997
+ }
998
+ }