@artblocks/contracts 0.0.1 → 1.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.
Files changed (138) hide show
  1. package/README.md +30 -11
  2. package/artifacts/contracts/AdminACLV1.sol/AdminACLV1.json +2 -2
  3. package/artifacts/contracts/BasicPolyptychRandomizerV0.sol/BasicPolyptychRandomizerV0.json +229 -0
  4. package/artifacts/contracts/BasicRandomizerV2.sol/BasicRandomizerV2.json +3 -3
  5. package/artifacts/contracts/GenArt721CoreV3.sol/GenArt721CoreV3.json +2 -2
  6. package/artifacts/contracts/GenArt721CoreV3_Engine.sol/GenArt721CoreV3_Engine.json +2 -2
  7. package/artifacts/contracts/archive/GenArt721CoreV0.sol/Address.json +10 -0
  8. package/artifacts/contracts/archive/GenArt721CoreV0.sol/Counters.json +10 -0
  9. package/artifacts/contracts/archive/GenArt721CoreV0.sol/CustomERC721Metadata.json +425 -0
  10. package/artifacts/contracts/archive/GenArt721CoreV0.sol/ERC165.json +38 -0
  11. package/artifacts/contracts/archive/GenArt721CoreV0.sol/ERC721.json +322 -0
  12. package/artifacts/contracts/archive/GenArt721CoreV0.sol/ERC721Enumerable.json +384 -0
  13. package/artifacts/contracts/archive/GenArt721CoreV0.sol/ERC721ReceiverMock.json +101 -0
  14. package/artifacts/contracts/archive/GenArt721CoreV0.sol/GenArt721.json +1528 -0
  15. package/artifacts/contracts/archive/GenArt721CoreV0.sol/IERC165.json +32 -0
  16. package/artifacts/contracts/archive/GenArt721CoreV0.sol/IERC721.json +316 -0
  17. package/artifacts/contracts/archive/GenArt721CoreV0.sol/IERC721Enumerable.json +378 -0
  18. package/artifacts/contracts/archive/GenArt721CoreV0.sol/IERC721Receiver.json +47 -0
  19. package/artifacts/contracts/archive/GenArt721CoreV0.sol/SafeMath.json +10 -0
  20. package/artifacts/contracts/archive/GenArt721CoreV0.sol/Strings.json +10 -0
  21. package/artifacts/contracts/archive/GenArt721CoreV1.sol/Address.json +10 -0
  22. package/artifacts/contracts/archive/GenArt721CoreV1.sol/Counters.json +10 -0
  23. package/artifacts/contracts/archive/GenArt721CoreV1.sol/CustomERC721Metadata.json +425 -0
  24. package/artifacts/contracts/archive/GenArt721CoreV1.sol/ERC165.json +38 -0
  25. package/artifacts/contracts/archive/GenArt721CoreV1.sol/ERC721.json +322 -0
  26. package/artifacts/contracts/archive/GenArt721CoreV1.sol/ERC721Enumerable.json +384 -0
  27. package/artifacts/contracts/archive/GenArt721CoreV1.sol/GenArt721Core.json +1773 -0
  28. package/artifacts/contracts/archive/GenArt721CoreV1.sol/IERC165.json +32 -0
  29. package/artifacts/contracts/archive/GenArt721CoreV1.sol/IERC721.json +316 -0
  30. package/artifacts/contracts/archive/GenArt721CoreV1.sol/IERC721Enumerable.json +378 -0
  31. package/artifacts/contracts/archive/GenArt721CoreV1.sol/IERC721Receiver.json +47 -0
  32. package/artifacts/contracts/archive/GenArt721CoreV1.sol/Randomizer.json +26 -0
  33. package/artifacts/contracts/archive/GenArt721CoreV1.sol/SafeMath.json +10 -0
  34. package/artifacts/contracts/archive/GenArt721CoreV1.sol/Strings.json +10 -0
  35. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV0.sol/MinterDAExpV0.json +575 -0
  36. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV1.sol/MinterDAExpV1.json +463 -0
  37. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExp/MinterDAExpV2.sol/MinterDAExpV2.json +3 -3
  38. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExp/MinterDAExpV3.sol/MinterDAExpV3.json +3 -3
  39. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol/MinterDAExpSettlementV0.json +15 -15
  40. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV1.sol/MinterDAExpSettlementV1.json +1066 -0
  41. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV0.sol/MinterDALinV0.json +551 -0
  42. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV1.sol/MinterDALinV1.json +439 -0
  43. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDALin/MinterDALinV2.sol/MinterDALinV2.json +3 -3
  44. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDALin/MinterDALinV3.sol/MinterDALinV3.json +3 -3
  45. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV0.sol/MinterHolderV0.json +622 -0
  46. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV1.sol/MinterHolderV1.json +719 -0
  47. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV2.sol/MinterHolderV2.json +794 -0
  48. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterHolder/MinterHolderV3.sol/MinterHolderV3.json +3 -3
  49. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV0.sol/MinterMerkleV0.json +873 -0
  50. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV1.sol/MinterMerkleV1.json +932 -0
  51. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV2.sol/MinterMerkleV2.json +984 -0
  52. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterMerkle/MinterMerkleV3.sol/MinterMerkleV3.json +3 -3
  53. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterMerkle/MinterMerkleV4.sol/MinterMerkleV4.json +3 -3
  54. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV0.sol/MinterSetPriceV0.json +400 -0
  55. package/artifacts/contracts/{minter-suite/Minters/MinterSetPrice/deprecated → archive/minter-suite/Minters/MinterSetPrice}/MinterSetPriceV1.sol/MinterSetPriceV1.json +3 -3
  56. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPrice/MinterSetPriceV2.sol/MinterSetPriceV2.json +3 -3
  57. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPrice/MinterSetPriceV3.sol/MinterSetPriceV3.json +3 -3
  58. package/artifacts/contracts/{minter-suite/Minters/MinterSetPriceERC20/deprecated → archive/minter-suite/Minters/MinterSetPriceERC20}/MinterSetPriceERC20V0.sol/MinterSetPriceERC20V0.json +3 -3
  59. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V1.sol/MinterSetPriceERC20V1.json +349 -0
  60. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol/MinterSetPriceERC20V2.json +3 -3
  61. package/artifacts/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol/MinterSetPriceERC20V3.json +3 -3
  62. package/artifacts/contracts/explorations/GenArt721CoreV3_Explorations.sol/GenArt721CoreV3_Explorations.json +2 -2
  63. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV0.sol/IFilteredMinterDAExpSettlementV0.json +12 -12
  64. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV1.sol/IFilteredMinterDAExpSettlementV1.json +767 -0
  65. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlement_Mixin.sol/IFilteredMinterDAExpSettlement_Mixin.json +161 -0
  66. package/artifacts/contracts/interfaces/0.8.x/IMinterBaseV0.sol/IMinterBaseV0.json +24 -0
  67. package/artifacts/contracts/interfaces/0.8.x/IMinterFilterV0.sol/IMinterFilterV0.json +6 -0
  68. package/artifacts/contracts/interfaces/0.8.x/IMintingAPICoreV0.sol/IMintingAPICoreV0.json +185 -0
  69. package/artifacts/contracts/interfaces/0.8.x/IMintingAPIMinterV0.sol/IMintingAPIMinterV0.json +88 -0
  70. package/artifacts/contracts/interfaces/0.8.x/IRandomizerPolyptychV0.sol/IRandomizerPolyptychV0.json +87 -0
  71. package/artifacts/contracts/interfaces/0.8.x/IRandomizerV2.sol/IRandomizerV2.json +1 -1
  72. package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV0.sol/MinterFilterV0.json +8 -2
  73. package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV1.sol/MinterFilterV1.json +34 -2
  74. package/artifacts/contracts/minter-suite/Minters/MinterBase_v0_1_1.sol/MinterBase.json +24 -0
  75. package/artifacts/contracts/minter-suite/Minters/MinterDAExpSettlementV2.sol/MinterDAExpSettlementV2.json +1127 -0
  76. package/artifacts/contracts/minter-suite/Minters/MinterDAExpV4.sol/MinterDAExpV4.json +882 -0
  77. package/artifacts/contracts/minter-suite/Minters/MinterDALinV4.sol/MinterDALinV4.json +858 -0
  78. package/artifacts/contracts/minter-suite/Minters/MinterHolderV4.sol/MinterHolderV4.json +1126 -0
  79. package/artifacts/contracts/minter-suite/Minters/MinterMerkleV5.sol/MinterMerkleV5.json +1065 -0
  80. package/artifacts/contracts/minter-suite/Minters/MinterPolyptychV0.sol/IGenArt721CoreContractV3WithRandomizer.json +662 -0
  81. package/artifacts/contracts/minter-suite/Minters/MinterPolyptychV0.sol/MinterPolyptychV0.json +1268 -0
  82. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20V4.sol/MinterSetPriceERC20V4.json +768 -0
  83. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceV4.sol/MinterSetPriceV4.json +697 -0
  84. package/artifacts/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol/GenArt721CoreV3_Engine_IncorrectCoreType.json +1817 -0
  85. package/artifacts/contracts/mock/RandomizerV2_NoAssignMock.sol/RandomizerV2_NoAssignMock.json +3 -3
  86. package/contracts/BasicPolyptychRandomizerV0.sol +126 -0
  87. package/contracts/BasicRandomizerV2.sol +3 -3
  88. package/contracts/archive/GenArt721CoreV0.sol +1621 -0
  89. package/contracts/archive/GenArt721CoreV1.sol +1577 -0
  90. package/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV0.sol +503 -0
  91. package/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV1.sol +442 -0
  92. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExp/MinterDAExpV2.sol +3 -3
  93. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExp/MinterDAExpV3.sol +3 -3
  94. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol +3 -3
  95. package/contracts/archive/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV1.sol +1026 -0
  96. package/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV0.sol +450 -0
  97. package/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV1.sol +406 -0
  98. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDALin/MinterDALinV2.sol +3 -3
  99. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterDALin/MinterDALinV3.sol +3 -3
  100. package/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV0.sol +540 -0
  101. package/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV1.sol +648 -0
  102. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterHolder/MinterHolderV2.sol +6 -6
  103. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterHolder/MinterHolderV3.sol +4 -4
  104. package/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV0.sol +523 -0
  105. package/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV1.sol +602 -0
  106. package/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV2.sol +679 -0
  107. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterMerkle/MinterMerkleV3.sol +4 -4
  108. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterMerkle/MinterMerkleV4.sol +4 -4
  109. package/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV0.sol +333 -0
  110. package/contracts/{minter-suite/Minters/MinterSetPrice/deprecated → archive/minter-suite/Minters/MinterSetPrice}/MinterSetPriceV1.sol +0 -0
  111. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPrice/MinterSetPriceV2.sol +3 -3
  112. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPrice/MinterSetPriceV3.sol +3 -3
  113. package/contracts/{minter-suite/Minters/MinterSetPriceERC20/deprecated → archive/minter-suite/Minters/MinterSetPriceERC20}/MinterSetPriceERC20V0.sol +0 -0
  114. package/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V1.sol +411 -0
  115. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol +3 -3
  116. package/contracts/{minter-suite → archive/minter-suite}/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol +3 -3
  117. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV0.sol +4 -53
  118. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV1.sol +21 -0
  119. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlement_Mixin.sol +62 -0
  120. package/contracts/interfaces/0.8.x/IMinterBaseV0.sol +20 -0
  121. package/contracts/interfaces/0.8.x/IMinterFilterV0.sol +6 -0
  122. package/contracts/interfaces/0.8.x/IMintingAPICoreV0.sol +62 -0
  123. package/contracts/interfaces/0.8.x/IMintingAPIMinterV0.sol +31 -0
  124. package/contracts/interfaces/0.8.x/IRandomizerPolyptychV0.sol +31 -0
  125. package/contracts/interfaces/0.8.x/IRandomizerV2.sol +5 -2
  126. package/contracts/minter-suite/MinterFilter/MinterFilterV1.sol +18 -0
  127. package/contracts/minter-suite/Minters/MinterBase_v0_1_1.sol +293 -0
  128. package/contracts/minter-suite/Minters/MinterDAExpSettlementV2.sol +1312 -0
  129. package/contracts/minter-suite/Minters/MinterDAExpV4.sol +600 -0
  130. package/contracts/minter-suite/Minters/MinterDALinV4.sol +552 -0
  131. package/contracts/minter-suite/Minters/MinterHolderV4.sol +781 -0
  132. package/contracts/minter-suite/Minters/MinterMerkleV5.sol +717 -0
  133. package/contracts/minter-suite/Minters/MinterPolyptychV0.sol +998 -0
  134. package/contracts/minter-suite/Minters/MinterSetPriceERC20V4.sol +480 -0
  135. package/contracts/minter-suite/Minters/MinterSetPriceV4.sol +380 -0
  136. package/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol +1979 -0
  137. package/package.json +8 -2
  138. package/artifacts/contracts/minter-suite/Minters/MinterHolder/MinterHolderV2.sol/MinterHolderV2.json +0 -794
