@artblocks/contracts 1.3.2 → 1.4.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 +11 -10
- package/artifacts/contracts/AdminACLV0RoyaltyRegistry.sol/AdminACLV0RoyaltyRegistry.json +193 -0
- package/artifacts/contracts/AdminACLV0RoyaltyRegistry.sol/IRoyaltyRegistry.json +35 -0
- package/artifacts/contracts/AdminACLV1.sol/AdminACLV1.json +2 -2
- package/artifacts/contracts/BytecodeStorageReaders/BytecodeStorageReaderContractV2.sol/BytecodeStorageReaderContractV2.json +2 -2
- package/artifacts/contracts/BytecodeStorageReaders/BytecodeStorageReaderContractV2_Web3Call.sol/BytecodeStorageReaderContractV2_Web3Call.json +2 -2
- package/artifacts/contracts/BytecodeStorageV2Writer.sol/BytecodeStorageV2Writer.json +2 -2
- package/artifacts/contracts/DependencyRegistryV0.sol/DependencyRegistryV0.json +210 -2
- package/artifacts/contracts/GenArt721CoreV3_Curated.sol/GenArt721CoreV3_Curated.json +235 -20
- package/artifacts/contracts/GenArt721CoreV3_Curated_Flex.sol/GenArt721CoreV3_Curated_Flex.json +3197 -0
- package/artifacts/contracts/GenArt721CoreV3_Explorations_Flex.sol/GenArt721CoreV3_Explorations_Flex.json +3192 -0
- package/artifacts/contracts/OwnedCreate2FactoryV0.sol/OwnedCreate2FactoryV0.json +2 -2
- package/artifacts/contracts/archive/GenArt721CoreV3.sol/GenArt721CoreV3.json +27 -2
- package/artifacts/contracts/archive/GenArt721CoreV3_Explorations.sol/GenArt721CoreV3_Explorations.json +27 -2
- 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/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV4.sol/MinterDAExpV4.json +2 -2
- 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 +2 -2
- 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/archive/minter-suite/Minters/MinterDALin/MinterDALinV4.sol/MinterDALinV4.json +2 -2
- 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/archive/minter-suite/Minters/MinterHolder/MinterHolderV4.sol/MinterHolderV4.json +2 -2
- 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/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV5.sol/MinterMerkleV5.json +2 -2
- package/artifacts/contracts/archive/minter-suite/Minters/MinterPolyptych/MinterPolyptychV0.sol/IGenArt721CoreContractV3WithRandomizer.json +25 -0
- package/artifacts/contracts/archive/minter-suite/Minters/MinterPolyptych/MinterPolyptychV0.sol/MinterPolyptychV0.json +2 -2
- package/artifacts/contracts/archive/minter-suite/Minters/MinterSEA/MinterSEAV0.sol/MinterSEAV0.json +2 -2
- 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/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV4.sol/MinterSetPriceV4.json +2 -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 +2 -2
- package/artifacts/contracts/engine/V3/EngineFactoryV0.sol/EngineFactoryV0.json +28 -2
- package/artifacts/contracts/engine/V3/GenArt721CoreV3_Engine.sol/GenArt721CoreV3_Engine.json +239 -20
- package/artifacts/contracts/engine/V3/GenArt721CoreV3_Engine_Flex.sol/GenArt721CoreV3_Engine_Flex.json +267 -48
- package/artifacts/contracts/engine/V3/forks/GenArt721CoreV3_Engine_Flex_PROOF.sol/GenArt721CoreV3_Engine_Flex_PROOF.json +27 -2
- 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 +27 -2
- package/artifacts/contracts/engine/V3/forks/PROHIBITION/interfaces/IGenArt721CoreContractV3_Engine_Flex_PROHIBITION.sol/IGenArt721CoreContractV3_Engine_Flex_PROHIBITION.json +25 -0
- package/artifacts/contracts/engine/V3/transfer-hooks/AbstractTransferHook.sol/AbstractTransferHook.json +79 -0
- package/artifacts/contracts/engine/V3/transfer-hooks/OwnerHistoryTransferHook.sol/OwnerHistoryTransferHook.json +315 -0
- package/artifacts/contracts/generator/GenArt721GeneratorV0.sol/GenArt721GeneratorV0.json +2 -2
- package/artifacts/contracts/interfaces/v0.8.x/IClaimMinter.sol/IClaimMinter.json +189 -0
- package/artifacts/contracts/interfaces/v0.8.x/IDependencyRegistryV0.sol/IDependencyRegistryV0.json +149 -0
- package/artifacts/contracts/interfaces/v0.8.x/IEngineFactoryV0.sol/IEngineFactoryV0.json +26 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3.sol/IGenArt721CoreContractV3.json +25 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Base.sol/IGenArt721CoreContractV3_Base.json +25 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine.sol/IGenArt721CoreContractV3_Engine.json +123 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_Flex.sol/IGenArt721CoreContractV3_Engine_Flex.json +123 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_Flex_PreV3p2.sol/IGenArt721CoreContractV3_Engine_Flex_PreV3p2.json +25 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_PreV3p2.sol/IGenArt721CoreContractV3_Engine_PreV3p2.json +25 -0
- package/artifacts/contracts/interfaces/v0.8.x/IOwnerHistoryTransferHook.sol/IOwnerHistoryTransferHook.json +299 -0
- package/artifacts/contracts/interfaces/v0.8.x/ISRHooks.sol/ISRHooks.json +432 -0
- package/artifacts/contracts/interfaces/v0.8.x/ISeaDropShimForContract.sol/ISeaDropShimForContract.json +0 -13
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterTieredAllowV0.sol/ISharedMinterTieredAllowV0.json +94 -0
- package/artifacts/contracts/interfaces/v0.8.x/ITransferHook.sol/ITransferHook.json +63 -0
- package/artifacts/contracts/libs/v0.8.x/AuthLib.sol/AuthLib.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/BytecodeStorageV2.sol/BytecodeStorageReader.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/BytecodeStorageV2.sol/BytecodeStorageWriter.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/DependencyRegistryStorageLib.sol/DependencyRegistryStorageLib.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/ENSLib.sol/ENSLib.json +10 -0
- package/artifacts/contracts/libs/v0.8.x/ENSLib.sol/IUniversalResolver.json +45 -0
- package/artifacts/contracts/libs/v0.8.x/EnumerableSetUint16.sol/EnumerableSetUint16.json +10 -0
- package/artifacts/contracts/libs/v0.8.x/FeistelWalkLib.sol/FeistelWalkLib.json +10 -0
- package/artifacts/contracts/libs/v0.8.x/ImmutableUint16Array.sol/ImmutableUint16Array.json +10 -0
- package/artifacts/contracts/libs/v0.8.x/V3EngineLib.sol/V3EngineLib.json +163 -0
- package/artifacts/contracts/libs/v0.8.x/V3FlexLib.sol/V3FlexLib.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/V3TransferHookLib.sol/V3TransferHookLib.json +79 -0
- package/artifacts/contracts/libs/v0.8.x/minter-libs/MaxInvocationsLib.sol/MaxInvocationsLib.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/minter-libs/OnChainAllowlistLib.sol/OnChainAllowlistLib.json +10 -0
- 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 +2 -2
- package/artifacts/contracts/libs/v0.8.x/minter-libs/SEALib.sol/SEALib.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/minter-libs/SettlementExpLib.sol/SettlementExpLib.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/minter-libs/SplitFundsLib.sol/SplitFundsLib.json +2 -2
- package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV1.sol/MinterFilterV1.json +2 -2
- package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV2.sol/MinterFilterV2.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterDAExpHolderV5.sol/MinterDAExpHolderV5.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterDAExpSettlementV3.sol/MinterDAExpSettlementV3.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterDAExpV5.sol/MinterDAExpV5.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterDALinHolderV5.sol/MinterDALinHolderV5.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterDALinV5.sol/MinterDALinV5.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterMinPriceMerkleV0.sol/MinterMinPriceMerkleV0.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterMinPriceV0.sol/MinterMinPriceV0.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterRAMV0.sol/MinterRAMV0.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterSEAV1.sol/MinterSEAV1.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20V5.sol/MinterSetPriceERC20V5.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceHolderV5.sol/MinterSetPriceHolderV5.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceMerkleV5.sol/MinterSetPriceMerkleV5.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceOnChainAllowV0.sol/MinterSetPriceOnChainAllowV0.json +522 -0
- package/artifacts/contracts/minter-suite/Minters/MinterSetPricePolyptychERC20V5.sol/MinterSetPricePolyptychERC20V5.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterSetPricePolyptychV5.sol/MinterSetPricePolyptychV5.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceTieredAllowV1.sol/MinterSetPriceTieredAllowV1.json +715 -0
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceV5.sol/MinterSetPriceV5.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterSlidingScaleV0.sol/MinterSlidingScaleV0.json +431 -0
- package/artifacts/contracts/minter-suite/Minters/one-off/ClaimMinter.sol/ClaimMinter.json +502 -0
- package/artifacts/contracts/minter-suite/Minters/one-off/MinterSetPriceTieredOnChainAllowV0.sol/MinterSetPriceTieredOnChainAllowV0.json +673 -0
- package/artifacts/contracts/minter-suite/Minters/one-off/MinterSetPriceV5_SingleCore.sol/MinterSetPriceV5_SingleCore.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/one-off/SeaDropXArtBlocksShim.sol/SeaDropXArtBlocksShim.json +6 -19
- package/artifacts/contracts/mock/BytecodeV2TextCR_DMock.sol/BytecodeV2TextCR_DMock.json +2 -2
- package/artifacts/contracts/mock/DummySharedMinter.sol/DummySharedMinter.json +2 -2
- package/artifacts/contracts/mock/ENSLibMock.sol/ENSLibMock.json +30 -0
- package/artifacts/contracts/mock/EnumerableSetUint16Mock.sol/EnumerableSetUint16Mock.json +146 -0
- package/artifacts/contracts/mock/FeistelWalkLibMock.sol/FeistelWalkLibMock.json +142 -0
- package/artifacts/contracts/mock/ForceSendMock.sol/ForceSendMock.json +2 -2
- package/artifacts/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol/GenArt721CoreV3_Engine_IncorrectCoreType.json +2 -2
- package/artifacts/contracts/mock/ImmutableUint16ArrayMock.sol/ImmutableUint16ArrayMock.json +89 -0
- package/artifacts/contracts/mock/MockAdminACLV0_PROHIBITION.sol/MockAdminACLV0Events_PROHIBITION.json +2 -2
- package/artifacts/contracts/mock/MockGenArt721V3Core.sol/MockGenArt721V3Core.json +490 -0
- package/artifacts/contracts/mock/MockPMP.sol/MockPMP.json +523 -0
- package/artifacts/contracts/mock/MockTransferHook.sol/MockTransferHook.json +453 -0
- package/artifacts/contracts/mock/MockTransferHookTestHelpers.sol/MockBatchTransferrer.json +39 -0
- package/artifacts/contracts/mock/MockTransferHookTestHelpers.sol/MockForwardingERC721Receiver.json +71 -0
- package/artifacts/contracts/mock/MockTransferHookTestHelpers.sol/MockSpoofingCore.json +94 -0
- package/artifacts/contracts/mock/RandomizerV2_NoAssignMock.sol/RandomizerV2_NoAssignMock.json +2 -2
- package/artifacts/contracts/mock/ReentrancyBatchMockShared.sol/IBatchMinter.json +64 -0
- package/artifacts/contracts/mock/ReentrancyBatchMockShared.sol/ReentrancyBatchMockShared.json +113 -0
- package/artifacts/contracts/mock/RelayExecutorTestHelper.sol/MockTarget.json +74 -0
- package/artifacts/contracts/mock/RelayExecutorTestHelper.sol/RelayExecutorPartialRevertsTestHelper.json +138 -0
- package/artifacts/contracts/mock/RelayExecutorTestHelper.sol/RelayExecutorTestHelper.json +119 -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/shared/SharedRandomizerV0.sol/SharedRandomizerV0.json +2 -2
- package/artifacts/contracts/relay/RelayExecutor.sol/RelayExecutor.json +101 -0
- package/artifacts/contracts/relay/RelayExecutorPartialReverts.sol/RelayExecutorPartialReverts.json +120 -0
- package/artifacts/contracts/royalty-registry/GenArt721RoyaltyOverrideSplits.sol/GenArt721RoyaltyOverrideSplits.json +263 -0
- package/artifacts/contracts/utils/MintMulticallUtil.sol/IMinterSetPriceV5.json +40 -0
- package/artifacts/contracts/utils/MintMulticallUtil.sol/MintMulticallUtil.json +163 -0
- package/artifacts/contracts/web3call/PMPV0.sol/PMPV0.json +2 -2
- package/artifacts/contracts/web3call/PMPV1.sol/PMPV1.json +648 -0
- package/artifacts/contracts/web3call/augment-hooks/InjectBaseGasFee.sol/InjectBaseGasFee.json +2 -2
- package/artifacts/contracts/web3call/augment-hooks/InjectBlockHeight.sol/InjectBlockHeight.json +83 -0
- package/artifacts/contracts/web3call/augment-hooks/InjectBlockHeightAndArtistProjectOverrides.sol/InjectBlockHeightAndArtistProjectOverrides.json +226 -0
- package/artifacts/contracts/web3call/augment-hooks/InjectBlockHeightAndNumOwnedProjectTokens.sol/InjectBlockHeightAndNumOwnedProjectTokens.json +182 -0
- package/artifacts/contracts/web3call/augment-hooks/InjectBlockHeightProjectInvocationsAndArtistProjectOverrides.sol/InjectBlockHeightProjectInvocationsAndArtistProjectOverrides.json +226 -0
- package/artifacts/contracts/web3call/augment-hooks/InjectBlockTimestamp.sol/InjectBlockTimestamp.json +83 -0
- package/artifacts/contracts/web3call/augment-hooks/InjectBytesPerToken.sol/InjectBytesPerToken.json +358 -0
- package/artifacts/contracts/web3call/augment-hooks/InjectChromieSquiggleFloorPrice.sol/InjectChromieSquiggleFloorPrice.json +2 -2
- package/artifacts/contracts/web3call/augment-hooks/InjectIsNounsDaoMember.sol/InjectIsNounsDaoMember.json +2 -2
- package/artifacts/contracts/web3call/augment-hooks/InjectIsProjectFullyMinted.sol/InjectIsProjectFullyMinted.json +2 -2
- package/artifacts/contracts/web3call/augment-hooks/InjectPolyptychTokenHash.sol/InjectPolyptychTokenHash.json +2 -2
- package/artifacts/contracts/web3call/augment-hooks/InjectTokenHashSeed.sol/InjectTokenHashSeed.json +2 -2
- package/artifacts/contracts/web3call/augment-hooks/InjectTokenOwner.sol/InjectTokenOwner.json +2 -2
- package/artifacts/contracts/web3call/augment-hooks/InjectTokenOwnerEthBalance.sol/InjectTokenOwnerEthBalance.json +2 -2
- package/artifacts/contracts/web3call/augment-hooks/InjectUSDCTotalSupply.sol/InjectUSDCTotalSupply.json +2 -2
- package/artifacts/contracts/web3call/augment-hooks/SRHooks.sol/SRHooks.json +899 -0
- package/artifacts/contracts/web3call/combined-hooks/LiftHooks.sol/IGenArt721V0_Minimal.json +30 -0
- package/artifacts/contracts/web3call/combined-hooks/LiftHooks.sol/IRelic.json +35 -0
- package/artifacts/contracts/web3call/combined-hooks/LiftHooks.sol/LiftHooks.json +256 -0
- package/artifacts/contracts/web3call/configure-hooks/{abstractPMPConfigureHook.sol → AbstractPMPConfigureHook.sol}/AbstractPMPConfigureHook.json +1 -1
- package/artifacts/contracts/web3call/configure-hooks/PMPConfigureLockHook.sol/PMPConfigureLockHook.json +195 -0
- package/contracts/AdminACLV0RoyaltyRegistry.sol +142 -0
- package/contracts/DependencyRegistryV0.sol +143 -13
- package/contracts/GenArt721CoreV3_Curated.sol +1 -1
- package/contracts/GenArt721CoreV3_Curated_Flex.sol +173 -0
- package/contracts/GenArt721CoreV3_Explorations_Flex.sol +159 -0
- package/contracts/engine/V3/EngineFactoryV0.sol +20 -1
- package/contracts/engine/V3/GenArt721CoreV3_Engine.sol +286 -299
- package/contracts/engine/V3/GenArt721CoreV3_Engine_Flex.sol +292 -301
- package/contracts/engine/V3/transfer-hooks/AbstractTransferHook.sol +101 -0
- package/contracts/engine/V3/transfer-hooks/OwnerHistoryTransferHook.sol +291 -0
- package/contracts/generator/GenArt721GeneratorV0.sol +145 -47
- package/contracts/helpers/ERC1967ProxyImport.sol +5 -0
- package/contracts/interfaces/v0.8.x/IArtblocksRoyaltyOverride.sol +1 -1
- package/contracts/interfaces/v0.8.x/IClaimMinter.sol +70 -0
- package/contracts/interfaces/v0.8.x/IDependencyRegistryV0.sol +95 -0
- package/contracts/interfaces/v0.8.x/IEngineFactoryV0.sol +15 -0
- package/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Base.sol +21 -2
- package/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine.sol +72 -0
- package/contracts/interfaces/v0.8.x/IOwnerHistoryTransferHook.sol +119 -0
- package/contracts/interfaces/v0.8.x/ISRHooks.sol +229 -0
- package/contracts/interfaces/v0.8.x/ISeaDropShimForContract.sol +0 -6
- package/contracts/interfaces/v0.8.x/ISharedMinterTieredAllowV0.sol +69 -0
- package/contracts/interfaces/v0.8.x/ITransferHook.sol +48 -0
- package/contracts/libs/v0.8.x/DependencyRegistryStorageLib.sol +12 -0
- package/contracts/libs/v0.8.x/ENSLib.sol +85 -0
- package/contracts/libs/v0.8.x/EnumerableSetUint16.sol +429 -0
- package/contracts/libs/v0.8.x/FeistelWalkLib.sol +221 -0
- package/contracts/libs/v0.8.x/ImmutableUint16Array.sol +201 -0
- package/contracts/libs/v0.8.x/V3EngineLib.sol +490 -0
- package/contracts/libs/v0.8.x/V3TransferHookLib.sol +251 -0
- package/contracts/libs/v0.8.x/minter-libs/OnChainAllowlistLib.sol +165 -0
- package/contracts/minter-suite/Minters/MinterSetPriceOnChainAllowV0.sol +632 -0
- package/contracts/minter-suite/Minters/MinterSetPriceTieredAllowV1.sol +871 -0
- package/contracts/minter-suite/Minters/MinterSlidingScaleV0.sol +493 -0
- package/contracts/minter-suite/Minters/one-off/ClaimMinter.sol +595 -0
- package/contracts/minter-suite/Minters/one-off/MinterSetPriceTieredOnChainAllowV0.sol +894 -0
- package/contracts/minter-suite/Minters/one-off/SeaDropXArtBlocksShim.sol +59 -41
- package/contracts/mock/ENSLibMock.sol +25 -0
- package/contracts/mock/EnumerableSetUint16Mock.sol +88 -0
- package/contracts/mock/FeistelWalkLibMock.sol +81 -0
- package/contracts/mock/ImmutableUint16ArrayMock.sol +62 -0
- package/contracts/mock/MockGenArt721V3Core.sol +416 -0
- package/contracts/mock/MockPMP.sol +287 -0
- package/contracts/mock/MockTransferHook.sol +160 -0
- package/contracts/mock/MockTransferHookTestHelpers.sol +96 -0
- package/contracts/mock/ReentrancyBatchMockShared.sol +53 -0
- package/contracts/mock/RelayExecutorTestHelper.sol +44 -0
- package/contracts/relay/RelayExecutor.sol +61 -0
- package/contracts/relay/RelayExecutorPartialReverts.sol +79 -0
- package/contracts/royalty-registry/GenArt721RoyaltyOverrideSplits.sol +130 -0
- package/contracts/utils/MintMulticallUtil.sol +103 -0
- package/contracts/web3call/PMPV1.sol +1204 -0
- package/contracts/web3call/augment-hooks/AbstractPMPAugmentHook.sol +1 -1
- package/contracts/web3call/augment-hooks/InjectBaseGasFee.sol +1 -1
- package/contracts/web3call/augment-hooks/InjectBlockHeight.sol +57 -0
- package/contracts/web3call/augment-hooks/InjectBlockHeightAndArtistProjectOverrides.sol +310 -0
- package/contracts/web3call/augment-hooks/InjectBlockHeightAndNumOwnedProjectTokens.sol +141 -0
- package/contracts/web3call/augment-hooks/InjectBlockHeightProjectInvocationsAndArtistProjectOverrides.sol +326 -0
- package/contracts/web3call/augment-hooks/InjectBlockTimestamp.sol +57 -0
- package/contracts/web3call/augment-hooks/InjectBytesPerToken.sol +279 -0
- package/contracts/web3call/augment-hooks/InjectIsProjectFullyMinted.sol +1 -1
- package/contracts/web3call/augment-hooks/InjectTokenHashSeed.sol +1 -1
- package/contracts/web3call/augment-hooks/InjectTokenOwner.sol +1 -1
- package/contracts/web3call/augment-hooks/InjectTokenOwnerEthBalance.sol +1 -1
- package/contracts/web3call/augment-hooks/SRHooks.sol +1722 -0
- package/contracts/web3call/combined-hooks/LiftHooks.sol +304 -0
- package/contracts/web3call/configure-hooks/{abstractPMPConfigureHook.sol → AbstractPMPConfigureHook.sol} +1 -1
- package/contracts/web3call/configure-hooks/PMPConfigureLockHook.sol +107 -0
- package/package.json +39 -24
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.20;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @title FeistelWalkLib
|
|
6
|
+
* @author Art Blocks Inc.
|
|
7
|
+
* @notice Uniform once-over traversal of [0..N) via a seeded Feistel permutation.
|
|
8
|
+
* @dev Designed for off-chain eth_call sampling (e.g., pick K=100 from N≈10k).
|
|
9
|
+
* - No duplicates, full coverage if you iterate k=0..N-1
|
|
10
|
+
* - O(1) per index; O(K) to sample K items
|
|
11
|
+
* - Works for any N (uses cycle-walking from next power-of-two domain)
|
|
12
|
+
* - Not cryptographic; optimized for gas efficiency with good mixing
|
|
13
|
+
* Uses 2 Feistel rounds with 64-bit round keys (k0, k1) derived from the seed.
|
|
14
|
+
* Additional keys (k2, k3) reserved for potential future use.
|
|
15
|
+
*
|
|
16
|
+
* The Feistel domain is exactly 2^logM = M (the next power of two >= N) for both
|
|
17
|
+
* even and odd logM, achieved with an UNBALANCED split in `_feistelOnPow2Domain`
|
|
18
|
+
* (`a = logM/2`, `b = logM - a`, `a + b = logM`). This keeps M <= 2N, so the
|
|
19
|
+
* cycle-walk in-range probability is >= ~0.5 and a full traversal (k = 0..N-1) is
|
|
20
|
+
* a true permutation of [0..N) with no duplicates or drops.
|
|
21
|
+
*/
|
|
22
|
+
library FeistelWalkLib {
|
|
23
|
+
uint256 private constant MAX_CYCLE_WALKS = 32;
|
|
24
|
+
// -------------------------------------------------------------------------
|
|
25
|
+
// Public API
|
|
26
|
+
// -------------------------------------------------------------------------
|
|
27
|
+
|
|
28
|
+
/// @notice Immutable traversal plan (deterministic from (seed, N)).
|
|
29
|
+
/// @dev Build once per call, then stream with `index(plan, k)` or batch via `sample(plan, K)`.
|
|
30
|
+
struct Plan {
|
|
31
|
+
uint256 N; // pool size (>= 1)
|
|
32
|
+
uint256 M; // next power-of-two >= N (<= 2N)
|
|
33
|
+
uint256 logM; // log2(M) - precomputed to avoid repeated calculation
|
|
34
|
+
uint256 rounds; // Feistel rounds (2 for gas-efficient mixing)
|
|
35
|
+
uint64 k0; // Round key 0
|
|
36
|
+
uint64 k1; // Round key 1
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/// @notice Build a Feistel permutation plan over [0..N).
|
|
40
|
+
/// @param seed Arbitrary seed (domain-separate upstream if you like).
|
|
41
|
+
/// @param N Domain size; must be > 0.
|
|
42
|
+
function makePlan(
|
|
43
|
+
bytes32 seed,
|
|
44
|
+
uint256 N
|
|
45
|
+
) internal pure returns (Plan memory p) {
|
|
46
|
+
require(N > 0, "FeistelWalkLib:N=0");
|
|
47
|
+
p.N = N;
|
|
48
|
+
p.M = _nextPow2(N); // <= 2N
|
|
49
|
+
p.logM = _log2ceil(p.M); // precompute to avoid repeated calculation
|
|
50
|
+
p.rounds = 2; // 2 rounds provides good mixing with lower gas cost
|
|
51
|
+
|
|
52
|
+
// Derive round keys for 2-round Feistel
|
|
53
|
+
p.k0 = uint64(
|
|
54
|
+
uint256(keccak256(abi.encodePacked(seed, "feistel.k0", N)))
|
|
55
|
+
);
|
|
56
|
+
p.k1 = uint64(
|
|
57
|
+
uint256(keccak256(abi.encodePacked(seed, "feistel.k1", N)))
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/// @notice Stream the k-th index in the seeded permutation.
|
|
62
|
+
/// @dev Requires 0 <= k < N. O(1) arithmetic; bounded cycle-walk if N not power of two.
|
|
63
|
+
function index(
|
|
64
|
+
Plan memory p,
|
|
65
|
+
uint256 k
|
|
66
|
+
) internal pure returns (uint256 idx) {
|
|
67
|
+
require(k < p.N, "FeistelWalkLib:k>=N");
|
|
68
|
+
if (p.N == 1) return 0; // trivial domain
|
|
69
|
+
|
|
70
|
+
// Permute k into [0..N) using Feistel over [0..M) + cycle-walking
|
|
71
|
+
return _feistelPermuteRange(k, p.N, p.M, p.logM, p.rounds, p.k0, p.k1);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/// @notice Return up to K indices from the permutation (k = 0..K-1).
|
|
75
|
+
/// @dev If K > N, it clamps to N. Allocates an array of size K'.
|
|
76
|
+
function sample(
|
|
77
|
+
Plan memory p,
|
|
78
|
+
uint256 K
|
|
79
|
+
) internal pure returns (uint256[] memory out) {
|
|
80
|
+
if (K > p.N) K = p.N;
|
|
81
|
+
out = new uint256[](K);
|
|
82
|
+
unchecked {
|
|
83
|
+
for (uint256 i = 0; i < K; ++i) {
|
|
84
|
+
out[i] = index(p, i);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// -------------------------------------------------------------------------
|
|
90
|
+
// Internal: Feistel on arbitrary N via power-of-two domain + cycle-walk
|
|
91
|
+
// -------------------------------------------------------------------------
|
|
92
|
+
|
|
93
|
+
/// @dev Permute x∈[0..N) by embedding into [0..M) (M power of two), running Feistel,
|
|
94
|
+
/// then cycle-walking until result < N. With M < 2N, p = N/M ≥ ~0.5 in worst case.
|
|
95
|
+
/// Hard-cap at MAX_CYCLE_WALKS to guarantee bounded work; on overflow, return `x`.
|
|
96
|
+
function _feistelPermuteRange(
|
|
97
|
+
uint256 x,
|
|
98
|
+
uint256 N,
|
|
99
|
+
uint256 M,
|
|
100
|
+
uint256 logM,
|
|
101
|
+
uint256 rounds,
|
|
102
|
+
uint64 k0,
|
|
103
|
+
uint64 k1
|
|
104
|
+
) private pure returns (uint256) {
|
|
105
|
+
if (N == 1) return 0; // trivial domain
|
|
106
|
+
uint256 y = x;
|
|
107
|
+
unchecked {
|
|
108
|
+
for (uint256 i = 0; i < MAX_CYCLE_WALKS; ++i) {
|
|
109
|
+
uint256 z = _feistelOnPow2Domain(y, M, logM, rounds, k0, k1);
|
|
110
|
+
if (z < N) return z; // landed inside domain
|
|
111
|
+
y = z; // cycle-walk and try again
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Ultra-rare guard: deterministic in-domain fallback (keeps progress).
|
|
115
|
+
return x;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/// @dev Feistel permutation over [0..M) where M is a power of two.
|
|
119
|
+
/// Split into a low half (a bits) and a high half (b bits) with
|
|
120
|
+
/// a + b = logM, and apply the round function twice for good mixing.
|
|
121
|
+
/// Using an UNBALANCED split (a = logM/2, b = logM - a) keeps the domain
|
|
122
|
+
/// exactly 2^logM = M for both even and odd logM. A balanced split
|
|
123
|
+
/// (half = (logM + 1) / 2) would span 2*half = logM + 1 bits for odd logM
|
|
124
|
+
/// and therefore permute [0, 2M) instead of [0, M); the wider domain pushes
|
|
125
|
+
/// the cycle-walk past its cap for N just above a power of two and triggers
|
|
126
|
+
/// the identity `return x` fallback, breaking the bijection (duplicate /
|
|
127
|
+
/// missing elements). Each round masks its output to the width of the half
|
|
128
|
+
/// it writes, so every round is invertible and the whole map is a bijection
|
|
129
|
+
/// over [0, M). For even logM, a == b and this is identical to a balanced
|
|
130
|
+
/// split.
|
|
131
|
+
function _feistelOnPow2Domain(
|
|
132
|
+
uint256 x,
|
|
133
|
+
uint256 M,
|
|
134
|
+
uint256 logM,
|
|
135
|
+
uint256 /* rounds */,
|
|
136
|
+
uint64 k0,
|
|
137
|
+
uint64 k1
|
|
138
|
+
) private pure returns (uint256) {
|
|
139
|
+
if (M == 1) return 0; // degenerate
|
|
140
|
+
if (M == 2) {
|
|
141
|
+
// Special case: 2-element domain, use key to determine permutation
|
|
142
|
+
return ((k0 & 1) == 0) ? x : (1 - x);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Full assembly for maximum gas efficiency
|
|
146
|
+
uint256 result;
|
|
147
|
+
assembly {
|
|
148
|
+
// Unbalanced Feistel: low half is `a` bits, high half is `b` bits,
|
|
149
|
+
// with a + b = logM (so the domain is exactly 2^logM = M).
|
|
150
|
+
let a := div(logM, 2)
|
|
151
|
+
let b := sub(logM, a)
|
|
152
|
+
let maskA := sub(shl(a, 1), 1)
|
|
153
|
+
let maskB := sub(shl(b, 1), 1)
|
|
154
|
+
|
|
155
|
+
// Split into L (low, a bits) and R (high, b bits)
|
|
156
|
+
let L := and(x, maskA)
|
|
157
|
+
let R := and(shr(a, x), maskB)
|
|
158
|
+
|
|
159
|
+
// Round 0: R (b bits) -> a-bit register
|
|
160
|
+
let F := and(R, 0xFFFFFFFFFFFFFFFF)
|
|
161
|
+
F := xor(F, k0)
|
|
162
|
+
F := xor(F, shl(13, F))
|
|
163
|
+
F := xor(F, shr(7, F))
|
|
164
|
+
F := xor(F, shl(17, F))
|
|
165
|
+
F := xor(F, shr(5, F))
|
|
166
|
+
|
|
167
|
+
let newR := and(xor(L, F), maskA) // a bits
|
|
168
|
+
L := R // b bits
|
|
169
|
+
R := newR // a bits
|
|
170
|
+
|
|
171
|
+
// Round 1: R (a bits) -> b-bit register
|
|
172
|
+
F := and(R, 0xFFFFFFFFFFFFFFFF)
|
|
173
|
+
F := xor(F, xor(k1, 1))
|
|
174
|
+
F := xor(F, shl(13, F))
|
|
175
|
+
F := xor(F, shr(7, F))
|
|
176
|
+
F := xor(F, shl(17, F))
|
|
177
|
+
F := xor(F, shr(5, F))
|
|
178
|
+
|
|
179
|
+
newR := and(xor(L, F), maskB) // b bits
|
|
180
|
+
L := R // a bits
|
|
181
|
+
R := newR // b bits
|
|
182
|
+
|
|
183
|
+
// Recombine: R (b bits) high, L (a bits) low => a + b = logM bits
|
|
184
|
+
result := or(shl(a, R), L)
|
|
185
|
+
}
|
|
186
|
+
return result;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// -------------------------------------------------------------------------
|
|
190
|
+
// Internal: Bit helpers
|
|
191
|
+
// -------------------------------------------------------------------------
|
|
192
|
+
|
|
193
|
+
/// @dev Next power of two ≥ x. For x==0, returns 1.
|
|
194
|
+
function _nextPow2(uint256 x) private pure returns (uint256) {
|
|
195
|
+
if (x <= 1) return 1;
|
|
196
|
+
unchecked {
|
|
197
|
+
x -= 1;
|
|
198
|
+
x |= x >> 1;
|
|
199
|
+
x |= x >> 2;
|
|
200
|
+
x |= x >> 4;
|
|
201
|
+
x |= x >> 8;
|
|
202
|
+
x |= x >> 16;
|
|
203
|
+
x |= x >> 32;
|
|
204
|
+
x |= x >> 64;
|
|
205
|
+
x |= x >> 128;
|
|
206
|
+
return x + 1;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/// @dev ceil(log2(x)) for x≥1. (Number of bits to represent x-1.)
|
|
211
|
+
function _log2ceil(uint256 x) private pure returns (uint256 n) {
|
|
212
|
+
require(x > 0, "log2ceil(0)");
|
|
213
|
+
unchecked {
|
|
214
|
+
x -= 1;
|
|
215
|
+
while (x > 0) {
|
|
216
|
+
x >>= 1;
|
|
217
|
+
++n;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-3.0-only
|
|
2
|
+
// Created By: Art Blocks Inc.
|
|
3
|
+
|
|
4
|
+
pragma solidity ^0.8.0;
|
|
5
|
+
|
|
6
|
+
import {SSTORE2} from "./SSTORE2.sol"; // Import SSTORE2 library
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @title ImmutableUint16Array
|
|
10
|
+
* @author Art Blocks Inc.
|
|
11
|
+
* @notice This library is optimized to store immutable arrays of uint16 values much more efficiently than using native Solidity storage arrays.
|
|
12
|
+
* It uses a single SSTORE2 contract to store the length + packed uint16 values
|
|
13
|
+
* Allows overwriting the pointer to point to a new immutable array.
|
|
14
|
+
*/
|
|
15
|
+
library ImmutableUint16Array {
|
|
16
|
+
/**
|
|
17
|
+
* @notice Struct to store the SSTORE2 pointer to the packed uint16 array.
|
|
18
|
+
* @dev dataPointer is the SSTORE2 pointer to the packed uint16 array. Assigned to address(0) if the array is empty.
|
|
19
|
+
*/
|
|
20
|
+
struct Uint16Array {
|
|
21
|
+
address dataPointer; // SSTORE2 pointer storing length + packed uint16 values
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @notice Stores a packed immutable uint16 array using a single SSTORE2 contract.
|
|
26
|
+
* Allows overwriting the pointer to point to a new immutable array.
|
|
27
|
+
* @dev Optimized for the case where the array is empty by assigning the dataPointer to address(0).
|
|
28
|
+
* @param storageArray The storage reference to store the packed array.
|
|
29
|
+
* @param values The array of strings to pack.
|
|
30
|
+
*/
|
|
31
|
+
function store(
|
|
32
|
+
Uint16Array storage storageArray,
|
|
33
|
+
uint16[] memory values
|
|
34
|
+
) internal {
|
|
35
|
+
uint256 arrayLength = values.length;
|
|
36
|
+
// edge case - empty array
|
|
37
|
+
if (arrayLength == 0) {
|
|
38
|
+
storageArray.dataPointer = address(0);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
// realistically will not overflow uint16, but check for security guarantees
|
|
42
|
+
// @dev no coverage on else (difficulty of triggering)
|
|
43
|
+
require(
|
|
44
|
+
arrayLength <= type(uint16).max,
|
|
45
|
+
"Total bytes length exceeds uint16 limit"
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
// compute total bytes length
|
|
49
|
+
// @dev this is deterministic and can be pre-computed since it is a fixed size array
|
|
50
|
+
uint256 totalBytesLength = arrayLength * 2; // 2 bytes per uint16
|
|
51
|
+
|
|
52
|
+
// prepare the combined storage structure (length + packed uint16 values)
|
|
53
|
+
// @dev 8 bytes for length, totalBytesLength bytes for uint16 values
|
|
54
|
+
// over-allocate 32 bytes for memory safety
|
|
55
|
+
// note: shorten length by 32 bytes at end of function before returning
|
|
56
|
+
uint256 packedDataLength = 8 + totalBytesLength;
|
|
57
|
+
bytes memory packedData = new bytes(packedDataLength + 0x20);
|
|
58
|
+
uint256 ptr;
|
|
59
|
+
|
|
60
|
+
// store the length of the values array in the first 8 bytes of the packedData
|
|
61
|
+
assembly ("memory-safe") {
|
|
62
|
+
ptr := add(packedData, 0x20) // pointer to first byte of packedData
|
|
63
|
+
mstore(ptr, shl(192, arrayLength)) // left-align only 8 bytes in the 32-byte slot
|
|
64
|
+
ptr := add(ptr, 8) // move pointer forward by 8 bytes
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// pack the values efficiently, using assembly to compile 32 bytes at a time
|
|
68
|
+
for (uint i = 0; i < arrayLength; i += 16) {
|
|
69
|
+
// 16 indices per loop, 2 bytes per index, 32 bytes per loop
|
|
70
|
+
// build the 32 bytes of the current value, 16 uint16 values per loop, left to right
|
|
71
|
+
// handle end of array case
|
|
72
|
+
uint256 maxIndex = i + 16 < arrayLength ? i + 16 : arrayLength;
|
|
73
|
+
bytes32 chunk;
|
|
74
|
+
for (uint j = 0; j < (maxIndex - i); j++) {
|
|
75
|
+
chunk |= bytes32(uint256(values[i + j])) << (240 - (j * 16));
|
|
76
|
+
}
|
|
77
|
+
// store the 32 bytes into the result
|
|
78
|
+
assembly ("memory-safe") {
|
|
79
|
+
// safe to write past end of final array - 32 bytes of buffer at end of array
|
|
80
|
+
mstore(ptr, chunk) // store the 32 bytes into the result
|
|
81
|
+
ptr := add(ptr, 0x20) // move the result pointer forward by 32 bytes
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// remove the buffer from the packedData bytes array length
|
|
86
|
+
assembly ("memory-safe") {
|
|
87
|
+
ptr := packedData
|
|
88
|
+
mstore(ptr, packedDataLength)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// store the packed data in the SSTORE2 contract
|
|
92
|
+
storageArray.dataPointer = SSTORE2.write(packedData);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @notice Clears the storage array by setting the dataPointer to address(0).
|
|
97
|
+
* @param storageArray The storage reference to clear.
|
|
98
|
+
*/
|
|
99
|
+
function clear(Uint16Array storage storageArray) internal {
|
|
100
|
+
storageArray.dataPointer = address(0);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function isEmpty(
|
|
104
|
+
Uint16Array storage storageArray
|
|
105
|
+
) internal view returns (bool) {
|
|
106
|
+
return storageArray.dataPointer == address(0);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @notice Retrieves the total number of stored uint16 values from SSTORE2.
|
|
111
|
+
* @param storageArray The storage reference containing packed values.
|
|
112
|
+
* @return count The count of stored values.
|
|
113
|
+
*/
|
|
114
|
+
function length(
|
|
115
|
+
Uint16Array storage storageArray
|
|
116
|
+
) internal view returns (uint256 count) {
|
|
117
|
+
// edge case - unassigned dataPointer or empty array
|
|
118
|
+
if (storageArray.dataPointer == address(0)) {
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// load the packed data from the SSTORE2 contract
|
|
123
|
+
bytes memory allData = SSTORE2.read(storageArray.dataPointer);
|
|
124
|
+
// load the total length of the values array from the first 8 bytes of the SSTORE2 contract
|
|
125
|
+
assembly ("memory-safe") {
|
|
126
|
+
count := shr(192, mload(add(allData, 32))) // skip first 8 bytes (length of the actual bytes array we stored)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @notice Retrieves a single uint16 value from storage by index.
|
|
132
|
+
* @param storageArray The storage reference containing packed values.
|
|
133
|
+
* @param index The index of the value to retrieve.
|
|
134
|
+
* @return result The retrieved value.
|
|
135
|
+
*/
|
|
136
|
+
function get(
|
|
137
|
+
Uint16Array storage storageArray,
|
|
138
|
+
uint256 index
|
|
139
|
+
) internal view returns (uint16 result) {
|
|
140
|
+
// edge case - unassigned dataPointer or empty array
|
|
141
|
+
if (storageArray.dataPointer == address(0)) {
|
|
142
|
+
revert("Index out of bounds");
|
|
143
|
+
}
|
|
144
|
+
// load the packed data from the SSTORE2 contract
|
|
145
|
+
bytes memory allData = SSTORE2.read(storageArray.dataPointer);
|
|
146
|
+
// load the total length of the values array from the first 8 bytes of the SSTORE2 contract
|
|
147
|
+
uint256 arrayLength;
|
|
148
|
+
assembly ("memory-safe") {
|
|
149
|
+
arrayLength := shr(192, mload(add(allData, 32))) // skip first 8 bytes (length of the actual bytes array we stored)
|
|
150
|
+
}
|
|
151
|
+
require(index < arrayLength, "Index out of bounds");
|
|
152
|
+
|
|
153
|
+
// the location is deterministic and can be pre-computed since it is a fixed size array
|
|
154
|
+
uint256 location = 32 + 8 + (index * 2); // 32 bytes for bytes array length, 8 bytes for overall array length, 2 bytes per index
|
|
155
|
+
// load the value from the packed data
|
|
156
|
+
assembly ("memory-safe") {
|
|
157
|
+
result := shr(240, mload(add(allData, location))) // load the 2 bytes of the value from the packed data
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @notice Retrieves all stored uint16 values in a single batch call.
|
|
163
|
+
* @param storageArray The storage reference containing packed values.
|
|
164
|
+
* @return results An array of all stored values.
|
|
165
|
+
*/
|
|
166
|
+
function getAll(
|
|
167
|
+
Uint16Array storage storageArray
|
|
168
|
+
) internal view returns (uint16[] memory results) {
|
|
169
|
+
// edge case - unassigned dataPointer or empty array
|
|
170
|
+
if (storageArray.dataPointer == address(0)) {
|
|
171
|
+
return new uint16[](0);
|
|
172
|
+
}
|
|
173
|
+
// load the packed data from the SSTORE2 contract
|
|
174
|
+
bytes memory allData = SSTORE2.read(storageArray.dataPointer);
|
|
175
|
+
// load the total length of the values array from the first 8 bytes of the SSTORE2 contract
|
|
176
|
+
uint256 arrayLength;
|
|
177
|
+
assembly ("memory-safe") {
|
|
178
|
+
arrayLength := shr(192, mload(add(allData, 32))) // skip first 8 bytes (length of the actual bytes array we stored)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// for each value in the array, populate results
|
|
182
|
+
results = new uint16[](arrayLength);
|
|
183
|
+
|
|
184
|
+
// loop in assembly to access the packed data directly
|
|
185
|
+
assembly ("memory-safe") {
|
|
186
|
+
let ptr := add(allData, 40) // skip first 8 bytes + 32 bytes for bytes array length (length of the actual bytes array we stored)
|
|
187
|
+
for {
|
|
188
|
+
let i := 0
|
|
189
|
+
} lt(i, arrayLength) {
|
|
190
|
+
i := add(i, 1)
|
|
191
|
+
} {
|
|
192
|
+
// @dev in memory, uint16 values are not packed, but are abi-encoded, so we add mul i * 0x20 to get the offset of the value in the results array
|
|
193
|
+
mstore(
|
|
194
|
+
add(results, add(mul(i, 0x20), 0x20)),
|
|
195
|
+
shr(240, mload(ptr))
|
|
196
|
+
) // store the 2 bytes of the value from the packed data into the results array
|
|
197
|
+
ptr := add(ptr, 2) // move the pointer forward by 2 bytes for next iteration
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|