@artblocks/contracts 1.2.0 → 1.3.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 +22 -38
- package/artifacts/contracts/AdminACLV1.sol/AdminACLV1.json +2 -2
- package/artifacts/contracts/BytecodeStorageReaders/BytecodeStorageReaderContractV2.sol/BytecodeStorageReaderContractV2.json +201 -0
- package/artifacts/contracts/BytecodeStorageReaders/BytecodeStorageReaderContractV2_Web3Call.sol/BytecodeStorageReaderContractV2_Web3Call.json +201 -0
- package/artifacts/contracts/BytecodeStorageReaders/UniversalBytecodeStorageReader.sol/UniversalBytecodeStorageReader.json +154 -0
- package/artifacts/contracts/BytecodeStorageV2Writer.sol/BytecodeStorageV2Writer.json +87 -0
- package/artifacts/contracts/DependencyRegistryV0.sol/DependencyRegistryV0.json +174 -55
- package/artifacts/contracts/GenArt721CoreV3_Curated.sol/GenArt721CoreV3_Curated.json +2493 -0
- package/artifacts/contracts/OwnedCreate2FactoryV0.sol/OwnedCreate2FactoryV0.json +311 -0
- package/artifacts/contracts/archive/GenArt721CoreV3.sol/GenArt721CoreV3.json +15 -2
- package/artifacts/contracts/archive/GenArt721CoreV3_Explorations.sol/GenArt721CoreV3_Explorations.json +15 -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 +37 -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 +20 -2
- package/artifacts/contracts/engine/V3/GenArt721CoreV3_Engine.sol/GenArt721CoreV3_Engine.json +48 -12
- package/artifacts/contracts/engine/V3/GenArt721CoreV3_Engine_Flex.sol/GenArt721CoreV3_Engine_Flex.json +76 -40
- package/artifacts/contracts/engine/V3/forks/GenArt721CoreV3_Engine_Flex_PROOF.sol/GenArt721CoreV3_Engine_Flex_PROOF.json +15 -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 +15 -2
- package/artifacts/contracts/engine/V3/forks/PROHIBITION/interfaces/IGenArt721CoreContractV3_Engine_Flex_PROHIBITION.sol/IGenArt721CoreContractV3_Engine_Flex_PROHIBITION.json +37 -0
- package/artifacts/contracts/engine-registry/CoreRegistryV1.sol/CoreRegistryV1.json +2 -2
- package/artifacts/contracts/generator/AddressChunks.sol/AddressChunks.json +10 -0
- package/artifacts/contracts/generator/GenArt721GeneratorV0.sol/GenArt721GeneratorV0.json +333 -0
- package/artifacts/contracts/generator/GenArt721GeneratorV0.sol/ILegacyGenArt721CoreV2_PBAB_Flex.json +47 -0
- package/artifacts/contracts/interfaces/v0.8.x/IBytecodeStorageReader.sol/IBytecodeStorageReader.json +7 -7
- package/artifacts/contracts/interfaces/v0.8.x/IBytecodeStorageReaderV2.sol/IBytecodeStorageReaderV2.json +7 -7
- package/artifacts/contracts/interfaces/v0.8.x/IBytecodeStorageReader_Base.sol/IBytecodeStorageReader_Base.json +30 -0
- package/artifacts/contracts/interfaces/v0.8.x/ICoreRegistryV1.sol/ICoreRegistryV1.json +13 -0
- package/artifacts/contracts/interfaces/v0.8.x/IDelegateRegistry.sol/IDelegateRegistry.json +820 -0
- package/artifacts/contracts/interfaces/v0.8.x/IDependencyRegistryV0.sol/IDependencyRegistryV0.json +183 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3.sol/IGenArt721CoreContractV3.json +37 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Base.sol/IGenArt721CoreContractV3_Base.json +37 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine.sol/IGenArt721CoreContractV3_Engine.json +42 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_Flex.sol/IGenArt721CoreContractV3_Engine_Flex.json +42 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_Flex_PreV3p2.sol/IGenArt721CoreContractV3_Engine_Flex_PreV3p2.json +37 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine_PreV3p2.sol/IGenArt721CoreContractV3_Engine_PreV3p2.json +37 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreProjectScriptV0.sol/IGenArt721CoreProjectScriptV0.json +59 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreProjectScriptV1.sol/IGenArt721CoreProjectScriptV1.json +64 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreTokenHashProviderV0.sol/IGenArt721CoreTokenHashProviderV0.json +30 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721CoreTokenHashProviderV1.sol/IGenArt721CoreTokenHashProviderV1.json +30 -0
- package/artifacts/contracts/interfaces/v0.8.x/IGenArt721GeneratorV0.sol/IGenArt721GeneratorV0.json +63 -0
- package/artifacts/contracts/interfaces/v0.8.x/IOwnedCreate2FactoryV0.sol/IOwnedCreate2FactoryV0.json +74 -0
- package/artifacts/contracts/interfaces/v0.8.x/IPMPAugmentHook.sol/IPMPAugmentHook.json +83 -0
- package/artifacts/contracts/interfaces/v0.8.x/IPMPConfigureHook.sol/IPMPConfigureHook.json +80 -0
- package/artifacts/contracts/interfaces/v0.8.x/IPMPV0.sol/IPMPV0.json +402 -0
- package/artifacts/contracts/interfaces/v0.8.x/ISeaDropShimForContract.sol/ISeaDropShimForContract.json +37 -0
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterMinPriceV0.sol/ISharedMinterMinPriceV0.json +37 -0
- package/artifacts/contracts/interfaces/v0.8.x/IUniversalBytecodeStorageReader.sol/IUniversalBytecodeStorageReader.json +69 -0
- package/artifacts/contracts/interfaces/v0.8.x/IWeb3Call.sol/IWeb3Call.json +47 -0
- package/artifacts/contracts/interfaces/v0.8.x/integration-refs/OpenSea/ERC721SeaDropStructsErrorsAndEvents.sol/ERC721SeaDropStructsErrorsAndEvents.json +43 -0
- package/artifacts/contracts/interfaces/v0.8.x/integration-refs/OpenSea/INonFungibleSeaDropToken.sol/INonFungibleSeaDropToken.json +715 -0
- package/artifacts/contracts/interfaces/v0.8.x/integration-refs/OpenSea/ISeaDrop.sol/ISeaDrop.json +1571 -0
- package/artifacts/contracts/interfaces/v0.8.x/integration-refs/OpenSea/ISeaDropTokenContractMetadata.sol/ISeaDropTokenContractMetadata.json +345 -0
- package/artifacts/contracts/interfaces/v0.8.x/integration-refs/OpenSea/SeaDropErrorsAndEvents.sol/SeaDropErrorsAndEvents.json +717 -0
- package/artifacts/contracts/libs/integration-refs/delegation-registry/DelegateRegistry.sol/DelegateRegistry.json +846 -0
- package/artifacts/contracts/libs/integration-refs/delegation-registry/libraries/RegistryHashes.sol/RegistryHashes.json +10 -0
- package/artifacts/contracts/libs/integration-refs/delegation-registry/libraries/RegistryOps.sol/RegistryOps.json +10 -0
- package/artifacts/contracts/libs/integration-refs/delegation-registry/libraries/RegistryStorage.sol/RegistryStorage.json +10 -0
- package/artifacts/contracts/libs/v0.8.x/AuthLib.sol/AuthLib.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/Bytes32Strings.sol/Bytes32Strings.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/DependencyRegistryStorageLib.sol/DependencyRegistryStorageLib.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/ImmutableStringArray.sol/ImmutableStringArray.json +10 -0
- package/artifacts/contracts/libs/v0.8.x/JsonStatic.sol/JsonStatic.json +10 -0
- package/artifacts/contracts/libs/v0.8.x/V3FlexLib.sol/V3FlexLib.json +9 -22
- package/artifacts/contracts/libs/v0.8.x/minter-libs/MaxInvocationsLib.sol/MaxInvocationsLib.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/minter-libs/MinPriceLib.sol/MinPriceLib.json +24 -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 +664 -0
- package/artifacts/contracts/minter-suite/Minters/MinterMinPriceV0.sol/MinterMinPriceV0.json +387 -0
- 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/MinterSetPricePolyptychERC20V5.sol/MinterSetPricePolyptychERC20V5.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterSetPricePolyptychV5.sol/MinterSetPricePolyptychV5.json +2 -2
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceV5.sol/MinterSetPriceV5.json +2 -2
- 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 +1206 -0
- package/artifacts/contracts/mock/BytecodeV1LibCallsMock.sol/BytecodeV1LibCallsMock.json +2 -2
- package/artifacts/contracts/mock/BytecodeV2LibCallsMock.sol/BytecodeV2LibCallsMock.json +2 -2
- package/artifacts/contracts/mock/DummySharedMinter.sol/DummySharedMinter.json +2 -2
- package/artifacts/contracts/mock/ERC20MockAltDecimals.sol/ERC20MockAltDecimals.json +318 -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/ImmutableStringArrayMock.sol/ImmutableStringArrayMock.json +69 -0
- package/artifacts/contracts/mock/MockAdminACLV0_PROHIBITION.sol/MockAdminACLV0Events_PROHIBITION.json +2 -2
- package/artifacts/contracts/mock/MockFileStore.sol/MockFileStore.json +35 -0
- package/artifacts/contracts/mock/MockPMPAugmentHook.sol/MockPMPAugmentHook.json +214 -0
- package/artifacts/contracts/mock/MockPMPConfigureHook.sol/MockPMPConfigureHook.json +236 -0
- 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/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/web3call/PMPV0.sol/PMPV0.json +629 -0
- package/artifacts/contracts/web3call/Web3Call.sol/Web3Call.json +66 -0
- package/artifacts/contracts/web3call/augment-hooks/AbstractPMPAugmentHook.sol/AbstractPMPAugmentHook.json +83 -0
- package/artifacts/contracts/web3call/augment-hooks/InjectBaseGasFee.sol/InjectBaseGasFee.json +83 -0
- package/artifacts/contracts/web3call/augment-hooks/InjectChromieSquiggleFloorPrice.sol/IUniswapV2Pair.json +60 -0
- package/artifacts/contracts/web3call/augment-hooks/InjectChromieSquiggleFloorPrice.sol/InjectChromieSquiggleFloorPrice.json +107 -0
- package/artifacts/contracts/web3call/augment-hooks/InjectIsNounsDaoMember.sol/InjectIsNounsDaoMember.json +96 -0
- package/artifacts/contracts/web3call/augment-hooks/InjectIsProjectFullyMinted.sol/InjectIsProjectFullyMinted.json +83 -0
- package/artifacts/contracts/web3call/augment-hooks/InjectPolyptychTokenHash.sol/InjectPolyptychTokenHash.json +141 -0
- package/artifacts/contracts/web3call/augment-hooks/InjectTokenHashSeed.sol/InjectTokenHashSeed.json +99 -0
- package/artifacts/contracts/web3call/augment-hooks/InjectTokenOwner.sol/InjectTokenOwner.json +99 -0
- package/artifacts/contracts/web3call/augment-hooks/InjectTokenOwnerEthBalance.sol/InjectTokenOwnerEthBalance.json +83 -0
- package/artifacts/contracts/web3call/augment-hooks/InjectUSDCTotalSupply.sol/InjectUSDCTotalSupply.json +107 -0
- package/artifacts/contracts/web3call/configure-hooks/abstractPMPConfigureHook.sol/AbstractPMPConfigureHook.json +80 -0
- package/contracts/BytecodeStorageReaders/BytecodeStorageReaderContractV2.sol +103 -0
- package/contracts/BytecodeStorageReaders/BytecodeStorageReaderContractV2_Web3Call.sol +128 -0
- package/contracts/BytecodeStorageReaders/UniversalBytecodeStorageReader.sol +70 -0
- package/contracts/BytecodeStorageV2Writer.sol +69 -0
- package/contracts/DependencyRegistryV0.sol +296 -88
- package/contracts/GenArt721CoreV3_Curated.sol +133 -0
- package/contracts/OwnedCreate2FactoryV0.sol +173 -0
- package/contracts/engine/V3/EngineFactoryV0.sol +10 -2
- package/contracts/engine/V3/GenArt721CoreV3_Engine.sol +139 -70
- package/contracts/engine/V3/GenArt721CoreV3_Engine_Flex.sol +148 -72
- package/contracts/generator/AddressChunks.sol +106 -0
- package/contracts/generator/GenArt721GeneratorV0.sol +1163 -0
- package/contracts/generator/scripty-support/Scripty.sol +5 -0
- package/contracts/interfaces/v0.8.x/IBytecodeStorageReader.sol +34 -36
- package/contracts/interfaces/v0.8.x/IBytecodeStorageReaderV2.sol +5 -3
- package/contracts/interfaces/v0.8.x/IBytecodeStorageReader_Base.sol +20 -0
- package/contracts/interfaces/v0.8.x/ICoreRegistryV1.sol +5 -0
- package/contracts/interfaces/v0.8.x/IDelegateRegistry.sol +318 -0
- package/contracts/interfaces/v0.8.x/IDependencyRegistryV0.sol +96 -0
- package/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Base.sol +13 -2
- package/contracts/interfaces/v0.8.x/IGenArt721CoreContractV3_Engine.sol +3 -1
- package/contracts/interfaces/v0.8.x/IGenArt721CoreProjectScriptV0.sol +22 -0
- package/contracts/interfaces/v0.8.x/IGenArt721CoreProjectScriptV1.sol +23 -0
- package/contracts/interfaces/v0.8.x/IGenArt721CoreTokenHashProviderV0.sol +11 -0
- package/contracts/interfaces/v0.8.x/IGenArt721CoreTokenHashProviderV1.sol +9 -0
- package/contracts/interfaces/v0.8.x/IGenArt721GeneratorV0.sol +14 -0
- package/contracts/interfaces/v0.8.x/IOwnedCreate2FactoryV0.sol +40 -0
- package/contracts/interfaces/v0.8.x/IPMPAugmentHook.sol +31 -0
- package/contracts/interfaces/v0.8.x/IPMPConfigureHook.sol +25 -0
- package/contracts/interfaces/v0.8.x/IPMPV0.sol +224 -0
- package/contracts/interfaces/v0.8.x/ISeaDropShimForContract.sol +19 -0
- package/contracts/interfaces/v0.8.x/ISharedMinterMinPriceV0.sol +22 -0
- package/contracts/interfaces/v0.8.x/ISharedMinterRequired.sol +10 -4
- package/contracts/interfaces/v0.8.x/IUniversalBytecodeStorageReader.sol +33 -0
- package/contracts/interfaces/v0.8.x/IWeb3Call.sol +28 -0
- package/contracts/interfaces/v0.8.x/integration-refs/OpenSea/ERC721SeaDropStructsErrorsAndEvents.sol +58 -0
- package/contracts/interfaces/v0.8.x/integration-refs/OpenSea/INonFungibleSeaDropToken.sol +186 -0
- package/contracts/interfaces/v0.8.x/integration-refs/OpenSea/ISeaDrop.sol +337 -0
- package/contracts/interfaces/v0.8.x/integration-refs/OpenSea/ISeaDropTokenContractMetadata.sol +152 -0
- package/contracts/interfaces/v0.8.x/integration-refs/OpenSea/SeaDropErrorsAndEvents.sol +320 -0
- package/contracts/interfaces/v0.8.x/integration-refs/OpenSea/SeaDropStructs.sol +146 -0
- package/contracts/libs/integration-refs/delegation-registry/DelegateRegistry.sol +753 -0
- package/contracts/libs/integration-refs/delegation-registry/libraries/RegistryHashes.sol +359 -0
- package/contracts/libs/integration-refs/delegation-registry/libraries/RegistryOps.sol +31 -0
- package/contracts/libs/integration-refs/delegation-registry/libraries/RegistryStorage.sol +87 -0
- package/contracts/libs/v0.8.x/Bytes32Strings.sol +20 -0
- package/contracts/libs/v0.8.x/DependencyRegistryStorageLib.sol +14 -3
- package/contracts/libs/v0.8.x/ImmutableStringArray.sol +289 -0
- package/contracts/libs/v0.8.x/JsonStatic.sol +373 -0
- package/contracts/libs/v0.8.x/V3FlexLib.sol +16 -4
- package/contracts/libs/v0.8.x/minter-libs/MinPriceLib.sol +64 -0
- package/contracts/libs/v0.8.x/minter-libs/SplitFundsLib.sol +107 -0
- package/contracts/minter-suite/Minters/MinterMinPriceMerkleV0.sol +765 -0
- package/contracts/minter-suite/Minters/MinterMinPriceV0.sol +462 -0
- package/contracts/minter-suite/Minters/one-off/SeaDropXArtBlocksShim.sol +869 -0
- package/contracts/mock/ERC20MockAltDecimals.sol +31 -0
- package/contracts/mock/ImmutableStringArrayMock.sol +47 -0
- package/contracts/mock/MockFileStore.sol +22 -0
- package/contracts/mock/MockPMPAugmentHook.sol +170 -0
- package/contracts/mock/MockPMPConfigureHook.sol +78 -0
- package/contracts/web3call/PMPV0.sol +1125 -0
- package/contracts/web3call/Web3Call.sol +25 -0
- package/contracts/web3call/augment-hooks/AbstractPMPAugmentHook.sol +46 -0
- package/contracts/web3call/augment-hooks/InjectBaseGasFee.sol +57 -0
- package/contracts/web3call/augment-hooks/InjectChromieSquiggleFloorPrice.sol +103 -0
- package/contracts/web3call/augment-hooks/InjectIsNounsDaoMember.sol +66 -0
- package/contracts/web3call/augment-hooks/InjectIsProjectFullyMinted.sol +73 -0
- package/contracts/web3call/augment-hooks/InjectPolyptychTokenHash.sol +88 -0
- package/contracts/web3call/augment-hooks/InjectTokenHashSeed.sol +62 -0
- package/contracts/web3call/augment-hooks/InjectTokenOwner.sol +60 -0
- package/contracts/web3call/augment-hooks/InjectTokenOwnerEthBalance.sol +61 -0
- package/contracts/web3call/augment-hooks/InjectUSDCTotalSupply.sol +69 -0
- package/contracts/web3call/configure-hooks/abstractPMPConfigureHook.sol +41 -0
- package/package.json +23 -21
|
@@ -0,0 +1,289 @@
|
|
|
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 ImmutableStringArray
|
|
10
|
+
* @author Art Blocks Inc.
|
|
11
|
+
* @notice This library is optimized to store immutable arrays of strings much more efficiently than using native Solidity storage arrays.
|
|
12
|
+
* It uses a single SSTORE2 contract to store the length + packed offsets + packed string data.
|
|
13
|
+
* Allows overwriting the pointer to point to a new immutable array.
|
|
14
|
+
*/
|
|
15
|
+
library ImmutableStringArray {
|
|
16
|
+
/**
|
|
17
|
+
* @notice Struct to store the SSTORE2 pointer to the packed string array.
|
|
18
|
+
* @dev dataPointer is the SSTORE2 pointer to the packed string array.
|
|
19
|
+
*/
|
|
20
|
+
struct StringArray {
|
|
21
|
+
address dataPointer; // SSTORE2 pointer storing length + packed offsets + packed string data
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @notice Stores a packed immutable string array using a single SSTORE2 contract.
|
|
26
|
+
* Allows overwriting the pointer to point to a new immutable array.
|
|
27
|
+
* @param storageArray The storage reference to store the packed array.
|
|
28
|
+
* @param strings The array of strings to pack.
|
|
29
|
+
*/
|
|
30
|
+
function store(
|
|
31
|
+
StringArray storage storageArray,
|
|
32
|
+
string[] memory strings
|
|
33
|
+
) internal {
|
|
34
|
+
uint256 arrayLength = strings.length;
|
|
35
|
+
uint64[] memory offsets = new uint64[](arrayLength);
|
|
36
|
+
|
|
37
|
+
// compute total bytes length and offsets (ensuring no overflow)
|
|
38
|
+
uint256 totalStringBytesLength;
|
|
39
|
+
for (uint256 i = 0; i < arrayLength; i++) {
|
|
40
|
+
offsets[i] = uint64(totalStringBytesLength);
|
|
41
|
+
totalStringBytesLength += bytes(strings[i]).length;
|
|
42
|
+
}
|
|
43
|
+
// realistically will not overflow uint64, but check for security guarantees
|
|
44
|
+
// @dev no coverage on else (difficulty of triggering)
|
|
45
|
+
require(
|
|
46
|
+
totalStringBytesLength <= type(uint64).max,
|
|
47
|
+
"Offset exceeds uint64 limit"
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// prepare the combined storage structure (length + packed offsets + packed strings)
|
|
51
|
+
// @dev 8 bytes for length, 8 bytes per offset, totalStringBytesLength bytes for strings
|
|
52
|
+
// over-allocate 32 bytes for memory safety
|
|
53
|
+
// note: shorten length by 32 bytes at end of function before returning
|
|
54
|
+
uint256 packedDataLength = 8 +
|
|
55
|
+
(arrayLength * 8) +
|
|
56
|
+
totalStringBytesLength;
|
|
57
|
+
bytes memory packedData = new bytes(packedDataLength + 0x20);
|
|
58
|
+
uint256 ptr;
|
|
59
|
+
|
|
60
|
+
// store the length of the strings 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
|
+
// store offsets in packed `uint64` format
|
|
68
|
+
for (uint256 i = 0; i < arrayLength; i++) {
|
|
69
|
+
uint256 offset = offsets[i];
|
|
70
|
+
assembly ("memory-safe") {
|
|
71
|
+
mstore(ptr, shl(192, offset))
|
|
72
|
+
// move pointer ahead 8 bytes for uint64
|
|
73
|
+
ptr := add(ptr, 8)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// pack the strings efficiently, using assembly to copy 32 bytes at a time
|
|
78
|
+
for (uint i = 0; i < arrayLength; i++) {
|
|
79
|
+
bytes memory currentString = bytes(strings[i]);
|
|
80
|
+
uint currentLength = currentString.length;
|
|
81
|
+
uint currentPtr;
|
|
82
|
+
|
|
83
|
+
assembly ("memory-safe") {
|
|
84
|
+
currentPtr := add(currentString, 0x20) // start of current string's data
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// copy the full 32-byte chunks
|
|
88
|
+
uint chunks = currentLength / 32;
|
|
89
|
+
uint remainder = currentLength % 32;
|
|
90
|
+
// store the full 32 byte chunks
|
|
91
|
+
for (uint j = 0; j < chunks; j++) {
|
|
92
|
+
assembly ("memory-safe") {
|
|
93
|
+
let chunk := mload(currentPtr) // load 32 bytes of the current string
|
|
94
|
+
mstore(ptr, chunk) // store the 32 bytes into the result
|
|
95
|
+
ptr := add(ptr, 0x20) // move the result pointer forward by 32 bytes
|
|
96
|
+
currentPtr := add(currentPtr, 0x20) // move the current string pointer forward by 32 bytes
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// store any partial chunks
|
|
100
|
+
if (remainder > 0) {
|
|
101
|
+
bytes32 chunk;
|
|
102
|
+
assembly ("memory-safe") {
|
|
103
|
+
chunk := mload(currentPtr) // load full 32-byte word
|
|
104
|
+
// safe to write past end of final array - 32 bytes of buffer at end of array
|
|
105
|
+
mstore(ptr, chunk) // store the final chunk's remaining bytes
|
|
106
|
+
ptr := add(ptr, remainder) // move the result pointer forward by the remainder length for next iteration
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// remove the buffer from the packedData bytes array length
|
|
112
|
+
assembly ("memory-safe") {
|
|
113
|
+
ptr := packedData
|
|
114
|
+
mstore(ptr, packedDataLength)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Store all packed data in a SSTORE2 contract, store result in storage
|
|
118
|
+
storageArray.dataPointer = SSTORE2.write(packedData);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @notice Retrieves the total number of stored strings from SSTORE2.
|
|
123
|
+
* @param storageArray The storage reference containing packed strings.
|
|
124
|
+
* @return count The count of stored strings.
|
|
125
|
+
*/
|
|
126
|
+
function length(
|
|
127
|
+
StringArray storage storageArray
|
|
128
|
+
) internal view returns (uint256 count) {
|
|
129
|
+
// @dev this could be more efficient by only reading the first 8 bytes of the SSTORE2 contract
|
|
130
|
+
// but prefer to keep simple
|
|
131
|
+
bytes memory allData = SSTORE2.read(storageArray.dataPointer);
|
|
132
|
+
|
|
133
|
+
assembly ("memory-safe") {
|
|
134
|
+
count := shr(192, mload(add(allData, 32)))
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @notice Retrieves a single string from storage by index.
|
|
140
|
+
* @param storageArray The storage reference containing packed strings.
|
|
141
|
+
* @param index The index of the string to retrieve.
|
|
142
|
+
* @return result The retrieved string.
|
|
143
|
+
*/
|
|
144
|
+
function get(
|
|
145
|
+
StringArray storage storageArray,
|
|
146
|
+
uint256 index
|
|
147
|
+
) internal view returns (string memory result) {
|
|
148
|
+
// edge case - unassigned dataPointer
|
|
149
|
+
if (storageArray.dataPointer == address(0)) {
|
|
150
|
+
revert("Index out of bounds");
|
|
151
|
+
}
|
|
152
|
+
bytes memory allData = SSTORE2.read(storageArray.dataPointer);
|
|
153
|
+
uint256 offsetsStart;
|
|
154
|
+
uint64 start;
|
|
155
|
+
uint64 end;
|
|
156
|
+
// load the total length of the strings array from the first 8 bytes of the SSTORE2 contract
|
|
157
|
+
uint256 arrayLength;
|
|
158
|
+
assembly ("memory-safe") {
|
|
159
|
+
arrayLength := shr(192, mload(add(allData, 32)))
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
require(index < arrayLength, "Index out of bounds");
|
|
163
|
+
if (index + 1 == arrayLength) {
|
|
164
|
+
uint256 allDataLength = allData.length;
|
|
165
|
+
assembly ("memory-safe") {
|
|
166
|
+
offsetsStart := add(allData, 40) // skipping first 8 bytes (length)
|
|
167
|
+
start := shr(192, mload(add(offsetsStart, mul(index, 8)))) // load offsets[index] as uint64
|
|
168
|
+
end := sub(
|
|
169
|
+
allDataLength,
|
|
170
|
+
add(8, mul(arrayLength, 8)) // subtract 8 bytes for overall array length, and 8*length for the offsets section
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
assembly ("memory-safe") {
|
|
175
|
+
offsetsStart := add(allData, 40) // skipping first 8 bytes (length)
|
|
176
|
+
start := shr(192, mload(add(offsetsStart, mul(index, 8)))) // load offsets[index] as uint64
|
|
177
|
+
end := shr(192, mload(add(offsetsStart, mul(add(index, 1), 8)))) // load offsets[index + 1]
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
uint256 strLength = end - start;
|
|
182
|
+
// over-allocate 32 bytes for memory safety
|
|
183
|
+
bytes memory strBytes = new bytes(strLength + 32);
|
|
184
|
+
uint256 ptr;
|
|
185
|
+
assembly ("memory-safe") {
|
|
186
|
+
ptr := add(strBytes, 0x20) // pointer to first byte of strBytes
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// efficiently copy 32 bytes at a time from allData to strBytes
|
|
190
|
+
for (uint256 i = 0; i < strLength; i += 32) {
|
|
191
|
+
// offset = 32 bytes for length + 8 bytes for overall array length + 8 bytes per offset * length of array + start of string + i
|
|
192
|
+
uint256 offset = 32 + 8 + (arrayLength * 8) + start + i;
|
|
193
|
+
assembly ("memory-safe") {
|
|
194
|
+
let chunk := mload(add(allData, offset)) // load 32 bytes of the current string
|
|
195
|
+
mstore(ptr, chunk) // store the 32 bytes into the result (buffer keeps this memory safe)
|
|
196
|
+
ptr := add(ptr, 0x20) // move the result pointer forward by 32 bytes
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// remove the buffer length from the strBytes bytes array length
|
|
201
|
+
assembly ("memory-safe") {
|
|
202
|
+
ptr := strBytes
|
|
203
|
+
mstore(ptr, strLength)
|
|
204
|
+
}
|
|
205
|
+
result = string(strBytes);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @notice Retrieves all stored strings in a single batch call.
|
|
210
|
+
* @param storageArray The storage reference containing packed strings.
|
|
211
|
+
* @return results An array of all stored strings.
|
|
212
|
+
*/
|
|
213
|
+
function getAll(
|
|
214
|
+
StringArray storage storageArray
|
|
215
|
+
) internal view returns (string[] memory results) {
|
|
216
|
+
// edge case - unassigned dataPointer
|
|
217
|
+
if (storageArray.dataPointer == address(0)) {
|
|
218
|
+
return new string[](0);
|
|
219
|
+
}
|
|
220
|
+
// load the packed data from the SSTORE2 contract
|
|
221
|
+
bytes memory allData = SSTORE2.read(storageArray.dataPointer);
|
|
222
|
+
// load the total length of the strings array from the first 8 bytes of the SSTORE2 contract
|
|
223
|
+
uint256 arrayLength;
|
|
224
|
+
assembly ("memory-safe") {
|
|
225
|
+
arrayLength := shr(192, mload(add(allData, 32)))
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// for each string in the array, populate results
|
|
229
|
+
results = new string[](arrayLength);
|
|
230
|
+
|
|
231
|
+
for (uint256 index = 0; index < arrayLength; index++) {
|
|
232
|
+
// @dev start and end are calculated for each index for code simplicity/code re-use from get() function
|
|
233
|
+
uint256 offsetsStart;
|
|
234
|
+
uint64 start;
|
|
235
|
+
uint64 end;
|
|
236
|
+
|
|
237
|
+
if (index + 1 == arrayLength) {
|
|
238
|
+
uint256 allDataLength = allData.length;
|
|
239
|
+
assembly ("memory-safe") {
|
|
240
|
+
offsetsStart := add(allData, 40) // Skipping first 8 bytes (length)
|
|
241
|
+
start := shr(192, mload(add(offsetsStart, mul(index, 8)))) // Load offsets[index] as uint64
|
|
242
|
+
end := sub(
|
|
243
|
+
allDataLength,
|
|
244
|
+
add(8, mul(arrayLength, 8)) // subtract 8 bytes for overall array length, and 8*length for the offsets section
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
} else {
|
|
248
|
+
assembly ("memory-safe") {
|
|
249
|
+
offsetsStart := add(allData, 40) // Skipping first 8 bytes (length)
|
|
250
|
+
start := shr(192, mload(add(offsetsStart, mul(index, 8)))) // Load offsets[index] as uint64
|
|
251
|
+
end := shr(
|
|
252
|
+
192,
|
|
253
|
+
mload(add(offsetsStart, mul(add(index, 1), 8)))
|
|
254
|
+
) // Load offsets[index + 1]
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
uint256 strLength = end - start;
|
|
259
|
+
// over-allocate 32 bytes for memory safety
|
|
260
|
+
bytes memory strBytes = new bytes(strLength + 32);
|
|
261
|
+
uint256 ptr;
|
|
262
|
+
assembly ("memory-safe") {
|
|
263
|
+
ptr := add(strBytes, 0x20) // pointer to first byte of strBytes
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// efficiently copy 32 bytes at a time from allData to strBytes
|
|
267
|
+
for (uint256 i = 0; i < strLength; i += 32) {
|
|
268
|
+
// offset = 32 bytes for length + 8 bytes for overall array length + 8 bytes per offset * length of array + start of string + i
|
|
269
|
+
uint256 offset = 32 + 8 + (arrayLength * 8) + start + i;
|
|
270
|
+
assembly ("memory-safe") {
|
|
271
|
+
let chunk := mload(add(allData, offset)) // Load 32 bytes of the current string
|
|
272
|
+
mstore(ptr, chunk) // Store the 32 bytes into the result (buffer keeps this memory safe)
|
|
273
|
+
ptr := add(ptr, 0x20) // Move the result pointer forward by 32 bytes
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// remove the buffer length from the strBytes bytes array length
|
|
278
|
+
assembly ("memory-safe") {
|
|
279
|
+
ptr := strBytes
|
|
280
|
+
mstore(ptr, strLength)
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// store the string in the results array
|
|
284
|
+
results[index] = string(strBytes);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// results is returned by reference, so no need for explicit return
|
|
288
|
+
}
|
|
289
|
+
}
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-3.0-only
|
|
2
|
+
// Created By: Art Blocks Inc.
|
|
3
|
+
|
|
4
|
+
import {Base64} from "@openzeppelin-5.0/contracts/utils/Base64.sol";
|
|
5
|
+
import {Strings} from "@openzeppelin-5.0/contracts/utils/Strings.sol";
|
|
6
|
+
|
|
7
|
+
pragma solidity ^0.8.22;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @title Art Blocks Json Library
|
|
11
|
+
* @author Art Blocks Inc.
|
|
12
|
+
* @notice UNAUDITED
|
|
13
|
+
* A library for helping write static JSON metadata for Art Blocks projects.
|
|
14
|
+
* The library writes JSON data to a string within solidity, while remaining O(n) in gas and memory complexity,
|
|
15
|
+
* where n is the number of elements in an array or key:value pairs in an object. The library is O(m^2)
|
|
16
|
+
* in gas and memory complexity, where m is the depth of nested objects or arrays.
|
|
17
|
+
* When used in memory, the library only supports arrays and objects of fixed, pre-allocated size,
|
|
18
|
+
* in order to avoid dynamic memory allocation.
|
|
19
|
+
* The library supports an optional flag to write input string values as base64 encoded strings, in
|
|
20
|
+
* order to avoid the need for escaping characters in JSON strings.
|
|
21
|
+
* Keys are assumed to be valid key names in JSON.
|
|
22
|
+
* The library supports writing JSON objects, arrays, strings, uints, booleans, and null values.
|
|
23
|
+
* The library does not support writing floating point numbers.
|
|
24
|
+
*/
|
|
25
|
+
library JsonStatic {
|
|
26
|
+
using Strings for uint256;
|
|
27
|
+
using JsonStatic for JsonStatic.Json;
|
|
28
|
+
|
|
29
|
+
enum JsonType {
|
|
30
|
+
OBJECT,
|
|
31
|
+
ARRAY,
|
|
32
|
+
ELEMENT_STRING,
|
|
33
|
+
ELEMENT_UINT,
|
|
34
|
+
ELEMENT_BOOLEAN,
|
|
35
|
+
ELEMENT_NULL
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
enum StringEncodingFlag {
|
|
39
|
+
NONE,
|
|
40
|
+
BASE64
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
struct Json {
|
|
44
|
+
JsonType jsonType;
|
|
45
|
+
string[] objectKeys; // array of keys if type is OBJECT
|
|
46
|
+
Json[] values; // array of values if type is OBJECT, or array values if type is ARRAY
|
|
47
|
+
StringEncodingFlag stringEncodingFlag;
|
|
48
|
+
string elementValueString; // value if type is ELEMENT_STRING
|
|
49
|
+
uint256 elementValueUintOrBool; // value if type is ELEMENT_UINT, 0/1 if type is ELEMENT_BOOLEAN
|
|
50
|
+
// implied null if type is ELEMENT_NULL
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Convenience function to create a new values array.
|
|
55
|
+
* @param length the length of the values array.
|
|
56
|
+
* @return the new values array.
|
|
57
|
+
*/
|
|
58
|
+
function newValuesArray(
|
|
59
|
+
uint256 length
|
|
60
|
+
) internal pure returns (Json[] memory) {
|
|
61
|
+
return new Json[](length);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Convenience function to create a new keys array.
|
|
66
|
+
* @param length the length of the keys array.
|
|
67
|
+
* @return the new keys array.
|
|
68
|
+
*/
|
|
69
|
+
function newKeysArray(
|
|
70
|
+
uint256 length
|
|
71
|
+
) internal pure returns (string[] memory) {
|
|
72
|
+
return new string[](length);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Convenience function to create a new object element.
|
|
77
|
+
* @param keys the keys of the object element.
|
|
78
|
+
* @param values the values of the object element.
|
|
79
|
+
* @return the new object element.
|
|
80
|
+
*/
|
|
81
|
+
function newObjectElement(
|
|
82
|
+
string[] memory keys,
|
|
83
|
+
Json[] memory values
|
|
84
|
+
) internal pure returns (Json memory) {
|
|
85
|
+
return
|
|
86
|
+
Json({
|
|
87
|
+
jsonType: JsonType.OBJECT, // type
|
|
88
|
+
objectKeys: keys, // input
|
|
89
|
+
values: values, // input
|
|
90
|
+
stringEncodingFlag: StringEncodingFlag.NONE, // default
|
|
91
|
+
elementValueString: "", // default
|
|
92
|
+
elementValueUintOrBool: 0 // default
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Convenience function to create a new array element.
|
|
98
|
+
* @param values the values of the array element.
|
|
99
|
+
* @return the new array element.
|
|
100
|
+
*/
|
|
101
|
+
function newArrayElement(
|
|
102
|
+
Json[] memory values
|
|
103
|
+
) internal pure returns (Json memory) {
|
|
104
|
+
return
|
|
105
|
+
Json({
|
|
106
|
+
jsonType: JsonType.ARRAY, // type
|
|
107
|
+
objectKeys: new string[](0), // default
|
|
108
|
+
values: values, // input
|
|
109
|
+
stringEncodingFlag: StringEncodingFlag.NONE, // default
|
|
110
|
+
elementValueString: "", // default
|
|
111
|
+
elementValueUintOrBool: 0 // default
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Convenience function to create a new string element.
|
|
117
|
+
* If base64 encoding is set as the encoding flag, the passed value will be encoded on WRITE and
|
|
118
|
+
* should NOT already be encoded. Passing an already encoded value will result in double encoding.
|
|
119
|
+
* @param value the string value of the element.
|
|
120
|
+
* @param stringEncodingFlag the string encoding flag for the element.
|
|
121
|
+
* @return the new string element.
|
|
122
|
+
*/
|
|
123
|
+
function newStringElement(
|
|
124
|
+
string memory value,
|
|
125
|
+
StringEncodingFlag stringEncodingFlag
|
|
126
|
+
) internal pure returns (Json memory) {
|
|
127
|
+
return
|
|
128
|
+
Json({
|
|
129
|
+
jsonType: JsonType.ELEMENT_STRING, // type
|
|
130
|
+
objectKeys: new string[](0), // default
|
|
131
|
+
values: new Json[](0), // default
|
|
132
|
+
stringEncodingFlag: stringEncodingFlag, // input
|
|
133
|
+
elementValueString: value, // input
|
|
134
|
+
elementValueUintOrBool: 0 // default
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Convenience function to create a new uint element.
|
|
140
|
+
* @param value the uint value of the element.
|
|
141
|
+
* @return the new uint element.
|
|
142
|
+
*/
|
|
143
|
+
function newUintElement(uint256 value) internal pure returns (Json memory) {
|
|
144
|
+
return
|
|
145
|
+
Json({
|
|
146
|
+
jsonType: JsonType.ELEMENT_UINT, // type
|
|
147
|
+
objectKeys: new string[](0), // default
|
|
148
|
+
values: new Json[](0), // default
|
|
149
|
+
stringEncodingFlag: StringEncodingFlag.NONE, // default
|
|
150
|
+
elementValueString: "", // default
|
|
151
|
+
elementValueUintOrBool: value // input
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Convenience function to create a new boolean element.
|
|
157
|
+
* @param value the boolean value of the element.
|
|
158
|
+
* @return the new boolean element.
|
|
159
|
+
*/
|
|
160
|
+
function newBooleanElement(bool value) internal pure returns (Json memory) {
|
|
161
|
+
return
|
|
162
|
+
Json({
|
|
163
|
+
jsonType: JsonType.ELEMENT_BOOLEAN, // type
|
|
164
|
+
objectKeys: new string[](0), // default
|
|
165
|
+
values: new Json[](0), // default
|
|
166
|
+
stringEncodingFlag: StringEncodingFlag.NONE, // default
|
|
167
|
+
elementValueString: "", // default
|
|
168
|
+
elementValueUintOrBool: value ? 1 : 0 // input
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* @notice writes a json struct to a string
|
|
174
|
+
* @param json the json struct to write
|
|
175
|
+
* @return the json string
|
|
176
|
+
*/
|
|
177
|
+
function write(Json memory json) internal pure returns (string memory) {
|
|
178
|
+
if (json.jsonType == JsonType.OBJECT) {
|
|
179
|
+
return _writeObject(json);
|
|
180
|
+
} else if (json.jsonType == JsonType.ARRAY) {
|
|
181
|
+
return _writeArray(json);
|
|
182
|
+
} else if (json.jsonType == JsonType.ELEMENT_STRING) {
|
|
183
|
+
return
|
|
184
|
+
_writeString(json.elementValueString, json.stringEncodingFlag);
|
|
185
|
+
} else if (json.jsonType == JsonType.ELEMENT_UINT) {
|
|
186
|
+
return _writeUint(json.elementValueUintOrBool);
|
|
187
|
+
} else if (json.jsonType == JsonType.ELEMENT_BOOLEAN) {
|
|
188
|
+
return _writeBoolean(json.elementValueUintOrBool);
|
|
189
|
+
} else {
|
|
190
|
+
return _writeNull();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* @notice writes a json struct of type JsonType.OBJECT to a string
|
|
196
|
+
* @param json the json struct of type JsonType.OBJECT to write
|
|
197
|
+
* @return the json string
|
|
198
|
+
*/
|
|
199
|
+
function _writeObject(
|
|
200
|
+
Json memory json
|
|
201
|
+
) private pure returns (string memory) {
|
|
202
|
+
// pre-allocate string array to avoid dynamic memory allocation
|
|
203
|
+
uint256 keysLength = json.objectKeys.length;
|
|
204
|
+
string[] memory valueStrings = new string[](keysLength);
|
|
205
|
+
for (uint256 i = 0; i < keysLength; i++) {
|
|
206
|
+
// only trailing comma if not last child, per JSON spec
|
|
207
|
+
string memory trailingChar = i < keysLength - 1 ? "," : "";
|
|
208
|
+
valueStrings[i] = string.concat(
|
|
209
|
+
'"',
|
|
210
|
+
json.objectKeys[i], // keys assumed to be valid JSON keys
|
|
211
|
+
'":',
|
|
212
|
+
json.values[i].write(),
|
|
213
|
+
trailingChar
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
// concat all valueStrings and return
|
|
217
|
+
return string.concat("{", _concatenateStrings(valueStrings), "}");
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* @notice writes a json struct of type JsonType.ARRAY to a string
|
|
222
|
+
* @param json the json struct of type JsonType.ARRAY to write
|
|
223
|
+
* @return the json string
|
|
224
|
+
*/
|
|
225
|
+
function _writeArray(
|
|
226
|
+
Json memory json
|
|
227
|
+
) private pure returns (string memory) {
|
|
228
|
+
// pre-allocate string array to avoid dynamic memory allocation
|
|
229
|
+
uint256 valuesLength = json.values.length;
|
|
230
|
+
string[] memory valueStrings = new string[](valuesLength);
|
|
231
|
+
for (uint256 i = 0; i < valuesLength; i++) {
|
|
232
|
+
// only trailing comma if not last child, per JSON spec
|
|
233
|
+
string memory trailingChar = i < valuesLength - 1 ? "," : "";
|
|
234
|
+
valueStrings[i] = string.concat(
|
|
235
|
+
json.values[i].write(),
|
|
236
|
+
trailingChar
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
// concat all valueStrings and return
|
|
240
|
+
return string.concat("[", _concatenateStrings(valueStrings), "]");
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* @notice writes a string value to a valid json string.
|
|
245
|
+
* If the string encoding flag is set to BASE64, the written value will be base64 encoded.
|
|
246
|
+
* @param value the string value to write
|
|
247
|
+
* @param stringEncodingFlag the string encoding flag for the value
|
|
248
|
+
* @return the json string
|
|
249
|
+
*/
|
|
250
|
+
function _writeString(
|
|
251
|
+
string memory value,
|
|
252
|
+
StringEncodingFlag stringEncodingFlag
|
|
253
|
+
) private pure returns (string memory) {
|
|
254
|
+
if (stringEncodingFlag == StringEncodingFlag.BASE64) {
|
|
255
|
+
return _writeBase64(value);
|
|
256
|
+
} else {
|
|
257
|
+
return _writePlainString(value);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @notice writes a string value to a valid json string
|
|
263
|
+
* @param value the string value to write
|
|
264
|
+
* @return the json string
|
|
265
|
+
*/
|
|
266
|
+
function _writePlainString(
|
|
267
|
+
string memory value
|
|
268
|
+
) private pure returns (string memory) {
|
|
269
|
+
return string.concat('"', value, '"');
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* @notice writes a base64 encoded string value to a valid json string
|
|
274
|
+
* @param value the string value to write
|
|
275
|
+
* @return the json string
|
|
276
|
+
*/
|
|
277
|
+
function _writeBase64(
|
|
278
|
+
string memory value
|
|
279
|
+
) private pure returns (string memory) {
|
|
280
|
+
return string.concat('"', Base64.encode(bytes(value)), '"');
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @notice writes a uint value to a valid json string
|
|
285
|
+
* @param value the uint value to write
|
|
286
|
+
* @return the json string
|
|
287
|
+
*/
|
|
288
|
+
function _writeUint(uint256 value) private pure returns (string memory) {
|
|
289
|
+
// @dev no quotes around numbers
|
|
290
|
+
return value.toString();
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* @notice writes a boolean value to a valid json string.
|
|
295
|
+
* If the value is equal to zero, it is written as false, otherwise it is written as true.
|
|
296
|
+
* @dev Booleans are written as true or false without quotes.
|
|
297
|
+
* @param value the value to write
|
|
298
|
+
* @return the json string
|
|
299
|
+
*/
|
|
300
|
+
function _writeBoolean(uint256 value) private pure returns (string memory) {
|
|
301
|
+
// @dev no quotes around booleans
|
|
302
|
+
return (value > 0) ? "true" : "false";
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* @notice writes a null value to a valid json string
|
|
307
|
+
* @return the json string
|
|
308
|
+
*/
|
|
309
|
+
function _writeNull() private pure returns (string memory) {
|
|
310
|
+
return "null";
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* @notice Helper function to efficiently concatenate an array of strings.
|
|
315
|
+
* @dev portions of code generated with AI Assistance, modified and tested by human developers.
|
|
316
|
+
* @param strings The array of strings to concatenate.
|
|
317
|
+
* @return The concatenated string.
|
|
318
|
+
*/
|
|
319
|
+
function _concatenateStrings(
|
|
320
|
+
string[] memory strings
|
|
321
|
+
) private pure returns (string memory) {
|
|
322
|
+
uint totalLength = 0;
|
|
323
|
+
|
|
324
|
+
// Step 1: Calculate the total length of the result string
|
|
325
|
+
for (uint i = 0; i < strings.length; i++) {
|
|
326
|
+
totalLength += bytes(strings[i]).length;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Step 2: Allocate memory for the resulting string
|
|
330
|
+
string memory result = new string(totalLength); // Allocate memory for the result, also defining its length
|
|
331
|
+
uint resultPtr;
|
|
332
|
+
assembly {
|
|
333
|
+
resultPtr := add(result, 0x20) // Point to the start of the string's data in memory
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Step 3: Copy each string into the result using assembly
|
|
337
|
+
for (uint i = 0; i < strings.length; i++) {
|
|
338
|
+
bytes memory currentString = bytes(strings[i]);
|
|
339
|
+
uint currentLength = currentString.length;
|
|
340
|
+
uint currentPtr;
|
|
341
|
+
|
|
342
|
+
assembly {
|
|
343
|
+
currentPtr := add(currentString, 0x20) // Start of current string's data
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// Copy the full 32-byte chunks
|
|
347
|
+
uint chunks = currentLength / 32;
|
|
348
|
+
uint remainder = currentLength % 32;
|
|
349
|
+
|
|
350
|
+
for (uint j = 0; j < chunks; j++) {
|
|
351
|
+
assembly {
|
|
352
|
+
let chunk := mload(currentPtr) // Load 32 bytes of the current string
|
|
353
|
+
mstore(resultPtr, chunk) // Store the 32 bytes into the result
|
|
354
|
+
resultPtr := add(resultPtr, 0x20) // Move the result pointer forward by 32 bytes
|
|
355
|
+
currentPtr := add(currentPtr, 0x20) // Move the current string pointer forward by 32 bytes
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// Handle remaining bytes (less than 32)
|
|
360
|
+
if (remainder > 0) {
|
|
361
|
+
assembly {
|
|
362
|
+
let chunk := mload(currentPtr) // Load 32 bytes
|
|
363
|
+
let mask := sub(shl(mul(8, sub(0x20, remainder)), 1), 1) // Create mask for the remainder
|
|
364
|
+
let lastChunk := and(chunk, not(mask)) // Mask out the excess bits
|
|
365
|
+
mstore(resultPtr, lastChunk) // Store the remaining bytes into the result
|
|
366
|
+
resultPtr := add(resultPtr, remainder) // Move the result pointer forward by the remainder length
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
return result;
|
|
372
|
+
}
|
|
373
|
+
}
|