@artblocks/contracts 0.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 (196) hide show
  1. package/.env.example +10 -0
  2. package/LICENSE +165 -0
  3. package/README.md +286 -0
  4. package/artifacts/contracts/AdminACLV0.sol/AdminACLV0.json +164 -0
  5. package/artifacts/contracts/AdminACLV1.sol/AdminACLV1.json +248 -0
  6. package/artifacts/contracts/BasicRandomizer.sol/BasicRandomizer.json +24 -0
  7. package/artifacts/contracts/BasicRandomizerV2.sol/BasicRandomizerV2.json +102 -0
  8. package/artifacts/contracts/DependencyRegistryV0.sol/DependencyRegistryV0.json +1020 -0
  9. package/artifacts/contracts/GenArt721CoreV3.sol/GenArt721CoreV3.json +1928 -0
  10. package/artifacts/contracts/GenArt721CoreV3_Engine.sol/GenArt721CoreV3_Engine.json +1942 -0
  11. package/artifacts/contracts/engine/GenArt721CoreV2_ENGINE_FLEX.sol/GenArt721CoreV2_ENGINE_FLEX.json +1708 -0
  12. package/artifacts/contracts/engine/GenArt721CoreV2_PBAB.sol/GenArt721CoreV2_PBAB.json +1410 -0
  13. package/artifacts/contracts/engine/GenArt721CoreV2_PRTNR.sol/GenArt721CoreV2_PRTNR.json +1436 -0
  14. package/artifacts/contracts/engine/GenArt721MinterBurner_PBAB.sol/GenArt721MinterBurner_PBAB.json +437 -0
  15. package/artifacts/contracts/engine/GenArt721MinterDAExp_PBAB.sol/GenArt721MinterDAExp_PBAB.json +508 -0
  16. package/artifacts/contracts/engine/GenArt721Minter_PBAB.sol/GenArt721Minter_PBAB.json +381 -0
  17. package/artifacts/contracts/engine-registry/EngineRegistryV0.sol/EngineRegistryV0.json +109 -0
  18. package/artifacts/contracts/engine-registry/future/EngineRegistryV1.sol/EngineRegistryV1.json +109 -0
  19. package/artifacts/contracts/explorations/GenArt721CoreV3_Explorations.sol/GenArt721CoreV3_Explorations.json +1902 -0
  20. package/artifacts/contracts/interfaces/0.5.x/IBonusContract.sol/IBonusContract.json +47 -0
  21. package/artifacts/contracts/interfaces/0.5.x/IGenArt721CoreContractV1.sol/IGenArt721CoreContractV1.json +413 -0
  22. package/artifacts/contracts/interfaces/0.5.x/IGenArt721CoreV2_PBAB.sol/IGenArt721CoreV2_PBAB.json +392 -0
  23. package/artifacts/contracts/interfaces/0.5.x/IRandomizer.sol/IRandomizer.json +26 -0
  24. package/artifacts/contracts/interfaces/0.8.x/IAdminACLV0.sol/IAdminACLV0.json +122 -0
  25. package/artifacts/contracts/interfaces/0.8.x/IArtblocksRoyaltyOverride.sol/IArtblocksRoyaltyOverride.json +59 -0
  26. package/artifacts/contracts/interfaces/0.8.x/IBonusContract.sol/IBonusContract.json +43 -0
  27. package/artifacts/contracts/interfaces/0.8.x/IDelegationRegistry.sol/IDelegationRegistry.json +510 -0
  28. package/artifacts/contracts/interfaces/0.8.x/IDependencyRegistryCompatibleV0.sol/IDependencyRegistryCompatibleV0.json +53 -0
  29. package/artifacts/contracts/interfaces/0.8.x/IDependencyRegistryV0.sol/IDependencyRegistryV0.json +350 -0
  30. package/artifacts/contracts/interfaces/0.8.x/IEngineRegistryV0.sol/IEngineRegistryV0.json +85 -0
  31. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV0.sol/IFilteredMinterDAExpSettlementV0.json +730 -0
  32. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpV0.sol/IFilteredMinterDAExpV0.json +311 -0
  33. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpV1.sol/IFilteredMinterDAExpV1.json +617 -0
  34. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDALinV0.sol/IFilteredMinterDALinV0.json +292 -0
  35. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDALinV1.sol/IFilteredMinterDALinV1.json +598 -0
  36. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterHolderV0.sol/IFilteredMinterHolderV0.json +355 -0
  37. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterHolderV1.sol/IFilteredMinterHolderV1.json +368 -0
  38. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterHolderV2.sol/IFilteredMinterHolderV2.json +674 -0
  39. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterMerkleV0.sol/IFilteredMinterMerkleV0.json +551 -0
  40. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterMerkleV1.sol/IFilteredMinterMerkleV1.json +564 -0
  41. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterMerkleV2.sol/IFilteredMinterMerkleV2.json +601 -0
  42. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterV0.sol/IFilteredMinterV0.json +216 -0
  43. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterV1.sol/IFilteredMinterV1.json +485 -0
  44. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterV2.sol/IFilteredMinterV2.json +522 -0
  45. package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreContractV1.sol/IGenArt721CoreContractV1.json +299 -0
  46. package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreContractV3.sol/IGenArt721CoreContractV3.json +609 -0
  47. package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Base.sol/IGenArt721CoreContractV3_Base.json +448 -0
  48. package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Engine.sol/IGenArt721CoreContractV3_Engine.json +649 -0
  49. package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreV2_PBAB.sol/IGenArt721CoreV2_PBAB.json +362 -0
  50. package/artifacts/contracts/interfaces/0.8.x/IManifold.sol/IManifold.json +35 -0
  51. package/artifacts/contracts/interfaces/0.8.x/IMinterFilterV0.sol/IMinterFilterV0.json +192 -0
  52. package/artifacts/contracts/interfaces/0.8.x/IRandomizer.sol/IRandomizer.json +24 -0
  53. package/artifacts/contracts/interfaces/0.8.x/IRandomizerV2.sol/IRandomizerV2.json +37 -0
  54. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/Address.json +10 -0
  55. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/Counters.json +10 -0
  56. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/CustomERC721Metadata.json +425 -0
  57. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/ERC165.json +38 -0
  58. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/ERC721.json +322 -0
  59. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/ERC721Enumerable.json +384 -0
  60. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/GenArt721CoreV1.json +1773 -0
  61. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/IERC165.json +32 -0
  62. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/IERC721.json +316 -0
  63. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/IERC721Enumerable.json +378 -0
  64. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/IERC721Receiver.json +47 -0
  65. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/SafeMath.json +10 -0
  66. package/artifacts/contracts/legacy/GenArt721CoreV1.sol/Strings.json +10 -0
  67. package/artifacts/contracts/legacy/GenArt721LegacyMinter.sol/GenArt721LegacyMinter.json +338 -0
  68. package/artifacts/contracts/libs/0.5.x/CustomERC721Metadata.sol/CustomERC721Metadata.json +425 -0
  69. package/artifacts/contracts/libs/0.5.x/IERC20.sol/IERC20.json +206 -0
  70. package/artifacts/contracts/libs/0.5.x/SafeMath.sol/SafeMath.json +10 -0
  71. package/artifacts/contracts/libs/0.5.x/Strings.sol/Strings.json +10 -0
  72. package/artifacts/contracts/libs/0.8.x/BytecodeStorage.sol/BytecodeStorage.json +10 -0
  73. package/artifacts/contracts/libs/0.8.x/Bytes32Strings.sol/Bytes32Strings.json +10 -0
  74. package/artifacts/contracts/libs/0.8.x/ERC721_PackedHashSeed.sol/ERC721_PackedHashSeed.json +357 -0
  75. package/artifacts/contracts/libs/integration-refs/delegation-registry/DelegationRegistry.sol/DelegationRegistry.json +529 -0
  76. package/artifacts/contracts/libs/integration-refs/gnosis-safe/GnosisSafeMock.sol/GnosisSafeMock.json +1037 -0
  77. package/artifacts/contracts/libs/integration-refs/gnosis-safe/GnosisSafeProxyFactoryMock.sol/GnosisSafeProxyFactoryMock.json +172 -0
  78. package/artifacts/contracts/libs/integration-refs/gnosis-safe/MultiSendMock.sol/MultiSendMock.json +24 -0
  79. package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV0.sol/MinterFilterV0.json +342 -0
  80. package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV1.sol/MinterFilterV1.json +322 -0
  81. package/artifacts/contracts/minter-suite/Minters/MinterDAExp/MinterDAExpV2.sol/MinterDAExpV2.json +550 -0
  82. package/artifacts/contracts/minter-suite/Minters/MinterDAExp/MinterDAExpV3.sol/MinterDAExpV3.json +856 -0
  83. package/artifacts/contracts/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol/MinterDAExpSettlementV0.json +1053 -0
  84. package/artifacts/contracts/minter-suite/Minters/MinterDALin/MinterDALinV2.sol/MinterDALinV2.json +526 -0
  85. package/artifacts/contracts/minter-suite/Minters/MinterDALin/MinterDALinV3.sol/MinterDALinV3.json +832 -0
  86. package/artifacts/contracts/minter-suite/Minters/MinterHolder/MinterHolderV2.sol/MinterHolderV2.json +794 -0
  87. package/artifacts/contracts/minter-suite/Minters/MinterHolder/MinterHolderV3.sol/MinterHolderV3.json +1100 -0
  88. package/artifacts/contracts/minter-suite/Minters/MinterMerkle/MinterMerkleV3.sol/MinterMerkleV3.json +1002 -0
  89. package/artifacts/contracts/minter-suite/Minters/MinterMerkle/MinterMerkleV4.sol/MinterMerkleV4.json +1039 -0
  90. package/artifacts/contracts/minter-suite/Minters/MinterSetPrice/MinterSetPriceV2.sol/MinterSetPriceV2.json +365 -0
  91. package/artifacts/contracts/minter-suite/Minters/MinterSetPrice/MinterSetPriceV3.sol/MinterSetPriceV3.json +671 -0
  92. package/artifacts/contracts/minter-suite/Minters/MinterSetPrice/deprecated/MinterSetPriceV1.sol/MinterSetPriceV1.json +288 -0
  93. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol/MinterSetPriceERC20V2.json +436 -0
  94. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol/MinterSetPriceERC20V3.json +742 -0
  95. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20/deprecated/MinterSetPriceERC20V0.sol/MinterSetPriceERC20V0.json +461 -0
  96. package/artifacts/contracts/mock/BytecodeTextCR_DMock.sol/BytecodeTextCR_DMock.json +194 -0
  97. package/artifacts/contracts/mock/DeadReceiverMock.sol/DeadReceiverMock.json +15 -0
  98. package/artifacts/contracts/mock/ERC20Mock.sol/ERC20Mock.json +292 -0
  99. package/artifacts/contracts/mock/MockAdminACLV0.sol/MockAdminACLV0Events.json +165 -0
  100. package/artifacts/contracts/mock/RandomizerV2_NoAssignMock.sol/RandomizerV2_NoAssignMock.json +128 -0
  101. package/artifacts/contracts/mock/ReentrancyHolderMock.sol/ReentrancyHolderMock.json +118 -0
  102. package/artifacts/contracts/mock/ReentrancyMerkleMock.sol/ReentrancyMerkleMock.json +87 -0
  103. package/artifacts/contracts/mock/ReentrancyMock.sol/ReentrancyMock.json +82 -0
  104. package/artifacts/contracts/royalty-registry/GenArt721RoyaltyOverride.sol/GenArt721RoyaltyOverride.json +208 -0
  105. package/artifacts/contracts/royalty-registry/GenArt721RoyaltyOverride_PBAB.sol/GenArt721RoyaltyOverride_PBAB.json +301 -0
  106. package/contracts/AdminACLV0.sol +103 -0
  107. package/contracts/AdminACLV1.sol +193 -0
  108. package/contracts/BasicRandomizer.sol +23 -0
  109. package/contracts/BasicRandomizerV2.sol +36 -0
  110. package/contracts/DependencyRegistryV0.sol +893 -0
  111. package/contracts/GenArt721CoreV3.sol +2001 -0
  112. package/contracts/GenArt721CoreV3_Engine.sol +2061 -0
  113. package/contracts/engine/GenArt721CoreV2_ENGINE_FLEX.sol +887 -0
  114. package/contracts/engine/GenArt721CoreV2_PBAB.sol +695 -0
  115. package/contracts/engine/GenArt721CoreV2_PRTNR.sol +749 -0
  116. package/contracts/engine/GenArt721MinterBurner_PBAB.sol +467 -0
  117. package/contracts/engine/GenArt721MinterDAExp_PBAB.sol +614 -0
  118. package/contracts/engine/GenArt721Minter_PBAB.sol +420 -0
  119. package/contracts/engine-registry/EngineRegistryV0.sol +72 -0
  120. package/contracts/engine-registry/future/EngineRegistryV1.sol +86 -0
  121. package/contracts/explorations/GenArt721CoreV3_Explorations.sol +1989 -0
  122. package/contracts/interfaces/0.5.x/IBonusContract.sol +10 -0
  123. package/contracts/interfaces/0.5.x/IGenArt721CoreContractV1.sol +91 -0
  124. package/contracts/interfaces/0.5.x/IGenArt721CoreV2_PBAB.sol +92 -0
  125. package/contracts/interfaces/0.5.x/IRandomizer.sol +8 -0
  126. package/contracts/interfaces/0.8.x/IAdminACLV0.sol +51 -0
  127. package/contracts/interfaces/0.8.x/IArtblocksRoyaltyOverride.sol +34 -0
  128. package/contracts/interfaces/0.8.x/IBonusContract.sol +10 -0
  129. package/contracts/interfaces/0.8.x/IDelegationRegistry.sol +221 -0
  130. package/contracts/interfaces/0.8.x/IDependencyRegistryCompatibleV0.sol +31 -0
  131. package/contracts/interfaces/0.8.x/IDependencyRegistryV0.sol +95 -0
  132. package/contracts/interfaces/0.8.x/IEngineRegistryV0.sol +38 -0
  133. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV0.sol +70 -0
  134. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpV0.sol +35 -0
  135. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpV1.sol +16 -0
  136. package/contracts/interfaces/0.8.x/IFilteredMinterDALinV0.sol +32 -0
  137. package/contracts/interfaces/0.8.x/IFilteredMinterDALinV1.sol +16 -0
  138. package/contracts/interfaces/0.8.x/IFilteredMinterHolderV0.sol +68 -0
  139. package/contracts/interfaces/0.8.x/IFilteredMinterHolderV1.sol +19 -0
  140. package/contracts/interfaces/0.8.x/IFilteredMinterHolderV2.sol +19 -0
  141. package/contracts/interfaces/0.8.x/IFilteredMinterMerkleV0.sol +37 -0
  142. package/contracts/interfaces/0.8.x/IFilteredMinterMerkleV1.sol +19 -0
  143. package/contracts/interfaces/0.8.x/IFilteredMinterMerkleV2.sol +19 -0
  144. package/contracts/interfaces/0.8.x/IFilteredMinterV0.sol +74 -0
  145. package/contracts/interfaces/0.8.x/IFilteredMinterV1.sol +127 -0
  146. package/contracts/interfaces/0.8.x/IFilteredMinterV2.sol +30 -0
  147. package/contracts/interfaces/0.8.x/IGenArt721CoreContractV1.sol +73 -0
  148. package/contracts/interfaces/0.8.x/IGenArt721CoreContractV3.sol +79 -0
  149. package/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Base.sol +127 -0
  150. package/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Engine.sol +80 -0
  151. package/contracts/interfaces/0.8.x/IGenArt721CoreV2_PBAB.sol +91 -0
  152. package/contracts/interfaces/0.8.x/IManifold.sol +24 -0
  153. package/contracts/interfaces/0.8.x/IMinterFilterV0.sol +47 -0
  154. package/contracts/interfaces/0.8.x/IRandomizer.sol +8 -0
  155. package/contracts/interfaces/0.8.x/IRandomizerV2.sol +15 -0
  156. package/contracts/legacy/GenArt721CoreV1.sol +1593 -0
  157. package/contracts/legacy/GenArt721LegacyMinter.sol +275 -0
  158. package/contracts/libs/0.5.x/CustomERC721Metadata.sol +52 -0
  159. package/contracts/libs/0.5.x/IERC20.sol +96 -0
  160. package/contracts/libs/0.5.x/SafeMath.sol +98 -0
  161. package/contracts/libs/0.5.x/Strings.sol +92 -0
  162. package/contracts/libs/0.8.x/BytecodeStorage.sol +314 -0
  163. package/contracts/libs/0.8.x/Bytes32Strings.sol +66 -0
  164. package/contracts/libs/0.8.x/ERC721_PackedHashSeed.sol +514 -0
  165. package/contracts/libs/integration-refs/delegation-registry/DelegationRegistry.sol +663 -0
  166. package/contracts/libs/integration-refs/gnosis-safe/GnosisSafeMock.sol +6 -0
  167. package/contracts/libs/integration-refs/gnosis-safe/GnosisSafeProxyFactoryMock.sol +6 -0
  168. package/contracts/libs/integration-refs/gnosis-safe/MultiSendMock.sol +6 -0
  169. package/contracts/minter-suite/MinterFilter/MinterFilterV0.sol +291 -0
  170. package/contracts/minter-suite/MinterFilter/MinterFilterV1.sol +320 -0
  171. package/contracts/minter-suite/Minters/MinterDAExp/MinterDAExpV2.sol +571 -0
  172. package/contracts/minter-suite/Minters/MinterDAExp/MinterDAExpV3.sol +622 -0
  173. package/contracts/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol +1066 -0
  174. package/contracts/minter-suite/Minters/MinterDALin/MinterDALinV2.sol +527 -0
  175. package/contracts/minter-suite/Minters/MinterDALin/MinterDALinV3.sol +576 -0
  176. package/contracts/minter-suite/Minters/MinterHolder/MinterHolderV2.sol +749 -0
  177. package/contracts/minter-suite/Minters/MinterHolder/MinterHolderV3.sol +798 -0
  178. package/contracts/minter-suite/Minters/MinterMerkle/MinterMerkleV3.sol +682 -0
  179. package/contracts/minter-suite/Minters/MinterMerkle/MinterMerkleV4.sol +733 -0
  180. package/contracts/minter-suite/Minters/MinterSetPrice/MinterSetPriceV2.sol +350 -0
  181. package/contracts/minter-suite/Minters/MinterSetPrice/MinterSetPriceV3.sol +401 -0
  182. package/contracts/minter-suite/Minters/MinterSetPrice/deprecated/MinterSetPriceV1.sol +274 -0
  183. package/contracts/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol +491 -0
  184. package/contracts/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol +542 -0
  185. package/contracts/minter-suite/Minters/MinterSetPriceERC20/deprecated/MinterSetPriceERC20V0.sol +470 -0
  186. package/contracts/mock/BytecodeTextCR_DMock.sol +184 -0
  187. package/contracts/mock/DeadReceiverMock.sol +13 -0
  188. package/contracts/mock/ERC20Mock.sol +11 -0
  189. package/contracts/mock/MockAdminACLV0.sol +65 -0
  190. package/contracts/mock/RandomizerV2_NoAssignMock.sol +43 -0
  191. package/contracts/mock/ReentrancyHolderMock.sol +50 -0
  192. package/contracts/mock/ReentrancyMerkleMock.sol +64 -0
  193. package/contracts/mock/ReentrancyMock.sol +44 -0
  194. package/contracts/royalty-registry/GenArt721RoyaltyOverride.sol +168 -0
  195. package/contracts/royalty-registry/GenArt721RoyaltyOverride_PBAB.sol +221 -0
  196. package/package.json +83 -0
