@artblocks/contracts 1.0.1 → 1.0.3

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