@artblocks/contracts 0.0.1
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/.env.example +10 -0
- package/LICENSE +165 -0
- package/README.md +286 -0
- package/artifacts/contracts/AdminACLV0.sol/AdminACLV0.json +164 -0
- package/artifacts/contracts/AdminACLV1.sol/AdminACLV1.json +248 -0
- package/artifacts/contracts/BasicRandomizer.sol/BasicRandomizer.json +24 -0
- package/artifacts/contracts/BasicRandomizerV2.sol/BasicRandomizerV2.json +102 -0
- package/artifacts/contracts/DependencyRegistryV0.sol/DependencyRegistryV0.json +1020 -0
- package/artifacts/contracts/GenArt721CoreV3.sol/GenArt721CoreV3.json +1928 -0
- package/artifacts/contracts/GenArt721CoreV3_Engine.sol/GenArt721CoreV3_Engine.json +1942 -0
- package/artifacts/contracts/engine/GenArt721CoreV2_ENGINE_FLEX.sol/GenArt721CoreV2_ENGINE_FLEX.json +1708 -0
- package/artifacts/contracts/engine/GenArt721CoreV2_PBAB.sol/GenArt721CoreV2_PBAB.json +1410 -0
- package/artifacts/contracts/engine/GenArt721CoreV2_PRTNR.sol/GenArt721CoreV2_PRTNR.json +1436 -0
- package/artifacts/contracts/engine/GenArt721MinterBurner_PBAB.sol/GenArt721MinterBurner_PBAB.json +437 -0
- package/artifacts/contracts/engine/GenArt721MinterDAExp_PBAB.sol/GenArt721MinterDAExp_PBAB.json +508 -0
- package/artifacts/contracts/engine/GenArt721Minter_PBAB.sol/GenArt721Minter_PBAB.json +381 -0
- package/artifacts/contracts/engine-registry/EngineRegistryV0.sol/EngineRegistryV0.json +109 -0
- package/artifacts/contracts/engine-registry/future/EngineRegistryV1.sol/EngineRegistryV1.json +109 -0
- package/artifacts/contracts/explorations/GenArt721CoreV3_Explorations.sol/GenArt721CoreV3_Explorations.json +1902 -0
- package/artifacts/contracts/interfaces/0.5.x/IBonusContract.sol/IBonusContract.json +47 -0
- package/artifacts/contracts/interfaces/0.5.x/IGenArt721CoreContractV1.sol/IGenArt721CoreContractV1.json +413 -0
- package/artifacts/contracts/interfaces/0.5.x/IGenArt721CoreV2_PBAB.sol/IGenArt721CoreV2_PBAB.json +392 -0
- package/artifacts/contracts/interfaces/0.5.x/IRandomizer.sol/IRandomizer.json +26 -0
- package/artifacts/contracts/interfaces/0.8.x/IAdminACLV0.sol/IAdminACLV0.json +122 -0
- package/artifacts/contracts/interfaces/0.8.x/IArtblocksRoyaltyOverride.sol/IArtblocksRoyaltyOverride.json +59 -0
- package/artifacts/contracts/interfaces/0.8.x/IBonusContract.sol/IBonusContract.json +43 -0
- package/artifacts/contracts/interfaces/0.8.x/IDelegationRegistry.sol/IDelegationRegistry.json +510 -0
- package/artifacts/contracts/interfaces/0.8.x/IDependencyRegistryCompatibleV0.sol/IDependencyRegistryCompatibleV0.json +53 -0
- package/artifacts/contracts/interfaces/0.8.x/IDependencyRegistryV0.sol/IDependencyRegistryV0.json +350 -0
- package/artifacts/contracts/interfaces/0.8.x/IEngineRegistryV0.sol/IEngineRegistryV0.json +85 -0
- package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV0.sol/IFilteredMinterDAExpSettlementV0.json +730 -0
- package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpV0.sol/IFilteredMinterDAExpV0.json +311 -0
- package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpV1.sol/IFilteredMinterDAExpV1.json +617 -0
- package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDALinV0.sol/IFilteredMinterDALinV0.json +292 -0
- package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDALinV1.sol/IFilteredMinterDALinV1.json +598 -0
- package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterHolderV0.sol/IFilteredMinterHolderV0.json +355 -0
- package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterHolderV1.sol/IFilteredMinterHolderV1.json +368 -0
- package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterHolderV2.sol/IFilteredMinterHolderV2.json +674 -0
- package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterMerkleV0.sol/IFilteredMinterMerkleV0.json +551 -0
- package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterMerkleV1.sol/IFilteredMinterMerkleV1.json +564 -0
- package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterMerkleV2.sol/IFilteredMinterMerkleV2.json +601 -0
- package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterV0.sol/IFilteredMinterV0.json +216 -0
- package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterV1.sol/IFilteredMinterV1.json +485 -0
- package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterV2.sol/IFilteredMinterV2.json +522 -0
- package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreContractV1.sol/IGenArt721CoreContractV1.json +299 -0
- package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreContractV3.sol/IGenArt721CoreContractV3.json +609 -0
- package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Base.sol/IGenArt721CoreContractV3_Base.json +448 -0
- package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Engine.sol/IGenArt721CoreContractV3_Engine.json +649 -0
- package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreV2_PBAB.sol/IGenArt721CoreV2_PBAB.json +362 -0
- package/artifacts/contracts/interfaces/0.8.x/IManifold.sol/IManifold.json +35 -0
- package/artifacts/contracts/interfaces/0.8.x/IMinterFilterV0.sol/IMinterFilterV0.json +192 -0
- package/artifacts/contracts/interfaces/0.8.x/IRandomizer.sol/IRandomizer.json +24 -0
- package/artifacts/contracts/interfaces/0.8.x/IRandomizerV2.sol/IRandomizerV2.json +37 -0
- package/artifacts/contracts/legacy/GenArt721CoreV1.sol/Address.json +10 -0
- package/artifacts/contracts/legacy/GenArt721CoreV1.sol/Counters.json +10 -0
- package/artifacts/contracts/legacy/GenArt721CoreV1.sol/CustomERC721Metadata.json +425 -0
- package/artifacts/contracts/legacy/GenArt721CoreV1.sol/ERC165.json +38 -0
- package/artifacts/contracts/legacy/GenArt721CoreV1.sol/ERC721.json +322 -0
- package/artifacts/contracts/legacy/GenArt721CoreV1.sol/ERC721Enumerable.json +384 -0
- package/artifacts/contracts/legacy/GenArt721CoreV1.sol/GenArt721CoreV1.json +1773 -0
- package/artifacts/contracts/legacy/GenArt721CoreV1.sol/IERC165.json +32 -0
- package/artifacts/contracts/legacy/GenArt721CoreV1.sol/IERC721.json +316 -0
- package/artifacts/contracts/legacy/GenArt721CoreV1.sol/IERC721Enumerable.json +378 -0
- package/artifacts/contracts/legacy/GenArt721CoreV1.sol/IERC721Receiver.json +47 -0
- package/artifacts/contracts/legacy/GenArt721CoreV1.sol/SafeMath.json +10 -0
- package/artifacts/contracts/legacy/GenArt721CoreV1.sol/Strings.json +10 -0
- package/artifacts/contracts/legacy/GenArt721LegacyMinter.sol/GenArt721LegacyMinter.json +338 -0
- package/artifacts/contracts/libs/0.5.x/CustomERC721Metadata.sol/CustomERC721Metadata.json +425 -0
- package/artifacts/contracts/libs/0.5.x/IERC20.sol/IERC20.json +206 -0
- package/artifacts/contracts/libs/0.5.x/SafeMath.sol/SafeMath.json +10 -0
- package/artifacts/contracts/libs/0.5.x/Strings.sol/Strings.json +10 -0
- package/artifacts/contracts/libs/0.8.x/BytecodeStorage.sol/BytecodeStorage.json +10 -0
- package/artifacts/contracts/libs/0.8.x/Bytes32Strings.sol/Bytes32Strings.json +10 -0
- package/artifacts/contracts/libs/0.8.x/ERC721_PackedHashSeed.sol/ERC721_PackedHashSeed.json +357 -0
- package/artifacts/contracts/libs/integration-refs/delegation-registry/DelegationRegistry.sol/DelegationRegistry.json +529 -0
- package/artifacts/contracts/libs/integration-refs/gnosis-safe/GnosisSafeMock.sol/GnosisSafeMock.json +1037 -0
- package/artifacts/contracts/libs/integration-refs/gnosis-safe/GnosisSafeProxyFactoryMock.sol/GnosisSafeProxyFactoryMock.json +172 -0
- package/artifacts/contracts/libs/integration-refs/gnosis-safe/MultiSendMock.sol/MultiSendMock.json +24 -0
- package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV0.sol/MinterFilterV0.json +342 -0
- package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV1.sol/MinterFilterV1.json +322 -0
- package/artifacts/contracts/minter-suite/Minters/MinterDAExp/MinterDAExpV2.sol/MinterDAExpV2.json +550 -0
- package/artifacts/contracts/minter-suite/Minters/MinterDAExp/MinterDAExpV3.sol/MinterDAExpV3.json +856 -0
- package/artifacts/contracts/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol/MinterDAExpSettlementV0.json +1053 -0
- package/artifacts/contracts/minter-suite/Minters/MinterDALin/MinterDALinV2.sol/MinterDALinV2.json +526 -0
- package/artifacts/contracts/minter-suite/Minters/MinterDALin/MinterDALinV3.sol/MinterDALinV3.json +832 -0
- package/artifacts/contracts/minter-suite/Minters/MinterHolder/MinterHolderV2.sol/MinterHolderV2.json +794 -0
- package/artifacts/contracts/minter-suite/Minters/MinterHolder/MinterHolderV3.sol/MinterHolderV3.json +1100 -0
- package/artifacts/contracts/minter-suite/Minters/MinterMerkle/MinterMerkleV3.sol/MinterMerkleV3.json +1002 -0
- package/artifacts/contracts/minter-suite/Minters/MinterMerkle/MinterMerkleV4.sol/MinterMerkleV4.json +1039 -0
- package/artifacts/contracts/minter-suite/Minters/MinterSetPrice/MinterSetPriceV2.sol/MinterSetPriceV2.json +365 -0
- package/artifacts/contracts/minter-suite/Minters/MinterSetPrice/MinterSetPriceV3.sol/MinterSetPriceV3.json +671 -0
- package/artifacts/contracts/minter-suite/Minters/MinterSetPrice/deprecated/MinterSetPriceV1.sol/MinterSetPriceV1.json +288 -0
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol/MinterSetPriceERC20V2.json +436 -0
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol/MinterSetPriceERC20V3.json +742 -0
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20/deprecated/MinterSetPriceERC20V0.sol/MinterSetPriceERC20V0.json +461 -0
- package/artifacts/contracts/mock/BytecodeTextCR_DMock.sol/BytecodeTextCR_DMock.json +194 -0
- package/artifacts/contracts/mock/DeadReceiverMock.sol/DeadReceiverMock.json +15 -0
- package/artifacts/contracts/mock/ERC20Mock.sol/ERC20Mock.json +292 -0
- package/artifacts/contracts/mock/MockAdminACLV0.sol/MockAdminACLV0Events.json +165 -0
- package/artifacts/contracts/mock/RandomizerV2_NoAssignMock.sol/RandomizerV2_NoAssignMock.json +128 -0
- package/artifacts/contracts/mock/ReentrancyHolderMock.sol/ReentrancyHolderMock.json +118 -0
- package/artifacts/contracts/mock/ReentrancyMerkleMock.sol/ReentrancyMerkleMock.json +87 -0
- package/artifacts/contracts/mock/ReentrancyMock.sol/ReentrancyMock.json +82 -0
- package/artifacts/contracts/royalty-registry/GenArt721RoyaltyOverride.sol/GenArt721RoyaltyOverride.json +208 -0
- package/artifacts/contracts/royalty-registry/GenArt721RoyaltyOverride_PBAB.sol/GenArt721RoyaltyOverride_PBAB.json +301 -0
- package/contracts/AdminACLV0.sol +103 -0
- package/contracts/AdminACLV1.sol +193 -0
- package/contracts/BasicRandomizer.sol +23 -0
- package/contracts/BasicRandomizerV2.sol +36 -0
- package/contracts/DependencyRegistryV0.sol +893 -0
- package/contracts/GenArt721CoreV3.sol +2001 -0
- package/contracts/GenArt721CoreV3_Engine.sol +2061 -0
- package/contracts/engine/GenArt721CoreV2_ENGINE_FLEX.sol +887 -0
- package/contracts/engine/GenArt721CoreV2_PBAB.sol +695 -0
- package/contracts/engine/GenArt721CoreV2_PRTNR.sol +749 -0
- package/contracts/engine/GenArt721MinterBurner_PBAB.sol +467 -0
- package/contracts/engine/GenArt721MinterDAExp_PBAB.sol +614 -0
- package/contracts/engine/GenArt721Minter_PBAB.sol +420 -0
- package/contracts/engine-registry/EngineRegistryV0.sol +72 -0
- package/contracts/engine-registry/future/EngineRegistryV1.sol +86 -0
- package/contracts/explorations/GenArt721CoreV3_Explorations.sol +1989 -0
- package/contracts/interfaces/0.5.x/IBonusContract.sol +10 -0
- package/contracts/interfaces/0.5.x/IGenArt721CoreContractV1.sol +91 -0
- package/contracts/interfaces/0.5.x/IGenArt721CoreV2_PBAB.sol +92 -0
- package/contracts/interfaces/0.5.x/IRandomizer.sol +8 -0
- package/contracts/interfaces/0.8.x/IAdminACLV0.sol +51 -0
- package/contracts/interfaces/0.8.x/IArtblocksRoyaltyOverride.sol +34 -0
- package/contracts/interfaces/0.8.x/IBonusContract.sol +10 -0
- package/contracts/interfaces/0.8.x/IDelegationRegistry.sol +221 -0
- package/contracts/interfaces/0.8.x/IDependencyRegistryCompatibleV0.sol +31 -0
- package/contracts/interfaces/0.8.x/IDependencyRegistryV0.sol +95 -0
- package/contracts/interfaces/0.8.x/IEngineRegistryV0.sol +38 -0
- package/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV0.sol +70 -0
- package/contracts/interfaces/0.8.x/IFilteredMinterDAExpV0.sol +35 -0
- package/contracts/interfaces/0.8.x/IFilteredMinterDAExpV1.sol +16 -0
- package/contracts/interfaces/0.8.x/IFilteredMinterDALinV0.sol +32 -0
- package/contracts/interfaces/0.8.x/IFilteredMinterDALinV1.sol +16 -0
- package/contracts/interfaces/0.8.x/IFilteredMinterHolderV0.sol +68 -0
- package/contracts/interfaces/0.8.x/IFilteredMinterHolderV1.sol +19 -0
- package/contracts/interfaces/0.8.x/IFilteredMinterHolderV2.sol +19 -0
- package/contracts/interfaces/0.8.x/IFilteredMinterMerkleV0.sol +37 -0
- package/contracts/interfaces/0.8.x/IFilteredMinterMerkleV1.sol +19 -0
- package/contracts/interfaces/0.8.x/IFilteredMinterMerkleV2.sol +19 -0
- package/contracts/interfaces/0.8.x/IFilteredMinterV0.sol +74 -0
- package/contracts/interfaces/0.8.x/IFilteredMinterV1.sol +127 -0
- package/contracts/interfaces/0.8.x/IFilteredMinterV2.sol +30 -0
- package/contracts/interfaces/0.8.x/IGenArt721CoreContractV1.sol +73 -0
- package/contracts/interfaces/0.8.x/IGenArt721CoreContractV3.sol +79 -0
- package/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Base.sol +127 -0
- package/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Engine.sol +80 -0
- package/contracts/interfaces/0.8.x/IGenArt721CoreV2_PBAB.sol +91 -0
- package/contracts/interfaces/0.8.x/IManifold.sol +24 -0
- package/contracts/interfaces/0.8.x/IMinterFilterV0.sol +47 -0
- package/contracts/interfaces/0.8.x/IRandomizer.sol +8 -0
- package/contracts/interfaces/0.8.x/IRandomizerV2.sol +15 -0
- package/contracts/legacy/GenArt721CoreV1.sol +1593 -0
- package/contracts/legacy/GenArt721LegacyMinter.sol +275 -0
- package/contracts/libs/0.5.x/CustomERC721Metadata.sol +52 -0
- package/contracts/libs/0.5.x/IERC20.sol +96 -0
- package/contracts/libs/0.5.x/SafeMath.sol +98 -0
- package/contracts/libs/0.5.x/Strings.sol +92 -0
- package/contracts/libs/0.8.x/BytecodeStorage.sol +314 -0
- package/contracts/libs/0.8.x/Bytes32Strings.sol +66 -0
- package/contracts/libs/0.8.x/ERC721_PackedHashSeed.sol +514 -0
- package/contracts/libs/integration-refs/delegation-registry/DelegationRegistry.sol +663 -0
- package/contracts/libs/integration-refs/gnosis-safe/GnosisSafeMock.sol +6 -0
- package/contracts/libs/integration-refs/gnosis-safe/GnosisSafeProxyFactoryMock.sol +6 -0
- package/contracts/libs/integration-refs/gnosis-safe/MultiSendMock.sol +6 -0
- package/contracts/minter-suite/MinterFilter/MinterFilterV0.sol +291 -0
- package/contracts/minter-suite/MinterFilter/MinterFilterV1.sol +320 -0
- package/contracts/minter-suite/Minters/MinterDAExp/MinterDAExpV2.sol +571 -0
- package/contracts/minter-suite/Minters/MinterDAExp/MinterDAExpV3.sol +622 -0
- package/contracts/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol +1066 -0
- package/contracts/minter-suite/Minters/MinterDALin/MinterDALinV2.sol +527 -0
- package/contracts/minter-suite/Minters/MinterDALin/MinterDALinV3.sol +576 -0
- package/contracts/minter-suite/Minters/MinterHolder/MinterHolderV2.sol +749 -0
- package/contracts/minter-suite/Minters/MinterHolder/MinterHolderV3.sol +798 -0
- package/contracts/minter-suite/Minters/MinterMerkle/MinterMerkleV3.sol +682 -0
- package/contracts/minter-suite/Minters/MinterMerkle/MinterMerkleV4.sol +733 -0
- package/contracts/minter-suite/Minters/MinterSetPrice/MinterSetPriceV2.sol +350 -0
- package/contracts/minter-suite/Minters/MinterSetPrice/MinterSetPriceV3.sol +401 -0
- package/contracts/minter-suite/Minters/MinterSetPrice/deprecated/MinterSetPriceV1.sol +274 -0
- package/contracts/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol +491 -0
- package/contracts/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol +542 -0
- package/contracts/minter-suite/Minters/MinterSetPriceERC20/deprecated/MinterSetPriceERC20V0.sol +470 -0
- package/contracts/mock/BytecodeTextCR_DMock.sol +184 -0
- package/contracts/mock/DeadReceiverMock.sol +13 -0
- package/contracts/mock/ERC20Mock.sol +11 -0
- package/contracts/mock/MockAdminACLV0.sol +65 -0
- package/contracts/mock/RandomizerV2_NoAssignMock.sol +43 -0
- package/contracts/mock/ReentrancyHolderMock.sol +50 -0
- package/contracts/mock/ReentrancyMerkleMock.sol +64 -0
- package/contracts/mock/ReentrancyMock.sol +44 -0
- package/contracts/royalty-registry/GenArt721RoyaltyOverride.sol +168 -0
- package/contracts/royalty-registry/GenArt721RoyaltyOverride_PBAB.sol +221 -0
- package/package.json +83 -0
package/contracts/minter-suite/Minters/MinterSetPriceERC20/deprecated/MinterSetPriceERC20V0.sol
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-3.0-only
|
|
2
|
+
// Created By: Art Blocks Inc.
|
|
3
|
+
|
|
4
|
+
import "../../../../interfaces/0.8.x/IGenArt721CoreContractV1.sol";
|
|
5
|
+
import "../../../../interfaces/0.8.x/IMinterFilterV0.sol";
|
|
6
|
+
import "../../../../interfaces/0.8.x/IFilteredMinterV0.sol";
|
|
7
|
+
|
|
8
|
+
import "@openzeppelin-4.5/contracts/token/ERC20/IERC20.sol";
|
|
9
|
+
import "@openzeppelin-4.5/contracts/security/ReentrancyGuard.sol";
|
|
10
|
+
|
|
11
|
+
pragma solidity 0.8.9;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @title Filtered Minter contract that allows tokens to be minted with ETH
|
|
15
|
+
* or any ERC-20 token.
|
|
16
|
+
* @author Art Blocks Inc.
|
|
17
|
+
*/
|
|
18
|
+
contract MinterSetPriceERC20V0 is ReentrancyGuard, IFilteredMinterV0 {
|
|
19
|
+
/// Core contract address this minter interacts with
|
|
20
|
+
address public immutable genArt721CoreAddress;
|
|
21
|
+
|
|
22
|
+
/// This contract handles cores with interface IV1
|
|
23
|
+
IGenArt721CoreContractV1 private immutable genArtCoreContract;
|
|
24
|
+
|
|
25
|
+
/// Minter filter address this minter interacts with
|
|
26
|
+
address public immutable minterFilterAddress;
|
|
27
|
+
|
|
28
|
+
/// Minter filter this minter may interact with.
|
|
29
|
+
IMinterFilterV0 private immutable minterFilter;
|
|
30
|
+
|
|
31
|
+
/// minterType for this minter
|
|
32
|
+
string public constant minterType = "MinterSetPriceERC20V0";
|
|
33
|
+
|
|
34
|
+
uint256 constant ONE_MILLION = 1_000_000;
|
|
35
|
+
|
|
36
|
+
/// projectId => are contracts allowed to mint?
|
|
37
|
+
mapping(uint256 => bool) public contractMintable;
|
|
38
|
+
/// projectId => are tokens allowed to be minted to other addresses?
|
|
39
|
+
mapping(uint256 => bool) public purchaseToDisabled;
|
|
40
|
+
/// purchaser address => projectId => number of mints purchased
|
|
41
|
+
mapping(address => mapping(uint256 => uint256)) public projectMintCounter;
|
|
42
|
+
/// projectId => maximum number of mints a given address may invoke
|
|
43
|
+
mapping(uint256 => uint256) public projectMintLimit;
|
|
44
|
+
/// projectId => has project reached its maximum number of invocations?
|
|
45
|
+
mapping(uint256 => bool) public projectMaxHasBeenInvoked;
|
|
46
|
+
/// projectId => project's maximum number of invocations
|
|
47
|
+
mapping(uint256 => uint256) public projectMaxInvocations;
|
|
48
|
+
/// projectId => price per token in wei - supersedes any defined core price
|
|
49
|
+
mapping(uint256 => uint256) private projectIdToPricePerTokenInWei;
|
|
50
|
+
/// projectId => price per token has been configured on this minter
|
|
51
|
+
mapping(uint256 => bool) private projectIdToPriceIsConfigured;
|
|
52
|
+
/// projectId => currency symbol - supersedes any defined core value
|
|
53
|
+
mapping(uint256 => string) private projectIdToCurrencySymbol;
|
|
54
|
+
/// projectId => currency address - supersedes any defined core value
|
|
55
|
+
mapping(uint256 => address) private projectIdToCurrencyAddress;
|
|
56
|
+
|
|
57
|
+
modifier onlyCoreWhitelisted() {
|
|
58
|
+
require(
|
|
59
|
+
genArtCoreContract.isWhitelisted(msg.sender),
|
|
60
|
+
"Only Core whitelisted"
|
|
61
|
+
);
|
|
62
|
+
_;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
modifier onlyArtist(uint256 _projectId) {
|
|
66
|
+
require(
|
|
67
|
+
msg.sender ==
|
|
68
|
+
genArtCoreContract.projectIdToArtistAddress(_projectId),
|
|
69
|
+
"Only Artist"
|
|
70
|
+
);
|
|
71
|
+
_;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @notice Initializes contract to be a Filtered Minter for
|
|
76
|
+
* `_minterFilter`, integrated with Art Blocks core contract
|
|
77
|
+
* at address `_genArt721Address`.
|
|
78
|
+
* @param _genArt721Address Art Blocks core contract for which this
|
|
79
|
+
* contract will be a minter.
|
|
80
|
+
* @param _minterFilter Minter filter for which
|
|
81
|
+
* this will a filtered minter.
|
|
82
|
+
*/
|
|
83
|
+
constructor(
|
|
84
|
+
address _genArt721Address,
|
|
85
|
+
address _minterFilter
|
|
86
|
+
) ReentrancyGuard() {
|
|
87
|
+
genArt721CoreAddress = _genArt721Address;
|
|
88
|
+
genArtCoreContract = IGenArt721CoreContractV1(_genArt721Address);
|
|
89
|
+
minterFilterAddress = _minterFilter;
|
|
90
|
+
minterFilter = IMinterFilterV0(_minterFilter);
|
|
91
|
+
require(
|
|
92
|
+
minterFilter.genArt721CoreAddress() == _genArt721Address,
|
|
93
|
+
"Illegal contract pairing"
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @notice Gets your balance of the ERC-20 token currently set
|
|
99
|
+
* as the payment currency for project `_projectId`.
|
|
100
|
+
* @param _projectId Project ID to be queried.
|
|
101
|
+
* @return balance Balance of ERC-20
|
|
102
|
+
*/
|
|
103
|
+
function getYourBalanceOfProjectERC20(
|
|
104
|
+
uint256 _projectId
|
|
105
|
+
) external view returns (uint256 balance) {
|
|
106
|
+
balance = IERC20(projectIdToCurrencyAddress[_projectId]).balanceOf(
|
|
107
|
+
msg.sender
|
|
108
|
+
);
|
|
109
|
+
return balance;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @notice Gets your allowance for this minter of the ERC-20
|
|
114
|
+
* token currently set as the payment currency for project
|
|
115
|
+
* `_projectId`.
|
|
116
|
+
* @param _projectId Project ID to be queried.
|
|
117
|
+
* @return remaining Remaining allowance of ERC-20
|
|
118
|
+
*/
|
|
119
|
+
function checkYourAllowanceOfProjectERC20(
|
|
120
|
+
uint256 _projectId
|
|
121
|
+
) external view returns (uint256 remaining) {
|
|
122
|
+
remaining = IERC20(projectIdToCurrencyAddress[_projectId]).allowance(
|
|
123
|
+
msg.sender,
|
|
124
|
+
address(this)
|
|
125
|
+
);
|
|
126
|
+
return remaining;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @notice Sets the mint limit of a single purchaser for project
|
|
131
|
+
* `_projectId` to `_limit`.
|
|
132
|
+
* @param _projectId Project ID to set the mint limit for.
|
|
133
|
+
* @param _limit Number of times a given address may mint the
|
|
134
|
+
* project's tokens.
|
|
135
|
+
*/
|
|
136
|
+
function setProjectMintLimit(
|
|
137
|
+
uint256 _projectId,
|
|
138
|
+
uint8 _limit
|
|
139
|
+
) external onlyCoreWhitelisted {
|
|
140
|
+
projectMintLimit[_projectId] = _limit;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @notice Sets the maximum invocations of project `_projectId` based
|
|
145
|
+
* on the value currently defined in the core contract.
|
|
146
|
+
* @param _projectId Project ID to set the maximum invocations for.
|
|
147
|
+
* @dev also checks and may refresh projectMaxHasBeenInvoked for project
|
|
148
|
+
* @dev this enables gas reduction after maxInvocations have been reached -
|
|
149
|
+
* core contracts shall still enforce a maxInvocation check during mint.
|
|
150
|
+
*/
|
|
151
|
+
function setProjectMaxInvocations(
|
|
152
|
+
uint256 _projectId
|
|
153
|
+
) external onlyCoreWhitelisted {
|
|
154
|
+
uint256 invocations;
|
|
155
|
+
uint256 maxInvocations;
|
|
156
|
+
(, , invocations, maxInvocations, , , , , ) = genArtCoreContract
|
|
157
|
+
.projectTokenInfo(_projectId);
|
|
158
|
+
// update storage with results
|
|
159
|
+
projectMaxInvocations[_projectId] = maxInvocations;
|
|
160
|
+
if (invocations < maxInvocations) {
|
|
161
|
+
projectMaxHasBeenInvoked[_projectId] = false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @notice Toggles if contracts are allowed to mint tokens for
|
|
167
|
+
* project `_projectId`.
|
|
168
|
+
* @param _projectId Project ID to be toggled.
|
|
169
|
+
*/
|
|
170
|
+
function toggleContractMintable(
|
|
171
|
+
uint256 _projectId
|
|
172
|
+
) external onlyCoreWhitelisted {
|
|
173
|
+
contractMintable[_projectId] = !contractMintable[_projectId];
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @notice Toggles if purchases to other address are enabled for
|
|
178
|
+
* project `_projectId`.
|
|
179
|
+
* @param _projectId Project ID to be toggled.
|
|
180
|
+
*/
|
|
181
|
+
function togglePurchaseToDisabled(
|
|
182
|
+
uint256 _projectId
|
|
183
|
+
) external onlyCoreWhitelisted {
|
|
184
|
+
purchaseToDisabled[_projectId] = !purchaseToDisabled[_projectId];
|
|
185
|
+
emit PurchaseToDisabledUpdated(
|
|
186
|
+
_projectId,
|
|
187
|
+
purchaseToDisabled[_projectId]
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* @notice Updates this minter's price per token of project `_projectId`
|
|
193
|
+
* to be '_pricePerTokenInWei`, in Wei.
|
|
194
|
+
* This price supersedes any legacy core contract price per token value.
|
|
195
|
+
*/
|
|
196
|
+
function updatePricePerTokenInWei(
|
|
197
|
+
uint256 _projectId,
|
|
198
|
+
uint256 _pricePerTokenInWei
|
|
199
|
+
) external onlyArtist(_projectId) {
|
|
200
|
+
projectIdToPricePerTokenInWei[_projectId] = _pricePerTokenInWei;
|
|
201
|
+
projectIdToPriceIsConfigured[_projectId] = true;
|
|
202
|
+
emit PricePerTokenInWeiUpdated(_projectId, _pricePerTokenInWei);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* @notice Updates payment currency of project `_projectId` to be
|
|
207
|
+
* `_currencySymbol` at address `_currencyAddress`.
|
|
208
|
+
* @param _projectId Project ID to update.
|
|
209
|
+
* @param _currencySymbol Currency symbol.
|
|
210
|
+
* @param _currencyAddress Currency address.
|
|
211
|
+
*/
|
|
212
|
+
function updateProjectCurrencyInfo(
|
|
213
|
+
uint256 _projectId,
|
|
214
|
+
string memory _currencySymbol,
|
|
215
|
+
address _currencyAddress
|
|
216
|
+
) external onlyArtist(_projectId) {
|
|
217
|
+
// require null address if symbol is "ETH"
|
|
218
|
+
require(
|
|
219
|
+
(keccak256(abi.encodePacked(_currencySymbol)) ==
|
|
220
|
+
keccak256(abi.encodePacked("ETH"))) ==
|
|
221
|
+
(_currencyAddress == address(0)),
|
|
222
|
+
"ETH is only null address"
|
|
223
|
+
);
|
|
224
|
+
projectIdToCurrencySymbol[_projectId] = _currencySymbol;
|
|
225
|
+
projectIdToCurrencyAddress[_projectId] = _currencyAddress;
|
|
226
|
+
emit ProjectCurrencyInfoUpdated(
|
|
227
|
+
_projectId,
|
|
228
|
+
_currencyAddress,
|
|
229
|
+
_currencySymbol
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @notice Purchases a token from project `_projectId`.
|
|
235
|
+
* @param _projectId Project ID to mint a token on.
|
|
236
|
+
* @return tokenId Token ID of minted token
|
|
237
|
+
*/
|
|
238
|
+
function purchase(
|
|
239
|
+
uint256 _projectId
|
|
240
|
+
) external payable returns (uint256 tokenId) {
|
|
241
|
+
tokenId = purchaseTo(msg.sender, _projectId);
|
|
242
|
+
return tokenId;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* @notice Purchases a token from project `_projectId` and sets
|
|
247
|
+
* the token's owner to `_to`.
|
|
248
|
+
* @param _to Address to be the new token's owner.
|
|
249
|
+
* @param _projectId Project ID to mint a token on.
|
|
250
|
+
* @return tokenId Token ID of minted token
|
|
251
|
+
*/
|
|
252
|
+
function purchaseTo(
|
|
253
|
+
address _to,
|
|
254
|
+
uint256 _projectId
|
|
255
|
+
) public payable nonReentrant returns (uint256 tokenId) {
|
|
256
|
+
// CHECKS
|
|
257
|
+
require(
|
|
258
|
+
!projectMaxHasBeenInvoked[_projectId],
|
|
259
|
+
"Maximum number of invocations reached"
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
// require artist to have configured price of token on this minter
|
|
263
|
+
require(
|
|
264
|
+
projectIdToPriceIsConfigured[_projectId],
|
|
265
|
+
"Price not configured"
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
// if contract filter is off, allow calls from another contract
|
|
269
|
+
if (!contractMintable[_projectId]) {
|
|
270
|
+
require(msg.sender == tx.origin, "No Contract Buys");
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// if purchaseTo is disabled, enforce purchase destination to be the TX
|
|
274
|
+
// sending address.
|
|
275
|
+
if (purchaseToDisabled[_projectId]) {
|
|
276
|
+
require(msg.sender == _to, "No `purchaseTo` Allowed");
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// limit mints per address by project
|
|
280
|
+
if (projectMintLimit[_projectId] > 0) {
|
|
281
|
+
require(
|
|
282
|
+
projectMintCounter[msg.sender][_projectId] <
|
|
283
|
+
projectMintLimit[_projectId],
|
|
284
|
+
"Reached minting limit"
|
|
285
|
+
);
|
|
286
|
+
// EFFECTS
|
|
287
|
+
projectMintCounter[msg.sender][_projectId]++;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
tokenId = minterFilter.mint(_to, _projectId, msg.sender);
|
|
291
|
+
// what if projectMaxInvocations[_projectId] is 0 (default value)?
|
|
292
|
+
// that is intended, so that by default the minter allows infinite transactions,
|
|
293
|
+
// allowing the artblocks contract to stop minting
|
|
294
|
+
// uint256 tokenInvocation = tokenId % ONE_MILLION;
|
|
295
|
+
if (
|
|
296
|
+
projectMaxInvocations[_projectId] > 0 &&
|
|
297
|
+
tokenId % ONE_MILLION == projectMaxInvocations[_projectId] - 1
|
|
298
|
+
) {
|
|
299
|
+
projectMaxHasBeenInvoked[_projectId] = true;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// INTERACTIONS
|
|
303
|
+
if (projectIdToCurrencyAddress[_projectId] != address(0)) {
|
|
304
|
+
require(
|
|
305
|
+
msg.value == 0,
|
|
306
|
+
"this project accepts a different currency and cannot accept ETH"
|
|
307
|
+
);
|
|
308
|
+
require(
|
|
309
|
+
IERC20(projectIdToCurrencyAddress[_projectId]).allowance(
|
|
310
|
+
msg.sender,
|
|
311
|
+
address(this)
|
|
312
|
+
) >= projectIdToPricePerTokenInWei[_projectId],
|
|
313
|
+
"Insufficient Funds Approved for TX"
|
|
314
|
+
);
|
|
315
|
+
require(
|
|
316
|
+
IERC20(projectIdToCurrencyAddress[_projectId]).balanceOf(
|
|
317
|
+
msg.sender
|
|
318
|
+
) >= projectIdToPricePerTokenInWei[_projectId],
|
|
319
|
+
"Insufficient balance."
|
|
320
|
+
);
|
|
321
|
+
_splitFundsERC20(_projectId);
|
|
322
|
+
} else {
|
|
323
|
+
require(
|
|
324
|
+
msg.value >= projectIdToPricePerTokenInWei[_projectId],
|
|
325
|
+
"Must send minimum value to mint!"
|
|
326
|
+
);
|
|
327
|
+
_splitFundsETH(_projectId);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return tokenId;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* @dev splits ETH funds between sender (if refund), foundation,
|
|
335
|
+
* artist, and artist's additional payee for a token purchased on
|
|
336
|
+
* project `_projectId`.
|
|
337
|
+
* @dev utilizes transfer() to send ETH, so access lists may need to be
|
|
338
|
+
* populated when purchasing tokens.
|
|
339
|
+
*/
|
|
340
|
+
function _splitFundsETH(uint256 _projectId) internal {
|
|
341
|
+
if (msg.value > 0) {
|
|
342
|
+
uint256 pricePerTokenInWei = projectIdToPricePerTokenInWei[
|
|
343
|
+
_projectId
|
|
344
|
+
];
|
|
345
|
+
uint256 refund = msg.value - pricePerTokenInWei;
|
|
346
|
+
if (refund > 0) {
|
|
347
|
+
(bool success_, ) = msg.sender.call{value: refund}("");
|
|
348
|
+
require(success_, "Refund failed");
|
|
349
|
+
}
|
|
350
|
+
uint256 foundationAmount = (pricePerTokenInWei *
|
|
351
|
+
genArtCoreContract.artblocksPercentage()) / 100;
|
|
352
|
+
if (foundationAmount > 0) {
|
|
353
|
+
(bool success_, ) = genArtCoreContract.artblocksAddress().call{
|
|
354
|
+
value: foundationAmount
|
|
355
|
+
}("");
|
|
356
|
+
require(success_, "Foundation payment failed");
|
|
357
|
+
}
|
|
358
|
+
uint256 projectFunds = pricePerTokenInWei - foundationAmount;
|
|
359
|
+
uint256 additionalPayeeAmount;
|
|
360
|
+
if (
|
|
361
|
+
genArtCoreContract.projectIdToAdditionalPayeePercentage(
|
|
362
|
+
_projectId
|
|
363
|
+
) > 0
|
|
364
|
+
) {
|
|
365
|
+
additionalPayeeAmount =
|
|
366
|
+
(projectFunds *
|
|
367
|
+
genArtCoreContract.projectIdToAdditionalPayeePercentage(
|
|
368
|
+
_projectId
|
|
369
|
+
)) /
|
|
370
|
+
100;
|
|
371
|
+
if (additionalPayeeAmount > 0) {
|
|
372
|
+
(bool success_, ) = genArtCoreContract
|
|
373
|
+
.projectIdToAdditionalPayee(_projectId)
|
|
374
|
+
.call{value: additionalPayeeAmount}("");
|
|
375
|
+
require(success_, "Additional payment failed");
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
uint256 creatorFunds = projectFunds - additionalPayeeAmount;
|
|
379
|
+
if (creatorFunds > 0) {
|
|
380
|
+
(bool success_, ) = genArtCoreContract
|
|
381
|
+
.projectIdToArtistAddress(_projectId)
|
|
382
|
+
.call{value: creatorFunds}("");
|
|
383
|
+
require(success_, "Artist payment failed");
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* @dev splits ERC-20 funds between foundation, artist, and artist's
|
|
390
|
+
* additional payee, for a token purchased on project `_projectId`.
|
|
391
|
+
*/
|
|
392
|
+
function _splitFundsERC20(uint256 _projectId) internal {
|
|
393
|
+
uint256 pricePerTokenInWei = projectIdToPricePerTokenInWei[_projectId];
|
|
394
|
+
uint256 foundationAmount = (pricePerTokenInWei *
|
|
395
|
+
genArtCoreContract.artblocksPercentage()) / 100;
|
|
396
|
+
if (foundationAmount > 0) {
|
|
397
|
+
IERC20(projectIdToCurrencyAddress[_projectId]).transferFrom(
|
|
398
|
+
msg.sender,
|
|
399
|
+
genArtCoreContract.artblocksAddress(),
|
|
400
|
+
foundationAmount
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
uint256 projectFunds = pricePerTokenInWei - foundationAmount;
|
|
404
|
+
uint256 additionalPayeeAmount;
|
|
405
|
+
if (
|
|
406
|
+
genArtCoreContract.projectIdToAdditionalPayeePercentage(
|
|
407
|
+
_projectId
|
|
408
|
+
) > 0
|
|
409
|
+
) {
|
|
410
|
+
additionalPayeeAmount =
|
|
411
|
+
(projectFunds *
|
|
412
|
+
genArtCoreContract.projectIdToAdditionalPayeePercentage(
|
|
413
|
+
_projectId
|
|
414
|
+
)) /
|
|
415
|
+
100;
|
|
416
|
+
if (additionalPayeeAmount > 0) {
|
|
417
|
+
IERC20(projectIdToCurrencyAddress[_projectId]).transferFrom(
|
|
418
|
+
msg.sender,
|
|
419
|
+
genArtCoreContract.projectIdToAdditionalPayee(_projectId),
|
|
420
|
+
additionalPayeeAmount
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
uint256 creatorFunds = projectFunds - additionalPayeeAmount;
|
|
425
|
+
if (creatorFunds > 0) {
|
|
426
|
+
IERC20(projectIdToCurrencyAddress[_projectId]).transferFrom(
|
|
427
|
+
msg.sender,
|
|
428
|
+
genArtCoreContract.projectIdToArtistAddress(_projectId),
|
|
429
|
+
creatorFunds
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* @notice Gets if price of token is configured, price of minting a
|
|
436
|
+
* token on project `_projectId`, and currency symbol and address to be
|
|
437
|
+
* used as payment. Supersedes any core contract price information.
|
|
438
|
+
* @param _projectId Project ID to get price information for.
|
|
439
|
+
* @return isConfigured true only if token price has been configured on
|
|
440
|
+
* this minter
|
|
441
|
+
* @return tokenPriceInWei current price of token on this minter - invalid
|
|
442
|
+
* if price has not yet been configured
|
|
443
|
+
* @return currencySymbol currency symbol for purchases of project on this
|
|
444
|
+
* minter. "ETH" reserved for ether.
|
|
445
|
+
* @return currencyAddress currency address for purchases of project on
|
|
446
|
+
* this minter. Null address reserved for ether.
|
|
447
|
+
*/
|
|
448
|
+
function getPriceInfo(
|
|
449
|
+
uint256 _projectId
|
|
450
|
+
)
|
|
451
|
+
external
|
|
452
|
+
view
|
|
453
|
+
returns (
|
|
454
|
+
bool isConfigured,
|
|
455
|
+
uint256 tokenPriceInWei,
|
|
456
|
+
string memory currencySymbol,
|
|
457
|
+
address currencyAddress
|
|
458
|
+
)
|
|
459
|
+
{
|
|
460
|
+
isConfigured = projectIdToPriceIsConfigured[_projectId];
|
|
461
|
+
tokenPriceInWei = projectIdToPricePerTokenInWei[_projectId];
|
|
462
|
+
currencyAddress = projectIdToCurrencyAddress[_projectId];
|
|
463
|
+
if (currencyAddress == address(0)) {
|
|
464
|
+
// defaults to ETH
|
|
465
|
+
currencySymbol = "ETH";
|
|
466
|
+
} else {
|
|
467
|
+
currencySymbol = projectIdToCurrencySymbol[_projectId];
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-3.0-only
|
|
2
|
+
pragma solidity 0.8.17;
|
|
3
|
+
|
|
4
|
+
// Created By: Art Blocks Inc.
|
|
5
|
+
|
|
6
|
+
import "../libs/0.8.x/BytecodeStorage.sol";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @title Art Blocks BytecodeTextCR_DMock.
|
|
10
|
+
* @author Art Blocks Inc.
|
|
11
|
+
* @notice This contract serves as a mock client of the BytecodeStorage library
|
|
12
|
+
* to allow for more granular testing of this library than is supported
|
|
13
|
+
* by the usage of the library directly by specific current Art Blocks
|
|
14
|
+
* client smart contracts, such as the `GenArt721CoreV3` contract. This
|
|
15
|
+
* mock exposes the CR_D (create, read, _not updates_, delete)
|
|
16
|
+
* operations that the underlying BytecodeStorage library allows clients
|
|
17
|
+
* to support.
|
|
18
|
+
* Note that because updates can only functionally be performed by
|
|
19
|
+
* combining a "delete" and "create" operation, given that deployed
|
|
20
|
+
* contracts cannot be _updated_ directly in chain-state, this mock does
|
|
21
|
+
* not expose updates (the usual "U" in "CRUD") as they are not
|
|
22
|
+
* supported by the underlying library.
|
|
23
|
+
*/
|
|
24
|
+
contract BytecodeTextCR_DMock {
|
|
25
|
+
using BytecodeStorage for string;
|
|
26
|
+
using BytecodeStorage for address;
|
|
27
|
+
|
|
28
|
+
// monotonically increasing slot counter and associated slot-storage mapping
|
|
29
|
+
uint256 public nextTextSlotId = 0;
|
|
30
|
+
mapping(uint256 => address) public storedTextBytecodeAddresses;
|
|
31
|
+
|
|
32
|
+
// save deployer address to support basic ACL checks for non-read operations
|
|
33
|
+
address public deployerAddress;
|
|
34
|
+
|
|
35
|
+
modifier onlyDeployer() {
|
|
36
|
+
require(msg.sender == deployerAddress, "Only deployer");
|
|
37
|
+
_;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @notice Initializes contract.
|
|
42
|
+
*/
|
|
43
|
+
constructor() {
|
|
44
|
+
deployerAddress = msg.sender;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/*//////////////////////////////////////////////////////////////
|
|
48
|
+
Create Read _ Delete
|
|
49
|
+
//////////////////////////////////////////////////////////////*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @notice "Create": Adds a chunk of text to be stored to chain-state.
|
|
53
|
+
* @param _text Text to be created in chain-state.
|
|
54
|
+
* @return uint256 Slot that the written bytecode contract address was
|
|
55
|
+
* stored in.
|
|
56
|
+
* @dev Intentionally do not perform input validation, instead allowing
|
|
57
|
+
* the underlying BytecodeStorage lib to throw errors where applicable.
|
|
58
|
+
*/
|
|
59
|
+
function createText(
|
|
60
|
+
string memory _text
|
|
61
|
+
) external onlyDeployer returns (uint256) {
|
|
62
|
+
// store text in contract bytecode
|
|
63
|
+
storedTextBytecodeAddresses[nextTextSlotId] = _text.writeToBytecode();
|
|
64
|
+
// record written slot before incrementing
|
|
65
|
+
uint256 textSlotId = nextTextSlotId;
|
|
66
|
+
nextTextSlotId++;
|
|
67
|
+
return textSlotId;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @notice "Read": Reads chunk of text currently in the provided slot, from
|
|
72
|
+
* chain-state.
|
|
73
|
+
* @param _textSlotId Slot (associated with this contract) for which to
|
|
74
|
+
* read text content.
|
|
75
|
+
* @return string Content read from contract bytecode in the given slot.
|
|
76
|
+
* @dev Intentionally do not perform input validation, instead allowing
|
|
77
|
+
* the underlying BytecodeStorage lib to throw errors where applicable.
|
|
78
|
+
*/
|
|
79
|
+
function readText(uint256 _textSlotId) public view returns (string memory) {
|
|
80
|
+
return storedTextBytecodeAddresses[_textSlotId].readFromBytecode();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @notice "Delete": Deletes chunk of text currently in the provided slot,
|
|
85
|
+
* from chain-state.
|
|
86
|
+
* @param _textSlotId Slot (associated with this contract) for which to
|
|
87
|
+
* delete text content.
|
|
88
|
+
* @dev Intentionally do not perform input validation, instead allowing
|
|
89
|
+
* the underlying BytecodeStorage lib to throw errors where applicable.
|
|
90
|
+
*/
|
|
91
|
+
function deleteText(uint256 _textSlotId) external onlyDeployer {
|
|
92
|
+
// purge old contract bytecode contract from the blockchain state
|
|
93
|
+
storedTextBytecodeAddresses[_textSlotId].purgeBytecode();
|
|
94
|
+
// delete reference to contract address that no longer exists
|
|
95
|
+
delete storedTextBytecodeAddresses[_textSlotId];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/*//////////////////////////////////////////////////////////////
|
|
99
|
+
Additional Introspection
|
|
100
|
+
//////////////////////////////////////////////////////////////*/
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @notice Allows additional read introspection, to read a chunk of text,
|
|
104
|
+
* from chain-state that lives at a given deployed address.
|
|
105
|
+
* @param _bytecodeAddress address from which to read text content.
|
|
106
|
+
* @return string Content read from contract bytecode at the given address.
|
|
107
|
+
* @dev Intentionally do not perform input validation, instead allowing
|
|
108
|
+
* the underlying BytecodeStorage lib to throw errors where applicable.
|
|
109
|
+
*/
|
|
110
|
+
function readTextAtAddress(
|
|
111
|
+
address _bytecodeAddress
|
|
112
|
+
) public view returns (string memory) {
|
|
113
|
+
return _bytecodeAddress.readFromBytecode();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @notice Allows introspection of who deployed a given contracts-as-storage
|
|
118
|
+
* contract, based on a provided `_bytecodeAddress`.
|
|
119
|
+
* @param _bytecodeAddress address for which to read the author address.
|
|
120
|
+
* @return address of the author who wrote the data contained in the
|
|
121
|
+
* given `_bytecodeAddress` contract.
|
|
122
|
+
* @dev Intentionally do not perform input validation, instead allowing
|
|
123
|
+
* the underlying BytecodeStorage lib to throw errors where applicable.
|
|
124
|
+
*/
|
|
125
|
+
function readAuthorForTextAtAddress(
|
|
126
|
+
address _bytecodeAddress
|
|
127
|
+
) public view returns (address) {
|
|
128
|
+
return _bytecodeAddress.getWriterAddressForBytecode();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @notice Allows additional delete introspection, to delete a chunk of text,
|
|
133
|
+
* from chain-state that lives at a given deployed address.
|
|
134
|
+
* @param _bytecodeAddress address from which to delete text content.
|
|
135
|
+
* @dev Intentionally do not perform input validation, instead allowing
|
|
136
|
+
* the underlying BytecodeStorage lib to throw errors where applicable.
|
|
137
|
+
*/
|
|
138
|
+
function deleteTextAtAddress(
|
|
139
|
+
address _bytecodeAddress
|
|
140
|
+
) external onlyDeployer {
|
|
141
|
+
// purge old contract bytecode contract from the blockchain state
|
|
142
|
+
_bytecodeAddress.purgeBytecode();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @notice Allows additional internal purge-logic introspection, by allowing
|
|
147
|
+
* for the sending of arbitrary data from this contract to the
|
|
148
|
+
* provided existing `_bytecodeAddress`.
|
|
149
|
+
* @param _bytecodeAddress address for which to send call data.
|
|
150
|
+
* @param _data aribtrary data to send as call-data for raw `.call`.
|
|
151
|
+
* @dev WARNING - THIS IS NOT SECURE AND SHOULD NOT BE USED IN PRODUCTION.
|
|
152
|
+
*/
|
|
153
|
+
function callWithNonsenseData(
|
|
154
|
+
address _bytecodeAddress,
|
|
155
|
+
bytes memory _data
|
|
156
|
+
) external onlyDeployer {
|
|
157
|
+
(bool success /* `data` not needed */, ) = _bytecodeAddress.call(_data);
|
|
158
|
+
if (success) {
|
|
159
|
+
// WARNING - This implementation does not make use of the low-level
|
|
160
|
+
// call return result indicating success/failure. This is
|
|
161
|
+
// contrary to best practice but is OK in this instance as
|
|
162
|
+
// this method IS NOT SECURE AND SHOULD NOT BE USED IN
|
|
163
|
+
// PRODUCTION under any normal circumstances.
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @notice Allows additional internal purge-logic introspection, by allowing
|
|
169
|
+
* for the sending of raw calls (with no data) from this contract to
|
|
170
|
+
* the provided existing `_bytecodeAddress`.
|
|
171
|
+
* @param _bytecodeAddress address for which to send call data.
|
|
172
|
+
* @dev WARNING - THIS IS NOT SECURE AND SHOULD NOT BE USED IN PRODUCTION.
|
|
173
|
+
*/
|
|
174
|
+
function callWithoutData(address _bytecodeAddress) external onlyDeployer {
|
|
175
|
+
(bool success /* `data` not needed */, ) = _bytecodeAddress.call("");
|
|
176
|
+
if (success) {
|
|
177
|
+
// WARNING - This implementation does not make use of the low-level
|
|
178
|
+
// call return result indicating success/failure. This is
|
|
179
|
+
// contrary to best practice but is OK in this instance as
|
|
180
|
+
// this method IS NOT SECURE AND SHOULD NOT BE USED IN
|
|
181
|
+
// PRODUCTION under any normal circumstances.
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-3.0-only
|
|
2
|
+
|
|
3
|
+
pragma solidity 0.8.17;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @notice This reverts when receiving Ether
|
|
7
|
+
* @dev Mock contract for testing purposes.
|
|
8
|
+
*/
|
|
9
|
+
contract DeadReceiverMock {
|
|
10
|
+
receive() external payable {
|
|
11
|
+
revert("DeadReceiverMock: I am dead");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
import "@openzeppelin-4.5/contracts/token/ERC20/ERC20.sol";
|
|
6
|
+
|
|
7
|
+
contract ERC20Mock is ERC20 {
|
|
8
|
+
constructor(uint256 initialSupply) ERC20("Mock Token", "MOCK") {
|
|
9
|
+
_mint(msg.sender, initialSupply);
|
|
10
|
+
}
|
|
11
|
+
}
|