@@ -0,0 +1,749 @@
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/IFilteredMinterHolderV1.sol";
7
+ import "../../../interfaces/0.8.x/IDelegationRegistry.sol";
8
+
9
+ import "@openzeppelin-4.5/contracts/token/ERC721/IERC721.sol";
10
+ import "@openzeppelin-4.5/contracts/token/ERC20/IERC20.sol";
11
+ import "@openzeppelin-4.5/contracts/security/ReentrancyGuard.sol";
12
+ import "@openzeppelin-4.5/contracts/utils/structs/EnumerableSet.sol";
13
+
14
+ pragma solidity 0.8.17;
15
+
16
+ /**
17
+ * @title Filtered Minter contract that allows tokens to be minted with ETH
18
+ * when purchaser owns an allowlisted ERC-721 NFT. This contract does NOT track
19
+ * if a purchaser has/has not minted already -- it simply restricts purchasing
20
+ * to anybody that holds one or more of a specified list of ERC-721 NFTs.
21
+ * This is designed to be used with IGenArt721CoreContractV3 contracts.
22
+ * @author Art Blocks Inc.
23
+ * @notice Privileged Roles and Ownership:
24
+ * This contract is designed to be managed, with limited powers.
25
+ * Privileged roles and abilities are controlled by the core contract's Admin
26
+ * ACL contract and a project's artist. Both of these roles hold extensive
27
+ * power and can modify minter details.
28
+ * Care must be taken to ensure that the admin ACL contract and artist
29
+ * addresses are secure behind a multi-sig or other access control mechanism.
30
+ * ----------------------------------------------------------------------------
31
+ * The following functions are restricted to the core contract's Admin ACL
32
+ * contract:
33
+ * - registerNFTAddress
34
+ * - unregisterNFTAddress
35
+ * ----------------------------------------------------------------------------
36
+ * The following functions are restricted to a project's artist:
37
+ * - allowHoldersOfProjects
38
+ * - removeHoldersOfProjects
39
+ * - allowRemoveHoldersOfProjects
40
+ * - updatePricePerTokenInWei
41
+ * ----------------------------------------------------------------------------
42
+ * Additional admin and artist privileged roles may be described on other
43
+ * contracts that this minter integrates with.
44
+ * ----------------------------------------------------------------------------
45
+ * This contract allows gated minting with support for vaults to delegate minting
46
+ * privileges via an external delegation registry. This means a vault holding an
47
+ * allowed token can delegate minting privileges to a wallet that is not holding an
48
+ * allowed token, enabling the vault to remain air-gapped while still allowing minting.
49
+ * The delegation registry contract is responsible for managing these delegations,
50
+ * and is available at the address returned by the public immutable
51
+ * `delegationRegistryAddress`. At the time of writing, the delegation
52
+ * registry enables easy delegation configuring at https://delegate.cash/.
53
+ * Art Blocks does not guarentee the security of the delegation registry, and
54
+ * users should take care to ensure that the delegation registry is secure.
55
+ * Delegations must be configured by the vault owner prior to purchase. Supported
56
+ * delegation types include token-level, contract-level (via genArt721CoreAddress), or
57
+ * wallet-level delegation. Contract-level delegations must be configured for the core
58
+ * token contract as returned by owned token's core contract address.
59
+ */
60
+ contract MinterHolderV2 is ReentrancyGuard, IFilteredMinterHolderV1 {
61
+ // add Enumerable Set methods
62
+ using EnumerableSet for EnumerableSet.AddressSet;
63
+
64
+ /// Delegation registry address
65
+ address public immutable delegationRegistryAddress;
66
+
67
+ /// Delegation registry address
68
+ IDelegationRegistry private immutable delegationRegistryContract;
69
+
70
+ /// Core contract address this minter interacts with
71
+ address public immutable genArt721CoreAddress;
72
+
73
+ /// This contract handles cores with interface IV3
74
+ IGenArt721CoreContractV3 private immutable genArtCoreContract;
75
+
76
+ /// Minter filter address this minter interacts with
77
+ address public immutable minterFilterAddress;
78
+
79
+ /// Minter filter this minter may interact with.
80
+ IMinterFilterV0 private immutable minterFilter;
81
+
82
+ /// minterType for this minter
83
+ string public constant minterType = "MinterHolderV2";
84
+
85
+ uint256 constant ONE_MILLION = 1_000_000;
86
+
87
+ struct ProjectConfig {
88
+ bool maxHasBeenInvoked;
89
+ bool priceIsConfigured;
90
+ uint24 maxInvocations;
91
+ uint256 pricePerTokenInWei;
92
+ }
93
+
94
+ mapping(uint256 => ProjectConfig) public projectConfig;
95
+
96
+ /// Set of core contracts allowed to be queried for token holders
97
+ EnumerableSet.AddressSet private _registeredNFTAddresses;
98
+
99
+ /**
100
+ * projectId => ownedNFTAddress => ownedNFTProjectIds => bool
101
+ * projects whose holders are allowed to purchase a token on `projectId`
102
+ */
103
+ mapping(uint256 => mapping(address => mapping(uint256 => bool)))
104
+ public allowedProjectHolders;
105
+
106
+ // modifier to restrict access to only AdminACL allowed calls
107
+ // @dev defers which ACL contract is used to the core contract
108
+ modifier onlyCoreAdminACL(bytes4 _selector) {
109
+ require(
110
+ genArtCoreContract.adminACLAllowed(
111
+ msg.sender,
112
+ address(this),
113
+ _selector
114
+ ),
115
+ "Only Core AdminACL allowed"
116
+ );
117
+ _;
118
+ }
119
+
120
+ modifier onlyArtist(uint256 _projectId) {
121
+ require(
122
+ msg.sender ==
123
+ genArtCoreContract.projectIdToArtistAddress(_projectId),
124
+ "Only Artist"
125
+ );
126
+ _;
127
+ }
128
+
129
+ /**
130
+ * @notice Initializes contract to be a Filtered Minter for
131
+ * `_minterFilter`, integrated with Art Blocks core contract
132
+ * at address `_genArt721Address`.
133
+ * @param _genArt721Address Art Blocks core contract for which this
134
+ * contract will be a minter.
135
+ * @param _minterFilter Minter filter for which
136
+ * this will a filtered minter.
137
+ * @param _delegationRegistryAddress Delegation registry contract address.
138
+ */
139
+ constructor(
140
+ address _genArt721Address,
141
+ address _minterFilter,
142
+ address _delegationRegistryAddress
143
+ ) ReentrancyGuard() {
144
+ genArt721CoreAddress = _genArt721Address;
145
+ genArtCoreContract = IGenArt721CoreContractV3(_genArt721Address);
146
+ delegationRegistryAddress = _delegationRegistryAddress;
147
+ emit DelegationRegistryUpdated(_delegationRegistryAddress);
148
+ delegationRegistryContract = IDelegationRegistry(
149
+ _delegationRegistryAddress
150
+ );
151
+ minterFilterAddress = _minterFilter;
152
+ minterFilter = IMinterFilterV0(_minterFilter);
153
+ require(
154
+ minterFilter.genArt721CoreAddress() == _genArt721Address,
155
+ "Illegal contract pairing"
156
+ );
157
+ }
158
+
159
+ /**
160
+ *
161
+ * @notice Registers holders of NFTs at address `_NFTAddress` to be
162
+ * considered for minting. New core address is assumed to follow syntax of:
163
+ * `projectId = tokenId / 1_000_000`
164
+ * @param _NFTAddress NFT core address to be registered.
165
+ */
166
+ function registerNFTAddress(
167
+ address _NFTAddress
168
+ ) external onlyCoreAdminACL(this.registerNFTAddress.selector) {
169
+ _registeredNFTAddresses.add(_NFTAddress);
170
+ emit RegisteredNFTAddress(_NFTAddress);
171
+ }
172
+
173
+ /**
174
+ *
175
+ * @notice Unregisters holders of NFTs at address `_NFTAddress` to be
176
+ * considered for adding to future allowlists.
177
+ * @param _NFTAddress NFT core address to be unregistered.
178
+ */
179
+ function unregisterNFTAddress(
180
+ address _NFTAddress
181
+ ) external onlyCoreAdminACL(this.unregisterNFTAddress.selector) {
182
+ _registeredNFTAddresses.remove(_NFTAddress);
183
+ emit UnregisteredNFTAddress(_NFTAddress);
184
+ }
185
+
186
+ /**
187
+ * @notice Allows holders of NFTs at addresses `_ownedNFTAddresses`,
188
+ * project IDs `_ownedNFTProjectIds` to mint on project `_projectId`.
189
+ * `_ownedNFTAddresses` assumed to be aligned with `_ownedNFTProjectIds`.
190
+ * e.g. Allows holders of project `_ownedNFTProjectIds[0]` on token
191
+ * contract `_ownedNFTAddresses[0]` to mint `_projectId`.
192
+ * @param _projectId Project ID to enable minting on.
193
+ * @param _ownedNFTAddresses NFT core addresses of projects to be
194
+ * allowlisted. Indexes must align with `_ownedNFTProjectIds`.
195
+ * @param _ownedNFTProjectIds Project IDs on `_ownedNFTAddresses` whose
196
+ * holders shall be allowlisted to mint project `_projectId`. Indexes must
197
+ * align with `_ownedNFTAddresses`.
198
+ */
199
+ function allowHoldersOfProjects(
200
+ uint256 _projectId,
201
+ address[] memory _ownedNFTAddresses,
202
+ uint256[] memory _ownedNFTProjectIds
203
+ ) public onlyArtist(_projectId) {
204
+ // require same length arrays
205
+ require(
206
+ _ownedNFTAddresses.length == _ownedNFTProjectIds.length,
207
+ "Length of add arrays must match"
208
+ );
209
+ // for each approved project
210
+ for (uint256 i = 0; i < _ownedNFTAddresses.length; i++) {
211
+ // ensure registered address
212
+ require(
213
+ _registeredNFTAddresses.contains(_ownedNFTAddresses[i]),
214
+ "Only Registered NFT Addresses"
215
+ );
216
+ // approve
217
+ allowedProjectHolders[_projectId][_ownedNFTAddresses[i]][
218
+ _ownedNFTProjectIds[i]
219
+ ] = true;
220
+ }
221
+ // emit approve event
222
+ emit AllowedHoldersOfProjects(
223
+ _projectId,
224
+ _ownedNFTAddresses,
225
+ _ownedNFTProjectIds
226
+ );
227
+ }
228
+
229
+ /**
230
+ * @notice Removes holders of NFTs at addresses `_ownedNFTAddresses`,
231
+ * project IDs `_ownedNFTProjectIds` to mint on project `_projectId`. If
232
+ * other projects owned by a holder are still allowed to mint, holder will
233
+ * maintain ability to purchase.
234
+ * `_ownedNFTAddresses` assumed to be aligned with `_ownedNFTProjectIds`.
235
+ * e.g. Removes holders of project `_ownedNFTProjectIds[0]` on token
236
+ * contract `_ownedNFTAddresses[0]` from mint allowlist of `_projectId`.
237
+ * @param _projectId Project ID to enable minting on.
238
+ * @param _ownedNFTAddresses NFT core addresses of projects to be removed
239
+ * from allowlist. Indexes must align with `_ownedNFTProjectIds`.
240
+ * @param _ownedNFTProjectIds Project IDs on `_ownedNFTAddresses` whose
241
+ * holders will be removed from allowlist to mint project `_projectId`.
242
+ * Indexes must align with `_ownedNFTAddresses`.
243
+ */
244
+ function removeHoldersOfProjects(
245
+ uint256 _projectId,
246
+ address[] memory _ownedNFTAddresses,
247
+ uint256[] memory _ownedNFTProjectIds
248
+ ) public onlyArtist(_projectId) {
249
+ // require same length arrays
250
+ require(
251
+ _ownedNFTAddresses.length == _ownedNFTProjectIds.length,
252
+ "Length of remove arrays must match"
253
+ );
254
+ // for each removed project
255
+ for (uint256 i = 0; i < _ownedNFTAddresses.length; i++) {
256
+ // revoke
257
+ allowedProjectHolders[_projectId][_ownedNFTAddresses[i]][
258
+ _ownedNFTProjectIds[i]
259
+ ] = false;
260
+ }
261
+ // emit removed event
262
+ emit RemovedHoldersOfProjects(
263
+ _projectId,
264
+ _ownedNFTAddresses,
265
+ _ownedNFTProjectIds
266
+ );
267
+ }
268
+
269
+ /**
270
+ * @notice Allows holders of NFTs at addresses `_ownedNFTAddressesAdd`,
271
+ * project IDs `_ownedNFTProjectIdsAdd` to mint on project `_projectId`.
272
+ * Also removes holders of NFTs at addresses `_ownedNFTAddressesRemove`,
273
+ * project IDs `_ownedNFTProjectIdsRemove` from minting on project
274
+ * `_projectId`.
275
+ * `_ownedNFTAddressesAdd` assumed to be aligned with
276
+ * `_ownedNFTProjectIdsAdd`.
277
+ * e.g. Allows holders of project `_ownedNFTProjectIdsAdd[0]` on token
278
+ * contract `_ownedNFTAddressesAdd[0]` to mint `_projectId`.
279
+ * `_ownedNFTAddressesRemove` also assumed to be aligned with
280
+ * `_ownedNFTProjectIdsRemove`.
281
+ * @param _projectId Project ID to enable minting on.
282
+ * @param _ownedNFTAddressesAdd NFT core addresses of projects to be
283
+ * allowlisted. Indexes must align with `_ownedNFTProjectIdsAdd`.
284
+ * @param _ownedNFTProjectIdsAdd Project IDs on `_ownedNFTAddressesAdd`
285
+ * whose holders shall be allowlisted to mint project `_projectId`. Indexes
286
+ * must align with `_ownedNFTAddressesAdd`.
287
+ * @param _ownedNFTAddressesRemove NFT core addresses of projects to be
288
+ * removed from allowlist. Indexes must align with
289
+ * `_ownedNFTProjectIdsRemove`.
290
+ * @param _ownedNFTProjectIdsRemove Project IDs on
291
+ * `_ownedNFTAddressesRemove` whose holders will be removed from allowlist
292
+ * to mint project `_projectId`. Indexes must align with
293
+ * `_ownedNFTAddressesRemove`.
294
+ * @dev if a project is included in both add and remove arrays, it will be
295
+ * removed.
296
+ */
297
+ function allowRemoveHoldersOfProjects(
298
+ uint256 _projectId,
299
+ address[] memory _ownedNFTAddressesAdd,
300
+ uint256[] memory _ownedNFTProjectIdsAdd,
301
+ address[] memory _ownedNFTAddressesRemove,
302
+ uint256[] memory _ownedNFTProjectIdsRemove
303
+ ) external onlyArtist(_projectId) {
304
+ allowHoldersOfProjects(
305
+ _projectId,
306
+ _ownedNFTAddressesAdd,
307
+ _ownedNFTProjectIdsAdd
308
+ );
309
+ removeHoldersOfProjects(
310
+ _projectId,
311
+ _ownedNFTAddressesRemove,
312
+ _ownedNFTProjectIdsRemove
313
+ );
314
+ }
315
+
316
+ /**
317
+ * @notice Returns if token is an allowlisted NFT for project `_projectId`.
318
+ * @param _projectId Project ID to be checked.
319
+ * @param _ownedNFTAddress ERC-721 NFT token address to be checked.
320
+ * @param _ownedNFTTokenId ERC-721 NFT token ID to be checked.
321
+ * @return bool Token is allowlisted
322
+ * @dev does not check if token has been used to purchase
323
+ * @dev assumes project ID can be derived from tokenId / 1_000_000
324
+ */
325
+ function isAllowlistedNFT(
326
+ uint256 _projectId,
327
+ address _ownedNFTAddress,
328
+ uint256 _ownedNFTTokenId
329
+ ) public view returns (bool) {
330
+ uint256 ownedNFTProjectId = _ownedNFTTokenId / ONE_MILLION;
331
+ return
332
+ allowedProjectHolders[_projectId][_ownedNFTAddress][
333
+ ownedNFTProjectId
334
+ ];
335
+ }
336
+
337
+ /**
338
+ * @notice Syncs local maximum invocations of project `_projectId` based on
339
+ * the value currently defined in the core contract. Only used for gas
340
+ * optimization of mints after maxInvocations has been reached.
341
+ * @param _projectId Project ID to set the maximum invocations for.
342
+ * @dev this enables gas reduction after maxInvocations have been reached -
343
+ * core contracts shall still enforce a maxInvocation check during mint.
344
+ * @dev function is intentionally not gated to any specific access control;
345
+ * it only syncs a local state variable to the core contract's state.
346
+ */
347
+ function setProjectMaxInvocations(uint256 _projectId) external {
348
+ uint256 maxInvocations;
349
+ (, maxInvocations, , , , ) = genArtCoreContract.projectStateData(
350
+ _projectId
351
+ );
352
+ // update storage with results
353
+ projectConfig[_projectId].maxInvocations = uint24(maxInvocations);
354
+ }
355
+
356
+ /**
357
+ * @notice Warning: Disabling purchaseTo is not supported on this minter.
358
+ * This method exists purely for interface-conformance purposes.
359
+ */
360
+ function togglePurchaseToDisabled(
361
+ uint256 _projectId
362
+ ) external view onlyArtist(_projectId) {
363
+ revert("Action not supported");
364
+ }
365
+
366
+ /**
367
+ * @notice projectId => has project reached its maximum number of
368
+ * invocations? Note that this returns a local cache of the core contract's
369
+ * state, and may be out of sync with the core contract. This is
370
+ * intentional, as it only enables gas optimization of mints after a
371
+ * project's maximum invocations has been reached. A false negative will
372
+ * only result in a gas cost increase, since the core contract will still
373
+ * enforce a maxInvocation check during minting. A false positive is not
374
+ * possible because the V3 core contract only allows maximum invocations
375
+ * to be reduced, not increased. Based on this rationale, we intentionally
376
+ * do not do input validation in this method as to whether or not the input
377
+ * `_projectId` is an existing project ID.
378
+ */
379
+ function projectMaxHasBeenInvoked(
380
+ uint256 _projectId
381
+ ) external view returns (bool) {
382
+ return projectConfig[_projectId].maxHasBeenInvoked;
383
+ }
384
+
385
+ /**
386
+ * @notice projectId => project's maximum number of invocations.
387
+ * Optionally synced with core contract value, for gas optimization.
388
+ * Note that this returns a local cache of the core contract's
389
+ * state, and may be out of sync with the core contract. This is
390
+ * intentional, as it only enables gas optimization of mints after a
391
+ * project's maximum invocations has been reached.
392
+ * @dev A number greater than the core contract's project max invocations
393
+ * will only result in a gas cost increase, since the core contract will
394
+ * still enforce a maxInvocation check during minting. A number less than
395
+ * the core contract's project max invocations is only possible when the
396
+ * project's max invocations have not been synced on this minter, since the
397
+ * V3 core contract only allows maximum invocations to be reduced, not
398
+ * increased. When this happens, the minter will enable minting, allowing
399
+ * the core contract to enforce the max invocations check. Based on this
400
+ * rationale, we intentionally do not do input validation in this method as
401
+ * to whether or not the input `_projectId` is an existing project ID.
402
+ */
403
+ function projectMaxInvocations(
404
+ uint256 _projectId
405
+ ) external view returns (uint256) {
406
+ return uint256(projectConfig[_projectId].maxInvocations);
407
+ }
408
+
409
+ /**
410
+ * @notice Updates this minter's price per token of project `_projectId`
411
+ * to be '_pricePerTokenInWei`, in Wei.
412
+ * This price supersedes any legacy core contract price per token value.
413
+ * @dev Note that it is intentionally supported here that the configured
414
+ * price may be explicitly set to `0`.
415
+ */
416
+ function updatePricePerTokenInWei(
417
+ uint256 _projectId,
418
+ uint256 _pricePerTokenInWei
419
+ ) external onlyArtist(_projectId) {
420
+ projectConfig[_projectId].pricePerTokenInWei = _pricePerTokenInWei;
421
+ projectConfig[_projectId].priceIsConfigured = true;
422
+ emit PricePerTokenInWeiUpdated(_projectId, _pricePerTokenInWei);
423
+ }
424
+
425
+ /**
426
+ * @notice Inactive function - requires NFT ownership to purchase.
427
+ */
428
+ function purchase(uint256) external payable returns (uint256) {
429
+ revert("Must claim NFT ownership");
430
+ }
431
+
432
+ /**
433
+ * @notice Inactive function - requires NFT ownership to purchase.
434
+ */
435
+ function purchaseTo(address, uint256) public payable returns (uint256) {
436
+ revert("Must claim NFT ownership");
437
+ }
438
+
439
+ /**
440
+ * @notice Purchases a token from project `_projectId`.
441
+ * @param _projectId Project ID to mint a token on.
442
+ * @param _ownedNFTAddress ERC-721 NFT address holding the project token
443
+ * owned by msg.sender being used to prove right to purchase.
444
+ * @param _ownedNFTTokenId ERC-721 NFT token ID owned by msg.sender being used
445
+ * to prove right to purchase.
446
+ * @return tokenId Token ID of minted token
447
+ */
448
+ function purchase(
449
+ uint256 _projectId,
450
+ address _ownedNFTAddress,
451
+ uint256 _ownedNFTTokenId
452
+ ) external payable returns (uint256 tokenId) {
453
+ tokenId = purchaseTo_dlc(
454
+ msg.sender,
455
+ _projectId,
456
+ _ownedNFTAddress,
457
+ _ownedNFTTokenId,
458
+ address(0)
459
+ );
460
+ return tokenId;
461
+ }
462
+
463
+ /**
464
+ * @notice gas-optimized version of purchase(uint256,address,uint256).
465
+ */
466
+ function purchase_nnf(
467
+ uint256 _projectId,
468
+ address _ownedNFTAddress,
469
+ uint256 _ownedNFTTokenId
470
+ ) external payable returns (uint256 tokenId) {
471
+ tokenId = purchaseTo_dlc(
472
+ msg.sender,
473
+ _projectId,
474
+ _ownedNFTAddress,
475
+ _ownedNFTTokenId,
476
+ address(0)
477
+ );
478
+ return tokenId;
479
+ }
480
+
481
+ /**
482
+ * @notice Purchases a token from project `_projectId` and sets
483
+ * the token's owner to `_to`.
484
+ * @param _to Address to be the new token's owner.
485
+ * @param _projectId Project ID to mint a token on.
486
+ * @param _ownedNFTAddress ERC-721 NFT holding the project token owned by
487
+ * msg.sender being used to claim right to purchase.
488
+ * @param _ownedNFTTokenId ERC-721 NFT token ID owned by msg.sender being used
489
+ * to claim right to purchase.
490
+ * @return tokenId Token ID of minted token
491
+ */
492
+ function purchaseTo(
493
+ address _to,
494
+ uint256 _projectId,
495
+ address _ownedNFTAddress,
496
+ uint256 _ownedNFTTokenId
497
+ ) external payable returns (uint256 tokenId) {
498
+ return
499
+ purchaseTo_dlc(
500
+ _to,
501
+ _projectId,
502
+ _ownedNFTAddress,
503
+ _ownedNFTTokenId,
504
+ address(0)
505
+ );
506
+ }
507
+
508
+ /**
509
+ * @notice Purchases a token from project `_projectId` and sets
510
+ * the token's owner to `_to`, as a delegate, (the `msg.sender`)
511
+ * on behalf of an explicitly defined vault.
512
+ * @param _to Address to be the new token's owner.
513
+ * @param _projectId Project ID to mint a token on.
514
+ * @param _ownedNFTAddress ERC-721 NFT address holding the project token owned by
515
+ * _vault (or msg.sender if no _vault is provided) being used to claim right to purchase.
516
+ * @param _ownedNFTTokenId ERC-721 NFT token ID owned by _vault (or msg.sender if
517
+ * no _vault is provided) being used to claim right to purchase.
518
+ * @param _vault Vault being purchased on behalf of. Acceptable to be `address(0)` if no vault.
519
+ * @return tokenId Token ID of minted token
520
+ */
521
+ function purchaseTo(
522
+ address _to,
523
+ uint256 _projectId,
524
+ address _ownedNFTAddress,
525
+ uint256 _ownedNFTTokenId,
526
+ address _vault
527
+ ) external payable returns (uint256 tokenId) {
528
+ return
529
+ purchaseTo_dlc(
530
+ _to,
531
+ _projectId,
532
+ _ownedNFTAddress,
533
+ _ownedNFTTokenId,
534
+ _vault
535
+ );
536
+ }
537
+
538
+ /**
539
+ * @notice gas-optimized version of purchaseTo(address,uint256,address,uint256,address).
540
+ * @param _to Address to be the new token's owner.
541
+ * @param _projectId Project ID to mint a token on.
542
+ * @param _ownedNFTAddress ERC-721 NFT address holding the project token owned by _vault
543
+ * (or msg.sender if no _vault is provided) being used to claim right to purchase.
544
+ * @param _ownedNFTTokenId ERC-721 NFT token ID owned by _vault (or msg.sender if
545
+ * no _vault is provided) being used to claim right to purchase.
546
+ * @param _vault Vault being purchased on behalf of. Acceptable to be `address(0)` if no vault.
547
+ * @return tokenId Token ID of minted token
548
+ */
549
+ function purchaseTo_dlc(
550
+ address _to,
551
+ uint256 _projectId,
552
+ address _ownedNFTAddress,
553
+ uint256 _ownedNFTTokenId,
554
+ address _vault
555
+ ) public payable nonReentrant returns (uint256 tokenId) {
556
+ // CHECKS
557
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
558
+
559
+ // Note that `maxHasBeenInvoked` is only checked here to reduce gas
560
+ // consumption after a project has been fully minted.
561
+ // `_projectConfig.maxHasBeenInvoked` is locally cached to reduce
562
+ // gas consumption, but if not in sync with the core contract's value,
563
+ // the core contract also enforces its own max invocation check during
564
+ // minting.
565
+ require(
566
+ !_projectConfig.maxHasBeenInvoked,
567
+ "Maximum number of invocations reached"
568
+ );
569
+
570
+ // load price of token into memory
571
+ uint256 _pricePerTokenInWei = _projectConfig.pricePerTokenInWei;
572
+
573
+ require(
574
+ msg.value >= _pricePerTokenInWei,
575
+ "Must send minimum value to mint!"
576
+ );
577
+
578
+ // require artist to have configured price of token on this minter
579
+ require(_projectConfig.priceIsConfigured, "Price not configured");
580
+
581
+ // require token used to claim to be in set of allowlisted NFTs
582
+ require(
583
+ isAllowlistedNFT(_projectId, _ownedNFTAddress, _ownedNFTTokenId),
584
+ "Only allowlisted NFTs"
585
+ );
586
+
587
+ // NOTE: delegate-vault handling **begins here**.
588
+
589
+ // handle that the vault may be either the `msg.sender` in the case
590
+ // that there is not a true vault, or may be `_vault` if one is
591
+ // provided explicitly (and it is valid).
592
+ address vault = msg.sender;
593
+ if (_vault != address(0)) {
594
+ // If a vault is provided, it must be valid, otherwise throw rather
595
+ // than optimistically-minting with original `msg.sender`.
596
+ // Note, we do not check `checkDelegateForAll` or `checkDelegateForContract` as well,
597
+ // as they are known to be implicitly checked by calling `checkDelegateForToken`.
598
+ bool isValidVault = delegationRegistryContract
599
+ .checkDelegateForToken(
600
+ msg.sender, // delegate
601
+ _vault, // vault
602
+ _ownedNFTAddress, // contract
603
+ _ownedNFTTokenId // tokenId
604
+ );
605
+ require(isValidVault, "Invalid delegate-vault pairing");
606
+ vault = _vault;
607
+ }
608
+
609
+ // EFFECTS
610
+ tokenId = minterFilter.mint(_to, _projectId, vault);
611
+
612
+ // NOTE: delegate-vault handling **ends here**.
613
+
614
+ // okay if this underflows because if statement will always eval false.
615
+ // this is only for gas optimization (core enforces maxInvocations).
616
+ unchecked {
617
+ if (tokenId % ONE_MILLION == _projectConfig.maxInvocations - 1) {
618
+ _projectConfig.maxHasBeenInvoked = true;
619
+ }
620
+ }
621
+
622
+ // INTERACTIONS
623
+ // require sender to own NFT used to redeem
624
+ /**
625
+ * @dev Considered an interaction because calling ownerOf on an NFT
626
+ * contract. Plan is to only register AB/PBAB NFTs on the minter, but
627
+ * in case other NFTs are registered, better to check here. Also,
628
+ * function is non-reentrant, so being extra cautious.
629
+ */
630
+ require(
631
+ IERC721(_ownedNFTAddress).ownerOf(_ownedNFTTokenId) == vault,
632
+ "Only owner of NFT"
633
+ );
634
+
635
+ // split funds
636
+ _splitFundsETH(_projectId, _pricePerTokenInWei);
637
+
638
+ return tokenId;
639
+ }
640
+
641
+ /**
642
+ * @dev splits ETH funds between sender (if refund), foundation,
643
+ * artist, and artist's additional payee for a token purchased on
644
+ * project `_projectId`.
645
+ * @dev possible DoS during splits is acknowledged, and mitigated by
646
+ * business practices, including end-to-end testing on mainnet, and
647
+ * admin-accepted artist payment addresses.
648
+ */
649
+ function _splitFundsETH(
650
+ uint256 _projectId,
651
+ uint256 _pricePerTokenInWei
652
+ ) internal {
653
+ if (msg.value > 0) {
654
+ bool success_;
655
+ // send refund to sender
656
+ uint256 refund = msg.value - _pricePerTokenInWei;
657
+ if (refund > 0) {
658
+ (success_, ) = msg.sender.call{value: refund}("");
659
+ require(success_, "Refund failed");
660
+ }
661
+ // split remaining funds between foundation, artist, and artist's
662
+ // additional payee
663
+ (
664
+ uint256 artblocksRevenue_,
665
+ address payable artblocksAddress_,
666
+ uint256 artistRevenue_,
667
+ address payable artistAddress_,
668
+ uint256 additionalPayeePrimaryRevenue_,
669
+ address payable additionalPayeePrimaryAddress_
670
+ ) = genArtCoreContract.getPrimaryRevenueSplits(
671
+ _projectId,
672
+ _pricePerTokenInWei
673
+ );
674
+ // Art Blocks payment
675
+ if (artblocksRevenue_ > 0) {
676
+ (success_, ) = artblocksAddress_.call{value: artblocksRevenue_}(
677
+ ""
678
+ );
679
+ require(success_, "Art Blocks payment failed");
680
+ }
681
+ // artist payment
682
+ if (artistRevenue_ > 0) {
683
+ (success_, ) = artistAddress_.call{value: artistRevenue_}("");
684
+ require(success_, "Artist payment failed");
685
+ }
686
+ // additional payee payment
687
+ if (additionalPayeePrimaryRevenue_ > 0) {
688
+ (success_, ) = additionalPayeePrimaryAddress_.call{
689
+ value: additionalPayeePrimaryRevenue_
690
+ }("");
691
+ require(success_, "Additional Payee payment failed");
692
+ }
693
+ }
694
+ }
695
+
696
+ /**
697
+ * @notice Gets quantity of NFT addresses registered on this minter.
698
+ * @return uint256 quantity of NFT addresses registered
699
+ */
700
+ function getNumRegisteredNFTAddresses() external view returns (uint256) {
701
+ return _registeredNFTAddresses.length();
702
+ }
703
+
704
+ /**
705
+ * @notice Get registered NFT core contract address at index `_index` of
706
+ * enumerable set.
707
+ * @param _index enumerable set index to query.
708
+ * @return NFTAddress NFT core contract address at index `_index`
709
+ * @dev index must be < quantity of registered NFT addresses
710
+ */
711
+ function getRegisteredNFTAddressAt(
712
+ uint256 _index
713
+ ) external view returns (address NFTAddress) {
714
+ return _registeredNFTAddresses.at(_index);
715
+ }
716
+
717
+ /**
718
+ * @notice Gets if price of token is configured, price of minting a
719
+ * token on project `_projectId`, and currency symbol and address to be
720
+ * used as payment. Supersedes any core contract price information.
721
+ * @param _projectId Project ID to get price information for.
722
+ * @return isConfigured true only if token price has been configured on
723
+ * this minter
724
+ * @return tokenPriceInWei current price of token on this minter - invalid
725
+ * if price has not yet been configured
726
+ * @return currencySymbol currency symbol for purchases of project on this
727
+ * minter. This minter always returns "ETH"
728
+ * @return currencyAddress currency address for purchases of project on
729
+ * this minter. This minter always returns null address, reserved for ether
730
+ */
731
+ function getPriceInfo(
732
+ uint256 _projectId
733
+ )
734
+ external
735
+ view
736
+ returns (
737
+ bool isConfigured,
738
+ uint256 tokenPriceInWei,
739
+ string memory currencySymbol,
740
+ address currencyAddress
741
+ )
742
+ {
743
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
744
+ isConfigured = _projectConfig.priceIsConfigured;
745
+ tokenPriceInWei = _projectConfig.pricePerTokenInWei;
746
+ currencySymbol = "ETH";
747
+ currencyAddress = address(0);
748
+ }
749
+ }