@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,1989 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ pragma solidity 0.8.17;
3
+
4
+ // Created By: Art Blocks Inc.
5
+
6
+ import "../interfaces/0.8.x/IRandomizerV2.sol";
7
+ import "../interfaces/0.8.x/IAdminACLV0.sol";
8
+ import "../interfaces/0.8.x/IGenArt721CoreContractV3.sol";
9
+ import "../interfaces/0.8.x/IManifold.sol";
10
+
11
+ import "@openzeppelin-4.7/contracts/utils/Strings.sol";
12
+ import "@openzeppelin-4.7/contracts/access/Ownable.sol";
13
+ import "../libs/0.8.x/ERC721_PackedHashSeed.sol";
14
+ import "../libs/0.8.x/BytecodeStorage.sol";
15
+ import "../libs/0.8.x/Bytes32Strings.sol";
16
+
17
+ /**
18
+ * @title Art Blocks ERC-721 core contract, V3_Explorations.
19
+ * @author Art Blocks Inc.
20
+ * @notice Privileged Roles and Ownership:
21
+ * This contract is designed to be managed, with progressively limited powers
22
+ * as a project progresses from active to locked.
23
+ * Privileged roles and abilities are controlled by the admin ACL contract and
24
+ * artists. Both of these roles hold extensive power and can arbitrarily
25
+ * control and modify portions of projects, dependent upon project state. After
26
+ * a project is locked, important project metadata fields are locked including
27
+ * the project name, artist name, and script and display details. Edition size
28
+ * can never be increased.
29
+ * Care must be taken to ensure that the admin ACL contract and artist
30
+ * addresses are secure behind a multi-sig or other access control mechanism.
31
+ * ----------------------------------------------------------------------------
32
+ * The following functions are restricted to the Admin ACL contract:
33
+ * - updateArtblocksDependencyRegistryAddress
34
+ * - updateArtblocksPrimarySalesAddress
35
+ * - updateArtblocksSecondarySalesAddress
36
+ * - updateArtblocksPrimarySalesPercentage (up to 100%)
37
+ * - updateArtblocksSecondarySalesBPS (up to 100%)
38
+ * - updateMinterContract
39
+ * - updateRandomizerAddress
40
+ * - toggleProjectIsActive
41
+ * - addProject
42
+ * - forbidNewProjects (forever forbidding new projects)
43
+ * - updateDefaultBaseURI (used to initialize new project base URIs)
44
+ * ----------------------------------------------------------------------------
45
+ * The following functions are restricted to either the the Artist address or
46
+ * the Admin ACL contract, only when the project is not locked:
47
+ * - updateProjectName
48
+ * - updateProjectArtistName
49
+ * - updateProjectLicense
50
+ * - Change project script via addProjectScript, updateProjectScript,
51
+ * and removeProjectLastScript
52
+ * - updateProjectScriptType
53
+ * - updateProjectAspectRatio
54
+ * ----------------------------------------------------------------------------
55
+ * The following functions are restricted to only the Artist address:
56
+ * - proposeArtistPaymentAddressesAndSplits (Note that this has to be accepted
57
+ * by adminAcceptArtistAddressesAndSplits to take effect, which is restricted
58
+ * to the Admin ACL contract, or the artist if the core contract owner has
59
+ * renounced ownership. Also note that a proposal will be automatically
60
+ * accepted if the artist only proposes changed payee percentages without
61
+ * modifying any payee addresses, or is only removing payee addresses.)
62
+ * - toggleProjectIsPaused (note the artist can still mint while paused)
63
+ * - updateProjectSecondaryMarketRoyaltyPercentage (up to
64
+ ARTIST_MAX_SECONDARY_ROYALTY_PERCENTAGE percent)
65
+ * - updateProjectWebsite
66
+ * - updateProjectMaxInvocations (to a number greater than or equal to the
67
+ * current number of invocations, and less than current project maximum
68
+ * invocations)
69
+ * - updateProjectBaseURI (controlling the base URI for tokens in the project)
70
+ * ----------------------------------------------------------------------------
71
+ * The following function is restricted to either the Admin ACL contract, or
72
+ * the Artist address if the core contract owner has renounced ownership:
73
+ * - adminAcceptArtistAddressesAndSplits
74
+ * - updateProjectArtistAddress (owner ultimately controlling the project and
75
+ * its and-on revenue, unless owner has renounced ownership)
76
+ * ----------------------------------------------------------------------------
77
+ * The following function is restricted to the artist when a project is
78
+ * unlocked, and only callable by Admin ACL contract when a project is locked:
79
+ * - updateProjectDescription
80
+ * ----------------------------------------------------------------------------
81
+ * The following function is restricted to owner calling directly:
82
+ * - transferOwnership
83
+ * - renounceOwnership
84
+ * ----------------------------------------------------------------------------
85
+ * Additional admin and artist privileged roles may be described on minters,
86
+ * registries, and other contracts that may interact with this core contract.
87
+ */
88
+ contract GenArt721CoreV3_Explorations is
89
+ ERC721_PackedHashSeed,
90
+ Ownable,
91
+ IGenArt721CoreContractV3
92
+ {
93
+ using BytecodeStorage for string;
94
+ using BytecodeStorage for address;
95
+ using Bytes32Strings for bytes32;
96
+ using Strings for uint256;
97
+ using Strings for address;
98
+ uint256 constant ONE_HUNDRED = 100;
99
+ uint256 constant ONE_MILLION = 1_000_000;
100
+ uint24 constant ONE_MILLION_UINT24 = 1_000_000;
101
+ uint256 constant FOUR_WEEKS_IN_SECONDS = 2_419_200;
102
+ uint8 constant AT_CHARACTER_CODE = uint8(bytes1("@")); // 0x40
103
+
104
+ // numeric constants
105
+ uint256 constant ART_BLOCKS_MAX_PRIMARY_SALES_PERCENTAGE = 100; // 100%
106
+ uint256 constant ART_BLOCKS_MAX_SECONDARY_SALES_BPS = 10000; // 10_000 BPS = 100%
107
+ uint256 constant ARTIST_MAX_SECONDARY_ROYALTY_PERCENTAGE = 95; // 95%
108
+
109
+ // This contract emits generic events that contain fields that indicate
110
+ // which parameter has been updated. This is sufficient for application
111
+ // state management, while also simplifying the contract and indexing code.
112
+ // This was done as an alternative to having custom events that emit what
113
+ // field-values have changed for each event, given that changed values can
114
+ // be introspected by indexers due to the design of this smart contract
115
+ // exposing these state changes via publicly viewable fields.
116
+ //
117
+ // The following fields are used to indicate which contract-level parameter
118
+ // has been updated in the `PlatformUpdated` event:
119
+ bytes32 constant FIELD_NEXT_PROJECT_ID = "nextProjectId";
120
+ bytes32 constant FIELD_NEW_PROJECTS_FORBIDDEN = "newProjectsForbidden";
121
+ bytes32 constant FIELD_DEFAULT_BASE_URI = "defaultBaseURI";
122
+ bytes32 constant FIELD_ARTBLOCKS_PRIMARY_SALES_ADDRESS =
123
+ "artblocksPrimarySalesAddress";
124
+ bytes32 constant FIELD_ARTBLOCKS_SECONDARY_SALES_ADDRESS =
125
+ "artblocksSecondarySalesAddress";
126
+ bytes32 constant FIELD_RANDOMIZER_ADDRESS = "randomizerAddress";
127
+ // note: Curation registry address will never be updated on V3 Explorations
128
+ bytes32 constant FIELD_ARTBLOCKS_CURATION_REGISTRY_ADDRESS =
129
+ "curationRegistryAddress";
130
+ bytes32 constant FIELD_ARTBLOCKS_DEPENDENCY_REGISTRY_ADDRESS =
131
+ "dependencyRegistryAddress";
132
+ bytes32 constant FIELD_ARTBLOCKS_PRIMARY_SALES_PERCENTAGE =
133
+ "artblocksPrimaryPercentage";
134
+ bytes32 constant FIELD_ARTBLOCKS_SECONDARY_SALES_BPS =
135
+ "artblocksSecondaryBPS";
136
+ // The following fields are used to indicate which project-level parameter
137
+ // has been updated in the `ProjectUpdated` event:
138
+ bytes32 constant FIELD_PROJECT_COMPLETED = "completed";
139
+ bytes32 constant FIELD_PROJECT_ACTIVE = "active";
140
+ bytes32 constant FIELD_PROJECT_ARTIST_ADDRESS = "artistAddress";
141
+ bytes32 constant FIELD_PROJECT_PAUSED = "paused";
142
+ bytes32 constant FIELD_PROJECT_CREATED = "created";
143
+ bytes32 constant FIELD_PROJECT_NAME = "name";
144
+ bytes32 constant FIELD_PROJECT_ARTIST_NAME = "artistName";
145
+ bytes32 constant FIELD_PROJECT_SECONDARY_MARKET_ROYALTY_PERCENTAGE =
146
+ "royaltyPercentage";
147
+ bytes32 constant FIELD_PROJECT_DESCRIPTION = "description";
148
+ bytes32 constant FIELD_PROJECT_WEBSITE = "website";
149
+ bytes32 constant FIELD_PROJECT_LICENSE = "license";
150
+ bytes32 constant FIELD_PROJECT_MAX_INVOCATIONS = "maxInvocations";
151
+ bytes32 constant FIELD_PROJECT_SCRIPT = "script";
152
+ bytes32 constant FIELD_PROJECT_SCRIPT_TYPE = "scriptType";
153
+ bytes32 constant FIELD_PROJECT_ASPECT_RATIO = "aspectRatio";
154
+ bytes32 constant FIELD_PROJECT_BASE_URI = "baseURI";
155
+
156
+ /// Curation registry is not relevant for Art Blocks Explorations, and will
157
+ /// remain null for interface-conformance purposes only, specifically for
158
+ /// indexing layers.
159
+ address public artblocksCurationRegistryAddress;
160
+ /// Dependency registry managed by Art Blocks
161
+ address public artblocksDependencyRegistryAddress;
162
+
163
+ /// current randomizer contract
164
+ IRandomizerV2 public randomizerContract;
165
+
166
+ /// append-only array of all randomizer contract addresses ever used by
167
+ /// this contract
168
+ address[] private _historicalRandomizerAddresses;
169
+
170
+ /// admin ACL contract
171
+ IAdminACLV0 public adminACLContract;
172
+
173
+ struct Project {
174
+ uint24 invocations;
175
+ uint24 maxInvocations;
176
+ uint24 scriptCount;
177
+ // max uint64 ~= 1.8e19 sec ~= 570 billion years
178
+ uint64 completedTimestamp;
179
+ bool active;
180
+ bool paused;
181
+ string name;
182
+ string artist;
183
+ string description;
184
+ string website;
185
+ string license;
186
+ string projectBaseURI;
187
+ bytes32 scriptTypeAndVersion;
188
+ string aspectRatio;
189
+ // mapping from script index to address storing script in bytecode
190
+ mapping(uint256 => address) scriptBytecodeAddresses;
191
+ }
192
+
193
+ mapping(uint256 => Project) projects;
194
+
195
+ /// packed struct containing project financial information
196
+ struct ProjectFinance {
197
+ address payable additionalPayeePrimarySales;
198
+ // packed uint: max of 95, max uint8 = 255
199
+ uint8 secondaryMarketRoyaltyPercentage;
200
+ address payable additionalPayeeSecondarySales;
201
+ // packed uint: max of 100, max uint8 = 255
202
+ uint8 additionalPayeeSecondarySalesPercentage;
203
+ address payable artistAddress;
204
+ // packed uint: max of 100, max uint8 = 255
205
+ uint8 additionalPayeePrimarySalesPercentage;
206
+ }
207
+ // Project financials mapping
208
+ mapping(uint256 => ProjectFinance) projectIdToFinancials;
209
+
210
+ /// hash of artist's proposed payment updates to be approved by admin
211
+ mapping(uint256 => bytes32) public proposedArtistAddressesAndSplitsHash;
212
+
213
+ /// Art Blocks payment address for all primary sales revenues (packed)
214
+ address payable public artblocksPrimarySalesAddress;
215
+ /// Percentage of primary sales revenue allocated to Art Blocks (packed)
216
+ // packed uint: max of 25, max uint8 = 255
217
+ uint8 private _artblocksPrimarySalesPercentage = 10;
218
+
219
+ /// Art Blocks payment address for all secondary sales royalty revenues
220
+ address payable public artblocksSecondarySalesAddress;
221
+ /// Basis Points of secondary sales royalties allocated to Art Blocks
222
+ uint256 public artblocksSecondarySalesBPS = 250;
223
+
224
+ /// single minter allowed for this core contract
225
+ address public minterContract;
226
+
227
+ /// starting (initial) project ID on this contract
228
+ uint256 public immutable startingProjectId;
229
+
230
+ /// next project ID to be created
231
+ uint248 private _nextProjectId;
232
+
233
+ /// bool indicating if adding new projects is forbidden;
234
+ /// default behavior is to allow new projects
235
+ bool public newProjectsForbidden;
236
+
237
+ /// version & type of this core contract
238
+ /// coreVersion is updated from Flagship V3 core due to minor changes
239
+ /// implemented in the Explorations version of the contract.
240
+ string public constant coreVersion = "v3.0.1";
241
+ /// coreType remains consistent with flagship V3 core because external &
242
+ /// public functions used for indexing are unchanged.
243
+ string public constant coreType = "GenArt721CoreV3";
244
+
245
+ /// default base URI to initialize all new project projectBaseURI values to
246
+ string public defaultBaseURI;
247
+
248
+ modifier onlyNonZeroAddress(address _address) {
249
+ require(_address != address(0), "Must input non-zero address");
250
+ _;
251
+ }
252
+
253
+ modifier onlyNonEmptyString(string memory _string) {
254
+ require(bytes(_string).length != 0, "Must input non-empty string");
255
+ _;
256
+ }
257
+
258
+ modifier onlyValidTokenId(uint256 _tokenId) {
259
+ require(_exists(_tokenId), "Token ID does not exist");
260
+ _;
261
+ }
262
+
263
+ modifier onlyValidProjectId(uint256 _projectId) {
264
+ require(
265
+ (_projectId >= startingProjectId) && (_projectId < _nextProjectId),
266
+ "Project ID does not exist"
267
+ );
268
+ _;
269
+ }
270
+
271
+ modifier onlyUnlocked(uint256 _projectId) {
272
+ // Note: calling `_projectUnlocked` enforces that the `_projectId`
273
+ // passed in is valid.`
274
+ require(_projectUnlocked(_projectId), "Only if unlocked");
275
+ _;
276
+ }
277
+
278
+ modifier onlyAdminACL(bytes4 _selector) {
279
+ require(
280
+ adminACLAllowed(msg.sender, address(this), _selector),
281
+ "Only Admin ACL allowed"
282
+ );
283
+ _;
284
+ }
285
+
286
+ modifier onlyArtist(uint256 _projectId) {
287
+ require(
288
+ msg.sender == projectIdToFinancials[_projectId].artistAddress,
289
+ "Only artist"
290
+ );
291
+ _;
292
+ }
293
+
294
+ modifier onlyArtistOrAdminACL(uint256 _projectId, bytes4 _selector) {
295
+ require(
296
+ msg.sender == projectIdToFinancials[_projectId].artistAddress ||
297
+ adminACLAllowed(msg.sender, address(this), _selector),
298
+ "Only artist or Admin ACL allowed"
299
+ );
300
+ _;
301
+ }
302
+
303
+ /**
304
+ * This modifier allows the artist of a project to call a function if the
305
+ * owner of the contract has renounced ownership. This is to allow the
306
+ * contract to continue to function if the owner decides to renounce
307
+ * ownership.
308
+ */
309
+ modifier onlyAdminACLOrRenouncedArtist(
310
+ uint256 _projectId,
311
+ bytes4 _selector
312
+ ) {
313
+ require(
314
+ adminACLAllowed(msg.sender, address(this), _selector) ||
315
+ (owner() == address(0) &&
316
+ msg.sender ==
317
+ projectIdToFinancials[_projectId].artistAddress),
318
+ "Only Admin ACL allowed, or artist if owner has renounced"
319
+ );
320
+ _;
321
+ }
322
+
323
+ /**
324
+ * @notice Initializes contract.
325
+ * @param _tokenName Name of token.
326
+ * @param _tokenSymbol Token symbol.
327
+ * @param _randomizerContract Randomizer contract.
328
+ * @param _adminACLContract Address of admin access control contract, to be
329
+ * set as contract owner.
330
+ * @param _startingProjectId The initial next project ID.
331
+ * @dev _startingProjectId should be set to a value much, much less than
332
+ * max(uint248), but an explicit input type of `uint248` is used as it is
333
+ * safer to cast up to `uint256` than it is to cast down for the purposes
334
+ * of setting `_nextProjectId`.
335
+ */
336
+ constructor(
337
+ string memory _tokenName,
338
+ string memory _tokenSymbol,
339
+ address _randomizerContract,
340
+ address _adminACLContract,
341
+ uint248 _startingProjectId
342
+ )
343
+ ERC721_PackedHashSeed(_tokenName, _tokenSymbol)
344
+ onlyNonZeroAddress(_randomizerContract)
345
+ {
346
+ // record contracts starting project ID
347
+ // casting-up is safe
348
+ startingProjectId = uint256(_startingProjectId);
349
+ _updateArtblocksPrimarySalesAddress(msg.sender);
350
+ _updateArtblocksSecondarySalesAddress(msg.sender);
351
+ _updateRandomizerAddress(_randomizerContract);
352
+ // set AdminACL management contract as owner
353
+ _transferOwnership(_adminACLContract);
354
+ // initialize default base URI
355
+ _updateDefaultBaseURI(
356
+ string.concat(
357
+ "https://token.artblocks.io/",
358
+ address(this).toHexString(),
359
+ "/"
360
+ )
361
+ );
362
+ // initialize next project ID
363
+ _nextProjectId = _startingProjectId;
364
+ emit PlatformUpdated(FIELD_NEXT_PROJECT_ID);
365
+ }
366
+
367
+ /**
368
+ * @notice Mints a token from project `_projectId` and sets the
369
+ * token's owner to `_to`. Hash may or may not be assigned to the token
370
+ * during the mint transaction, depending on the randomizer contract.
371
+ * @param _to Address to be the minted token's owner.
372
+ * @param _projectId Project ID to mint a token on.
373
+ * @param _by Purchaser of minted token.
374
+ * @return _tokenId The ID of the minted token.
375
+ * @dev sender must be the allowed minterContract
376
+ * @dev name of function is optimized for gas usage
377
+ */
378
+ function mint_Ecf(
379
+ address _to,
380
+ uint256 _projectId,
381
+ address _by
382
+ ) external returns (uint256 _tokenId) {
383
+ // CHECKS
384
+ require(msg.sender == minterContract, "Must mint from minter contract");
385
+ Project storage project = projects[_projectId];
386
+ // load invocations into memory
387
+ uint24 invocationsBefore = project.invocations;
388
+ uint24 invocationsAfter;
389
+ unchecked {
390
+ // invocationsBefore guaranteed <= maxInvocations <= 1_000_000,
391
+ // 1_000_000 << max uint24, so no possible overflow
392
+ invocationsAfter = invocationsBefore + 1;
393
+ }
394
+ uint24 maxInvocations = project.maxInvocations;
395
+
396
+ require(
397
+ invocationsBefore < maxInvocations,
398
+ "Must not exceed max invocations"
399
+ );
400
+ require(
401
+ project.active ||
402
+ _by == projectIdToFinancials[_projectId].artistAddress,
403
+ "Project must exist and be active"
404
+ );
405
+ require(
406
+ !project.paused ||
407
+ _by == projectIdToFinancials[_projectId].artistAddress,
408
+ "Purchases are paused."
409
+ );
410
+
411
+ // EFFECTS
412
+ // increment project's invocations
413
+ project.invocations = invocationsAfter;
414
+ uint256 thisTokenId;
415
+ unchecked {
416
+ // invocationsBefore is uint24 << max uint256. In production use,
417
+ // _projectId * ONE_MILLION must be << max uint256, otherwise
418
+ // tokenIdToProjectId function become invalid.
419
+ // Therefore, no risk of overflow
420
+ thisTokenId = (_projectId * ONE_MILLION) + invocationsBefore;
421
+ }
422
+
423
+ // mark project as completed if hit max invocations
424
+ if (invocationsAfter == maxInvocations) {
425
+ _completeProject(_projectId);
426
+ }
427
+
428
+ // INTERACTIONS
429
+ _mint(_to, thisTokenId);
430
+
431
+ // token hash is updated by the randomizer contract on V3
432
+ randomizerContract.assignTokenHash(thisTokenId);
433
+
434
+ // Do not need to also log `projectId` in event, as the `projectId` for
435
+ // a given token can be derived from the `tokenId` with:
436
+ // projectId = tokenId / 1_000_000
437
+ emit Mint(_to, thisTokenId);
438
+
439
+ return thisTokenId;
440
+ }
441
+
442
+ /**
443
+ * @notice Sets the hash seed for a given token ID `_tokenId`.
444
+ * May only be called by the current randomizer contract.
445
+ * May only be called for tokens that have not already been assigned a
446
+ * non-zero hash.
447
+ * @param _tokenId Token ID to set the hash for.
448
+ * @param _hashSeed Hash seed to set for the token ID. Only last 12 bytes
449
+ * will be used.
450
+ * @dev gas-optimized function name because called during mint sequence
451
+ * @dev if a separate event is required when the token hash is set, e.g.
452
+ * for indexing purposes, it must be emitted by the randomizer. This is to
453
+ * minimize gas when minting.
454
+ */
455
+ function setTokenHash_8PT(
456
+ uint256 _tokenId,
457
+ bytes32 _hashSeed
458
+ ) external onlyValidTokenId(_tokenId) {
459
+ OwnerAndHashSeed storage ownerAndHashSeed = _ownersAndHashSeeds[
460
+ _tokenId
461
+ ];
462
+ require(
463
+ msg.sender == address(randomizerContract),
464
+ "Only randomizer may set"
465
+ );
466
+ require(
467
+ ownerAndHashSeed.hashSeed == bytes12(0),
468
+ "Token hash already set"
469
+ );
470
+ require(_hashSeed != bytes12(0), "No zero hash seed");
471
+ ownerAndHashSeed.hashSeed = bytes12(_hashSeed);
472
+ }
473
+
474
+ /**
475
+ * @notice Allows owner (AdminACL) to revoke ownership of the contract.
476
+ * Note that the contract is intended to continue to function after the
477
+ * owner renounces ownership, but no new projects will be able to be added.
478
+ * Renouncing ownership will leave the contract without an owner,
479
+ * thereby removing any functionality that is only available to the
480
+ * owner/AdminACL contract. The same is true for any dependent contracts
481
+ * that also integrate with the owner/AdminACL contract (e.g. potentially
482
+ * minter suite contracts, registry contracts, etc.).
483
+ * After renouncing ownership, artists will be in control of updates to
484
+ * their payment addresses and splits (see modifier
485
+ * onlyAdminACLOrRenouncedArtist`).
486
+ * While there is no currently intended reason to call this method based on
487
+ * defined Art Blocks business practices, this method exists to allow
488
+ * artists to continue to maintain the limited set of contract
489
+ * functionality that exists post-project-lock in an environment in which
490
+ * there is no longer an admin maintaining this smart contract.
491
+ * @dev This function is intended to be called directly by the AdminACL,
492
+ * not by an address allowed by the AdminACL contract.
493
+ */
494
+ function renounceOwnership() public override onlyOwner {
495
+ // broadcast that new projects are no longer allowed (if not already)
496
+ _forbidNewProjects();
497
+ // renounce ownership viw Ownable
498
+ Ownable.renounceOwnership();
499
+ }
500
+
501
+ /**
502
+ * @notice Warning: Configuring Curation Registry contract is not supported
503
+ * on V3 Explorations version of this contract.
504
+ * This method exists only to maintain this portion of the contract
505
+ * interface with other V3 cores.
506
+ * @param _artblocksCurationRegistryAddress)
507
+ */
508
+ function updateArtblocksCurationRegistryAddress(
509
+ address _artblocksCurationRegistryAddress
510
+ )
511
+ external
512
+ onlyAdminACL(this.updateArtblocksCurationRegistryAddress.selector)
513
+ onlyNonZeroAddress(_artblocksCurationRegistryAddress)
514
+ {
515
+ revert("Action not supported");
516
+ }
517
+
518
+ /**
519
+ * @notice Updates reference to Art Blocks Dependency Registry contract.
520
+ * @param _artblocksDependencyRegistryAddress Address of new Dependency
521
+ * Registry.
522
+ */
523
+ function updateArtblocksDependencyRegistryAddress(
524
+ address _artblocksDependencyRegistryAddress
525
+ )
526
+ external
527
+ onlyAdminACL(this.updateArtblocksDependencyRegistryAddress.selector)
528
+ onlyNonZeroAddress(_artblocksDependencyRegistryAddress)
529
+ {
530
+ artblocksDependencyRegistryAddress = _artblocksDependencyRegistryAddress;
531
+ emit PlatformUpdated(FIELD_ARTBLOCKS_DEPENDENCY_REGISTRY_ADDRESS);
532
+ }
533
+
534
+ /**
535
+ * @notice Updates artblocksPrimarySalesAddress to
536
+ * `_artblocksPrimarySalesAddress`.
537
+ * @param _artblocksPrimarySalesAddress Address of new primary sales
538
+ * payment address.
539
+ */
540
+ function updateArtblocksPrimarySalesAddress(
541
+ address payable _artblocksPrimarySalesAddress
542
+ )
543
+ external
544
+ onlyAdminACL(this.updateArtblocksPrimarySalesAddress.selector)
545
+ onlyNonZeroAddress(_artblocksPrimarySalesAddress)
546
+ {
547
+ _updateArtblocksPrimarySalesAddress(_artblocksPrimarySalesAddress);
548
+ }
549
+
550
+ /**
551
+ * @notice Updates Art Blocks secondary sales royalty payment address to
552
+ * `_artblocksSecondarySalesAddress`.
553
+ * @param _artblocksSecondarySalesAddress Address of new secondary sales
554
+ * payment address.
555
+ */
556
+ function updateArtblocksSecondarySalesAddress(
557
+ address payable _artblocksSecondarySalesAddress
558
+ )
559
+ external
560
+ onlyAdminACL(this.updateArtblocksSecondarySalesAddress.selector)
561
+ onlyNonZeroAddress(_artblocksSecondarySalesAddress)
562
+ {
563
+ _updateArtblocksSecondarySalesAddress(_artblocksSecondarySalesAddress);
564
+ }
565
+
566
+ /**
567
+ * @notice Updates Art Blocks primary sales revenue percentage to
568
+ * `artblocksPrimarySalesPercentage_`.
569
+ * @param artblocksPrimarySalesPercentage_ New primary sales revenue
570
+ * percentage.
571
+ */
572
+ function updateArtblocksPrimarySalesPercentage(
573
+ uint256 artblocksPrimarySalesPercentage_
574
+ )
575
+ external
576
+ onlyAdminACL(this.updateArtblocksPrimarySalesPercentage.selector)
577
+ {
578
+ require(
579
+ artblocksPrimarySalesPercentage_ <=
580
+ ART_BLOCKS_MAX_PRIMARY_SALES_PERCENTAGE,
581
+ "Max of ART_BLOCKS_MAX_PRIMARY_SALES_PERCENTAGE percent"
582
+ );
583
+ _artblocksPrimarySalesPercentage = uint8(
584
+ artblocksPrimarySalesPercentage_
585
+ );
586
+ emit PlatformUpdated(FIELD_ARTBLOCKS_PRIMARY_SALES_PERCENTAGE);
587
+ }
588
+
589
+ /**
590
+ * @notice Updates Art Blocks secondary sales royalty Basis Points to
591
+ * `_artblocksSecondarySalesBPS`.
592
+ * @param _artblocksSecondarySalesBPS New secondary sales royalty Basis
593
+ * points.
594
+ * @dev Due to secondary royalties being ultimately enforced via social
595
+ * consensus, no hard upper limit is imposed on the BPS value, other than
596
+ * <= 100% royalty, which would not make mathematical sense. Realistically,
597
+ * changing this value is expected to either never occur, or be a rare
598
+ * occurrence.
599
+ */
600
+ function updateArtblocksSecondarySalesBPS(
601
+ uint256 _artblocksSecondarySalesBPS
602
+ ) external onlyAdminACL(this.updateArtblocksSecondarySalesBPS.selector) {
603
+ require(
604
+ _artblocksSecondarySalesBPS <= ART_BLOCKS_MAX_SECONDARY_SALES_BPS,
605
+ "Max of ART_BLOCKS_MAX_SECONDARY_SALES_BPS BPS"
606
+ );
607
+ artblocksSecondarySalesBPS = _artblocksSecondarySalesBPS;
608
+ emit PlatformUpdated(FIELD_ARTBLOCKS_SECONDARY_SALES_BPS);
609
+ }
610
+
611
+ /**
612
+ * @notice Updates minter to `_address`.
613
+ * @param _address Address of new minter.
614
+ */
615
+ function updateMinterContract(
616
+ address _address
617
+ )
618
+ external
619
+ onlyAdminACL(this.updateMinterContract.selector)
620
+ onlyNonZeroAddress(_address)
621
+ {
622
+ minterContract = _address;
623
+ emit MinterUpdated(_address);
624
+ }
625
+
626
+ /**
627
+ * @notice Updates randomizer to `_randomizerAddress`.
628
+ * @param _randomizerAddress Address of new randomizer.
629
+ */
630
+ function updateRandomizerAddress(
631
+ address _randomizerAddress
632
+ )
633
+ external
634
+ onlyAdminACL(this.updateRandomizerAddress.selector)
635
+ onlyNonZeroAddress(_randomizerAddress)
636
+ {
637
+ _updateRandomizerAddress(_randomizerAddress);
638
+ }
639
+
640
+ /**
641
+ * @notice Toggles project `_projectId` as active/inactive.
642
+ * @param _projectId Project ID to be toggled.
643
+ */
644
+ function toggleProjectIsActive(
645
+ uint256 _projectId
646
+ )
647
+ external
648
+ onlyAdminACL(this.toggleProjectIsActive.selector)
649
+ onlyValidProjectId(_projectId)
650
+ {
651
+ projects[_projectId].active = !projects[_projectId].active;
652
+ emit ProjectUpdated(_projectId, FIELD_PROJECT_ACTIVE);
653
+ }
654
+
655
+ /**
656
+ * @notice Artist proposes updated set of artist address, additional payee
657
+ * addresses, and percentage splits for project `_projectId`. Addresses and
658
+ * percentages do not have to all be changed, but they must all be defined
659
+ * as a complete set.
660
+ * Note that if the artist is only proposing a change to the payee percentage
661
+ * splits, without modifying the payee addresses, the proposal will be
662
+ * automatically approved and the new splits will become active immediately.
663
+ * Automatic approval will also be granted if the artist is only removing
664
+ * additional payee addresses, without adding any new ones.
665
+ * Also note that if the artist is proposing sending funds to the zero
666
+ * address, this function will revert and the proposal will not be created.
667
+ * @param _projectId Project ID.
668
+ * @param _artistAddress Artist address that controls the project, and may
669
+ * receive payments.
670
+ * @param _additionalPayeePrimarySales Address that may receive a
671
+ * percentage split of the artist's primary sales revenue.
672
+ * @param _additionalPayeePrimarySalesPercentage Percent of artist's
673
+ * portion of primary sale revenue that will be split to address
674
+ * `_additionalPayeePrimarySales`.
675
+ * @param _additionalPayeeSecondarySales Address that may receive a percentage
676
+ * split of the secondary sales royalties.
677
+ * @param _additionalPayeeSecondarySalesPercentage Percent of artist's portion
678
+ * of secondary sale royalties that will be split to address
679
+ * `_additionalPayeeSecondarySales`.
680
+ * @dev `_artistAddress` must be a valid address (non-zero-address), but it
681
+ * is intentionally allowable for `_additionalPayee{Primary,Secondaary}Sales`
682
+ * and their associated percentages to be zero'd out by the controlling artist.
683
+ */
684
+ function proposeArtistPaymentAddressesAndSplits(
685
+ uint256 _projectId,
686
+ address payable _artistAddress,
687
+ address payable _additionalPayeePrimarySales,
688
+ uint256 _additionalPayeePrimarySalesPercentage,
689
+ address payable _additionalPayeeSecondarySales,
690
+ uint256 _additionalPayeeSecondarySalesPercentage
691
+ )
692
+ external
693
+ onlyValidProjectId(_projectId)
694
+ onlyArtist(_projectId)
695
+ onlyNonZeroAddress(_artistAddress)
696
+ {
697
+ ProjectFinance storage projectFinance = projectIdToFinancials[
698
+ _projectId
699
+ ];
700
+ // checks
701
+ require(
702
+ _additionalPayeePrimarySalesPercentage <= ONE_HUNDRED &&
703
+ _additionalPayeeSecondarySalesPercentage <= ONE_HUNDRED,
704
+ "Max of 100%"
705
+ );
706
+ require(
707
+ _additionalPayeePrimarySalesPercentage == 0 ||
708
+ _additionalPayeePrimarySales != address(0),
709
+ "Primary payee is zero address"
710
+ );
711
+ require(
712
+ _additionalPayeeSecondarySalesPercentage == 0 ||
713
+ _additionalPayeeSecondarySales != address(0),
714
+ "Secondary payee is zero address"
715
+ );
716
+ // effects
717
+ // emit event for off-chain indexing
718
+ // note: always emit a proposal event, even in the pathway of
719
+ // automatic approval, to simplify indexing expectations
720
+ emit ProposedArtistAddressesAndSplits(
721
+ _projectId,
722
+ _artistAddress,
723
+ _additionalPayeePrimarySales,
724
+ _additionalPayeePrimarySalesPercentage,
725
+ _additionalPayeeSecondarySales,
726
+ _additionalPayeeSecondarySalesPercentage
727
+ );
728
+ // automatically accept if no proposed addresses modifications, or if
729
+ // the proposal only removes payee addresses.
730
+ // store proposal hash on-chain, only if not automatic accept
731
+ bool automaticAccept;
732
+ {
733
+ // block scope to avoid stack too deep error
734
+ bool artistUnchanged = _artistAddress ==
735
+ projectFinance.artistAddress;
736
+ bool additionalPrimaryUnchangedOrRemoved = (_additionalPayeePrimarySales ==
737
+ projectFinance.additionalPayeePrimarySales) ||
738
+ (_additionalPayeePrimarySales == address(0));
739
+ bool additionalSecondaryUnchangedOrRemoved = (_additionalPayeeSecondarySales ==
740
+ projectFinance.additionalPayeeSecondarySales) ||
741
+ (_additionalPayeeSecondarySales == address(0));
742
+ automaticAccept =
743
+ artistUnchanged &&
744
+ additionalPrimaryUnchangedOrRemoved &&
745
+ additionalSecondaryUnchangedOrRemoved;
746
+ }
747
+ if (automaticAccept) {
748
+ // clear any previously proposed values
749
+ proposedArtistAddressesAndSplitsHash[_projectId] = bytes32(0);
750
+ // update storage
751
+ // (artist address cannot change during automatic accept)
752
+ projectFinance
753
+ .additionalPayeePrimarySales = _additionalPayeePrimarySales;
754
+ // safe to cast as uint8 as max is 100%, max uint8 is 255
755
+ projectFinance.additionalPayeePrimarySalesPercentage = uint8(
756
+ _additionalPayeePrimarySalesPercentage
757
+ );
758
+ projectFinance
759
+ .additionalPayeeSecondarySales = _additionalPayeeSecondarySales;
760
+ // safe to cast as uint8 as max is 100%, max uint8 is 255
761
+ projectFinance.additionalPayeeSecondarySalesPercentage = uint8(
762
+ _additionalPayeeSecondarySalesPercentage
763
+ );
764
+ // emit event for off-chain indexing
765
+ emit AcceptedArtistAddressesAndSplits(_projectId);
766
+ } else {
767
+ proposedArtistAddressesAndSplitsHash[_projectId] = keccak256(
768
+ abi.encode(
769
+ _artistAddress,
770
+ _additionalPayeePrimarySales,
771
+ _additionalPayeePrimarySalesPercentage,
772
+ _additionalPayeeSecondarySales,
773
+ _additionalPayeeSecondarySalesPercentage
774
+ )
775
+ );
776
+ }
777
+ }
778
+
779
+ /**
780
+ * @notice Admin accepts a proposed set of updated artist address,
781
+ * additional payee addresses, and percentage splits for project
782
+ * `_projectId`. Addresses and percentages do not have to all be changed,
783
+ * but they must all be defined as a complete set.
784
+ * @param _projectId Project ID.
785
+ * @param _artistAddress Artist address that controls the project, and may
786
+ * receive payments.
787
+ * @param _additionalPayeePrimarySales Address that may receive a
788
+ * percentage split of the artist's primary sales revenue.
789
+ * @param _additionalPayeePrimarySalesPercentage Percent of artist's
790
+ * portion of primary sale revenue that will be split to address
791
+ * `_additionalPayeePrimarySales`.
792
+ * @param _additionalPayeeSecondarySales Address that may receive a percentage
793
+ * split of the secondary sales royalties.
794
+ * @param _additionalPayeeSecondarySalesPercentage Percent of artist's portion
795
+ * of secondary sale royalties that will be split to address
796
+ * `_additionalPayeeSecondarySales`.
797
+ * @dev this must be called by the Admin ACL contract, and must only accept
798
+ * the most recent proposed values for a given project (validated on-chain
799
+ * by comparing the hash of the proposed and accepted values).
800
+ * @dev `_artistAddress` must be a valid address (non-zero-address), but it
801
+ * is intentionally allowable for `_additionalPayee{Primary,Secondaary}Sales`
802
+ * and their associated percentages to be zero'd out by the controlling artist.
803
+ */
804
+ function adminAcceptArtistAddressesAndSplits(
805
+ uint256 _projectId,
806
+ address payable _artistAddress,
807
+ address payable _additionalPayeePrimarySales,
808
+ uint256 _additionalPayeePrimarySalesPercentage,
809
+ address payable _additionalPayeeSecondarySales,
810
+ uint256 _additionalPayeeSecondarySalesPercentage
811
+ )
812
+ external
813
+ onlyValidProjectId(_projectId)
814
+ onlyAdminACLOrRenouncedArtist(
815
+ _projectId,
816
+ this.adminAcceptArtistAddressesAndSplits.selector
817
+ )
818
+ onlyNonZeroAddress(_artistAddress)
819
+ {
820
+ // checks
821
+ require(
822
+ proposedArtistAddressesAndSplitsHash[_projectId] ==
823
+ keccak256(
824
+ abi.encode(
825
+ _artistAddress,
826
+ _additionalPayeePrimarySales,
827
+ _additionalPayeePrimarySalesPercentage,
828
+ _additionalPayeeSecondarySales,
829
+ _additionalPayeeSecondarySalesPercentage
830
+ )
831
+ ),
832
+ "Must match artist proposal"
833
+ );
834
+ // effects
835
+ ProjectFinance storage projectFinance = projectIdToFinancials[
836
+ _projectId
837
+ ];
838
+ projectFinance.artistAddress = _artistAddress;
839
+ projectFinance
840
+ .additionalPayeePrimarySales = _additionalPayeePrimarySales;
841
+ projectFinance.additionalPayeePrimarySalesPercentage = uint8(
842
+ _additionalPayeePrimarySalesPercentage
843
+ );
844
+ projectFinance
845
+ .additionalPayeeSecondarySales = _additionalPayeeSecondarySales;
846
+ projectFinance.additionalPayeeSecondarySalesPercentage = uint8(
847
+ _additionalPayeeSecondarySalesPercentage
848
+ );
849
+ // clear proposed values
850
+ proposedArtistAddressesAndSplitsHash[_projectId] = bytes32(0);
851
+ // emit event for off-chain indexing
852
+ emit AcceptedArtistAddressesAndSplits(_projectId);
853
+ }
854
+
855
+ /**
856
+ * @notice Updates artist of project `_projectId` to `_artistAddress`.
857
+ * This is to only be used in the event that the artist address is
858
+ * compromised or sanctioned.
859
+ * @param _projectId Project ID.
860
+ * @param _artistAddress New artist address.
861
+ */
862
+ function updateProjectArtistAddress(
863
+ uint256 _projectId,
864
+ address payable _artistAddress
865
+ )
866
+ external
867
+ onlyValidProjectId(_projectId)
868
+ onlyAdminACLOrRenouncedArtist(
869
+ _projectId,
870
+ this.updateProjectArtistAddress.selector
871
+ )
872
+ onlyNonZeroAddress(_artistAddress)
873
+ {
874
+ projectIdToFinancials[_projectId].artistAddress = _artistAddress;
875
+ emit ProjectUpdated(_projectId, FIELD_PROJECT_ARTIST_ADDRESS);
876
+ }
877
+
878
+ /**
879
+ * @notice Toggles paused state of project `_projectId`.
880
+ * @param _projectId Project ID to be toggled.
881
+ */
882
+ function toggleProjectIsPaused(
883
+ uint256 _projectId
884
+ ) external onlyArtist(_projectId) {
885
+ projects[_projectId].paused = !projects[_projectId].paused;
886
+ emit ProjectUpdated(_projectId, FIELD_PROJECT_PAUSED);
887
+ }
888
+
889
+ /**
890
+ * @notice Adds new project `_projectName` by `_artistAddress`.
891
+ * @param _projectName Project name.
892
+ * @param _artistAddress Artist's address.
893
+ * @dev token price now stored on minter
894
+ */
895
+ function addProject(
896
+ string memory _projectName,
897
+ address payable _artistAddress
898
+ )
899
+ external
900
+ onlyAdminACL(this.addProject.selector)
901
+ onlyNonEmptyString(_projectName)
902
+ onlyNonZeroAddress(_artistAddress)
903
+ {
904
+ require(!newProjectsForbidden, "New projects forbidden");
905
+ uint256 projectId = _nextProjectId;
906
+ projectIdToFinancials[projectId].artistAddress = _artistAddress;
907
+ projects[projectId].name = _projectName;
908
+ projects[projectId].paused = true;
909
+ projects[projectId].maxInvocations = ONE_MILLION_UINT24;
910
+ projects[projectId].projectBaseURI = defaultBaseURI;
911
+
912
+ _nextProjectId = uint248(projectId) + 1;
913
+ emit ProjectUpdated(projectId, FIELD_PROJECT_CREATED);
914
+ }
915
+
916
+ /**
917
+ * @notice Forever forbids new projects from being added to this contract.
918
+ */
919
+ function forbidNewProjects()
920
+ external
921
+ onlyAdminACL(this.forbidNewProjects.selector)
922
+ {
923
+ require(!newProjectsForbidden, "Already forbidden");
924
+ _forbidNewProjects();
925
+ }
926
+
927
+ /**
928
+ * @notice Updates name of project `_projectId` to be `_projectName`.
929
+ * @param _projectId Project ID.
930
+ * @param _projectName New project name.
931
+ */
932
+ function updateProjectName(
933
+ uint256 _projectId,
934
+ string memory _projectName
935
+ )
936
+ external
937
+ onlyUnlocked(_projectId)
938
+ onlyArtistOrAdminACL(_projectId, this.updateProjectName.selector)
939
+ onlyNonEmptyString(_projectName)
940
+ {
941
+ projects[_projectId].name = _projectName;
942
+ emit ProjectUpdated(_projectId, FIELD_PROJECT_NAME);
943
+ }
944
+
945
+ /**
946
+ * @notice Updates artist name for project `_projectId` to be
947
+ * `_projectArtistName`.
948
+ * @param _projectId Project ID.
949
+ * @param _projectArtistName New artist name.
950
+ */
951
+ function updateProjectArtistName(
952
+ uint256 _projectId,
953
+ string memory _projectArtistName
954
+ )
955
+ external
956
+ onlyUnlocked(_projectId)
957
+ onlyArtistOrAdminACL(_projectId, this.updateProjectArtistName.selector)
958
+ onlyNonEmptyString(_projectArtistName)
959
+ {
960
+ projects[_projectId].artist = _projectArtistName;
961
+ emit ProjectUpdated(_projectId, FIELD_PROJECT_ARTIST_NAME);
962
+ }
963
+
964
+ /**
965
+ * @notice Updates artist secondary market royalties for project
966
+ * `_projectId` to be `_secondMarketRoyalty` percent.
967
+ * This DOES NOT include the secondary market royalty percentages collected
968
+ * by Art Blocks; this is only the total percentage of royalties that will
969
+ * be split to artist and additionalSecondaryPayee.
970
+ * @param _projectId Project ID.
971
+ * @param _secondMarketRoyalty Percent of secondary sales revenue that will
972
+ * be split to artist and additionalSecondaryPayee. This must be less than
973
+ * or equal to ARTIST_MAX_SECONDARY_ROYALTY_PERCENTAGE percent.
974
+ */
975
+ function updateProjectSecondaryMarketRoyaltyPercentage(
976
+ uint256 _projectId,
977
+ uint256 _secondMarketRoyalty
978
+ ) external onlyArtist(_projectId) {
979
+ require(
980
+ _secondMarketRoyalty <= ARTIST_MAX_SECONDARY_ROYALTY_PERCENTAGE,
981
+ "Max of ARTIST_MAX_SECONDARY_ROYALTY_PERCENTAGE percent"
982
+ );
983
+ projectIdToFinancials[_projectId]
984
+ .secondaryMarketRoyaltyPercentage = uint8(_secondMarketRoyalty);
985
+ emit ProjectUpdated(
986
+ _projectId,
987
+ FIELD_PROJECT_SECONDARY_MARKET_ROYALTY_PERCENTAGE
988
+ );
989
+ }
990
+
991
+ /**
992
+ * @notice Updates description of project `_projectId`.
993
+ * Only artist may call when unlocked, only admin may call when locked.
994
+ * @param _projectId Project ID.
995
+ * @param _projectDescription New project description.
996
+ */
997
+ function updateProjectDescription(
998
+ uint256 _projectId,
999
+ string memory _projectDescription
1000
+ ) external {
1001
+ // checks
1002
+ require(
1003
+ _projectUnlocked(_projectId)
1004
+ ? msg.sender == projectIdToFinancials[_projectId].artistAddress
1005
+ : adminACLAllowed(
1006
+ msg.sender,
1007
+ address(this),
1008
+ this.updateProjectDescription.selector
1009
+ ),
1010
+ "Only artist when unlocked, owner when locked"
1011
+ );
1012
+ // effects
1013
+ projects[_projectId].description = _projectDescription;
1014
+ emit ProjectUpdated(_projectId, FIELD_PROJECT_DESCRIPTION);
1015
+ }
1016
+
1017
+ /**
1018
+ * @notice Updates website of project `_projectId` to be `_projectWebsite`.
1019
+ * @param _projectId Project ID.
1020
+ * @param _projectWebsite New project website.
1021
+ * @dev It is intentionally allowed for this to be set to the empty string.
1022
+ */
1023
+ function updateProjectWebsite(
1024
+ uint256 _projectId,
1025
+ string memory _projectWebsite
1026
+ ) external onlyArtist(_projectId) {
1027
+ projects[_projectId].website = _projectWebsite;
1028
+ emit ProjectUpdated(_projectId, FIELD_PROJECT_WEBSITE);
1029
+ }
1030
+
1031
+ /**
1032
+ * @notice Updates license for project `_projectId`.
1033
+ * @param _projectId Project ID.
1034
+ * @param _projectLicense New project license.
1035
+ */
1036
+ function updateProjectLicense(
1037
+ uint256 _projectId,
1038
+ string memory _projectLicense
1039
+ )
1040
+ external
1041
+ onlyUnlocked(_projectId)
1042
+ onlyArtistOrAdminACL(_projectId, this.updateProjectLicense.selector)
1043
+ onlyNonEmptyString(_projectLicense)
1044
+ {
1045
+ projects[_projectId].license = _projectLicense;
1046
+ emit ProjectUpdated(_projectId, FIELD_PROJECT_LICENSE);
1047
+ }
1048
+
1049
+ /**
1050
+ * @notice Updates maximum invocations for project `_projectId` to
1051
+ * `_maxInvocations`. Maximum invocations may only be decreased by the
1052
+ * artist, and must be greater than or equal to current invocations.
1053
+ * New projects are created with maximum invocations of 1 million by
1054
+ * default.
1055
+ * @param _projectId Project ID.
1056
+ * @param _maxInvocations New maximum invocations.
1057
+ */
1058
+ function updateProjectMaxInvocations(
1059
+ uint256 _projectId,
1060
+ uint24 _maxInvocations
1061
+ ) external onlyArtist(_projectId) {
1062
+ // CHECKS
1063
+ Project storage project = projects[_projectId];
1064
+ uint256 _invocations = project.invocations;
1065
+ require(
1066
+ (_maxInvocations < project.maxInvocations),
1067
+ "maxInvocations may only be decreased"
1068
+ );
1069
+ require(
1070
+ _maxInvocations >= _invocations,
1071
+ "Only max invocations gte current invocations"
1072
+ );
1073
+ // EFFECTS
1074
+ project.maxInvocations = _maxInvocations;
1075
+ emit ProjectUpdated(_projectId, FIELD_PROJECT_MAX_INVOCATIONS);
1076
+
1077
+ // register completed timestamp if action completed the project
1078
+ if (_maxInvocations == _invocations) {
1079
+ _completeProject(_projectId);
1080
+ }
1081
+ }
1082
+
1083
+ /**
1084
+ * @notice Adds a script to project `_projectId`.
1085
+ * @param _projectId Project to be updated.
1086
+ * @param _script Script to be added.
1087
+ */
1088
+ function addProjectScript(
1089
+ uint256 _projectId,
1090
+ string memory _script
1091
+ )
1092
+ external
1093
+ onlyUnlocked(_projectId)
1094
+ onlyArtistOrAdminACL(_projectId, this.addProjectScript.selector)
1095
+ onlyNonEmptyString(_script)
1096
+ {
1097
+ Project storage project = projects[_projectId];
1098
+ // store script in contract bytecode
1099
+ project.scriptBytecodeAddresses[project.scriptCount] = _script
1100
+ .writeToBytecode();
1101
+ project.scriptCount = project.scriptCount + 1;
1102
+ emit ProjectUpdated(_projectId, FIELD_PROJECT_SCRIPT);
1103
+ }
1104
+
1105
+ /**
1106
+ * @notice Updates script for project `_projectId` at script ID `_scriptId`.
1107
+ * @param _projectId Project to be updated.
1108
+ * @param _scriptId Script ID to be updated.
1109
+ * @param _script The updated script value.
1110
+ */
1111
+ function updateProjectScript(
1112
+ uint256 _projectId,
1113
+ uint256 _scriptId,
1114
+ string memory _script
1115
+ )
1116
+ external
1117
+ onlyUnlocked(_projectId)
1118
+ onlyArtistOrAdminACL(_projectId, this.updateProjectScript.selector)
1119
+ onlyNonEmptyString(_script)
1120
+ {
1121
+ Project storage project = projects[_projectId];
1122
+ require(_scriptId < project.scriptCount, "scriptId out of range");
1123
+ // purge old contract bytecode contract from the blockchain state
1124
+ project.scriptBytecodeAddresses[_scriptId].purgeBytecode();
1125
+ // store script in contract bytecode, replacing reference address from
1126
+ // the contract that no longer exists with the newly created one
1127
+ project.scriptBytecodeAddresses[_scriptId] = _script.writeToBytecode();
1128
+ emit ProjectUpdated(_projectId, FIELD_PROJECT_SCRIPT);
1129
+ }
1130
+
1131
+ /**
1132
+ * @notice Removes last script from project `_projectId`.
1133
+ * @param _projectId Project to be updated.
1134
+ */
1135
+ function removeProjectLastScript(
1136
+ uint256 _projectId
1137
+ )
1138
+ external
1139
+ onlyUnlocked(_projectId)
1140
+ onlyArtistOrAdminACL(_projectId, this.removeProjectLastScript.selector)
1141
+ {
1142
+ Project storage project = projects[_projectId];
1143
+ require(project.scriptCount > 0, "there are no scripts to remove");
1144
+ // purge old contract bytecode contract from the blockchain state
1145
+ project
1146
+ .scriptBytecodeAddresses[project.scriptCount - 1]
1147
+ .purgeBytecode();
1148
+ // delete reference to contract address that no longer exists
1149
+ delete project.scriptBytecodeAddresses[project.scriptCount - 1];
1150
+ unchecked {
1151
+ project.scriptCount = project.scriptCount - 1;
1152
+ }
1153
+ emit ProjectUpdated(_projectId, FIELD_PROJECT_SCRIPT);
1154
+ }
1155
+
1156
+ /**
1157
+ * @notice Updates script type for project `_projectId`.
1158
+ * @param _projectId Project to be updated.
1159
+ * @param _scriptTypeAndVersion Script type and version e.g. "p5js@1.0.0",
1160
+ * as bytes32 encoded string.
1161
+ */
1162
+ function updateProjectScriptType(
1163
+ uint256 _projectId,
1164
+ bytes32 _scriptTypeAndVersion
1165
+ )
1166
+ external
1167
+ onlyUnlocked(_projectId)
1168
+ onlyArtistOrAdminACL(_projectId, this.updateProjectScriptType.selector)
1169
+ {
1170
+ Project storage project = projects[_projectId];
1171
+ // require exactly one @ symbol in _scriptTypeAndVersion
1172
+ require(
1173
+ _scriptTypeAndVersion.containsExactCharacterQty(
1174
+ AT_CHARACTER_CODE,
1175
+ uint8(1)
1176
+ ),
1177
+ "must contain exactly one @"
1178
+ );
1179
+ project.scriptTypeAndVersion = _scriptTypeAndVersion;
1180
+ emit ProjectUpdated(_projectId, FIELD_PROJECT_SCRIPT_TYPE);
1181
+ }
1182
+
1183
+ /**
1184
+ * @notice Updates project's aspect ratio.
1185
+ * @param _projectId Project to be updated.
1186
+ * @param _aspectRatio Aspect ratio to be set. Intended to be string in the
1187
+ * format of a decimal, e.g. "1" for square, "1.77777778" for 16:9, etc.,
1188
+ * allowing for a maximum of 10 digits and one (optional) decimal separator.
1189
+ */
1190
+ function updateProjectAspectRatio(
1191
+ uint256 _projectId,
1192
+ string memory _aspectRatio
1193
+ )
1194
+ external
1195
+ onlyUnlocked(_projectId)
1196
+ onlyArtistOrAdminACL(_projectId, this.updateProjectAspectRatio.selector)
1197
+ onlyNonEmptyString(_aspectRatio)
1198
+ {
1199
+ // Perform more detailed input validation for aspect ratio.
1200
+ bytes memory aspectRatioBytes = bytes(_aspectRatio);
1201
+ uint256 bytesLength = aspectRatioBytes.length;
1202
+ require(bytesLength <= 11, "Aspect ratio format too long");
1203
+ bool hasSeenDecimalSeparator = false;
1204
+ bool hasSeenNumber = false;
1205
+ for (uint256 i; i < bytesLength; i++) {
1206
+ bytes1 character = aspectRatioBytes[i];
1207
+ // Allow as many #s as desired.
1208
+ if (character >= 0x30 && character <= 0x39) {
1209
+ // 9-0
1210
+ // We need to ensure there is at least 1 `9-0` occurrence.
1211
+ hasSeenNumber = true;
1212
+ continue;
1213
+ }
1214
+ if (character == 0x2E) {
1215
+ // .
1216
+ // Allow no more than 1 `.` occurrence.
1217
+ if (!hasSeenDecimalSeparator) {
1218
+ hasSeenDecimalSeparator = true;
1219
+ continue;
1220
+ }
1221
+ }
1222
+ revert("Improperly formatted aspect ratio");
1223
+ }
1224
+ require(hasSeenNumber, "Aspect ratio has no numbers");
1225
+
1226
+ projects[_projectId].aspectRatio = _aspectRatio;
1227
+ emit ProjectUpdated(_projectId, FIELD_PROJECT_ASPECT_RATIO);
1228
+ }
1229
+
1230
+ /**
1231
+ * @notice Updates base URI for project `_projectId` to `_newBaseURI`.
1232
+ * This is the controlling base URI for all tokens in the project. The
1233
+ * contract-level defaultBaseURI is only used when initializing new
1234
+ * projects.
1235
+ * @param _projectId Project to be updated.
1236
+ * @param _newBaseURI New base URI.
1237
+ */
1238
+ function updateProjectBaseURI(
1239
+ uint256 _projectId,
1240
+ string memory _newBaseURI
1241
+ ) external onlyArtist(_projectId) onlyNonEmptyString(_newBaseURI) {
1242
+ projects[_projectId].projectBaseURI = _newBaseURI;
1243
+ emit ProjectUpdated(_projectId, FIELD_PROJECT_BASE_URI);
1244
+ }
1245
+
1246
+ /**
1247
+ * @notice Updates default base URI to `_defaultBaseURI`. The
1248
+ * contract-level defaultBaseURI is only used when initializing new
1249
+ * projects. Token URIs are determined by their project's `projectBaseURI`.
1250
+ * @param _defaultBaseURI New default base URI.
1251
+ */
1252
+ function updateDefaultBaseURI(
1253
+ string memory _defaultBaseURI
1254
+ )
1255
+ external
1256
+ onlyAdminACL(this.updateDefaultBaseURI.selector)
1257
+ onlyNonEmptyString(_defaultBaseURI)
1258
+ {
1259
+ _updateDefaultBaseURI(_defaultBaseURI);
1260
+ }
1261
+
1262
+ /**
1263
+ * @notice Next project ID to be created on this contract.
1264
+ * @return uint256 Next project ID.
1265
+ */
1266
+ function nextProjectId() external view returns (uint256) {
1267
+ return _nextProjectId;
1268
+ }
1269
+
1270
+ /**
1271
+ * @notice Returns token hash for token ID `_tokenId`. Returns null if hash
1272
+ * has not been set.
1273
+ * @param _tokenId Token ID to be queried.
1274
+ * @return bytes32 Token hash.
1275
+ * @dev token hash is the keccak256 hash of the stored hash seed
1276
+ */
1277
+ function tokenIdToHash(uint256 _tokenId) external view returns (bytes32) {
1278
+ bytes12 _hashSeed = _ownersAndHashSeeds[_tokenId].hashSeed;
1279
+ if (_hashSeed == 0) {
1280
+ return 0;
1281
+ }
1282
+ return keccak256(abi.encode(_hashSeed));
1283
+ }
1284
+
1285
+ /**
1286
+ * @notice View function returning Art Blocks portion of primary sales, in
1287
+ * percent.
1288
+ * @return uint256 Art Blocks portion of primary sales, in percent.
1289
+ */
1290
+ function artblocksPrimarySalesPercentage() external view returns (uint256) {
1291
+ return _artblocksPrimarySalesPercentage;
1292
+ }
1293
+
1294
+ /**
1295
+ * @notice View function returning Artist's address for project
1296
+ * `_projectId`.
1297
+ * @param _projectId Project ID to be queried.
1298
+ * @return address Artist's address.
1299
+ */
1300
+ function projectIdToArtistAddress(
1301
+ uint256 _projectId
1302
+ ) external view returns (address payable) {
1303
+ return projectIdToFinancials[_projectId].artistAddress;
1304
+ }
1305
+
1306
+ /**
1307
+ * @notice View function returning Artist's secondary market royalty
1308
+ * percentage for project `_projectId`.
1309
+ * This does not include Art Blocks portion of secondary market royalties.
1310
+ * @param _projectId Project ID to be queried.
1311
+ * @return uint256 Artist's secondary market royalty percentage.
1312
+ */
1313
+ function projectIdToSecondaryMarketRoyaltyPercentage(
1314
+ uint256 _projectId
1315
+ ) external view returns (uint256) {
1316
+ return
1317
+ projectIdToFinancials[_projectId].secondaryMarketRoyaltyPercentage;
1318
+ }
1319
+
1320
+ /**
1321
+ * @notice View function returning Artist's additional payee address for
1322
+ * primary sales, for project `_projectId`.
1323
+ * @param _projectId Project ID to be queried.
1324
+ * @return address Artist's additional payee address for primary sales.
1325
+ */
1326
+ function projectIdToAdditionalPayeePrimarySales(
1327
+ uint256 _projectId
1328
+ ) external view returns (address payable) {
1329
+ return projectIdToFinancials[_projectId].additionalPayeePrimarySales;
1330
+ }
1331
+
1332
+ /**
1333
+ * @notice View function returning Artist's additional payee primary sales
1334
+ * percentage, for project `_projectId`.
1335
+ * @param _projectId Project ID to be queried.
1336
+ * @return uint256 Artist's additional payee primary sales percentage.
1337
+ */
1338
+ function projectIdToAdditionalPayeePrimarySalesPercentage(
1339
+ uint256 _projectId
1340
+ ) external view returns (uint256) {
1341
+ return
1342
+ projectIdToFinancials[_projectId]
1343
+ .additionalPayeePrimarySalesPercentage;
1344
+ }
1345
+
1346
+ /**
1347
+ * @notice View function returning Artist's additional payee address for
1348
+ * secondary sales, for project `_projectId`.
1349
+ * @param _projectId Project ID to be queried.
1350
+ * @return address payable Artist's additional payee address for secondary
1351
+ * sales.
1352
+ */
1353
+ function projectIdToAdditionalPayeeSecondarySales(
1354
+ uint256 _projectId
1355
+ ) external view returns (address payable) {
1356
+ return projectIdToFinancials[_projectId].additionalPayeeSecondarySales;
1357
+ }
1358
+
1359
+ /**
1360
+ * @notice View function returning Artist's additional payee secondary
1361
+ * sales percentage, for project `_projectId`.
1362
+ * @param _projectId Project ID to be queried.
1363
+ * @return uint256 Artist's additional payee secondary sales percentage.
1364
+ */
1365
+ function projectIdToAdditionalPayeeSecondarySalesPercentage(
1366
+ uint256 _projectId
1367
+ ) external view returns (uint256) {
1368
+ return
1369
+ projectIdToFinancials[_projectId]
1370
+ .additionalPayeeSecondarySalesPercentage;
1371
+ }
1372
+
1373
+ /**
1374
+ * @notice Returns project details for project `_projectId`.
1375
+ * @param _projectId Project to be queried.
1376
+ * @return projectName Name of project
1377
+ * @return artist Artist of project
1378
+ * @return description Project description
1379
+ * @return website Project website
1380
+ * @return license Project license
1381
+ * @dev this function was named projectDetails prior to V3 core contract.
1382
+ */
1383
+ function projectDetails(
1384
+ uint256 _projectId
1385
+ )
1386
+ external
1387
+ view
1388
+ returns (
1389
+ string memory projectName,
1390
+ string memory artist,
1391
+ string memory description,
1392
+ string memory website,
1393
+ string memory license
1394
+ )
1395
+ {
1396
+ Project storage project = projects[_projectId];
1397
+ projectName = project.name;
1398
+ artist = project.artist;
1399
+ description = project.description;
1400
+ website = project.website;
1401
+ license = project.license;
1402
+ }
1403
+
1404
+ /**
1405
+ * @notice Returns project state data for project `_projectId`.
1406
+ * @param _projectId Project to be queried
1407
+ * @return invocations Current number of invocations
1408
+ * @return maxInvocations Maximum allowed invocations
1409
+ * @return active Boolean representing if project is currently active
1410
+ * @return paused Boolean representing if project is paused
1411
+ * @return completedTimestamp zero if project not complete, otherwise
1412
+ * timestamp of project completion.
1413
+ * @return locked Boolean representing if project is locked
1414
+ * @dev price and currency info are located on minter contracts
1415
+ */
1416
+ function projectStateData(
1417
+ uint256 _projectId
1418
+ )
1419
+ external
1420
+ view
1421
+ returns (
1422
+ uint256 invocations,
1423
+ uint256 maxInvocations,
1424
+ bool active,
1425
+ bool paused,
1426
+ uint256 completedTimestamp,
1427
+ bool locked
1428
+ )
1429
+ {
1430
+ Project storage project = projects[_projectId];
1431
+ invocations = project.invocations;
1432
+ maxInvocations = project.maxInvocations;
1433
+ active = project.active;
1434
+ paused = project.paused;
1435
+ completedTimestamp = project.completedTimestamp;
1436
+ locked = !_projectUnlocked(_projectId);
1437
+ }
1438
+
1439
+ /**
1440
+ * @notice Returns artist payment information for project `_projectId`.
1441
+ * @param _projectId Project to be queried
1442
+ * @return artistAddress Project Artist's address
1443
+ * @return additionalPayeePrimarySales Additional payee address for primary
1444
+ * sales
1445
+ * @return additionalPayeePrimarySalesPercentage Percentage of artist revenue
1446
+ * to be sent to the additional payee address for primary sales
1447
+ * @return additionalPayeeSecondarySales Additional payee address for secondary
1448
+ * sales royalties
1449
+ * @return additionalPayeeSecondarySalesPercentage Percentage of artist revenue
1450
+ * to be sent to the additional payee address for secondary sales royalties
1451
+ * @return secondaryMarketRoyaltyPercentage Royalty percentage to be sent to
1452
+ * combination of artist and additional payee. This does not include the
1453
+ * platform's percentage of secondary sales royalties, which is defined by
1454
+ * `artblocksSecondarySalesBPS`.
1455
+ */
1456
+ function projectArtistPaymentInfo(
1457
+ uint256 _projectId
1458
+ )
1459
+ external
1460
+ view
1461
+ returns (
1462
+ address artistAddress,
1463
+ address additionalPayeePrimarySales,
1464
+ uint256 additionalPayeePrimarySalesPercentage,
1465
+ address additionalPayeeSecondarySales,
1466
+ uint256 additionalPayeeSecondarySalesPercentage,
1467
+ uint256 secondaryMarketRoyaltyPercentage
1468
+ )
1469
+ {
1470
+ ProjectFinance storage projectFinance = projectIdToFinancials[
1471
+ _projectId
1472
+ ];
1473
+ artistAddress = projectFinance.artistAddress;
1474
+ additionalPayeePrimarySales = projectFinance
1475
+ .additionalPayeePrimarySales;
1476
+ additionalPayeePrimarySalesPercentage = projectFinance
1477
+ .additionalPayeePrimarySalesPercentage;
1478
+ additionalPayeeSecondarySales = projectFinance
1479
+ .additionalPayeeSecondarySales;
1480
+ additionalPayeeSecondarySalesPercentage = projectFinance
1481
+ .additionalPayeeSecondarySalesPercentage;
1482
+ secondaryMarketRoyaltyPercentage = projectFinance
1483
+ .secondaryMarketRoyaltyPercentage;
1484
+ }
1485
+
1486
+ /**
1487
+ * @notice Returns script information for project `_projectId`.
1488
+ * @param _projectId Project to be queried.
1489
+ * @return scriptTypeAndVersion Project's script type and version
1490
+ * (e.g. "p5js(atSymbol)1.0.0")
1491
+ * @return aspectRatio Aspect ratio of project (e.g. "1" for square,
1492
+ * "1.77777778" for 16:9, etc.)
1493
+ * @return scriptCount Count of scripts for project
1494
+ */
1495
+ function projectScriptDetails(
1496
+ uint256 _projectId
1497
+ )
1498
+ external
1499
+ view
1500
+ returns (
1501
+ string memory scriptTypeAndVersion,
1502
+ string memory aspectRatio,
1503
+ uint256 scriptCount
1504
+ )
1505
+ {
1506
+ Project storage project = projects[_projectId];
1507
+ scriptTypeAndVersion = project.scriptTypeAndVersion.toString();
1508
+ aspectRatio = project.aspectRatio;
1509
+ scriptCount = project.scriptCount;
1510
+ }
1511
+
1512
+ /**
1513
+ * @notice Returns address with bytecode containing project script for
1514
+ * project `_projectId` at script index `_index`.
1515
+ */
1516
+ function projectScriptBytecodeAddressByIndex(
1517
+ uint256 _projectId,
1518
+ uint256 _index
1519
+ ) external view returns (address) {
1520
+ return projects[_projectId].scriptBytecodeAddresses[_index];
1521
+ }
1522
+
1523
+ /**
1524
+ * @notice Returns script for project `_projectId` at script index `_index`.
1525
+ * @param _projectId Project to be queried.
1526
+ * @param _index Index of script to be queried.
1527
+ */
1528
+ function projectScriptByIndex(
1529
+ uint256 _projectId,
1530
+ uint256 _index
1531
+ ) external view returns (string memory) {
1532
+ Project storage project = projects[_projectId];
1533
+ // If trying to access an out-of-index script, return the empty string.
1534
+ if (_index >= project.scriptCount) {
1535
+ return "";
1536
+ }
1537
+ return project.scriptBytecodeAddresses[_index].readFromBytecode();
1538
+ }
1539
+
1540
+ /**
1541
+ * @notice Returns base URI for project `_projectId`.
1542
+ * @param _projectId Project to be queried.
1543
+ * @return projectBaseURI Base URI for project
1544
+ */
1545
+ function projectURIInfo(
1546
+ uint256 _projectId
1547
+ ) external view returns (string memory projectBaseURI) {
1548
+ projectBaseURI = projects[_projectId].projectBaseURI;
1549
+ }
1550
+
1551
+ /**
1552
+ * @notice Backwards-compatible (pre-V3) function returning if `_minter` is
1553
+ * minterContract.
1554
+ * @param _minter Address to be queried.
1555
+ * @return bool Boolean representing if `_minter` is minterContract.
1556
+ */
1557
+ function isMintWhitelisted(address _minter) external view returns (bool) {
1558
+ return (minterContract == _minter);
1559
+ }
1560
+
1561
+ /**
1562
+ * @notice Gets qty of randomizers in history of all randomizers used by
1563
+ * this core contract. If a randomizer is switched away from then back to,
1564
+ * it will show up in the history twice.
1565
+ * @return randomizerHistoryCount Count of randomizers in history
1566
+ */
1567
+ function numHistoricalRandomizers() external view returns (uint256) {
1568
+ return _historicalRandomizerAddresses.length;
1569
+ }
1570
+
1571
+ /**
1572
+ * @notice Gets address of randomizer at index `_index` in history of all
1573
+ * randomizers used by this core contract. Index is zero-based.
1574
+ * @param _index Historical index of randomizer to be queried.
1575
+ * @return randomizerAddress Address of randomizer at index `_index`.
1576
+ * @dev If a randomizer is switched away from and then switched back to, it
1577
+ * will show up in the history twice.
1578
+ */
1579
+ function getHistoricalRandomizerAt(
1580
+ uint256 _index
1581
+ ) external view returns (address) {
1582
+ require(
1583
+ _index < _historicalRandomizerAddresses.length,
1584
+ "Index out of bounds"
1585
+ );
1586
+ return _historicalRandomizerAddresses[_index];
1587
+ }
1588
+
1589
+ /**
1590
+ * @notice Backwards-compatible (pre-V3) function returning Art Blocks
1591
+ * primary sales payment address (now called artblocksPrimarySalesAddress).
1592
+ * @return address payable Art Blocks primary sales payment address
1593
+ */
1594
+ function artblocksAddress() external view returns (address payable) {
1595
+ return artblocksPrimarySalesAddress;
1596
+ }
1597
+
1598
+ /**
1599
+ * @notice Backwards-compatible (pre-V3) function returning Art Blocks
1600
+ * primary sales percentage (now called artblocksPrimarySalesPercentage).
1601
+ * @return uint256 Art Blocks primary sales percentage
1602
+ */
1603
+ function artblocksPercentage() external view returns (uint256) {
1604
+ return _artblocksPrimarySalesPercentage;
1605
+ }
1606
+
1607
+ /**
1608
+ * @notice Backwards-compatible (pre-V3) function.
1609
+ * Gets artist + artist's additional payee royalty data for token ID
1610
+ `_tokenId`.
1611
+ * WARNING: Does not include Art Blocks portion of royalties.
1612
+ * @param _tokenId Token ID to be queried.
1613
+ * @return artistAddress Artist's payment address
1614
+ * @return additionalPayee Additional payee's payment address
1615
+ * @return additionalPayeePercentage Percentage of artist revenue
1616
+ * to be sent to the additional payee's address
1617
+ * @return royaltyFeeByID Total royalty percentage to be sent to
1618
+ * combination of artist and additional payee
1619
+ * @dev Does not include Art Blocks portion of royalties.
1620
+ */
1621
+ function getRoyaltyData(
1622
+ uint256 _tokenId
1623
+ )
1624
+ external
1625
+ view
1626
+ returns (
1627
+ address artistAddress,
1628
+ address additionalPayee,
1629
+ uint256 additionalPayeePercentage,
1630
+ uint256 royaltyFeeByID
1631
+ )
1632
+ {
1633
+ uint256 projectId = tokenIdToProjectId(_tokenId);
1634
+ ProjectFinance storage projectFinance = projectIdToFinancials[
1635
+ projectId
1636
+ ];
1637
+ artistAddress = projectFinance.artistAddress;
1638
+ additionalPayee = projectFinance.additionalPayeeSecondarySales;
1639
+ additionalPayeePercentage = projectFinance
1640
+ .additionalPayeeSecondarySalesPercentage;
1641
+ royaltyFeeByID = projectFinance.secondaryMarketRoyaltyPercentage;
1642
+ }
1643
+
1644
+ /**
1645
+ * @notice Gets royalty Basis Points (BPS) for token ID `_tokenId`.
1646
+ * This conforms to the IManifold interface designated in the Royalty
1647
+ * Registry's RoyaltyEngineV1.sol contract.
1648
+ * ref: https://github.com/manifoldxyz/royalty-registry-solidity
1649
+ * @param _tokenId Token ID to be queried.
1650
+ * @return recipients Array of royalty payment recipients
1651
+ * @return bps Array of Basis Points (BPS) allocated to each recipient,
1652
+ * aligned by index.
1653
+ * @dev reverts if invalid _tokenId
1654
+ * @dev only returns recipients that have a non-zero BPS allocation
1655
+ */
1656
+ function getRoyalties(
1657
+ uint256 _tokenId
1658
+ )
1659
+ external
1660
+ view
1661
+ onlyValidTokenId(_tokenId)
1662
+ returns (address payable[] memory recipients, uint256[] memory bps)
1663
+ {
1664
+ // initialize arrays with maximum potential length
1665
+ recipients = new address payable[](3);
1666
+ bps = new uint256[](3);
1667
+
1668
+ uint256 projectId = tokenIdToProjectId(_tokenId);
1669
+ ProjectFinance storage projectFinance = projectIdToFinancials[
1670
+ projectId
1671
+ ];
1672
+ // load values into memory
1673
+ uint256 royaltyPercentageForArtistAndAdditional = projectFinance
1674
+ .secondaryMarketRoyaltyPercentage;
1675
+ uint256 additionalPayeePercentage = projectFinance
1676
+ .additionalPayeeSecondarySalesPercentage;
1677
+ // calculate BPS = percentage * 100
1678
+ uint256 artistBPS = (ONE_HUNDRED - additionalPayeePercentage) *
1679
+ royaltyPercentageForArtistAndAdditional;
1680
+
1681
+ uint256 additionalBPS = additionalPayeePercentage *
1682
+ royaltyPercentageForArtistAndAdditional;
1683
+ uint256 artblocksBPS = artblocksSecondarySalesBPS;
1684
+ // populate arrays
1685
+ uint256 payeeCount;
1686
+ if (artistBPS > 0) {
1687
+ recipients[payeeCount] = projectFinance.artistAddress;
1688
+ bps[payeeCount++] = artistBPS;
1689
+ }
1690
+ if (additionalBPS > 0) {
1691
+ recipients[payeeCount] = projectFinance
1692
+ .additionalPayeeSecondarySales;
1693
+ bps[payeeCount++] = additionalBPS;
1694
+ }
1695
+ if (artblocksBPS > 0) {
1696
+ recipients[payeeCount] = artblocksSecondarySalesAddress;
1697
+ bps[payeeCount++] = artblocksBPS;
1698
+ }
1699
+ // trim arrays if necessary
1700
+ if (3 > payeeCount) {
1701
+ assembly {
1702
+ let decrease := sub(3, payeeCount)
1703
+ mstore(recipients, sub(mload(recipients), decrease))
1704
+ mstore(bps, sub(mload(bps), decrease))
1705
+ }
1706
+ }
1707
+ return (recipients, bps);
1708
+ }
1709
+
1710
+ /**
1711
+ * @notice View function that returns appropriate revenue splits between
1712
+ * different Art Blocks, Artist, and Artist's additional primary sales
1713
+ * payee given a sale price of `_price` on project `_projectId`.
1714
+ * This always returns three revenue amounts and three addresses, but if a
1715
+ * revenue is zero for either Artist or additional payee, the corresponding
1716
+ * address returned will also be null (for gas optimization).
1717
+ * Does not account for refund if user overpays for a token (minter should
1718
+ * handle a refund of the difference, if appropriate).
1719
+ * Some minters may have alternative methods of splitting payments, in
1720
+ * which case they should implement their own payment splitting logic.
1721
+ * @param _projectId Project ID to be queried.
1722
+ * @param _price Sale price of token.
1723
+ * @return artblocksRevenue_ amount of revenue to be sent to Art Blocks
1724
+ * @return artblocksAddress_ address to send Art Blocks revenue to
1725
+ * @return artistRevenue_ amount of revenue to be sent to Artist
1726
+ * @return artistAddress_ address to send Artist revenue to. Will be null
1727
+ * if no revenue is due to artist (gas optimization).
1728
+ * @return additionalPayeePrimaryRevenue_ amount of revenue to be sent to
1729
+ * additional payee for primary sales
1730
+ * @return additionalPayeePrimaryAddress_ address to send Artist's
1731
+ * additional payee for primary sales revenue to. Will be null if no
1732
+ * revenue is due to additional payee for primary sales (gas optimization).
1733
+ * @dev this always returns three addresses and three revenues, but if the
1734
+ * revenue is zero, the corresponding address will be address(0). It is up
1735
+ * to the contract performing the revenue split to handle this
1736
+ * appropriately.
1737
+ */
1738
+ function getPrimaryRevenueSplits(
1739
+ uint256 _projectId,
1740
+ uint256 _price
1741
+ )
1742
+ external
1743
+ view
1744
+ returns (
1745
+ uint256 artblocksRevenue_,
1746
+ address payable artblocksAddress_,
1747
+ uint256 artistRevenue_,
1748
+ address payable artistAddress_,
1749
+ uint256 additionalPayeePrimaryRevenue_,
1750
+ address payable additionalPayeePrimaryAddress_
1751
+ )
1752
+ {
1753
+ ProjectFinance storage projectFinance = projectIdToFinancials[
1754
+ _projectId
1755
+ ];
1756
+ // calculate revenues
1757
+ artblocksRevenue_ =
1758
+ (_price * uint256(_artblocksPrimarySalesPercentage)) /
1759
+ ONE_HUNDRED;
1760
+ uint256 projectFunds;
1761
+ unchecked {
1762
+ // artblocksRevenue_ is always <=25, so guaranteed to never underflow
1763
+ projectFunds = _price - artblocksRevenue_;
1764
+ }
1765
+ additionalPayeePrimaryRevenue_ =
1766
+ (projectFunds *
1767
+ projectFinance.additionalPayeePrimarySalesPercentage) /
1768
+ ONE_HUNDRED;
1769
+ unchecked {
1770
+ // projectIdToAdditionalPayeePrimarySalesPercentage is always
1771
+ // <=100, so guaranteed to never underflow
1772
+ artistRevenue_ = projectFunds - additionalPayeePrimaryRevenue_;
1773
+ }
1774
+ // set addresses from storage
1775
+ artblocksAddress_ = artblocksPrimarySalesAddress;
1776
+ if (artistRevenue_ > 0) {
1777
+ artistAddress_ = projectFinance.artistAddress;
1778
+ }
1779
+ if (additionalPayeePrimaryRevenue_ > 0) {
1780
+ additionalPayeePrimaryAddress_ = projectFinance
1781
+ .additionalPayeePrimarySales;
1782
+ }
1783
+ }
1784
+
1785
+ /**
1786
+ * @notice Backwards-compatible (pre-V3) getter returning contract admin
1787
+ * @return address Address of contract admin (same as owner)
1788
+ */
1789
+ function admin() external view returns (address) {
1790
+ return owner();
1791
+ }
1792
+
1793
+ /**
1794
+ * @notice Gets the project ID for a given `_tokenId`.
1795
+ * @param _tokenId Token ID to be queried.
1796
+ * @return _projectId Project ID for given `_tokenId`.
1797
+ */
1798
+ function tokenIdToProjectId(
1799
+ uint256 _tokenId
1800
+ ) public pure returns (uint256 _projectId) {
1801
+ return _tokenId / ONE_MILLION;
1802
+ }
1803
+
1804
+ /**
1805
+ * @notice Convenience function that returns whether `_sender` is allowed
1806
+ * to call function with selector `_selector` on contract `_contract`, as
1807
+ * determined by this contract's current Admin ACL contract. Expected use
1808
+ * cases include minter contracts checking if caller is allowed to call
1809
+ * admin-gated functions on minter contracts.
1810
+ * @param _sender Address of the sender calling function with selector
1811
+ * `_selector` on contract `_contract`.
1812
+ * @param _contract Address of the contract being called by `_sender`.
1813
+ * @param _selector Function selector of the function being called by
1814
+ * `_sender`.
1815
+ * @return bool Whether `_sender` is allowed to call function with selector
1816
+ * `_selector` on contract `_contract`.
1817
+ * @dev assumes the Admin ACL contract is the owner of this contract, which
1818
+ * is expected to always be true.
1819
+ * @dev adminACLContract is expected to either be null address (if owner
1820
+ * has renounced ownership), or conform to IAdminACLV0 interface. Check for
1821
+ * null address first to avoid revert when admin has renounced ownership.
1822
+ */
1823
+ function adminACLAllowed(
1824
+ address _sender,
1825
+ address _contract,
1826
+ bytes4 _selector
1827
+ ) public returns (bool) {
1828
+ return
1829
+ owner() != address(0) &&
1830
+ adminACLContract.allowed(_sender, _contract, _selector);
1831
+ }
1832
+
1833
+ /**
1834
+ * @notice Returns contract owner. Set to deployer's address by default on
1835
+ * contract deployment.
1836
+ * @return address Address of contract owner.
1837
+ * @dev ref: https://docs.openzeppelin.com/contracts/4.x/api/access#Ownable
1838
+ * @dev owner role was called `admin` prior to V3 core contract
1839
+ */
1840
+ function owner()
1841
+ public
1842
+ view
1843
+ override(Ownable, IGenArt721CoreContractV3_Base)
1844
+ returns (address)
1845
+ {
1846
+ return Ownable.owner();
1847
+ }
1848
+
1849
+ /**
1850
+ * @notice Gets token URI for token ID `_tokenId`.
1851
+ * @param _tokenId Token ID to be queried.
1852
+ * @return string URI of token ID `_tokenId`.
1853
+ * @dev token URIs are the concatenation of the project base URI and the
1854
+ * token ID.
1855
+ */
1856
+ function tokenURI(
1857
+ uint256 _tokenId
1858
+ ) public view override onlyValidTokenId(_tokenId) returns (string memory) {
1859
+ string memory _projectBaseURI = projects[tokenIdToProjectId(_tokenId)]
1860
+ .projectBaseURI;
1861
+ return string.concat(_projectBaseURI, _tokenId.toString());
1862
+ }
1863
+
1864
+ /**
1865
+ * @dev See {IERC165-supportsInterface}.
1866
+ */
1867
+ function supportsInterface(
1868
+ bytes4 interfaceId
1869
+ ) public view virtual override returns (bool) {
1870
+ return
1871
+ interfaceId == type(IManifold).interfaceId ||
1872
+ super.supportsInterface(interfaceId);
1873
+ }
1874
+
1875
+ /**
1876
+ * @notice Forbids new projects from being created
1877
+ * @dev only performs operation and emits event if contract is not already
1878
+ * forbidding new projects.
1879
+ */
1880
+ function _forbidNewProjects() internal {
1881
+ if (!newProjectsForbidden) {
1882
+ newProjectsForbidden = true;
1883
+ emit PlatformUpdated(FIELD_NEW_PROJECTS_FORBIDDEN);
1884
+ }
1885
+ }
1886
+
1887
+ /**
1888
+ * @notice Transfers ownership of the contract to a new account (`newOwner`).
1889
+ * Internal function without access restriction.
1890
+ * @param newOwner New owner.
1891
+ * @dev owner role was called `admin` prior to V3 core contract.
1892
+ * @dev Overrides and wraps OpenZeppelin's _transferOwnership function to
1893
+ * also update adminACLContract for improved introspection.
1894
+ */
1895
+ function _transferOwnership(address newOwner) internal override {
1896
+ Ownable._transferOwnership(newOwner);
1897
+ adminACLContract = IAdminACLV0(newOwner);
1898
+ }
1899
+
1900
+ /**
1901
+ * @notice Updates Art Blocks payment address to `_artblocksPrimarySalesAddress`.
1902
+ * @param _artblocksPrimarySalesAddress New Art Blocks payment address.
1903
+ * @dev Note that this method does not check that the input address is
1904
+ * not `address(0)`, as it is expected that callers of this method should
1905
+ * perform input validation where applicable.
1906
+ */
1907
+ function _updateArtblocksPrimarySalesAddress(
1908
+ address _artblocksPrimarySalesAddress
1909
+ ) internal {
1910
+ artblocksPrimarySalesAddress = payable(_artblocksPrimarySalesAddress);
1911
+ emit PlatformUpdated(FIELD_ARTBLOCKS_PRIMARY_SALES_ADDRESS);
1912
+ }
1913
+
1914
+ /**
1915
+ * @notice Updates Art Blocks secondary sales royalty payment address to
1916
+ * `_artblocksSecondarySalesAddress`.
1917
+ * @param _artblocksSecondarySalesAddress New Art Blocks secondary sales
1918
+ * payment address.
1919
+ * @dev Note that this method does not check that the input address is
1920
+ * not `address(0)`, as it is expected that callers of this method should
1921
+ * perform input validation where applicable.
1922
+ */
1923
+ function _updateArtblocksSecondarySalesAddress(
1924
+ address _artblocksSecondarySalesAddress
1925
+ ) internal {
1926
+ artblocksSecondarySalesAddress = payable(
1927
+ _artblocksSecondarySalesAddress
1928
+ );
1929
+ emit PlatformUpdated(FIELD_ARTBLOCKS_SECONDARY_SALES_ADDRESS);
1930
+ }
1931
+
1932
+ /**
1933
+ * @notice Updates randomizer address to `_randomizerAddress`.
1934
+ * @param _randomizerAddress New randomizer address.
1935
+ * @dev Note that this method does not check that the input address is
1936
+ * not `address(0)`, as it is expected that callers of this method should
1937
+ * perform input validation where applicable.
1938
+ */
1939
+ function _updateRandomizerAddress(address _randomizerAddress) internal {
1940
+ randomizerContract = IRandomizerV2(_randomizerAddress);
1941
+ // populate historical randomizer array
1942
+ _historicalRandomizerAddresses.push(_randomizerAddress);
1943
+ emit PlatformUpdated(FIELD_RANDOMIZER_ADDRESS);
1944
+ }
1945
+
1946
+ /**
1947
+ * @notice Updates default base URI to `_defaultBaseURI`.
1948
+ * When new projects are added, their `projectBaseURI` is automatically
1949
+ * initialized to `_defaultBaseURI`.
1950
+ * @param _defaultBaseURI New default base URI.
1951
+ * @dev Note that this method does not check that the input string is not
1952
+ * the empty string, as it is expected that callers of this method should
1953
+ * perform input validation where applicable.
1954
+ */
1955
+ function _updateDefaultBaseURI(string memory _defaultBaseURI) internal {
1956
+ defaultBaseURI = _defaultBaseURI;
1957
+ emit PlatformUpdated(FIELD_DEFAULT_BASE_URI);
1958
+ }
1959
+
1960
+ /**
1961
+ * @notice Internal function to complete a project.
1962
+ * @param _projectId Project ID to be completed.
1963
+ */
1964
+ function _completeProject(uint256 _projectId) internal {
1965
+ projects[_projectId].completedTimestamp = uint64(block.timestamp);
1966
+ emit ProjectUpdated(_projectId, FIELD_PROJECT_COMPLETED);
1967
+ }
1968
+
1969
+ /**
1970
+ * @notice Internal function that returns whether a project is unlocked.
1971
+ * Projects automatically lock four weeks after they are completed.
1972
+ * Projects are considered completed when they have been invoked the
1973
+ * maximum number of times.
1974
+ * @param _projectId Project ID to be queried.
1975
+ * @return bool true if project is unlocked, false otherwise.
1976
+ * @dev This also enforces that the `_projectId` passed in is valid.
1977
+ */
1978
+ function _projectUnlocked(
1979
+ uint256 _projectId
1980
+ ) internal view onlyValidProjectId(_projectId) returns (bool) {
1981
+ uint256 projectCompletedTimestamp = projects[_projectId]
1982
+ .completedTimestamp;
1983
+ bool projectOpen = projectCompletedTimestamp == 0;
1984
+ return
1985
+ projectOpen ||
1986
+ (block.timestamp - projectCompletedTimestamp <
1987
+ FOUR_WEEKS_IN_SECONDS);
1988
+ }
1989
+ }