@@ -0,0 +1,480 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Created By: Art Blocks Inc.
3
+
4
+ import "../../interfaces/0.8.x/IGenArt721CoreContractV3_Base.sol";
5
+ import "../../interfaces/0.8.x/IGenArt721CoreContractV3.sol";
6
+ import "../../interfaces/0.8.x/IGenArt721CoreContractV3_Engine.sol";
7
+ import "../../interfaces/0.8.x/IMinterFilterV0.sol";
8
+ import "../../interfaces/0.8.x/IFilteredMinterV2.sol";
9
+ import "./MinterBase_v0_1_1.sol";
10
+
11
+ import "@openzeppelin-4.5/contracts/security/ReentrancyGuard.sol";
12
+
13
+ pragma solidity 0.8.17;
14
+
15
+ /**
16
+ * @title Filtered Minter contract that allows tokens to be minted with ETH
17
+ * or any ERC-20 token.
18
+ * This is designed to be used with GenArt721CoreContractV3 flagship or
19
+ * engine contracts.
20
+ * @author Art Blocks Inc.
21
+ * @notice Privileged Roles and Ownership:
22
+ * This contract is designed to be managed, with limited powers.
23
+ * Privileged roles and abilities are controlled by the project's artist, which
24
+ * can be modified by the core contract's Admin ACL contract. Both of these
25
+ * roles hold extensive power and can modify minter details.
26
+ * Care must be taken to ensure that the admin ACL contract and artist
27
+ * addresses are secure behind a multi-sig or other access control mechanism.
28
+ * ----------------------------------------------------------------------------
29
+ * The following functions are restricted to a project's artist:
30
+ * - updatePricePerTokenInWei
31
+ * - updateProjectCurrencyInfo
32
+ * - setProjectMaxInvocations
33
+ * - manuallyLimitProjectMaxInvocations
34
+ * ----------------------------------------------------------------------------
35
+ * Additional admin and artist privileged roles may be described on other
36
+ * contracts that this minter integrates with.
37
+ */
38
+ contract MinterSetPriceERC20V4 is
39
+ ReentrancyGuard,
40
+ MinterBase,
41
+ IFilteredMinterV2
42
+ {
43
+ /// Core contract address this minter interacts with
44
+ address public immutable genArt721CoreAddress;
45
+
46
+ /// The core contract integrates with V3 contracts
47
+ IGenArt721CoreContractV3_Base private immutable genArtCoreContract_Base;
48
+
49
+ /// Minter filter address this minter interacts with
50
+ address public immutable minterFilterAddress;
51
+
52
+ /// Minter filter this minter may interact with.
53
+ IMinterFilterV0 private immutable minterFilter;
54
+
55
+ /// minterType for this minter
56
+ string public constant minterType = "MinterSetPriceERC20V4";
57
+
58
+ /// minter version for this minter
59
+ string public constant minterVersion = "v4.1.0";
60
+
61
+ uint256 constant ONE_MILLION = 1_000_000;
62
+
63
+ struct ProjectConfig {
64
+ bool maxHasBeenInvoked;
65
+ bool priceIsConfigured;
66
+ uint24 maxInvocations;
67
+ address currencyAddress;
68
+ uint256 pricePerTokenInWei;
69
+ string currencySymbol;
70
+ }
71
+
72
+ mapping(uint256 => ProjectConfig) public projectConfig;
73
+
74
+ // /// projectId => currency symbol - supersedes any defined core value
75
+ // mapping(uint256 => string) private projectIdToCurrencySymbol;
76
+ // /// projectId => currency address - supersedes any defined core value
77
+ // mapping(uint256 => address) private projectIdToCurrencyAddress;
78
+
79
+ modifier onlyArtist(uint256 _projectId) {
80
+ require(
81
+ msg.sender ==
82
+ genArtCoreContract_Base.projectIdToArtistAddress(_projectId),
83
+ "Only Artist"
84
+ );
85
+ _;
86
+ }
87
+
88
+ /**
89
+ * @notice Initializes contract to be a Filtered Minter for
90
+ * `_minterFilter`, integrated with Art Blocks core contract
91
+ * at address `_genArt721Address`.
92
+ * @param _genArt721Address Art Blocks core contract for which this
93
+ * contract will be a minter.
94
+ * @param _minterFilter Minter filter for which
95
+ * this will a filtered minter.
96
+ */
97
+ constructor(
98
+ address _genArt721Address,
99
+ address _minterFilter
100
+ ) ReentrancyGuard() MinterBase(_genArt721Address) {
101
+ genArt721CoreAddress = _genArt721Address;
102
+ // always populate immutable engine contracts, but only use appropriate
103
+ // interface based on isEngine in the rest of the contract
104
+ genArtCoreContract_Base = IGenArt721CoreContractV3_Base(
105
+ _genArt721Address
106
+ );
107
+ minterFilterAddress = _minterFilter;
108
+ minterFilter = IMinterFilterV0(_minterFilter);
109
+ require(
110
+ minterFilter.genArt721CoreAddress() == _genArt721Address,
111
+ "Illegal contract pairing"
112
+ );
113
+ }
114
+
115
+ /**
116
+ * @notice Gets your balance of the ERC-20 token currently set
117
+ * as the payment currency for project `_projectId`.
118
+ * @param _projectId Project ID to be queried.
119
+ * @return balance Balance of ERC-20
120
+ */
121
+ function getYourBalanceOfProjectERC20(
122
+ uint256 _projectId
123
+ ) external view returns (uint256 balance) {
124
+ balance = IERC20(projectConfig[_projectId].currencyAddress).balanceOf(
125
+ msg.sender
126
+ );
127
+ return balance;
128
+ }
129
+
130
+ /**
131
+ * @notice Gets your allowance for this minter of the ERC-20
132
+ * token currently set as the payment currency for project
133
+ * `_projectId`.
134
+ * @param _projectId Project ID to be queried.
135
+ * @return remaining Remaining allowance of ERC-20
136
+ */
137
+ function checkYourAllowanceOfProjectERC20(
138
+ uint256 _projectId
139
+ ) external view returns (uint256 remaining) {
140
+ remaining = IERC20(projectConfig[_projectId].currencyAddress).allowance(
141
+ msg.sender,
142
+ address(this)
143
+ );
144
+ return remaining;
145
+ }
146
+
147
+ /**
148
+ * @notice Syncs local maximum invocations of project `_projectId` based on
149
+ * the value currently defined in the core contract.
150
+ * @param _projectId Project ID to set the maximum invocations for.
151
+ * @dev this enables gas reduction after maxInvocations have been reached -
152
+ * core contracts shall still enforce a maxInvocation check during mint.
153
+ */
154
+ function setProjectMaxInvocations(
155
+ uint256 _projectId
156
+ ) public onlyArtist(_projectId) {
157
+ uint256 maxInvocations;
158
+ uint256 invocations;
159
+ (invocations, maxInvocations, , , , ) = genArtCoreContract_Base
160
+ .projectStateData(_projectId);
161
+ // update storage with results
162
+ projectConfig[_projectId].maxInvocations = uint24(maxInvocations);
163
+
164
+ // We need to ensure maxHasBeenInvoked is correctly set after manually syncing the
165
+ // local maxInvocations value with the core contract's maxInvocations value.
166
+ // This synced value of maxInvocations from the core contract will always be greater
167
+ // than or equal to the previous value of maxInvocations stored locally.
168
+ projectConfig[_projectId].maxHasBeenInvoked =
169
+ invocations == maxInvocations;
170
+
171
+ emit ProjectMaxInvocationsLimitUpdated(_projectId, maxInvocations);
172
+ }
173
+
174
+ /**
175
+ * @notice Manually sets the local maximum invocations of project `_projectId`
176
+ * with the provided `_maxInvocations`, checking that `_maxInvocations` is less
177
+ * than or equal to the value of project `_project_id`'s maximum invocations that is
178
+ * set on the core contract.
179
+ * @dev Note that a `_maxInvocations` of 0 can only be set if the current `invocations`
180
+ * value is also 0 and this would also set `maxHasBeenInvoked` to true, correctly short-circuiting
181
+ * this minter's purchase function, avoiding extra gas costs from the core contract's maxInvocations check.
182
+ * @param _projectId Project ID to set the maximum invocations for.
183
+ * @param _maxInvocations Maximum invocations to set for the project.
184
+ */
185
+ function manuallyLimitProjectMaxInvocations(
186
+ uint256 _projectId,
187
+ uint256 _maxInvocations
188
+ ) external onlyArtist(_projectId) {
189
+ // CHECKS
190
+ // ensure that the manually set maxInvocations is not greater than what is set on the core contract
191
+ uint256 maxInvocations;
192
+ uint256 invocations;
193
+ (invocations, maxInvocations, , , , ) = genArtCoreContract_Base
194
+ .projectStateData(_projectId);
195
+ require(
196
+ _maxInvocations <= maxInvocations,
197
+ "Cannot increase project max invocations above core contract set project max invocations"
198
+ );
199
+ require(
200
+ _maxInvocations >= invocations,
201
+ "Cannot set project max invocations to less than current invocations"
202
+ );
203
+
204
+ // EFFECTS
205
+ // update storage with results
206
+ projectConfig[_projectId].maxInvocations = uint24(_maxInvocations);
207
+ // We need to ensure maxHasBeenInvoked is correctly set after manually setting the
208
+ // local maxInvocations value.
209
+ projectConfig[_projectId].maxHasBeenInvoked =
210
+ invocations == _maxInvocations;
211
+
212
+ emit ProjectMaxInvocationsLimitUpdated(_projectId, _maxInvocations);
213
+ }
214
+
215
+ /**
216
+ * @notice Warning: Disabling purchaseTo is not supported on this minter.
217
+ * This method exists purely for interface-conformance purposes.
218
+ */
219
+ function togglePurchaseToDisabled(
220
+ uint256 _projectId
221
+ ) external view onlyArtist(_projectId) {
222
+ revert("Action not supported");
223
+ }
224
+
225
+ /**
226
+ * @notice projectId => has project reached its maximum number of
227
+ * invocations? Note that this returns a local cache of the core contract's
228
+ * state, and may be out of sync with the core contract. This is
229
+ * intentional, as it only enables gas optimization of mints after a
230
+ * project's maximum invocations has been reached. A false negative will
231
+ * only result in a gas cost increase, since the core contract will still
232
+ * enforce a maxInvocation check during minting. A false positive is not
233
+ * possible because the V3 core contract only allows maximum invocations
234
+ * to be reduced, not increased. Based on this rationale, we intentionally
235
+ * do not do input validation in this method as to whether or not the input
236
+ * `_projectId` is an existing project ID.
237
+ */
238
+ function projectMaxHasBeenInvoked(
239
+ uint256 _projectId
240
+ ) external view returns (bool) {
241
+ return projectConfig[_projectId].maxHasBeenInvoked;
242
+ }
243
+
244
+ /**
245
+ * @notice projectId => project's maximum number of invocations.
246
+ * Optionally synced with core contract value, for gas optimization.
247
+ * Note that this returns a local cache of the core contract's
248
+ * state, and may be out of sync with the core contract. This is
249
+ * intentional, as it only enables gas optimization of mints after a
250
+ * project's maximum invocations has been reached.
251
+ * @dev A number greater than the core contract's project max invocations
252
+ * will only result in a gas cost increase, since the core contract will
253
+ * still enforce a maxInvocation check during minting. A number less than
254
+ * the core contract's project max invocations is only possible when the
255
+ * project's max invocations have not been synced on this minter, since the
256
+ * V3 core contract only allows maximum invocations to be reduced, not
257
+ * increased. When this happens, the minter will enable minting, allowing
258
+ * the core contract to enforce the max invocations check. Based on this
259
+ * rationale, we intentionally do not do input validation in this method as
260
+ * to whether or not the input `_projectId` is an existing project ID.
261
+ */
262
+ function projectMaxInvocations(
263
+ uint256 _projectId
264
+ ) external view returns (uint256) {
265
+ return uint256(projectConfig[_projectId].maxInvocations);
266
+ }
267
+
268
+ /**
269
+ * @notice Updates this minter's price per token of project `_projectId`
270
+ * to be '_pricePerTokenInWei`, in Wei.
271
+ * This price supersedes any legacy core contract price per token value.
272
+ */
273
+ function updatePricePerTokenInWei(
274
+ uint256 _projectId,
275
+ uint256 _pricePerTokenInWei
276
+ ) external onlyArtist(_projectId) {
277
+ require(_pricePerTokenInWei > 0, "Price may not be 0");
278
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
279
+ _projectConfig.pricePerTokenInWei = _pricePerTokenInWei;
280
+ _projectConfig.priceIsConfigured = true;
281
+ emit PricePerTokenInWeiUpdated(_projectId, _pricePerTokenInWei);
282
+
283
+ // sync local max invocations if not initially populated
284
+ // @dev if local max invocations and maxHasBeenInvoked are both
285
+ // initial values, we know they have not been populated.
286
+ if (
287
+ _projectConfig.maxInvocations == 0 &&
288
+ _projectConfig.maxHasBeenInvoked == false
289
+ ) {
290
+ setProjectMaxInvocations(_projectId);
291
+ }
292
+ }
293
+
294
+ /**
295
+ * @notice Updates payment currency of project `_projectId` to be
296
+ * `_currencySymbol` at address `_currencyAddress`.
297
+ * @param _projectId Project ID to update.
298
+ * @param _currencySymbol Currency symbol.
299
+ * @param _currencyAddress Currency address.
300
+ */
301
+ function updateProjectCurrencyInfo(
302
+ uint256 _projectId,
303
+ string memory _currencySymbol,
304
+ address _currencyAddress
305
+ ) external onlyArtist(_projectId) {
306
+ // require null address if symbol is "ETH"
307
+ require(
308
+ (keccak256(abi.encodePacked(_currencySymbol)) ==
309
+ keccak256(abi.encodePacked("ETH"))) ==
310
+ (_currencyAddress == address(0)),
311
+ "ETH is only null address"
312
+ );
313
+ projectConfig[_projectId].currencySymbol = _currencySymbol;
314
+ projectConfig[_projectId].currencyAddress = _currencyAddress;
315
+ emit ProjectCurrencyInfoUpdated(
316
+ _projectId,
317
+ _currencyAddress,
318
+ _currencySymbol
319
+ );
320
+ }
321
+
322
+ /**
323
+ * @notice Purchases a token from project `_projectId`.
324
+ * @param _projectId Project ID to mint a token on.
325
+ * @return tokenId Token ID of minted token
326
+ */
327
+ function purchase(
328
+ uint256 _projectId
329
+ ) external payable returns (uint256 tokenId) {
330
+ tokenId = purchaseTo_do6(msg.sender, _projectId);
331
+ return tokenId;
332
+ }
333
+
334
+ /**
335
+ * @notice gas-optimized version of purchase(uint256).
336
+ */
337
+ function purchase_H4M(
338
+ uint256 _projectId
339
+ ) external payable returns (uint256 tokenId) {
340
+ tokenId = purchaseTo_do6(msg.sender, _projectId);
341
+ return tokenId;
342
+ }
343
+
344
+ /**
345
+ * @notice Purchases a token from project `_projectId` and sets
346
+ * the token's owner to `_to`.
347
+ * @param _to Address to be the new token's owner.
348
+ * @param _projectId Project ID to mint a token on.
349
+ * @return tokenId Token ID of minted token
350
+ */
351
+ function purchaseTo(
352
+ address _to,
353
+ uint256 _projectId
354
+ ) external payable returns (uint256 tokenId) {
355
+ return purchaseTo_do6(_to, _projectId);
356
+ }
357
+
358
+ /**
359
+ * @notice gas-optimized version of purchaseTo(address, uint256).
360
+ */
361
+ function purchaseTo_do6(
362
+ address _to,
363
+ uint256 _projectId
364
+ ) public payable nonReentrant returns (uint256 tokenId) {
365
+ // CHECKS
366
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
367
+
368
+ // Note that `maxHasBeenInvoked` is only checked here to reduce gas
369
+ // consumption after a project has been fully minted.
370
+ // `_projectConfig.maxHasBeenInvoked` is locally cached to reduce
371
+ // gas consumption, but if not in sync with the core contract's value,
372
+ // the core contract also enforces its own max invocation check during
373
+ // minting.
374
+ require(
375
+ !_projectConfig.maxHasBeenInvoked,
376
+ "Maximum number of invocations reached"
377
+ );
378
+
379
+ // require artist to have configured price of token on this minter
380
+ require(_projectConfig.priceIsConfigured, "Price not configured");
381
+
382
+ // EFFECTS
383
+ tokenId = minterFilter.mint(_to, _projectId, msg.sender);
384
+
385
+ // invocation is token number plus one, and will never overflow due to
386
+ // limit of 1e6 invocations per project. block scope for gas efficiency
387
+ // (i.e. avoid an unnecessary var initialization to 0).
388
+ unchecked {
389
+ uint256 tokenInvocation = (tokenId % ONE_MILLION) + 1;
390
+ uint256 localMaxInvocations = _projectConfig.maxInvocations;
391
+ // handle the case where the token invocation == minter local max
392
+ // invocations occurred on a different minter, and we have a stale
393
+ // local maxHasBeenInvoked value returning a false negative.
394
+ // @dev this is a CHECK after EFFECTS, so security was considered
395
+ // in detail here.
396
+ require(
397
+ tokenInvocation <= localMaxInvocations,
398
+ "Maximum invocations reached"
399
+ );
400
+ // in typical case, update the local maxHasBeenInvoked value
401
+ // to true if the token invocation == minter local max invocations
402
+ // (enables gas efficient reverts after sellout)
403
+ if (tokenInvocation == localMaxInvocations) {
404
+ _projectConfig.maxHasBeenInvoked = true;
405
+ }
406
+ }
407
+
408
+ // INTERACTIONS
409
+ uint256 pricePerTokenInWei = _projectConfig.pricePerTokenInWei;
410
+ address _currencyAddress = _projectConfig.currencyAddress;
411
+ if (_currencyAddress != address(0)) {
412
+ require(
413
+ msg.value == 0,
414
+ "this project accepts a different currency and cannot accept ETH"
415
+ );
416
+ require(
417
+ IERC20(_currencyAddress).allowance(msg.sender, address(this)) >=
418
+ pricePerTokenInWei,
419
+ "Insufficient Funds Approved for TX"
420
+ );
421
+ require(
422
+ IERC20(_currencyAddress).balanceOf(msg.sender) >=
423
+ pricePerTokenInWei,
424
+ "Insufficient balance."
425
+ );
426
+ splitFundsERC20(
427
+ _projectId,
428
+ pricePerTokenInWei,
429
+ _currencyAddress,
430
+ genArt721CoreAddress
431
+ );
432
+ } else {
433
+ require(
434
+ msg.value >= pricePerTokenInWei,
435
+ "Must send minimum value to mint!"
436
+ );
437
+ splitFundsETH(_projectId, pricePerTokenInWei, genArt721CoreAddress);
438
+ }
439
+
440
+ return tokenId;
441
+ }
442
+
443
+ /**
444
+ * @notice Gets if price of token is configured, price of minting a
445
+ * token on project `_projectId`, and currency symbol and address to be
446
+ * used as payment. Supersedes any core contract price information.
447
+ * @param _projectId Project ID to get price information for.
448
+ * @return isConfigured true only if token price has been configured on
449
+ * this minter
450
+ * @return tokenPriceInWei current price of token on this minter - invalid
451
+ * if price has not yet been configured
452
+ * @return currencySymbol currency symbol for purchases of project on this
453
+ * minter. "ETH" reserved for ether.
454
+ * @return currencyAddress currency address for purchases of project on
455
+ * this minter. Null address reserved for ether.
456
+ */
457
+ function getPriceInfo(
458
+ uint256 _projectId
459
+ )
460
+ external
461
+ view
462
+ returns (
463
+ bool isConfigured,
464
+ uint256 tokenPriceInWei,
465
+ string memory currencySymbol,
466
+ address currencyAddress
467
+ )
468
+ {
469
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
470
+ isConfigured = _projectConfig.priceIsConfigured;
471
+ tokenPriceInWei = _projectConfig.pricePerTokenInWei;
472
+ currencyAddress = _projectConfig.currencyAddress;
473
+ if (currencyAddress == address(0)) {
474
+ // defaults to ETH
475
+ currencySymbol = "ETH";
476
+ } else {
477
+ currencySymbol = _projectConfig.currencySymbol;
478
+ }
479
+ }
480
+ }