@artblocks/contracts 1.0.4 → 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.
- package/README.md +75 -7
- package/artifacts/contracts/AdminACLV0.sol/AdminACLV0.json +2 -2
- package/artifacts/contracts/AdminACLV1.sol/AdminACLV1.json +2 -2
- package/artifacts/contracts/DependencyRegistryV0.sol/DependencyRegistryV0.json +336 -131
- package/artifacts/contracts/archive/GenArt721CoreV3.sol/GenArt721CoreV3.json +2047 -0
- package/artifacts/contracts/archive/GenArt721CoreV3_Explorations.sol/GenArt721CoreV3_Explorations.json +2021 -0
- package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterBase_v0_1_1.sol/MinterBase.json +1 -1
- package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV2.sol/MinterDAExpV2.json +2 -2
- package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV3.sol/MinterDAExpV3.json +2 -2
- package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterDAExp}/MinterDAExpV4.sol/MinterDAExpV4.json +3 -3
- package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol/MinterDAExpSettlementV0.json +2 -2
- package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV1.sol/MinterDAExpSettlementV1.json +2 -2
- package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV2.sol/MinterDAExpSettlementV2.json +1109 -0
- package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV2.sol/MinterDALinV2.json +2 -2
- package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV3.sol/MinterDALinV3.json +2 -2
- package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterDALin}/MinterDALinV4.sol/MinterDALinV4.json +3 -3
- package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV1.sol/MinterHolderV1.json +2 -2
- package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV2.sol/MinterHolderV2.json +2 -2
- package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV3.sol/MinterHolderV3.json +2 -2
- package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterHolder}/MinterHolderV4.sol/MinterHolderV4.json +3 -3
- package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV1.sol/MinterMerkleV1.json +2 -2
- package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV2.sol/MinterMerkleV2.json +2 -2
- package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV3.sol/MinterMerkleV3.json +2 -2
- package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV4.sol/MinterMerkleV4.json +2 -2
- package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterMerkle}/MinterMerkleV5.sol/MinterMerkleV5.json +3 -3
- package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterPolyptych}/MinterPolyptychV0.sol/IGenArt721CoreContractV3WithRandomizer.json +31 -63
- package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterPolyptych}/MinterPolyptychV0.sol/MinterPolyptychV0.json +3 -3
- package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterSEA}/MinterSEAV0.sol/MinterSEAV0.json +3 -3
- package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV2.sol/MinterSetPriceV2.json +2 -2
- package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV3.sol/MinterSetPriceV3.json +2 -2
- package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterSetPrice}/MinterSetPriceV4.sol/MinterSetPriceV4.json +3 -3
- package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V0.sol/MinterSetPriceERC20V0.json +65 -2
- package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V1.sol/MinterSetPriceERC20V1.json +65 -2
- package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol/MinterSetPriceERC20V2.json +2 -2
- package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol/MinterSetPriceERC20V3.json +2 -2
- package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V4.sol/MinterSetPriceERC20V4.json +807 -0
- package/artifacts/contracts/engine/V2/GenArt721MinterBurner_PBAB.sol/GenArt721MinterBurner_PBAB.json +65 -2
- package/artifacts/contracts/engine/V2/GenArt721Minter_PBAB.sol/GenArt721Minter_PBAB.json +65 -2
- package/artifacts/contracts/engine/V3/EngineFactoryV0.sol/EngineFactoryV0.json +606 -0
- package/artifacts/contracts/engine/V3/GenArt721CoreV3_Engine.sol/GenArt721CoreV3_Engine.json +565 -209
- package/artifacts/contracts/engine/V3/GenArt721CoreV3_Engine_Flex.sol/GenArt721CoreV3_Engine_Flex.json +785 -227
- package/artifacts/contracts/engine/V3/forks/GenArt721CoreV3_Engine_Flex_PROOF.sol/GenArt721CoreV3_Engine_Flex_PROOF.json +40 -15
- package/artifacts/contracts/engine/V3/forks/PROHIBITION/AdminACLV0_PROHIBITION.sol/AdminACLV0_PROHIBITION.json +2 -2
- package/artifacts/contracts/engine/V3/forks/PROHIBITION/GenArt721CoreV3_Engine_Flex_PROHIBITION.sol/GenArt721CoreV3_Engine_Flex_PROHIBITION.json +40 -15
- package/artifacts/contracts/engine/V3/forks/PROHIBITION/interfaces/IGenArt721CoreContractV3_Engine_Flex_PROHIBITION.sol/IGenArt721CoreContractV3_Engine_Flex_PROHIBITION.json +36 -68
- package/artifacts/contracts/engine-registry/CoreRegistryV1.sol/CoreRegistryV1.json +12 -12
- package/artifacts/contracts/interfaces/v0.8.x/IAdminACLV0_Extended.sol/IAdminACLV0_Extended.json +140 -0
- package/artifacts/contracts/interfaces/v0.8.x/IBytecodeStorageReaderV2.sol/IBytecodeStorageReaderV2.json +130 -0
- package/artifacts/contracts/interfaces/v0.8.x/ICoreRegistryV1.sol/ICoreRegistryV1.json +6 -6
- package/artifacts/contracts/interfaces/v0.8.x/IDependencyRegistryV0.sol/IDependencyRegistryV0.json +71 -39
- package/artifacts/contracts/interfaces/v0.8.x/IEngineFactoryV0.sol/IEngineFactoryV0.json +283 -0
- package/artifacts/contracts/interfaces/v0.8.x/IFilteredMinterDAExpSettlementV0.sol/IFilteredMinterDAExpSettlementV0.json +12 -12
- package/artifacts/contracts/interfaces/v0.8.x/IFilteredMinterDAExpSettlementV1.sol/IFilteredMinterDAExpSettlementV1.json +12 -12
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3.sol/IGenArt721CoreContractV3.json +30 -62
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Base.sol/IGenArt721CoreContractV3_Base.json +30 -62
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine.sol/IGenArt721CoreContractV3_Engine.json +170 -104
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_Flex.sol/IGenArt721CoreContractV3_Engine_Flex.json +170 -104
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_Flex_PreV3p2.sol/IGenArt721CoreContractV3_Engine_Flex_PreV3p2.json +1028 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_PreV3p2.sol/IGenArt721CoreContractV3_Engine_PreV3p2.json +741 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_ProjectFinance.sol/IGenArt721CoreContractV3_ProjectFinance.json +87 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721Minter_PBAB.sol/IGenArt721Minter_PBAB.json +279 -0
- package/artifacts/contracts/interfaces/v0.8.x/IMinterFilterV1.sol/IMinterFilterV1.json +22 -22
- package/artifacts/contracts/interfaces/v0.8.x/IPseudorandomAtomic.sol/IPseudorandomAtomic.json +1 -1
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterDAExpSettlementV0.sol/ISharedMinterDAExpSettlementV0.json +26 -101
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterDAExpV0.sol/ISharedMinterDAExpV0.json +1 -57
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterDALinV0.sol/ISharedMinterDALinV0.json +1 -57
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterDAV0.sol/ISharedMinterDAV0.json +2 -21
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterHolderERC20V0.sol/ISharedMinterHolderERC20V0.json +158 -0
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterHolderV0.sol/ISharedMinterHolderV0.json +15 -90
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterMerkleV0.sol/ISharedMinterMerkleV0.json +10 -36
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterRAMV0.sol/ISharedMinterRAMV0.json +62 -0
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterRequired.sol/ISharedMinterRequired.json +37 -0
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterSEAV0.sol/ISharedMinterSEAV0.json +4 -236
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterSimplePurchaseV0.sol/ISharedMinterSimplePurchaseV0.json +5 -5
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterV0.sol/ISharedMinterV0.json +7 -423
- package/artifacts/contracts/interfaces/v0.8.x/ISharedRandomizerV0.sol/ISharedRandomizerV0.json +17 -17
- package/artifacts/contracts/interfaces/v0.8.x/ISplitAtomicFactoryV0.sol/ISplitAtomicFactoryV0.json +170 -0
- package/artifacts/contracts/interfaces/v0.8.x/ISplitAtomicV0.sol/ISplitAtomicV0.json +126 -0
- package/artifacts/contracts/interfaces/v0.8.x/ISplitProviderV0.sol/ISplitProviderV0.json +98 -0
- package/artifacts/contracts/interfaces/v0.8.x/integration-refs/splits-0x-v2/ISplitFactoryV2.sol/ISplitFactoryV2.json +123 -0
- package/artifacts/contracts/libs/integration-refs/delegation-registry/DelegationRegistry.sol/DelegationRegistry.json +2 -2
- package/artifacts/contracts/libs/integration-refs/gnosis-safe/GnosisSafeMock.sol/GnosisSafeMock.json +2 -2
- package/artifacts/contracts/libs/integration-refs/gnosis-safe/GnosisSafeProxyFactoryMock.sol/GnosisSafeProxyFactoryMock.json +2 -2
- package/artifacts/contracts/libs/integration-refs/gnosis-safe/MultiSendMock.sol/MultiSendMock.json +2 -2
- package/artifacts/contracts/libs/integration-refs/weth9/weth9.sol/WETH9_.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/ABHelpers.sol/ABHelpers.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/AuthLib.sol/AuthLib.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/BitMap.sol/BitMaps256.json +10 -0
- package/artifacts/contracts/libs/v0.8.x/BytecodeStorageV0.sol/BytecodeStorage.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/BytecodeStorageV1.sol/BytecodeStorageReader.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/BytecodeStorageV1.sol/BytecodeStorageWriter.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/BytecodeStorageV2.sol/BytecodeStorageReader.json +214 -0
- package/artifacts/contracts/libs/v0.8.x/BytecodeStorageV2.sol/BytecodeStorageWriter.json +10 -0
- package/artifacts/contracts/libs/v0.8.x/Bytes32Strings.sol/Bytes32Strings.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/DependencyRegistryStorageLib.sol/DependencyRegistryStorageLib.json +10 -0
- package/artifacts/contracts/libs/v0.8.x/ERC721_PackedHashSeed.sol/ERC721_PackedHashSeed.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/ERC721_PackedHashSeedV1.sol/ERC721_PackedHashSeedV1.json +444 -0
- package/artifacts/contracts/libs/v0.8.x/PackedBools.sol/PackedBools.json +10 -0
- package/artifacts/contracts/libs/v0.8.x/SSTORE2.sol/SSTORE2.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/V3FlexLib.sol/V3FlexLib.json +208 -0
- package/artifacts/contracts/libs/v0.8.x/minter-libs/DAExpLib.sol/DAExpLib.json +60 -3
- package/artifacts/contracts/libs/v0.8.x/minter-libs/DALib.sol/DALib.json +30 -0
- package/artifacts/contracts/libs/v0.8.x/minter-libs/DALinLib.sol/DALinLib.json +60 -3
- package/artifacts/contracts/libs/v0.8.x/minter-libs/GenericMinterEventsLib.sol/GenericMinterEventsLib.json +346 -0
- package/artifacts/contracts/libs/v0.8.x/minter-libs/MaxInvocationsLib.sol/MaxInvocationsLib.json +29 -3
- package/artifacts/contracts/libs/v0.8.x/minter-libs/MerkleLib.sol/MerkleLib.json +30 -3
- package/artifacts/contracts/libs/v0.8.x/minter-libs/PolyptychLib.sol/PolyptychLib.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/minter-libs/RAMLib.sol/RAMLib.json +398 -0
- package/artifacts/contracts/libs/v0.8.x/minter-libs/SEALib.sol/SEALib.json +254 -3
- package/artifacts/contracts/libs/v0.8.x/minter-libs/SetPriceLib.sol/SetPriceLib.json +48 -3
- package/artifacts/contracts/libs/v0.8.x/minter-libs/SettlementExpLib.sol/SettlementExpLib.json +41 -3
- package/artifacts/contracts/libs/v0.8.x/minter-libs/SplitFundsLib.sol/SplitFundsLib.json +35 -3
- package/artifacts/contracts/libs/v0.8.x/minter-libs/TokenHolderLib.sol/TokenHolderLib.json +79 -3
- package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV1.sol/MinterFilterV1.json +2 -2
- package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV2.sol/MinterFilterV2.json +41 -41
- package/artifacts/contracts/minter-suite/Minters/MinterDAExpHolderV5.sol/MinterDAExpHolderV5.json +66 -632
- package/artifacts/contracts/minter-suite/Minters/MinterDAExpSettlementV3.sol/MinterDAExpSettlementV3.json +67 -594
- package/artifacts/contracts/minter-suite/Minters/MinterDAExpV5.sol/MinterDAExpV5.json +33 -524
- package/artifacts/contracts/minter-suite/Minters/MinterDALinHolderV5.sol/MinterDALinHolderV5.json +66 -632
- package/artifacts/contracts/minter-suite/Minters/MinterDALinV5.sol/MinterDALinV5.json +33 -524
- package/artifacts/contracts/minter-suite/Minters/MinterRAMV0.sol/MinterRAMV0.json +1374 -0
- package/artifacts/contracts/minter-suite/Minters/MinterSEAV1.sol/MinterSEAV1.json +56 -722
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20V5.sol/MinterSetPriceERC20V5.json +58 -454
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceHolderV5.sol/MinterSetPriceHolderV5.json +61 -552
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceMerkleV5.sol/MinterSetPriceMerkleV5.json +55 -497
- package/artifacts/contracts/minter-suite/Minters/MinterSetPricePolyptychERC20V5.sol/MinterSetPricePolyptychERC20V5.json +110 -571
- package/artifacts/contracts/minter-suite/Minters/MinterSetPricePolyptychV5.sol/MinterSetPricePolyptychV5.json +69 -560
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceV5.sol/MinterSetPriceV5.json +28 -444
- package/artifacts/contracts/minter-suite/Minters/one-off/MinterSetPriceV5_SingleCore.sol/MinterSetPriceV5_SingleCore.json +417 -0
- package/artifacts/contracts/mock/BytecodeV2LibCallsMock.sol/BytecodeV2LibCallsMock.json +154 -0
- package/artifacts/contracts/mock/BytecodeV2TextCR_DMock.sol/BytecodeV2TextCR_DMock.json +428 -0
- package/artifacts/contracts/mock/DummySharedMinter.sol/DummySharedMinter.json +2 -2
- package/artifacts/contracts/mock/ERC20Mock.sol/ERC20Mock.json +2 -2
- package/artifacts/contracts/mock/ForceSendMock.sol/ForceSendMock.json +24 -0
- package/artifacts/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol/GenArt721CoreV3_Engine_IncorrectCoreType.json +4 -9
- package/artifacts/contracts/mock/Mock0xSplitsV2PullFactory.sol/Mock0xSplitsV2PullFactory.json +149 -0
- package/artifacts/contracts/mock/Mock0xSplitsV2Splitter.sol/Mock0xSplitsV2Splitter.json +99 -0
- package/artifacts/contracts/mock/MockAdminACLV0.sol/MockAdminACLV0Events.json +20 -2
- package/artifacts/contracts/mock/MockAdminACLV0_PROHIBITION.sol/MockAdminACLV0Events_PROHIBITION.json +20 -2
- package/artifacts/contracts/mock/OriginRegisterMock.sol/OriginRegisterMock.json +2 -2
- package/artifacts/contracts/mock/RandomizerV2_NoAssignMock.sol/RandomizerV2_NoAssignMock.json +2 -2
- package/artifacts/contracts/mock/ReentrancyGenArt721MinterMock.sol/ReentrancyGenArt721MinterMock.json +100 -0
- package/artifacts/contracts/mock/ReentrancyHolderMock.sol/ReentrancyHolderMock.json +2 -2
- package/artifacts/contracts/mock/ReentrancyHolderMockShared.sol/ReentrancyHolderMockShared.json +136 -0
- package/artifacts/contracts/mock/ReentrancyMerkleMock.sol/ReentrancyMerkleMock.json +2 -2
- package/artifacts/contracts/mock/ReentrancyMerkleMockShared.sol/ReentrancyMerkleMockShared.json +105 -0
- package/artifacts/contracts/mock/ReentrancyMock.sol/ReentrancyMock.json +2 -2
- package/artifacts/contracts/mock/ReentrancyMockShared.sol/ReentrancyMockShared.json +100 -0
- package/artifacts/contracts/mock/ReentrancySEAMock.sol/ReentrancySEAAutoBidderMock.json +2 -2
- package/artifacts/contracts/mock/ReentrancySEAMockShared.sol/ReentrancySEAAutoBidderMockShared.json +69 -0
- package/artifacts/contracts/mock/ReentrancySplitterMocks.sol/ReentrancySplitterDrainETHMock.json +54 -0
- package/artifacts/contracts/mock/ReentrancySplitterMocks.sol/ReentrancySplitterSendETHMock.json +54 -0
- package/artifacts/contracts/randomizer/deprecated/PolyptychRandomizerV0.sol/BasicPolyptychRandomizerV0.json +2 -2
- package/artifacts/contracts/randomizer/deprecated/RandomizerV2.sol/BasicRandomizerV2.json +2 -2
- package/artifacts/contracts/randomizer/primitive/PseudorandomAtomicBasic.sol/PseudorandomAtomic.json +2 -2
- package/artifacts/contracts/randomizer/shared/SharedRandomizerV0.sol/SharedRandomizerV0.json +19 -19
- package/artifacts/contracts/split/SplitAtomicFactoryV0.sol/SplitAtomicFactoryV0.json +203 -0
- package/artifacts/contracts/split/SplitAtomicV0.sol/SplitAtomicV0.json +168 -0
- package/artifacts/contracts/split/split-provider/SplitProviderV0.sol/SplitProviderV0.json +141 -0
- package/contracts/AdminACLV0.sol +6 -2
- package/contracts/AdminACLV1.sol +2 -2
- package/contracts/DependencyRegistryV0.sol +737 -390
- package/contracts/{GenArt721CoreV3.sol → archive/GenArt721CoreV3.sol} +56 -20
- package/contracts/{explorations → archive}/GenArt721CoreV3_Explorations.sol +49 -13
- package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterBase_v0_1_1.sol +4 -4
- package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterDAExp}/MinterDAExpV4.sol +4 -4
- package/contracts/archive/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol +4 -4
- package/contracts/archive/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV1.sol +5 -5
- package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterDAExpSettlement}/MinterDAExpSettlementV2.sol +9 -62
- package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterDALin}/MinterDALinV4.sol +4 -4
- package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterHolder}/MinterHolderV4.sol +5 -5
- package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterMerkle}/MinterMerkleV5.sol +5 -5
- package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterPolyptych}/MinterPolyptychV0.sol +7 -7
- package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterSEA}/MinterSEAV0.sol +13 -13
- package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterSetPrice}/MinterSetPriceV4.sol +4 -4
- package/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V0.sol +82 -10
- package/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V1.sol +82 -10
- package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterSetPriceERC20}/MinterSetPriceERC20V4.sol +88 -21
- package/contracts/engine/V2/GenArt721MinterBurner_PBAB.sol +81 -22
- package/contracts/engine/V2/GenArt721Minter_PBAB.sol +80 -22
- package/contracts/engine/V3/EngineFactoryV0.sol +419 -0
- package/contracts/engine/V3/GenArt721CoreV3_Engine.sol +893 -493
- package/contracts/engine/V3/GenArt721CoreV3_Engine_Flex.sol +1053 -655
- package/contracts/engine/V3/forks/GenArt721CoreV3_Engine_Flex_PROOF.sol +7 -13
- package/contracts/engine/V3/forks/PROHIBITION/GenArt721CoreV3_Engine_Flex_PROHIBITION.sol +5 -11
- package/contracts/engine/V3/forks/PROHIBITION/interfaces/IGenArt721CoreContractV3_Engine_Flex_PROHIBITION.sol +2 -2
- package/contracts/engine-registry/CoreRegistryV1.sol +58 -65
- package/contracts/interfaces/v0.8.x/IAdminACLV0_Extended.sol +20 -0
- package/contracts/interfaces/v0.8.x/IBytecodeStorageReaderV2.sol +23 -0
- package/contracts/interfaces/v0.8.x/ICoreRegistryV1.sol +6 -8
- package/contracts/interfaces/v0.8.x/IDependencyRegistryV0.sol +48 -43
- package/contracts/interfaces/v0.8.x/IEngineFactoryV0.sol +124 -0
- package/contracts/interfaces/v0.8.x/IFilteredMinterDAExpSettlementV0.sol +1 -3
- package/contracts/interfaces/v0.8.x/IFilteredMinterDAExpSettlementV1.sol +1 -3
- package/contracts/interfaces/v0.8.x/IFilteredMinterDAExpV1.sol +1 -3
- package/contracts/interfaces/v0.8.x/IFilteredMinterDALinV1.sol +1 -3
- package/contracts/interfaces/v0.8.x/IFilteredMinterHolderV2.sol +1 -3
- package/contracts/interfaces/v0.8.x/IFilteredMinterMerkleV2.sol +1 -3
- package/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Base.sol +115 -11
- package/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine.sol +84 -8
- package/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_Flex.sol +26 -8
- package/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_Flex_PreV3p2.sol +141 -0
- package/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_PreV3p2.sol +78 -0
- package/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_ProjectFinance.sol +47 -0
- package/contracts/interfaces/v0.8.x/IGenArt721Minter_PBAB.sol +91 -0
- package/contracts/interfaces/v0.8.x/IMinterFilterV1.sol +25 -25
- package/contracts/interfaces/v0.8.x/IPseudorandomAtomic.sol +1 -3
- package/contracts/interfaces/v0.8.x/ISharedMinterDAExpSettlementV0.sol +30 -20
- package/contracts/interfaces/v0.8.x/ISharedMinterDAExpV0.sol +1 -14
- package/contracts/interfaces/v0.8.x/ISharedMinterDALinV0.sol +1 -15
- package/contracts/interfaces/v0.8.x/ISharedMinterDAV0.sol +2 -8
- package/contracts/interfaces/v0.8.x/ISharedMinterHolderERC20V0.sol +47 -0
- package/contracts/interfaces/v0.8.x/ISharedMinterHolderV0.sol +15 -43
- package/contracts/interfaces/v0.8.x/ISharedMinterMerkleV0.sol +10 -20
- package/contracts/interfaces/v0.8.x/ISharedMinterRAMV0.sol +23 -0
- package/contracts/interfaces/v0.8.x/ISharedMinterRequired.sol +20 -0
- package/contracts/interfaces/v0.8.x/ISharedMinterSEAV0.sol +1 -67
- package/contracts/interfaces/v0.8.x/ISharedMinterSimplePurchaseV0.sol +5 -5
- package/contracts/interfaces/v0.8.x/ISharedMinterV0.sol +18 -160
- package/contracts/interfaces/v0.8.x/ISharedRandomizerV0.sol +37 -37
- package/contracts/interfaces/v0.8.x/ISplitAtomicFactoryV0.sol +81 -0
- package/contracts/interfaces/v0.8.x/ISplitAtomicV0.sol +72 -0
- package/contracts/interfaces/v0.8.x/ISplitProviderV0.sol +49 -0
- package/contracts/interfaces/v0.8.x/integration-refs/splits-0x-v2/ISplitFactoryV2.sol +62 -0
- package/contracts/libs/v0.8.x/ABHelpers.sol +31 -17
- package/contracts/libs/v0.8.x/AuthLib.sol +101 -102
- package/contracts/libs/v0.8.x/BitMap.sol +112 -0
- package/contracts/libs/v0.8.x/BytecodeStorageV2.sol +593 -0
- package/contracts/libs/v0.8.x/Bytes32Strings.sol +5 -5
- package/contracts/libs/v0.8.x/DependencyRegistryStorageLib.sol +90 -0
- package/contracts/libs/v0.8.x/ERC721_PackedHashSeedV1.sol +591 -0
- package/contracts/libs/v0.8.x/PackedBools.sol +42 -0
- package/contracts/libs/v0.8.x/V3FlexLib.sol +591 -0
- package/contracts/libs/v0.8.x/minter-libs/DAExpLib.sol +162 -39
- package/contracts/libs/v0.8.x/minter-libs/DALib.sol +26 -0
- package/contracts/libs/v0.8.x/minter-libs/DALinLib.sol +139 -37
- package/contracts/libs/v0.8.x/minter-libs/GenericMinterEventsLib.sol +171 -0
- package/contracts/libs/v0.8.x/minter-libs/MaxInvocationsLib.sol +299 -158
- package/contracts/libs/v0.8.x/minter-libs/MerkleLib.sol +268 -55
- package/contracts/libs/v0.8.x/minter-libs/PolyptychLib.sol +138 -58
- package/contracts/libs/v0.8.x/minter-libs/RAMLib.sol +2927 -0
- package/contracts/libs/v0.8.x/minter-libs/SEALib.sol +796 -123
- package/contracts/libs/v0.8.x/minter-libs/SetPriceLib.sol +131 -13
- package/contracts/libs/v0.8.x/minter-libs/SettlementExpLib.sol +607 -224
- package/contracts/libs/v0.8.x/minter-libs/SplitFundsLib.sol +494 -330
- package/contracts/libs/v0.8.x/minter-libs/TokenHolderLib.sol +217 -78
- package/contracts/minter-suite/MinterFilter/MinterFilterV2.sol +358 -309
- package/contracts/minter-suite/Minters/MinterDAExpHolderV5.sol +391 -491
- package/contracts/minter-suite/Minters/MinterDAExpSettlementV3.sol +396 -632
- package/contracts/minter-suite/Minters/MinterDAExpV5.sol +212 -273
- package/contracts/minter-suite/Minters/MinterDALinHolderV5.sol +393 -488
- package/contracts/minter-suite/Minters/MinterDALinV5.sol +220 -277
- package/contracts/minter-suite/Minters/MinterRAMV0.sol +1205 -0
- package/contracts/minter-suite/Minters/MinterSEAV1.sol +329 -677
- package/contracts/minter-suite/Minters/MinterSetPriceERC20V5.sol +287 -303
- package/contracts/minter-suite/Minters/MinterSetPriceHolderV5.sol +355 -446
- package/contracts/minter-suite/Minters/MinterSetPriceMerkleV5.sol +328 -416
- package/contracts/minter-suite/Minters/MinterSetPricePolyptychERC20V5.sol +552 -622
- package/contracts/minter-suite/Minters/MinterSetPricePolyptychV5.sol +429 -553
- package/contracts/minter-suite/Minters/MinterSetPriceV5.sol +180 -227
- package/contracts/minter-suite/Minters/one-off/MinterSetPriceV5_SingleCore.sol +446 -0
- package/contracts/mock/BytecodeV2LibCallsMock.sol +128 -0
- package/contracts/mock/BytecodeV2TextCR_DMock.sol +316 -0
- package/contracts/mock/ForceSendMock.sol +22 -0
- package/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol +3 -10
- package/contracts/mock/Mock0xSplitsV2PullFactory.sol +75 -0
- package/contracts/mock/Mock0xSplitsV2Splitter.sol +47 -0
- package/contracts/mock/MockAdminACLV0.sol +21 -0
- package/contracts/mock/MockAdminACLV0_PROHIBITION.sol +21 -0
- package/contracts/mock/ReentrancyGenArt721MinterMock.sol +47 -0
- package/contracts/mock/ReentrancyHolderMockShared.sol +59 -0
- package/contracts/mock/ReentrancyMerkleMockShared.sol +58 -0
- package/contracts/mock/ReentrancyMockShared.sol +48 -0
- package/contracts/mock/ReentrancySEAMockShared.sol +40 -0
- package/contracts/mock/ReentrancySplitterMocks.sol +67 -0
- package/contracts/randomizer/primitive/PseudorandomAtomicBasic.sol +1 -1
- package/contracts/randomizer/shared/SharedRandomizerV0.sol +79 -71
- package/contracts/split/SplitAtomicFactoryV0.sol +121 -0
- package/contracts/split/SplitAtomicV0.sol +265 -0
- package/contracts/split/split-provider/SplitProviderV0.sol +201 -0
- package/package.json +79 -45
- package/artifacts/contracts/GenArt721CoreV3.sol/GenArt721CoreV3.json +0 -1965
- package/artifacts/contracts/explorations/GenArt721CoreV3_Explorations.sol/GenArt721CoreV3_Explorations.json +0 -1939
- package/artifacts/contracts/minter-suite/Minters/MinterDAExpSettlementV2.sol/MinterDAExpSettlementV2.json +0 -1127
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20V4.sol/MinterSetPriceERC20V4.json +0 -768
- package/artifacts/contracts/royalty-registry/GenArt721RoyaltyOverride.sol/GenArt721RoyaltyOverride.json +0 -208
- package/artifacts/contracts/royalty-registry/GenArt721RoyaltyOverride_PBAB.sol/GenArt721RoyaltyOverride_PBAB.json +0 -301
- package/contracts/royalty-registry/GenArt721RoyaltyOverride.sol +0 -168
- 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
|
+
}
|
|
@@ -9,13 +9,13 @@ pragma solidity ^0.8.0;
|
|
|
9
9
|
*/
|
|
10
10
|
library Bytes32Strings {
|
|
11
11
|
/**
|
|
12
|
-
* @
|
|
12
|
+
* @notice Intended to convert a `bytes32`-encoded string literal to `string`.
|
|
13
13
|
* Trims zero padding to arrive at original string literal.
|
|
14
14
|
*/
|
|
15
15
|
function toString(
|
|
16
16
|
bytes32 source
|
|
17
17
|
) internal pure returns (string memory result) {
|
|
18
|
-
uint8 length
|
|
18
|
+
uint8 length;
|
|
19
19
|
while (source[length] != 0 && length < 32) {
|
|
20
20
|
length++;
|
|
21
21
|
}
|
|
@@ -33,7 +33,7 @@ library Bytes32Strings {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* @
|
|
36
|
+
* @notice Intended to check if a `bytes32`-encoded string contains a given
|
|
37
37
|
* character with UTF-8 character code `utf8CharCode exactly `targetQty`
|
|
38
38
|
* times. Does not support searching for multi-byte characters, only
|
|
39
39
|
* characters with UTF-8 character codes < 0x80.
|
|
@@ -43,9 +43,9 @@ library Bytes32Strings {
|
|
|
43
43
|
uint8 utf8CharCode,
|
|
44
44
|
uint8 targetQty
|
|
45
45
|
) internal pure returns (bool) {
|
|
46
|
-
uint8 _occurrences
|
|
46
|
+
uint8 _occurrences;
|
|
47
47
|
uint8 i;
|
|
48
|
-
for (i
|
|
48
|
+
for (i; i < 32; ) {
|
|
49
49
|
uint8 _charCode = uint8(source[i]);
|
|
50
50
|
// if not a null byte, or a multi-byte UTF-8 character, check match
|
|
51
51
|
if (_charCode != 0 && _charCode < 0x80) {
|