@artblocks/contracts 1.1.0 → 1.2.0

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 (257) hide show
  1. package/README.md +75 -7
  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 +273 -155
  5. package/artifacts/contracts/archive/GenArt721CoreV3.sol/GenArt721CoreV3.json +2047 -0
  6. package/artifacts/contracts/archive/GenArt721CoreV3_Explorations.sol/GenArt721CoreV3_Explorations.json +2021 -0
  7. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterBase_v0_1_1.sol/MinterBase.json +1 -1
  8. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV2.sol/MinterDAExpV2.json +2 -2
  9. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV3.sol/MinterDAExpV3.json +2 -2
  10. package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterDAExp}/MinterDAExpV4.sol/MinterDAExpV4.json +3 -3
  11. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol/MinterDAExpSettlementV0.json +2 -2
  12. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV1.sol/MinterDAExpSettlementV1.json +2 -2
  13. package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterDAExpSettlement}/MinterDAExpSettlementV2.sol/MinterDAExpSettlementV2.json +3 -3
  14. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV2.sol/MinterDALinV2.json +2 -2
  15. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV3.sol/MinterDALinV3.json +2 -2
  16. package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterDALin}/MinterDALinV4.sol/MinterDALinV4.json +3 -3
  17. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV1.sol/MinterHolderV1.json +2 -2
  18. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV2.sol/MinterHolderV2.json +2 -2
  19. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV3.sol/MinterHolderV3.json +2 -2
  20. package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterHolder}/MinterHolderV4.sol/MinterHolderV4.json +3 -3
  21. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV1.sol/MinterMerkleV1.json +2 -2
  22. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV2.sol/MinterMerkleV2.json +2 -2
  23. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV3.sol/MinterMerkleV3.json +2 -2
  24. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV4.sol/MinterMerkleV4.json +2 -2
  25. package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterMerkle}/MinterMerkleV5.sol/MinterMerkleV5.json +3 -3
  26. package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterPolyptych}/MinterPolyptychV0.sol/IGenArt721CoreContractV3WithRandomizer.json +31 -63
  27. package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterPolyptych}/MinterPolyptychV0.sol/MinterPolyptychV0.json +3 -3
  28. package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterSEA}/MinterSEAV0.sol/MinterSEAV0.json +3 -3
  29. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV2.sol/MinterSetPriceV2.json +2 -2
  30. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV3.sol/MinterSetPriceV3.json +2 -2
  31. package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterSetPrice}/MinterSetPriceV4.sol/MinterSetPriceV4.json +3 -3
  32. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V0.sol/MinterSetPriceERC20V0.json +65 -2
  33. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V1.sol/MinterSetPriceERC20V1.json +65 -2
  34. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol/MinterSetPriceERC20V2.json +2 -2
  35. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol/MinterSetPriceERC20V3.json +2 -2
  36. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V4.sol/MinterSetPriceERC20V4.json +807 -0
  37. package/artifacts/contracts/engine/V2/GenArt721MinterBurner_PBAB.sol/GenArt721MinterBurner_PBAB.json +65 -2
  38. package/artifacts/contracts/engine/V2/GenArt721Minter_PBAB.sol/GenArt721Minter_PBAB.json +65 -2
  39. package/artifacts/contracts/engine/V3/EngineFactoryV0.sol/EngineFactoryV0.json +606 -0
  40. package/artifacts/contracts/engine/V3/GenArt721CoreV3_Engine.sol/GenArt721CoreV3_Engine.json +567 -206
  41. package/artifacts/contracts/engine/V3/GenArt721CoreV3_Engine_Flex.sol/GenArt721CoreV3_Engine_Flex.json +787 -224
  42. package/artifacts/contracts/engine/V3/forks/GenArt721CoreV3_Engine_Flex_PROOF.sol/GenArt721CoreV3_Engine_Flex_PROOF.json +38 -8
  43. package/artifacts/contracts/engine/V3/forks/PROHIBITION/AdminACLV0_PROHIBITION.sol/AdminACLV0_PROHIBITION.json +2 -2
  44. package/artifacts/contracts/engine/V3/forks/PROHIBITION/GenArt721CoreV3_Engine_Flex_PROHIBITION.sol/GenArt721CoreV3_Engine_Flex_PROHIBITION.json +38 -8
  45. package/artifacts/contracts/engine/V3/forks/PROHIBITION/interfaces/IGenArt721CoreContractV3_Engine_Flex_PROHIBITION.sol/IGenArt721CoreContractV3_Engine_Flex_PROHIBITION.json +36 -68
  46. package/artifacts/contracts/interfaces/v0.8.x/IAdminACLV0_Extended.sol/IAdminACLV0_Extended.json +140 -0
  47. package/artifacts/contracts/interfaces/v0.8.x/IBytecodeStorageReaderV2.sol/IBytecodeStorageReaderV2.json +130 -0
  48. package/artifacts/contracts/interfaces/v0.8.x/IDependencyRegistryV0.sol/IDependencyRegistryV0.json +58 -45
  49. package/artifacts/contracts/interfaces/v0.8.x/IEngineFactoryV0.sol/IEngineFactoryV0.json +283 -0
  50. package/artifacts/contracts/interfaces/v0.8.x/IFilteredMinterDAExpSettlementV0.sol/IFilteredMinterDAExpSettlementV0.json +12 -12
  51. package/artifacts/contracts/interfaces/v0.8.x/IFilteredMinterDAExpSettlementV1.sol/IFilteredMinterDAExpSettlementV1.json +12 -12
  52. package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3.sol/IGenArt721CoreContractV3.json +30 -62
  53. package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Base.sol/IGenArt721CoreContractV3_Base.json +30 -62
  54. package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine.sol/IGenArt721CoreContractV3_Engine.json +170 -104
  55. package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_Flex.sol/IGenArt721CoreContractV3_Engine_Flex.json +170 -104
  56. package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_Flex_PreV3p2.sol/IGenArt721CoreContractV3_Engine_Flex_PreV3p2.json +1028 -0
  57. package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_PreV3p2.sol/IGenArt721CoreContractV3_Engine_PreV3p2.json +741 -0
  58. package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_ProjectFinance.sol/IGenArt721CoreContractV3_ProjectFinance.json +87 -0
  59. package/artifacts/contracts/interfaces/v0.8.x/IGenArt721Minter_PBAB.sol/IGenArt721Minter_PBAB.json +279 -0
  60. package/artifacts/contracts/interfaces/v0.8.x/IPseudorandomAtomic.sol/IPseudorandomAtomic.json +1 -1
  61. package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterDAExpSettlementV0.sol/ISharedMinterDAExpSettlementV0.json +18 -0
  62. package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterRAMV0.sol/ISharedMinterRAMV0.json +62 -0
  63. package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterRequired.sol/ISharedMinterRequired.json +37 -0
  64. package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterSEAV0.sol/ISharedMinterSEAV0.json +1 -1
  65. package/artifacts/contracts/interfaces/v0.8.x/ISplitAtomicFactoryV0.sol/ISplitAtomicFactoryV0.json +170 -0
  66. package/artifacts/contracts/interfaces/v0.8.x/ISplitAtomicV0.sol/ISplitAtomicV0.json +126 -0
  67. package/artifacts/contracts/interfaces/v0.8.x/ISplitProviderV0.sol/ISplitProviderV0.json +98 -0
  68. package/artifacts/contracts/interfaces/v0.8.x/integration-refs/splits-0x-v2/ISplitFactoryV2.sol/ISplitFactoryV2.json +123 -0
  69. package/artifacts/contracts/libs/integration-refs/delegation-registry/DelegationRegistry.sol/DelegationRegistry.json +2 -2
  70. package/artifacts/contracts/libs/integration-refs/gnosis-safe/GnosisSafeMock.sol/GnosisSafeMock.json +2 -2
  71. package/artifacts/contracts/libs/integration-refs/gnosis-safe/GnosisSafeProxyFactoryMock.sol/GnosisSafeProxyFactoryMock.json +2 -2
  72. package/artifacts/contracts/libs/integration-refs/gnosis-safe/MultiSendMock.sol/MultiSendMock.json +2 -2
  73. package/artifacts/contracts/libs/integration-refs/weth9/weth9.sol/WETH9_.json +2 -2
  74. package/artifacts/contracts/libs/v0.8.x/ABHelpers.sol/ABHelpers.json +2 -2
  75. package/artifacts/contracts/libs/v0.8.x/AuthLib.sol/AuthLib.json +2 -2
  76. package/artifacts/contracts/libs/v0.8.x/BitMap.sol/BitMaps256.json +10 -0
  77. package/artifacts/contracts/libs/v0.8.x/BytecodeStorageV0.sol/BytecodeStorage.json +2 -2
  78. package/artifacts/contracts/libs/v0.8.x/BytecodeStorageV1.sol/BytecodeStorageReader.json +2 -2
  79. package/artifacts/contracts/libs/v0.8.x/BytecodeStorageV1.sol/BytecodeStorageWriter.json +2 -2
  80. package/artifacts/contracts/libs/v0.8.x/BytecodeStorageV2.sol/BytecodeStorageReader.json +214 -0
  81. package/artifacts/contracts/libs/v0.8.x/BytecodeStorageV2.sol/BytecodeStorageWriter.json +10 -0
  82. package/artifacts/contracts/libs/v0.8.x/Bytes32Strings.sol/Bytes32Strings.json +2 -2
  83. package/artifacts/contracts/libs/v0.8.x/DependencyRegistryStorageLib.sol/DependencyRegistryStorageLib.json +10 -0
  84. package/artifacts/contracts/libs/v0.8.x/ERC721_PackedHashSeed.sol/ERC721_PackedHashSeed.json +2 -2
  85. package/artifacts/contracts/libs/v0.8.x/ERC721_PackedHashSeedV1.sol/ERC721_PackedHashSeedV1.json +444 -0
  86. package/artifacts/contracts/libs/v0.8.x/PackedBools.sol/PackedBools.json +10 -0
  87. package/artifacts/contracts/libs/v0.8.x/SSTORE2.sol/SSTORE2.json +2 -2
  88. package/artifacts/contracts/libs/v0.8.x/V3FlexLib.sol/V3FlexLib.json +208 -0
  89. package/artifacts/contracts/libs/v0.8.x/minter-libs/DAExpLib.sol/DAExpLib.json +2 -2
  90. package/artifacts/contracts/libs/v0.8.x/minter-libs/DALib.sol/DALib.json +2 -2
  91. package/artifacts/contracts/libs/v0.8.x/minter-libs/DALinLib.sol/DALinLib.json +2 -2
  92. package/artifacts/contracts/libs/v0.8.x/minter-libs/GenericMinterEventsLib.sol/GenericMinterEventsLib.json +2 -2
  93. package/artifacts/contracts/libs/v0.8.x/minter-libs/MaxInvocationsLib.sol/MaxInvocationsLib.json +2 -2
  94. package/artifacts/contracts/libs/v0.8.x/minter-libs/MerkleLib.sol/MerkleLib.json +2 -2
  95. package/artifacts/contracts/libs/v0.8.x/minter-libs/PolyptychLib.sol/PolyptychLib.json +2 -2
  96. package/artifacts/contracts/libs/v0.8.x/minter-libs/RAMLib.sol/RAMLib.json +398 -0
  97. package/artifacts/contracts/libs/v0.8.x/minter-libs/SEALib.sol/SEALib.json +2 -2
  98. package/artifacts/contracts/libs/v0.8.x/minter-libs/SetPriceLib.sol/SetPriceLib.json +2 -2
  99. package/artifacts/contracts/libs/v0.8.x/minter-libs/SettlementExpLib.sol/SettlementExpLib.json +2 -2
  100. package/artifacts/contracts/libs/v0.8.x/minter-libs/SplitFundsLib.sol/SplitFundsLib.json +2 -2
  101. package/artifacts/contracts/libs/v0.8.x/minter-libs/TokenHolderLib.sol/TokenHolderLib.json +2 -2
  102. package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV1.sol/MinterFilterV1.json +2 -2
  103. package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV2.sol/MinterFilterV2.json +2 -2
  104. package/artifacts/contracts/minter-suite/Minters/MinterDAExpHolderV5.sol/MinterDAExpHolderV5.json +2 -2
  105. package/artifacts/contracts/minter-suite/Minters/MinterDAExpSettlementV3.sol/MinterDAExpSettlementV3.json +2 -2
  106. package/artifacts/contracts/minter-suite/Minters/MinterDAExpV5.sol/MinterDAExpV5.json +2 -2
  107. package/artifacts/contracts/minter-suite/Minters/MinterDALinHolderV5.sol/MinterDALinHolderV5.json +2 -2
  108. package/artifacts/contracts/minter-suite/Minters/MinterDALinV5.sol/MinterDALinV5.json +2 -2
  109. package/artifacts/contracts/minter-suite/Minters/MinterRAMV0.sol/MinterRAMV0.json +1374 -0
  110. package/artifacts/contracts/minter-suite/Minters/MinterSEAV1.sol/MinterSEAV1.json +7 -7
  111. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20V5.sol/MinterSetPriceERC20V5.json +2 -2
  112. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceHolderV5.sol/MinterSetPriceHolderV5.json +2 -2
  113. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceMerkleV5.sol/MinterSetPriceMerkleV5.json +2 -2
  114. package/artifacts/contracts/minter-suite/Minters/MinterSetPricePolyptychERC20V5.sol/MinterSetPricePolyptychERC20V5.json +2 -2
  115. package/artifacts/contracts/minter-suite/Minters/MinterSetPricePolyptychV5.sol/MinterSetPricePolyptychV5.json +2 -2
  116. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceV5.sol/MinterSetPriceV5.json +2 -2
  117. package/artifacts/contracts/minter-suite/Minters/one-off/MinterSetPriceV5_SingleCore.sol/MinterSetPriceV5_SingleCore.json +417 -0
  118. package/artifacts/contracts/mock/BytecodeV2LibCallsMock.sol/BytecodeV2LibCallsMock.json +154 -0
  119. package/artifacts/contracts/mock/BytecodeV2TextCR_DMock.sol/BytecodeV2TextCR_DMock.json +428 -0
  120. package/artifacts/contracts/mock/DummySharedMinter.sol/DummySharedMinter.json +2 -2
  121. package/artifacts/contracts/mock/ERC20Mock.sol/ERC20Mock.json +2 -2
  122. package/artifacts/contracts/mock/ForceSendMock.sol/ForceSendMock.json +24 -0
  123. package/artifacts/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol/GenArt721CoreV3_Engine_IncorrectCoreType.json +2 -2
  124. package/artifacts/contracts/mock/Mock0xSplitsV2PullFactory.sol/Mock0xSplitsV2PullFactory.json +149 -0
  125. package/artifacts/contracts/mock/Mock0xSplitsV2Splitter.sol/Mock0xSplitsV2Splitter.json +99 -0
  126. package/artifacts/contracts/mock/MockAdminACLV0.sol/MockAdminACLV0Events.json +20 -2
  127. package/artifacts/contracts/mock/MockAdminACLV0_PROHIBITION.sol/MockAdminACLV0Events_PROHIBITION.json +20 -2
  128. package/artifacts/contracts/mock/RandomizerV2_NoAssignMock.sol/RandomizerV2_NoAssignMock.json +2 -2
  129. package/artifacts/contracts/mock/ReentrancyGenArt721MinterMock.sol/ReentrancyGenArt721MinterMock.json +100 -0
  130. package/artifacts/contracts/mock/ReentrancyHolderMock.sol/ReentrancyHolderMock.json +2 -2
  131. package/artifacts/contracts/mock/ReentrancyHolderMockShared.sol/ReentrancyHolderMockShared.json +2 -2
  132. package/artifacts/contracts/mock/ReentrancyMerkleMock.sol/ReentrancyMerkleMock.json +2 -2
  133. package/artifacts/contracts/mock/ReentrancyMerkleMockShared.sol/ReentrancyMerkleMockShared.json +2 -2
  134. package/artifacts/contracts/mock/ReentrancyMock.sol/ReentrancyMock.json +2 -2
  135. package/artifacts/contracts/mock/ReentrancyMockShared.sol/ReentrancyMockShared.json +2 -2
  136. package/artifacts/contracts/mock/ReentrancySEAMock.sol/ReentrancySEAAutoBidderMock.json +2 -2
  137. package/artifacts/contracts/mock/ReentrancySEAMockShared.sol/ReentrancySEAAutoBidderMockShared.json +2 -2
  138. package/artifacts/contracts/mock/ReentrancySplitterMocks.sol/ReentrancySplitterDrainETHMock.json +54 -0
  139. package/artifacts/contracts/mock/ReentrancySplitterMocks.sol/ReentrancySplitterSendETHMock.json +54 -0
  140. package/artifacts/contracts/randomizer/deprecated/PolyptychRandomizerV0.sol/BasicPolyptychRandomizerV0.json +2 -2
  141. package/artifacts/contracts/randomizer/deprecated/RandomizerV2.sol/BasicRandomizerV2.json +2 -2
  142. package/artifacts/contracts/randomizer/primitive/PseudorandomAtomicBasic.sol/PseudorandomAtomic.json +2 -2
  143. package/artifacts/contracts/randomizer/shared/SharedRandomizerV0.sol/SharedRandomizerV0.json +2 -2
  144. package/artifacts/contracts/split/SplitAtomicFactoryV0.sol/SplitAtomicFactoryV0.json +203 -0
  145. package/artifacts/contracts/split/SplitAtomicV0.sol/SplitAtomicV0.json +168 -0
  146. package/artifacts/contracts/split/split-provider/SplitProviderV0.sol/SplitProviderV0.json +141 -0
  147. package/contracts/AdminACLV0.sol +6 -2
  148. package/contracts/AdminACLV1.sol +2 -2
  149. package/contracts/DependencyRegistryV0.sol +687 -408
  150. package/contracts/{GenArt721CoreV3.sol → archive/GenArt721CoreV3.sol} +56 -20
  151. package/contracts/{explorations → archive}/GenArt721CoreV3_Explorations.sol +49 -13
  152. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterBase_v0_1_1.sol +4 -4
  153. package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterDAExp}/MinterDAExpV4.sol +4 -4
  154. package/contracts/archive/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol +4 -4
  155. package/contracts/archive/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV1.sol +5 -5
  156. package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterDAExpSettlement}/MinterDAExpSettlementV2.sol +8 -8
  157. package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterDALin}/MinterDALinV4.sol +4 -4
  158. package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterHolder}/MinterHolderV4.sol +5 -5
  159. package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterMerkle}/MinterMerkleV5.sol +5 -5
  160. package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterPolyptych}/MinterPolyptychV0.sol +7 -7
  161. package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterSEA}/MinterSEAV0.sol +13 -13
  162. package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterSetPrice}/MinterSetPriceV4.sol +4 -4
  163. package/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V0.sol +82 -10
  164. package/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V1.sol +82 -10
  165. package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterSetPriceERC20}/MinterSetPriceERC20V4.sol +88 -21
  166. package/contracts/engine/V2/GenArt721MinterBurner_PBAB.sol +81 -22
  167. package/contracts/engine/V2/GenArt721Minter_PBAB.sol +80 -22
  168. package/contracts/engine/V3/EngineFactoryV0.sol +419 -0
  169. package/contracts/engine/V3/GenArt721CoreV3_Engine.sol +894 -488
  170. package/contracts/engine/V3/GenArt721CoreV3_Engine_Flex.sol +1054 -650
  171. package/contracts/engine/V3/forks/GenArt721CoreV3_Engine_Flex_PROOF.sol +3 -3
  172. package/contracts/engine/V3/forks/PROHIBITION/GenArt721CoreV3_Engine_Flex_PROHIBITION.sol +1 -1
  173. package/contracts/engine/V3/forks/PROHIBITION/interfaces/IGenArt721CoreContractV3_Engine_Flex_PROHIBITION.sol +2 -2
  174. package/contracts/interfaces/v0.8.x/IAdminACLV0_Extended.sol +20 -0
  175. package/contracts/interfaces/v0.8.x/IBytecodeStorageReaderV2.sol +23 -0
  176. package/contracts/interfaces/v0.8.x/IDependencyRegistryV0.sol +47 -45
  177. package/contracts/interfaces/v0.8.x/IEngineFactoryV0.sol +124 -0
  178. package/contracts/interfaces/v0.8.x/IFilteredMinterDAExpSettlementV0.sol +1 -3
  179. package/contracts/interfaces/v0.8.x/IFilteredMinterDAExpSettlementV1.sol +1 -3
  180. package/contracts/interfaces/v0.8.x/IFilteredMinterDAExpV1.sol +1 -3
  181. package/contracts/interfaces/v0.8.x/IFilteredMinterDALinV1.sol +1 -3
  182. package/contracts/interfaces/v0.8.x/IFilteredMinterHolderV2.sol +1 -3
  183. package/contracts/interfaces/v0.8.x/IFilteredMinterMerkleV2.sol +1 -3
  184. package/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Base.sol +115 -11
  185. package/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine.sol +84 -8
  186. package/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_Flex.sol +26 -8
  187. package/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_Flex_PreV3p2.sol +141 -0
  188. package/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_PreV3p2.sol +78 -0
  189. package/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_ProjectFinance.sol +47 -0
  190. package/contracts/interfaces/v0.8.x/IGenArt721Minter_PBAB.sol +91 -0
  191. package/contracts/interfaces/v0.8.x/IPseudorandomAtomic.sol +1 -3
  192. package/contracts/interfaces/v0.8.x/ISharedMinterDAExpSettlementV0.sol +19 -0
  193. package/contracts/interfaces/v0.8.x/ISharedMinterRAMV0.sol +23 -0
  194. package/contracts/interfaces/v0.8.x/ISharedMinterRequired.sol +20 -0
  195. package/contracts/interfaces/v0.8.x/ISharedMinterSEAV0.sol +1 -4
  196. package/contracts/interfaces/v0.8.x/ISharedMinterV0.sol +12 -6
  197. package/contracts/interfaces/v0.8.x/ISplitAtomicFactoryV0.sol +81 -0
  198. package/contracts/interfaces/v0.8.x/ISplitAtomicV0.sol +72 -0
  199. package/contracts/interfaces/v0.8.x/ISplitProviderV0.sol +49 -0
  200. package/contracts/interfaces/v0.8.x/integration-refs/splits-0x-v2/ISplitFactoryV2.sol +62 -0
  201. package/contracts/libs/v0.8.x/ABHelpers.sol +18 -4
  202. package/contracts/libs/v0.8.x/BitMap.sol +112 -0
  203. package/contracts/libs/v0.8.x/BytecodeStorageV2.sol +593 -0
  204. package/contracts/libs/v0.8.x/DependencyRegistryStorageLib.sol +90 -0
  205. package/contracts/libs/v0.8.x/ERC721_PackedHashSeedV1.sol +591 -0
  206. package/contracts/libs/v0.8.x/PackedBools.sol +42 -0
  207. package/contracts/libs/v0.8.x/V3FlexLib.sol +591 -0
  208. package/contracts/libs/v0.8.x/minter-libs/DAExpLib.sol +10 -12
  209. package/contracts/libs/v0.8.x/minter-libs/DALinLib.sol +4 -9
  210. package/contracts/libs/v0.8.x/minter-libs/GenericMinterEventsLib.sol +44 -44
  211. package/contracts/libs/v0.8.x/minter-libs/MaxInvocationsLib.sol +64 -63
  212. package/contracts/libs/v0.8.x/minter-libs/MerkleLib.sol +14 -10
  213. package/contracts/libs/v0.8.x/minter-libs/RAMLib.sol +2927 -0
  214. package/contracts/libs/v0.8.x/minter-libs/SEALib.sol +60 -62
  215. package/contracts/libs/v0.8.x/minter-libs/SetPriceLib.sol +4 -8
  216. package/contracts/libs/v0.8.x/minter-libs/SettlementExpLib.sol +92 -89
  217. package/contracts/libs/v0.8.x/minter-libs/SplitFundsLib.sol +21 -15
  218. package/contracts/libs/v0.8.x/minter-libs/TokenHolderLib.sol +5 -4
  219. package/contracts/minter-suite/MinterFilter/MinterFilterV2.sol +16 -10
  220. package/contracts/minter-suite/Minters/MinterDAExpHolderV5.sol +2 -2
  221. package/contracts/minter-suite/Minters/MinterDAExpSettlementV3.sol +19 -15
  222. package/contracts/minter-suite/Minters/MinterDAExpV5.sol +2 -2
  223. package/contracts/minter-suite/Minters/MinterDALinHolderV5.sol +2 -2
  224. package/contracts/minter-suite/Minters/MinterDALinV5.sol +2 -2
  225. package/contracts/minter-suite/Minters/MinterRAMV0.sol +1205 -0
  226. package/contracts/minter-suite/Minters/MinterSEAV1.sol +21 -32
  227. package/contracts/minter-suite/Minters/MinterSetPriceERC20V5.sol +17 -8
  228. package/contracts/minter-suite/Minters/MinterSetPriceHolderV5.sol +2 -2
  229. package/contracts/minter-suite/Minters/MinterSetPriceMerkleV5.sol +2 -2
  230. package/contracts/minter-suite/Minters/MinterSetPricePolyptychERC20V5.sol +23 -9
  231. package/contracts/minter-suite/Minters/MinterSetPricePolyptychV5.sol +2 -2
  232. package/contracts/minter-suite/Minters/MinterSetPriceV5.sol +2 -2
  233. package/contracts/minter-suite/Minters/one-off/MinterSetPriceV5_SingleCore.sol +446 -0
  234. package/contracts/mock/BytecodeV2LibCallsMock.sol +128 -0
  235. package/contracts/mock/BytecodeV2TextCR_DMock.sol +316 -0
  236. package/contracts/mock/ForceSendMock.sol +22 -0
  237. package/contracts/mock/Mock0xSplitsV2PullFactory.sol +75 -0
  238. package/contracts/mock/Mock0xSplitsV2Splitter.sol +47 -0
  239. package/contracts/mock/MockAdminACLV0.sol +21 -0
  240. package/contracts/mock/MockAdminACLV0_PROHIBITION.sol +21 -0
  241. package/contracts/mock/ReentrancyGenArt721MinterMock.sol +47 -0
  242. package/contracts/mock/ReentrancySplitterMocks.sol +67 -0
  243. package/contracts/randomizer/primitive/PseudorandomAtomicBasic.sol +1 -1
  244. package/contracts/randomizer/shared/SharedRandomizerV0.sol +1 -1
  245. package/contracts/split/SplitAtomicFactoryV0.sol +121 -0
  246. package/contracts/split/SplitAtomicV0.sol +265 -0
  247. package/contracts/split/split-provider/SplitProviderV0.sol +201 -0
  248. package/package.json +62 -34
  249. package/artifacts/contracts/GenArt721CoreV3.sol/GenArt721CoreV3.json +0 -1965
  250. package/artifacts/contracts/explorations/GenArt721CoreV3_Explorations.sol/GenArt721CoreV3_Explorations.json +0 -1939
  251. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20V4.sol/MinterSetPriceERC20V4.json +0 -768
  252. package/artifacts/contracts/royalty-registry/GenArt721RoyaltyOverride.sol/GenArt721RoyaltyOverride.json +0 -208
  253. package/artifacts/contracts/royalty-registry/GenArt721RoyaltyOverride_PBAB.sol/GenArt721RoyaltyOverride_PBAB.json +0 -301
  254. package/contracts/archive/readme.md +0 -16
  255. package/contracts/engine/README.md +0 -21
  256. package/contracts/royalty-registry/GenArt721RoyaltyOverride.sol +0 -168
  257. package/contracts/royalty-registry/GenArt721RoyaltyOverride_PBAB.sol +0 -221
