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