@@ -0,0 +1,593 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Created By: Art Blocks Inc.
3
+
4
+ import {LibZip} from "solady/src/utils/LibZip.sol";
5
+
6
+ pragma solidity ^0.8.0;
7
+
8
+ /**
9
+ * @title Art Blocks Script Storage Library
10
+ * @notice Utilize contract bytecode as persistent storage for large chunks of script string data.
11
+ * V2 includes optional on-chain compression/decompression via solady LibZip.
12
+ * This library is intended to have an external deployed copy that is released in the future,
13
+ * and, as such, has been designed to support both updated V2 and V1 (versioned, with purging removed)
14
+ * reads as well as backwards-compatible reads for both a) the unversioned "V0" storage contracts
15
+ * which were deployed by the original version of this libary and b) contracts that were deployed
16
+ * using one of the SSTORE2 implementations referenced below.
17
+ * For these pre-V1 storage contracts (which themselves did not have any explicit versioning semantics)
18
+ * backwards-compatible reads are optimistic, and only expected to work for contracts actually
19
+ * deployed by the original version of this library – and may fail ungracefully if attempted to be
20
+ * used to read from other contracts.
21
+ * This library is split into two components, intended to be updated in tandem, and thus included
22
+ * here in the same source file. One component is an internal library that is intended to be embedded
23
+ * directly into other contracts and provides all _write_ functionality. The other is a public library
24
+ * that is intended to be deployed as a standalone contract and provides all _read_ functionality.
25
+ *
26
+ * @author Art Blocks Inc.
27
+ * @author Modified from 0xSequence (https://github.com/0xsequence/sstore2/blob/master/contracts/SSTORE2.sol)
28
+ * @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SSTORE2.sol)
29
+ * @author Utilizes LibZip from solady (https://github.com/Vectorized/solady/blob/main/src/utils/LibZip.sol)
30
+ *
31
+ * @dev Compared to the above two rerferenced libraries, this contracts-as-storage implementation makes a few
32
+ * notably different design decisions:
33
+ * - uses the `string` data type for input/output on reads, rather than speaking in bytes directly,
34
+ * with an exception for optionally compressed data which are input as bytes
35
+ * - stores the "writer" address (library user) in the deployed contract bytes, which is useful for
36
+ * on-chain introspection and provenance purposes
37
+ * - stores a very simple versioning string in the deployed contract bytes, which captures the version
38
+ * of the library that was used to deploy the storage contract and useful for supporting future
39
+ * compatibility management as this library evolves (e.g. in response to EOF v1 migration plans)
40
+ * - stores a bool indicating if the stored data are compressed.
41
+ * Also, given that much of this library is written in assembly, this library makes use of a slightly
42
+ * different convention (when compared to the rest of the Art Blocks smart contract repo) around
43
+ * pre-defining return values in some cases in order to simplify need to directly memory manage these
44
+ * return values.
45
+ */
46
+
47
+ /**
48
+ * @title Art Blocks Script Storage Library (Public, Reads)
49
+ * @author Art Blocks Inc.
50
+ * @notice The public library for reading from storage contracts. This library is intended to be deployed as a
51
+ * standalone contract, and provides all _read_ functionality.
52
+ */
53
+ library BytecodeStorageReader {
54
+ // Define the set of known valid version strings that may be stored in the deployed storage contract bytecode
55
+ // note: These are all intentionally exactly 32-bytes and are null-terminated. Null-termination is used due
56
+ // to this being the standard expected formatting in common web3 tooling such as ethers.js. Please see
57
+ // the following for additional context: https://docs.ethers.org/v5/api/utils/strings/#Bytes32String
58
+ // Used for storage contracts that were deployed by an unknown source
59
+ bytes32 public constant UNKNOWN_VERSION_STRING =
60
+ "UNKNOWN_VERSION_STRING_________ ";
61
+ // Pre-dates versioning string, so this doesn't actually exist in any deployed contracts,
62
+ // but is useful for backwards-compatible semantics with original version of this library
63
+ bytes32 public constant V0_VERSION_STRING =
64
+ "BytecodeStorage_V0.0.0_________ ";
65
+ // The first versioned storage contract, deployed by an updated version of this library
66
+ bytes32 public constant V1_VERSION_STRING =
67
+ "BytecodeStorage_V1.0.0_________ ";
68
+ // The first versioned storage contract, deployed by an updated version of this library
69
+ bytes32 public constant V2_VERSION_STRING =
70
+ "BytecodeStorage_V2.0.0_________ ";
71
+ // The current version of this library.
72
+ bytes32 public constant CURRENT_VERSION = V2_VERSION_STRING;
73
+
74
+ //---------------------------------------------------------------------------------------------------------------//
75
+ // Starting Index | Size | Ending Index | Description //
76
+ //---------------------------------------------------------------------------------------------------------------//
77
+ // 0 | N/A | 0 | //
78
+ // 0 | 1 | 1 | single byte opcode for making the storage contract non-executable //
79
+ // 1 | 32 | 33 | the 32 byte slot used for storing a basic versioning string //
80
+ // 33 | 32 | 65 | the 32 bytes for storing the deploying contract's (0-padded) address //
81
+ // 65 | 1 | 66 | single byte indicating if the stored data are compressed //
82
+ //---------------------------------------------------------------------------------------------------------------//
83
+ // Define the offset for where the "meta bytes" end, and the "data bytes" begin. Note that this is a manually
84
+ // calculated value, and must be updated if the above table is changed. It is expected that tests will fail
85
+ // loudly if these values are not updated in-step with eachother.
86
+ uint256 private constant VERSION_OFFSET = 1;
87
+ uint256 private constant ADDRESS_OFFSET = 33;
88
+ uint256 private constant COMPRESSION_OFFSET = 65;
89
+ uint256 private constant DATA_OFFSET = 66;
90
+
91
+ // Define the set of known *historic* offset values for where the "meta bytes" end, and the "data bytes" begin.
92
+ // SSTORE2 deployed storage contracts take the general format of:
93
+ // concat(0x00, data)
94
+ // note: this is true for both variants of the SSTORE2 library
95
+ uint256 private constant SSTORE2_DATA_OFFSET = 1;
96
+ // V0 deployed storage contracts take the general format of:
97
+ // concat(gated-cleanup-logic, deployer-address, data)
98
+ uint256 private constant V0_ADDRESS_OFFSET = 72;
99
+ uint256 private constant V0_DATA_OFFSET = 104;
100
+ // V1 deployed storage contracts take the general format of:
101
+ // concat(invalid opcode, version, deployer-address, data)
102
+ uint256 private constant V1_ADDRESS_OFFSET = 33;
103
+ uint256 private constant V1_DATA_OFFSET = 65;
104
+ // V2 deployed storage contracts take the general format of:
105
+ // concat(invalid opcode, version, deployer-address, compression-bool, data)
106
+ uint256 private constant V2_ADDRESS_OFFSET = ADDRESS_OFFSET;
107
+ uint256 private constant V2_DATA_OFFSET = DATA_OFFSET;
108
+
109
+ /*//////////////////////////////////////////////////////////////
110
+ READ LOGIC
111
+ //////////////////////////////////////////////////////////////*/
112
+
113
+ /**
114
+ * @notice Read a string from contract bytecode
115
+ * @param _address address of deployed contract with bytecode stored in the V0 or V1 or V2 format
116
+ * @return data string read from contract bytecode
117
+ * @dev This function performs input validation that the contract to read is in an expected format
118
+ */
119
+ function readFromBytecode(
120
+ address _address
121
+ ) public view returns (string memory data) {
122
+ (
123
+ uint256 dataOffset,
124
+ bool isCompressed
125
+ ) = _bytecodeDataOffsetAndIsCompressedAt(_address);
126
+ if (isCompressed) {
127
+ return
128
+ string(
129
+ LibZip.flzDecompress(
130
+ readBytesFromBytecode(_address, dataOffset)
131
+ )
132
+ );
133
+ } else {
134
+ return string(readBytesFromBytecode(_address, dataOffset));
135
+ }
136
+ }
137
+
138
+ /**
139
+ * @notice Read the bytes from contract bytecode that was written to the EVM using SSTORE2
140
+ * @param _address address of deployed contract with bytecode stored in the SSTORE2 format
141
+ * @return data bytes read from contract bytecode
142
+ * @dev This function performs no input validation on the provided contract,
143
+ * other than that there is content to read (but not that its a "storage contract")
144
+ */
145
+ function readBytesFromSSTORE2Bytecode(
146
+ address _address
147
+ ) public view returns (bytes memory data) {
148
+ return readBytesFromBytecode(_address, SSTORE2_DATA_OFFSET);
149
+ }
150
+
151
+ /**
152
+ * @notice Read the bytes from contract bytecode, with an explicitly provided starting offset
153
+ * @param _address address of deployed contract with bytecode stored in the V0 or V1 format
154
+ * @param _offset offset to read from in contract bytecode, explicitly provided (not calculated)
155
+ * @return data bytes read from contract bytecode
156
+ * @dev This function performs no input validation on the provided contract,
157
+ * other than that there is content to read (but not that its a "storage contract")
158
+ */
159
+ function readBytesFromBytecode(
160
+ address _address,
161
+ uint256 _offset
162
+ ) public view returns (bytes memory data) {
163
+ // get the size of the bytecode
164
+ uint256 bytecodeSize = _bytecodeSizeAt(_address);
165
+ // handle case where address contains code < _offset
166
+ if (bytecodeSize < _offset) {
167
+ revert("ContractAsStorage: Read Error");
168
+ }
169
+
170
+ // handle case where address contains code >= dataOffset
171
+ // decrement by dataOffset to account for header info
172
+ uint256 size;
173
+ unchecked {
174
+ size = bytecodeSize - _offset;
175
+ }
176
+
177
+ assembly {
178
+ // allocate free memory
179
+ data := mload(0x40)
180
+ // update free memory pointer
181
+ // use and(x, not(0x1f) as cheaper equivalent to sub(x, mod(x, 0x20)).
182
+ // adding 0x1f to size + logic above ensures the free memory pointer
183
+ // remains word-aligned, following the Solidity convention.
184
+ mstore(0x40, add(data, and(add(add(size, 0x20), 0x1f), not(0x1f))))
185
+ // store length of data in first 32 bytes
186
+ mstore(data, size)
187
+ // copy code to memory, excluding the deployer-address
188
+ extcodecopy(_address, add(data, 0x20), _offset, size)
189
+ }
190
+ }
191
+
192
+ /**
193
+ * @notice Get address for deployer for given contract bytecode
194
+ * @param _address address of deployed contract with bytecode stored in the V0 or V1 format
195
+ * @return writerAddress address read from contract bytecode
196
+ */
197
+ function getWriterAddressForBytecode(
198
+ address _address
199
+ ) public view returns (address) {
200
+ // get the size of the data
201
+ uint256 bytecodeSize = _bytecodeSizeAt(_address);
202
+ // the dataOffset for the bytecode
203
+ uint256 addressOffset = _bytecodeAddressOffsetAt(_address);
204
+ // handle case where address contains code < addressOffset + 32 (address takes a whole slot)
205
+ if (bytecodeSize < (addressOffset + 32)) {
206
+ revert("ContractAsStorage: Read Error");
207
+ }
208
+
209
+ assembly {
210
+ // allocate free memory
211
+ let writerAddress := mload(0x40)
212
+ // shift free memory pointer by one slot
213
+ mstore(0x40, add(mload(0x40), 0x20))
214
+ // copy the 32-byte address of the data contract writer to memory
215
+ // note: this relies on the assumption noted at the top-level of
216
+ // this file that the storage layout for the deployed
217
+ // contracts-as-storage contract looks like::
218
+ // | invalid opcode | version-string (unless v0) | deployer-address (padded) | data |
219
+ extcodecopy(
220
+ _address,
221
+ writerAddress,
222
+ addressOffset,
223
+ 0x20 // full 32-bytes, as address is expected to be zero-padded
224
+ )
225
+ return(
226
+ writerAddress,
227
+ 0x20 // return size is entire slot, as it is zero-padded
228
+ )
229
+ }
230
+ }
231
+
232
+ /**
233
+ * @notice Get version for given contract bytecode
234
+ * @param _address address of deployed contract with bytecode stored in the V0 or V1 format
235
+ * @return version version read from contract bytecode
236
+ */
237
+ function getLibraryVersionForBytecode(
238
+ address _address
239
+ ) public view returns (bytes32) {
240
+ return _bytecodeVersionAt(_address);
241
+ }
242
+
243
+ /**
244
+ * @notice Get if data are stored in compressed format for given contract bytecode
245
+ * @param _address address of deployed contract with bytecode stored in the V0, V1, or V2 format
246
+ * @return isCompressed boolean indicating if the stored data are compressed
247
+ */
248
+ function getIsCompressedForBytecode(
249
+ address _address
250
+ ) public view returns (bool) {
251
+ (, bool isCompressed) = _bytecodeDataOffsetAndIsCompressedAt(_address);
252
+ return isCompressed;
253
+ }
254
+
255
+ /**
256
+ * Utility function to get the compressed form of a message string using solady LibZip's
257
+ * flz compress algorithm.
258
+ * The compressed message is returned as bytes, which may be used as the input to
259
+ * the function `BytecodeStorageWriter.writeToBytecodeCompressed`.
260
+ * @param _data string to be compressed
261
+ * @return bytes compressed bytes
262
+ */
263
+ function getCompressed(
264
+ string memory _data
265
+ ) public pure returns (bytes memory) {
266
+ return LibZip.flzCompress(bytes(_data));
267
+ }
268
+
269
+ /*//////////////////////////////////////////////////////////////
270
+ INTERNAL HELPER LOGIC
271
+ //////////////////////////////////////////////////////////////*/
272
+
273
+ /**
274
+ * @notice Returns the size of the bytecode at address `_address`
275
+ * @param _address address that may or may not contain bytecode
276
+ * @return size size of the bytecode code at `_address`
277
+ */
278
+ function _bytecodeSizeAt(
279
+ address _address
280
+ ) private view returns (uint256 size) {
281
+ assembly {
282
+ size := extcodesize(_address)
283
+ }
284
+ if (size == 0) {
285
+ revert("ContractAsStorage: Read Error");
286
+ }
287
+ }
288
+
289
+ /**
290
+ * @notice Returns the offset of the data in the bytecode at address `_address`
291
+ * @param _address address that may or may not contain bytecode
292
+ * @return dataOffset offset of data in bytecode if a known version, otherwise 0
293
+ * @return isCompressed bool indicating if the stored data are compressed
294
+ */
295
+ function _bytecodeDataOffsetAndIsCompressedAt(
296
+ address _address
297
+ ) private view returns (uint256 dataOffset, bool isCompressed) {
298
+ bytes32 version = _bytecodeVersionAt(_address);
299
+ if (version == V2_VERSION_STRING) {
300
+ dataOffset = V2_DATA_OFFSET;
301
+ isCompressed = _isCompressedAt(_address, version);
302
+ } else if (version == V1_VERSION_STRING) {
303
+ dataOffset = V1_DATA_OFFSET;
304
+ // isCompressed remains false, as V1 contracts do not support compression
305
+ } else if (version == V0_VERSION_STRING) {
306
+ dataOffset = V0_DATA_OFFSET;
307
+ // isCompressed remains false, as V0 contracts do not support compression
308
+ } else {
309
+ // unknown version, revert
310
+ revert("ContractAsStorage: Unsupported Version");
311
+ }
312
+ }
313
+
314
+ /**
315
+ * @notice Returns the offset of the address in the bytecode at address `_address`
316
+ * @param _address address that may or may not contain bytecode
317
+ * @return addressOffset offset of address in bytecode if a known version, otherwise 0
318
+ */
319
+ function _bytecodeAddressOffsetAt(
320
+ address _address
321
+ ) private view returns (uint256 addressOffset) {
322
+ bytes32 version = _bytecodeVersionAt(_address);
323
+ if (version == V2_VERSION_STRING) {
324
+ addressOffset = V2_ADDRESS_OFFSET;
325
+ } else if (version == V1_VERSION_STRING) {
326
+ addressOffset = V1_ADDRESS_OFFSET;
327
+ } else if (version == V0_VERSION_STRING) {
328
+ addressOffset = V0_ADDRESS_OFFSET;
329
+ } else {
330
+ // unknown version, revert
331
+ revert("ContractAsStorage: Unsupported Version");
332
+ }
333
+ }
334
+
335
+ /**
336
+ * @notice Get version string for given contract bytecode
337
+ * @param _address address of deployed contract with bytecode stored in the V0 or V1 format
338
+ * @return version version string read from contract bytecode
339
+ */
340
+ function _bytecodeVersionAt(
341
+ address _address
342
+ ) private view returns (bytes32 version) {
343
+ // get the size of the data
344
+ uint256 bytecodeSize = _bytecodeSizeAt(_address);
345
+ // handle case where address contains code < minimum expected version string size,
346
+ // by returning early with the unknown version string
347
+ if (bytecodeSize < (VERSION_OFFSET + 32)) {
348
+ return UNKNOWN_VERSION_STRING;
349
+ }
350
+
351
+ assembly {
352
+ // allocate free memory
353
+ let versionString := mload(0x40)
354
+ // shift free memory pointer by one slot
355
+ mstore(0x40, add(mload(0x40), 0x20))
356
+ // copy the 32-byte version string of the bytecode library to memory
357
+ // note: this relies on the assumption noted at the top-level of
358
+ // this file that the storage layout for the deployed
359
+ // contracts-as-storage contract looks like:
360
+ // | invalid opcode | version-string (unless v0) | deployer-address (padded) | data |
361
+ extcodecopy(
362
+ _address,
363
+ versionString,
364
+ VERSION_OFFSET,
365
+ 0x20 // 32-byte version string
366
+ )
367
+ // note: must check against literal strings, as Yul does not allow for
368
+ // dynamic strings in switch statements.
369
+ switch mload(versionString)
370
+ case "BytecodeStorage_V2.0.0_________ " {
371
+ version := V2_VERSION_STRING
372
+ }
373
+ case "BytecodeStorage_V1.0.0_________ " {
374
+ version := V1_VERSION_STRING
375
+ }
376
+ case 0x2060486000396000513314601057fe5b60013614601957fe5b6000357fff0000 {
377
+ // the v0 variant of this library pre-dates formal versioning w/ version strings,
378
+ // so we check the first 32 bytes of the execution bytecode itself which
379
+ // is static and known across all storage contracts deployed with the first version
380
+ // of this library.
381
+ version := V0_VERSION_STRING
382
+ }
383
+ default {
384
+ version := UNKNOWN_VERSION_STRING
385
+ }
386
+ }
387
+ }
388
+
389
+ /**
390
+ * @notice Get if stored data are compressed for given contract bytecode
391
+ * @param _address address of deployed contract with bytecode stored
392
+ * @param _version version string of the bytecode library used to deploy the contract at `_address`
393
+ * @return isCompressed bool indicating if the stored data are compressed
394
+ */
395
+ function _isCompressedAt(
396
+ address _address,
397
+ bytes32 _version
398
+ ) private view returns (bool isCompressed) {
399
+ // @dev if branch no coverage - unreachable as used, remains for redundant safety
400
+ if (_version == V0_VERSION_STRING || _version == V1_VERSION_STRING) {
401
+ // V0 and V1 and unknown contracts do not support compression
402
+ return false;
403
+ }
404
+ // @dev if branch no coverage - unreachable as used, remains for redundant safety
405
+ if (_version != V2_VERSION_STRING) {
406
+ // unsupported version, throw error
407
+ revert("ContractAsStorage: Unsupported Version");
408
+ }
409
+ // get the size of the data
410
+ uint256 bytecodeSize = _bytecodeSizeAt(_address);
411
+ // handle case where address contains code < minimum expected version string size,
412
+ // by returning early with false
413
+ if (bytecodeSize < (COMPRESSION_OFFSET + 1)) {
414
+ return false;
415
+ }
416
+
417
+ assembly {
418
+ // allocate free memory
419
+ let compressedByte := mload(0x40)
420
+ // shift free memory pointer by one slot
421
+ mstore(0x40, add(mload(0x40), 0x20))
422
+ // zero out word at compressedByte (solidity does not guarantee zeroed memory beyond free memory pointer)
423
+ mstore(compressedByte, 0x00)
424
+ // copy the 1-byte compressed flag of the bytecode library to memory
425
+ // note: this relies on the assumption noted at the top-level of
426
+ // this file that the storage layout for the deployed
427
+ // contracts-as-storage contract looks like:
428
+ // | invalid opcode | version-string (unless v0) | deployer-address (padded) | isCompressed | data |
429
+ extcodecopy(
430
+ _address,
431
+ compressedByte,
432
+ COMPRESSION_OFFSET,
433
+ 0x1 // 1-byte version string
434
+ )
435
+ // check if the compressed flag is set
436
+ switch mload(compressedByte)
437
+ case 0x00 {
438
+ isCompressed := false
439
+ }
440
+ default {
441
+ isCompressed := true
442
+ }
443
+ }
444
+ }
445
+ }
446
+
447
+ /**
448
+ * @title Art Blocks Script Storage Library (Internal, Writes)
449
+ * @author Art Blocks Inc.
450
+ * @notice The internal library for writing to storage contracts. This library is intended to be deployed
451
+ * within library client contracts that use this library to perform _write_ operations on storage.
452
+ */
453
+ library BytecodeStorageWriter {
454
+ /*//////////////////////////////////////////////////////////////
455
+ WRITE LOGIC
456
+ //////////////////////////////////////////////////////////////*/
457
+
458
+ /**
459
+ * @notice Write a string to contract bytecode
460
+ * @param _data string to be written to contract. No input validation is performed on this parameter.
461
+ * @return address_ address of deployed contract with bytecode stored in the V2 format
462
+ */
463
+ function writeToBytecode(
464
+ string memory _data
465
+ ) internal returns (address address_) {
466
+ // prefix bytecode with
467
+ bytes memory creationCode = abi.encodePacked(
468
+ //---------------------------------------------------------------------------------------------------------------//
469
+ // Opcode | Opcode + Arguments | Description | Stack View //
470
+ //---------------------------------------------------------------------------------------------------------------//
471
+ // a.) creation code returns all code in the contract except for the first 11 (0B in hex) bytes, as these 11
472
+ // bytes are the creation code itself which we do not want to store in the deployed storage contract result
473
+ //---------------------------------------------------------------------------------------------------------------//
474
+ // 0x60 | 0x60_0B | PUSH1 11 | codeOffset //
475
+ // 0x59 | 0x59 | MSIZE | 0 codeOffset //
476
+ // 0x81 | 0x81 | DUP2 | codeOffset 0 codeOffset //
477
+ // 0x38 | 0x38 | CODESIZE | codeSize codeOffset 0 codeOffset //
478
+ // 0x03 | 0x03 | SUB | (codeSize - codeOffset) 0 codeOffset //
479
+ // 0x80 | 0x80 | DUP | (codeSize - codeOffset) (codeSize - codeOffset) 0 codeOffset //
480
+ // 0x92 | 0x92 | SWAP3 | codeOffset (codeSize - codeOffset) 0 (codeSize - codeOffset) //
481
+ // 0x59 | 0x59 | MSIZE | 0 codeOffset (codeSize - codeOffset) 0 (codeSize - codeOffset) //
482
+ // 0x39 | 0x39 | CODECOPY | 0 (codeSize - codeOffset) //
483
+ // 0xF3 | 0xF3 | RETURN | //
484
+ //---------------------------------------------------------------------------------------------------------------//
485
+ // (11 bytes)
486
+ hex"60_0B_59_81_38_03_80_92_59_39_F3",
487
+ //---------------------------------------------------------------------------------------------------------------//
488
+ // b.) ensure that the deployed storage contract is non-executeable (first opcode is the `invalid` opcode)
489
+ //---------------------------------------------------------------------------------------------------------------//
490
+ //---------------------------------------------------------------------------------------------------------------//
491
+ // 0xFE | 0xFE | INVALID | //
492
+ //---------------------------------------------------------------------------------------------------------------//
493
+ // (1 byte)
494
+ hex"FE",
495
+ //---------------------------------------------------------------------------------------------------------------//
496
+ // c.) store the version string, which is already represented as a 32-byte value
497
+ //---------------------------------------------------------------------------------------------------------------//
498
+ // (32 bytes)
499
+ BytecodeStorageReader.CURRENT_VERSION,
500
+ //---------------------------------------------------------------------------------------------------------------//
501
+ // d.) store the deploying-contract's address with 0-padding to fit a 20-byte address into a 32-byte slot
502
+ //---------------------------------------------------------------------------------------------------------------//
503
+ // (12 bytes)
504
+ hex"00_00_00_00_00_00_00_00_00_00_00_00",
505
+ // (20 bytes)
506
+ address(this),
507
+ //---------------------------------------------------------------------------------------------------------------//
508
+ // e.) store the bool indicating if the data is compressed. true for this function.
509
+ //---------------------------------------------------------------------------------------------------------------//
510
+ // (1 byte)
511
+ hex"00",
512
+ // uploaded data (stored as bytecode) comes last
513
+ _data
514
+ );
515
+
516
+ assembly {
517
+ // deploy a new contract with the generated creation code.
518
+ // start 32 bytes into creationCode to avoid copying the byte length.
519
+ address_ := create(0, add(creationCode, 0x20), mload(creationCode))
520
+ }
521
+
522
+ // address must be non-zero if contract was deployed successfully
523
+ require(address_ != address(0), "ContractAsStorage: Write Error");
524
+ }
525
+
526
+ /**
527
+ * @notice Write a string to contract bytecode, input as compressed bytes from solady LibZip
528
+ * @param _dataCompressed compressed bytes to be written to contract. No input validation is performed on this parameter.
529
+ * @return address_ address of deployed contract with bytecode stored in the V2 format
530
+ */
531
+ function writeToBytecodeCompressed(
532
+ bytes memory _dataCompressed
533
+ ) internal returns (address address_) {
534
+ // prefix bytecode with
535
+ bytes memory creationCode = abi.encodePacked(
536
+ //---------------------------------------------------------------------------------------------------------------//
537
+ // Opcode | Opcode + Arguments | Description | Stack View //
538
+ //---------------------------------------------------------------------------------------------------------------//
539
+ // a.) creation code returns all code in the contract except for the first 11 (0B in hex) bytes, as these 11
540
+ // bytes are the creation code itself which we do not want to store in the deployed storage contract result
541
+ //---------------------------------------------------------------------------------------------------------------//
542
+ // 0x60 | 0x60_0B | PUSH1 11 | codeOffset //
543
+ // 0x59 | 0x59 | MSIZE | 0 codeOffset //
544
+ // 0x81 | 0x81 | DUP2 | codeOffset 0 codeOffset //
545
+ // 0x38 | 0x38 | CODESIZE | codeSize codeOffset 0 codeOffset //
546
+ // 0x03 | 0x03 | SUB | (codeSize - codeOffset) 0 codeOffset //
547
+ // 0x80 | 0x80 | DUP | (codeSize - codeOffset) (codeSize - codeOffset) 0 codeOffset //
548
+ // 0x92 | 0x92 | SWAP3 | codeOffset (codeSize - codeOffset) 0 (codeSize - codeOffset) //
549
+ // 0x59 | 0x59 | MSIZE | 0 codeOffset (codeSize - codeOffset) 0 (codeSize - codeOffset) //
550
+ // 0x39 | 0x39 | CODECOPY | 0 (codeSize - codeOffset) //
551
+ // 0xF3 | 0xF3 | RETURN | //
552
+ //---------------------------------------------------------------------------------------------------------------//
553
+ // (11 bytes)
554
+ hex"60_0B_59_81_38_03_80_92_59_39_F3",
555
+ //---------------------------------------------------------------------------------------------------------------//
556
+ // b.) ensure that the deployed storage contract is non-executeable (first opcode is the `invalid` opcode)
557
+ //---------------------------------------------------------------------------------------------------------------//
558
+ //---------------------------------------------------------------------------------------------------------------//
559
+ // 0xFE | 0xFE | INVALID | //
560
+ //---------------------------------------------------------------------------------------------------------------//
561
+ // (1 byte)
562
+ hex"FE",
563
+ //---------------------------------------------------------------------------------------------------------------//
564
+ // c.) store the version string, which is already represented as a 32-byte value
565
+ //---------------------------------------------------------------------------------------------------------------//
566
+ // (32 bytes)
567
+ BytecodeStorageReader.CURRENT_VERSION,
568
+ //---------------------------------------------------------------------------------------------------------------//
569
+ // d.) store the deploying-contract's address with 0-padding to fit a 20-byte address into a 32-byte slot
570
+ //---------------------------------------------------------------------------------------------------------------//
571
+ // (12 bytes)
572
+ hex"00_00_00_00_00_00_00_00_00_00_00_00",
573
+ // (20 bytes)
574
+ address(this),
575
+ //---------------------------------------------------------------------------------------------------------------//
576
+ // e.) store the bool indicating if the data is compressed. true for this function.
577
+ //---------------------------------------------------------------------------------------------------------------//
578
+ // (1 byte)
579
+ hex"01",
580
+ // uploaded compressed data (stored as bytecode) comes last
581
+ _dataCompressed
582
+ );
583
+
584
+ assembly {
585
+ // deploy a new contract with the generated creation code.
586
+ // start 32 bytes into creationCode to avoid copying the byte length.
587
+ address_ := create(0, add(creationCode, 0x20), mload(creationCode))
588
+ }
589
+
590
+ // address must be non-zero if contract was deployed successfully
591
+ require(address_ != address(0), "ContractAsStorage: Write Error");
592
+ }
593
+ }