@artblocks/contracts 1.0.0 → 1.0.2

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 (106) hide show
  1. package/.env.example +8 -1
  2. package/README.md +44 -165
  3. package/artifacts/contracts/AdminACLV1.sol/AdminACLV1.json +2 -2
  4. package/artifacts/contracts/DependencyRegistryV0.sol/DependencyRegistryV0.json +2 -2
  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/GenArt721CoreV3_Engine_Flex.sol/GenArt721CoreV3_Engine_Flex.json +2229 -0
  8. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV0.sol/MinterDAExpV0.json +2 -2
  9. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV1.sol/MinterDAExpV1.json +2 -2
  10. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV2.sol/MinterDAExpV2.json +2 -2
  11. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExp/MinterDAExpV3.sol/MinterDAExpV3.json +2 -2
  12. package/artifacts/contracts/archive/minter-suite/Minters/MinterDAExpSettlement/MinterDAExpSettlementV0.sol/MinterDAExpSettlementV0.json +2 -2
  13. package/artifacts/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterDAExpSettlement}/MinterDAExpSettlementV1.sol/MinterDAExpSettlementV1.json +3 -3
  14. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV0.sol/MinterDALinV0.json +2 -2
  15. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV1.sol/MinterDALinV1.json +2 -2
  16. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV2.sol/MinterDALinV2.json +2 -2
  17. package/artifacts/contracts/archive/minter-suite/Minters/MinterDALin/MinterDALinV3.sol/MinterDALinV3.json +2 -2
  18. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV0.sol/MinterHolderV0.json +2 -2
  19. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV1.sol/MinterHolderV1.json +2 -2
  20. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV2.sol/MinterHolderV2.json +2 -2
  21. package/artifacts/contracts/archive/minter-suite/Minters/MinterHolder/MinterHolderV3.sol/MinterHolderV3.json +2 -2
  22. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV0.sol/MinterMerkleV0.json +2 -2
  23. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV1.sol/MinterMerkleV1.json +2 -2
  24. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV2.sol/MinterMerkleV2.json +2 -2
  25. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV3.sol/MinterMerkleV3.json +2 -2
  26. package/artifacts/contracts/archive/minter-suite/Minters/MinterMerkle/MinterMerkleV4.sol/MinterMerkleV4.json +2 -2
  27. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV0.sol/MinterSetPriceV0.json +2 -2
  28. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV1.sol/MinterSetPriceV1.json +2 -2
  29. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV2.sol/MinterSetPriceV2.json +2 -2
  30. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPrice/MinterSetPriceV3.sol/MinterSetPriceV3.json +2 -2
  31. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V0.sol/MinterSetPriceERC20V0.json +2 -2
  32. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V1.sol/MinterSetPriceERC20V1.json +2 -2
  33. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V2.sol/MinterSetPriceERC20V2.json +2 -2
  34. package/artifacts/contracts/archive/minter-suite/Minters/MinterSetPriceERC20/MinterSetPriceERC20V3.sol/MinterSetPriceERC20V3.json +2 -2
  35. package/artifacts/contracts/explorations/GenArt721CoreV3_Explorations.sol/GenArt721CoreV3_Explorations.json +2 -2
  36. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV1.sol/IFilteredMinterDAExpSettlementV1.json +767 -0
  37. package/artifacts/contracts/interfaces/0.8.x/IFilteredMinterSEAV0.sol/IFilteredMinterSEAV0.json +1032 -0
  38. package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreContractV3.sol/IGenArt721CoreContractV3.json +149 -0
  39. package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Base.sol/IGenArt721CoreContractV3_Base.json +149 -0
  40. package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Engine.sol/IGenArt721CoreContractV3_Engine.json +130 -0
  41. package/artifacts/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Engine_Flex.sol/IGenArt721CoreContractV3_Engine_Flex.json +1066 -0
  42. package/artifacts/contracts/interfaces/0.8.x/IMinterFilterV0.sol/IMinterFilterV0.json +6 -0
  43. package/artifacts/contracts/interfaces/0.8.x/IRandomizerPolyptychV0.sol/IRandomizerPolyptychV0.json +87 -0
  44. package/artifacts/contracts/interfaces/0.8.x/IRandomizerV2.sol/IRandomizerV2.json +1 -1
  45. package/artifacts/contracts/interfaces/0.8.x/IWETH.sol/IWETH.json +55 -0
  46. package/artifacts/contracts/libs/integration-refs/weth9/weth9.sol/WETH9_.json +295 -0
  47. package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV0.sol/MinterFilterV0.json +8 -2
  48. package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV1.sol/MinterFilterV1.json +34 -2
  49. package/artifacts/contracts/minter-suite/Minters/MinterDAExpSettlementV2.sol/MinterDAExpSettlementV2.json +1127 -0
  50. package/artifacts/contracts/minter-suite/Minters/MinterDAExpV4.sol/MinterDAExpV4.json +15 -2
  51. package/artifacts/contracts/minter-suite/Minters/MinterDALinV4.sol/MinterDALinV4.json +15 -2
  52. package/artifacts/contracts/minter-suite/Minters/MinterHolderV4.sol/MinterHolderV4.json +15 -2
  53. package/artifacts/contracts/minter-suite/Minters/MinterMerkleV5.sol/MinterMerkleV5.json +15 -2
  54. package/artifacts/contracts/minter-suite/Minters/MinterPolyptychV0.sol/IGenArt721CoreContractV3WithRandomizer.json +792 -0
  55. package/artifacts/contracts/minter-suite/Minters/MinterPolyptychV0.sol/MinterPolyptychV0.json +1268 -0
  56. package/artifacts/contracts/minter-suite/Minters/MinterSEAV0.sol/MinterSEAV0.json +1310 -0
  57. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20V4.sol/MinterSetPriceERC20V4.json +15 -2
  58. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceV4.sol/MinterSetPriceV4.json +15 -2
  59. package/artifacts/contracts/mock/DeadReceiverBidderMock.sol/DeadReceiverBidderMock.json +33 -0
  60. package/artifacts/contracts/mock/GasLimitReceiverBidderMock.sol/GasLimitReceiverBidderMock.json +46 -0
  61. package/artifacts/contracts/mock/GasLimitReceiverMock.sol/GasLimitReceiverMock.json +28 -0
  62. package/artifacts/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol/GenArt721CoreV3_Engine_IncorrectCoreType.json +2 -2
  63. package/artifacts/contracts/mock/RandomizerV2_NoAssignMock.sol/RandomizerV2_NoAssignMock.json +3 -3
  64. package/artifacts/contracts/mock/ReentrancySEAMock.sol/ReentrancySEAAutoBidderMock.json +51 -0
  65. package/artifacts/contracts/{BasicRandomizer.sol → randomizer/BasicRandomizer.sol}/BasicRandomizer.json +3 -3
  66. package/artifacts/contracts/randomizer/BasicRandomizerBase_v0_0_0.sol/RandomizerBase.json +10 -0
  67. package/artifacts/contracts/randomizer/PolyptychRandomizerV0.sol/BasicPolyptychRandomizerV0.json +229 -0
  68. package/artifacts/contracts/randomizer/RandomizerV2.sol/BasicRandomizerV2.json +102 -0
  69. package/artifacts/contracts/royalty-registry/GenArt721RoyaltyOverride.sol/GenArt721RoyaltyOverride.json +2 -2
  70. package/contracts/DependencyRegistryV0.sol +74 -113
  71. package/contracts/GenArt721CoreV3.sol +124 -171
  72. package/contracts/GenArt721CoreV3_Engine.sol +136 -198
  73. package/contracts/GenArt721CoreV3_Engine_Flex.sol +2274 -0
  74. package/contracts/{minter-suite/Minters → archive/minter-suite/Minters/MinterDAExpSettlement}/MinterDAExpSettlementV1.sol +4 -4
  75. package/contracts/explorations/GenArt721CoreV3_Explorations.sol +147 -176
  76. package/contracts/interfaces/0.8.x/IFilteredMinterDAExpSettlementV1.sol +21 -0
  77. package/contracts/interfaces/0.8.x/IFilteredMinterSEAV0.sol +145 -0
  78. package/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Base.sol +39 -0
  79. package/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Engine.sol +0 -3
  80. package/contracts/interfaces/0.8.x/IGenArt721CoreContractV3_Engine_Flex.sol +132 -0
  81. package/contracts/interfaces/0.8.x/IMinterFilterV0.sol +6 -0
  82. package/contracts/interfaces/0.8.x/IRandomizerPolyptychV0.sol +31 -0
  83. package/contracts/interfaces/0.8.x/IRandomizerV2.sol +5 -2
  84. package/contracts/interfaces/0.8.x/IWETH.sol +11 -0
  85. package/contracts/libs/integration-refs/weth9/weth9.sol +763 -0
  86. package/contracts/minter-suite/MinterFilter/MinterFilterV1.sol +53 -47
  87. package/contracts/minter-suite/Minters/MinterDAExpSettlementV2.sol +1304 -0
  88. package/contracts/minter-suite/Minters/MinterDAExpV4.sol +47 -24
  89. package/contracts/minter-suite/Minters/MinterDALinV4.sol +46 -21
  90. package/contracts/minter-suite/Minters/MinterHolderV4.sol +54 -25
  91. package/contracts/minter-suite/Minters/MinterMerkleV5.sol +47 -20
  92. package/contracts/minter-suite/Minters/MinterPolyptychV0.sol +998 -0
  93. package/contracts/minter-suite/Minters/MinterSEAV0.sol +1224 -0
  94. package/contracts/minter-suite/Minters/MinterSetPriceERC20V4.sol +45 -16
  95. package/contracts/minter-suite/Minters/MinterSetPriceV4.sol +40 -13
  96. package/contracts/mock/DeadReceiverBidderMock.sol +23 -0
  97. package/contracts/mock/GasLimitReceiverBidderMock.sol +23 -0
  98. package/contracts/mock/GasLimitReceiverMock.sol +19 -0
  99. package/contracts/mock/RandomizerV2_NoAssignMock.sol +2 -11
  100. package/contracts/mock/ReentrancySEAMock.sol +36 -0
  101. package/contracts/{BasicRandomizer.sol → randomizer/BasicRandomizer.sol} +1 -1
  102. package/contracts/randomizer/BasicRandomizerBase_v0_0_0.sol +23 -0
  103. package/contracts/randomizer/PolyptychRandomizerV0.sol +117 -0
  104. package/contracts/{BasicRandomizerV2.sol → randomizer/RandomizerV2.sol} +7 -15
  105. package/package.json +32 -13
  106. package/artifacts/contracts/BasicRandomizerV2.sol/BasicRandomizerV2.json +0 -102
@@ -55,6 +55,9 @@ contract MinterSetPriceERC20V4 is
55
55
  /// minterType for this minter
56
56
  string public constant minterType = "MinterSetPriceERC20V4";
57
57
 
58
+ /// minter version for this minter
59
+ string public constant minterVersion = "v4.1.0";
60
+
58
61
  uint256 constant ONE_MILLION = 1_000_000;
59
62
 
60
63
  struct ProjectConfig {
@@ -73,13 +76,12 @@ contract MinterSetPriceERC20V4 is
73
76
  // /// projectId => currency address - supersedes any defined core value
74
77
  // mapping(uint256 => address) private projectIdToCurrencyAddress;
75
78
 
76
- modifier onlyArtist(uint256 _projectId) {
79
+ function _onlyArtist(uint256 _projectId) internal view {
77
80
  require(
78
81
  msg.sender ==
79
82
  genArtCoreContract_Base.projectIdToArtistAddress(_projectId),
80
83
  "Only Artist"
81
84
  );
82
- _;
83
85
  }
84
86
 
85
87
  /**
@@ -148,9 +150,8 @@ contract MinterSetPriceERC20V4 is
148
150
  * @dev this enables gas reduction after maxInvocations have been reached -
149
151
  * core contracts shall still enforce a maxInvocation check during mint.
150
152
  */
151
- function setProjectMaxInvocations(
152
- uint256 _projectId
153
- ) external onlyArtist(_projectId) {
153
+ function setProjectMaxInvocations(uint256 _projectId) public {
154
+ _onlyArtist(_projectId);
154
155
  uint256 maxInvocations;
155
156
  uint256 invocations;
156
157
  (invocations, maxInvocations, , , , ) = genArtCoreContract_Base
@@ -182,7 +183,8 @@ contract MinterSetPriceERC20V4 is
182
183
  function manuallyLimitProjectMaxInvocations(
183
184
  uint256 _projectId,
184
185
  uint256 _maxInvocations
185
- ) external onlyArtist(_projectId) {
186
+ ) external {
187
+ _onlyArtist(_projectId);
186
188
  // CHECKS
187
189
  // ensure that the manually set maxInvocations is not greater than what is set on the core contract
188
190
  uint256 maxInvocations;
@@ -213,9 +215,8 @@ contract MinterSetPriceERC20V4 is
213
215
  * @notice Warning: Disabling purchaseTo is not supported on this minter.
214
216
  * This method exists purely for interface-conformance purposes.
215
217
  */
216
- function togglePurchaseToDisabled(
217
- uint256 _projectId
218
- ) external view onlyArtist(_projectId) {
218
+ function togglePurchaseToDisabled(uint256 _projectId) external view {
219
+ _onlyArtist(_projectId);
219
220
  revert("Action not supported");
220
221
  }
221
222
 
@@ -270,11 +271,23 @@ contract MinterSetPriceERC20V4 is
270
271
  function updatePricePerTokenInWei(
271
272
  uint256 _projectId,
272
273
  uint256 _pricePerTokenInWei
273
- ) external onlyArtist(_projectId) {
274
+ ) external {
275
+ _onlyArtist(_projectId);
274
276
  require(_pricePerTokenInWei > 0, "Price may not be 0");
275
- projectConfig[_projectId].pricePerTokenInWei = _pricePerTokenInWei;
276
- projectConfig[_projectId].priceIsConfigured = true;
277
+ ProjectConfig storage _projectConfig = projectConfig[_projectId];
278
+ _projectConfig.pricePerTokenInWei = _pricePerTokenInWei;
279
+ _projectConfig.priceIsConfigured = true;
277
280
  emit PricePerTokenInWeiUpdated(_projectId, _pricePerTokenInWei);
281
+
282
+ // sync local max invocations if not initially populated
283
+ // @dev if local max invocations and maxHasBeenInvoked are both
284
+ // initial values, we know they have not been populated.
285
+ if (
286
+ _projectConfig.maxInvocations == 0 &&
287
+ _projectConfig.maxHasBeenInvoked == false
288
+ ) {
289
+ setProjectMaxInvocations(_projectId);
290
+ }
278
291
  }
279
292
 
280
293
  /**
@@ -288,7 +301,8 @@ contract MinterSetPriceERC20V4 is
288
301
  uint256 _projectId,
289
302
  string memory _currencySymbol,
290
303
  address _currencyAddress
291
- ) external onlyArtist(_projectId) {
304
+ ) external {
305
+ _onlyArtist(_projectId);
292
306
  // require null address if symbol is "ETH"
293
307
  require(
294
308
  (keccak256(abi.encodePacked(_currencySymbol)) ==
@@ -368,10 +382,25 @@ contract MinterSetPriceERC20V4 is
368
382
  // EFFECTS
369
383
  tokenId = minterFilter.mint(_to, _projectId, msg.sender);
370
384
 
371
- // okay if this underflows because if statement will always eval false.
372
- // this is only for gas optimization (core enforces maxInvocations).
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).
373
388
  unchecked {
374
- if (tokenId % ONE_MILLION == _projectConfig.maxInvocations - 1) {
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) {
375
404
  _projectConfig.maxHasBeenInvoked = true;
376
405
  }
377
406
  }
@@ -47,6 +47,9 @@ contract MinterSetPriceV4 is ReentrancyGuard, MinterBase, IFilteredMinterV2 {
47
47
  /// minterType for this minter
48
48
  string public constant minterType = "MinterSetPriceV4";
49
49
 
50
+ /// minter version for this minter
51
+ string public constant minterVersion = "v4.1.0";
52
+
50
53
  uint256 constant ONE_MILLION = 1_000_000;
51
54
 
52
55
  struct ProjectConfig {
@@ -58,13 +61,12 @@ contract MinterSetPriceV4 is ReentrancyGuard, MinterBase, IFilteredMinterV2 {
58
61
 
59
62
  mapping(uint256 => ProjectConfig) public projectConfig;
60
63
 
61
- modifier onlyArtist(uint256 _projectId) {
64
+ function _onlyArtist(uint256 _projectId) internal view {
62
65
  require(
63
66
  msg.sender ==
64
67
  genArtCoreContract_Base.projectIdToArtistAddress(_projectId),
65
68
  "Only Artist"
66
69
  );
67
- _;
68
70
  }
69
71
 
70
72
  /**
@@ -101,9 +103,8 @@ contract MinterSetPriceV4 is ReentrancyGuard, MinterBase, IFilteredMinterV2 {
101
103
  * @dev this enables gas reduction after maxInvocations have been reached -
102
104
  * core contracts shall still enforce a maxInvocation check during mint.
103
105
  */
104
- function setProjectMaxInvocations(
105
- uint256 _projectId
106
- ) external onlyArtist(_projectId) {
106
+ function setProjectMaxInvocations(uint256 _projectId) public {
107
+ _onlyArtist(_projectId);
107
108
  uint256 maxInvocations;
108
109
  uint256 invocations;
109
110
  (invocations, maxInvocations, , , , ) = genArtCoreContract_Base
@@ -135,7 +136,8 @@ contract MinterSetPriceV4 is ReentrancyGuard, MinterBase, IFilteredMinterV2 {
135
136
  function manuallyLimitProjectMaxInvocations(
136
137
  uint256 _projectId,
137
138
  uint256 _maxInvocations
138
- ) external onlyArtist(_projectId) {
139
+ ) external {
140
+ _onlyArtist(_projectId);
139
141
  // CHECKS
140
142
  // ensure that the manually set maxInvocations is not greater than what is set on the core contract
141
143
  uint256 maxInvocations;
@@ -166,9 +168,8 @@ contract MinterSetPriceV4 is ReentrancyGuard, MinterBase, IFilteredMinterV2 {
166
168
  * @notice Warning: Disabling purchaseTo is not supported on this minter.
167
169
  * This method exists purely for interface-conformance purposes.
168
170
  */
169
- function togglePurchaseToDisabled(
170
- uint256 _projectId
171
- ) external view onlyArtist(_projectId) {
171
+ function togglePurchaseToDisabled(uint256 _projectId) external view {
172
+ _onlyArtist(_projectId);
172
173
  revert("Action not supported");
173
174
  }
174
175
 
@@ -225,11 +226,22 @@ contract MinterSetPriceV4 is ReentrancyGuard, MinterBase, IFilteredMinterV2 {
225
226
  function updatePricePerTokenInWei(
226
227
  uint256 _projectId,
227
228
  uint256 _pricePerTokenInWei
228
- ) external onlyArtist(_projectId) {
229
+ ) external {
230
+ _onlyArtist(_projectId);
229
231
  ProjectConfig storage _projectConfig = projectConfig[_projectId];
230
232
  _projectConfig.pricePerTokenInWei = _pricePerTokenInWei;
231
233
  _projectConfig.priceIsConfigured = true;
232
234
  emit PricePerTokenInWeiUpdated(_projectId, _pricePerTokenInWei);
235
+
236
+ // sync local max invocations if not initially populated
237
+ // @dev if local max invocations and maxHasBeenInvoked are both
238
+ // initial values, we know they have not been populated.
239
+ if (
240
+ _projectConfig.maxInvocations == 0 &&
241
+ _projectConfig.maxHasBeenInvoked == false
242
+ ) {
243
+ setProjectMaxInvocations(_projectId);
244
+ }
233
245
  }
234
246
 
235
247
  /**
@@ -303,10 +315,25 @@ contract MinterSetPriceV4 is ReentrancyGuard, MinterBase, IFilteredMinterV2 {
303
315
  // EFFECTS
304
316
  tokenId = minterFilter.mint(_to, _projectId, msg.sender);
305
317
 
306
- // okay if this underflows because if statement will always eval false.
307
- // this is only for gas optimization (core enforces maxInvocations).
318
+ // invocation is token number plus one, and will never overflow due to
319
+ // limit of 1e6 invocations per project. block scope for gas efficiency
320
+ // (i.e. avoid an unnecessary var initialization to 0).
308
321
  unchecked {
309
- if (tokenId % ONE_MILLION == _projectConfig.maxInvocations - 1) {
322
+ uint256 tokenInvocation = (tokenId % ONE_MILLION) + 1;
323
+ uint256 localMaxInvocations = _projectConfig.maxInvocations;
324
+ // handle the case where the token invocation == minter local max
325
+ // invocations occurred on a different minter, and we have a stale
326
+ // local maxHasBeenInvoked value returning a false negative.
327
+ // @dev this is a CHECK after EFFECTS, so security was considered
328
+ // in detail here.
329
+ require(
330
+ tokenInvocation <= localMaxInvocations,
331
+ "Maximum invocations reached"
332
+ );
333
+ // in typical case, update the local maxHasBeenInvoked value
334
+ // to true if the token invocation == minter local max invocations
335
+ // (enables gas efficient reverts after sellout)
336
+ if (tokenInvocation == localMaxInvocations) {
310
337
  _projectConfig.maxHasBeenInvoked = true;
311
338
  }
312
339
  }
@@ -0,0 +1,23 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+
3
+ pragma solidity 0.8.17;
4
+
5
+ import {DeadReceiverMock} from "./DeadReceiverMock.sol";
6
+
7
+ /**
8
+ * @notice This reverts when receiving Ether.
9
+ * Also exposes a createBidOnAuction function to create a bid on an auction
10
+ * of a serial English auction minter.
11
+ * @dev Mock contract for testing purposes.
12
+ */
13
+ contract DeadReceiverBidderMock is DeadReceiverMock {
14
+ function createBidOnAuction(
15
+ address minter,
16
+ uint256 tokenId
17
+ ) external payable {
18
+ (bool success, ) = minter.call{value: msg.value}(
19
+ abi.encodeWithSignature("createBid(uint256)", tokenId)
20
+ );
21
+ require(success, "DeadReceiverBidderMock: call failed");
22
+ }
23
+ }
@@ -0,0 +1,23 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+
3
+ pragma solidity 0.8.17;
4
+
5
+ import {GasLimitReceiverMock} from "./GasLimitReceiverMock.sol";
6
+
7
+ /**
8
+ * @notice This reverts when receiving Ether.
9
+ * Also exposes a createBidOnAuction function to create a bid on an auction
10
+ * of a serial English auction minter.
11
+ * @dev Mock contract for testing purposes.
12
+ */
13
+ contract GasLimitReceiverBidderMock is GasLimitReceiverMock {
14
+ function createBidOnAuction(
15
+ address minter,
16
+ uint256 tokenId
17
+ ) external payable {
18
+ (bool success, ) = minter.call{value: msg.value}(
19
+ abi.encodeWithSignature("createBid(uint256)", tokenId)
20
+ );
21
+ require(success, "GasLimitReceiverBidderMock: call failed");
22
+ }
23
+ }
@@ -0,0 +1,19 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+
3
+ pragma solidity 0.8.17;
4
+
5
+ /**
6
+ * @notice This uses all gas when receiving Ether, useful when testing denial
7
+ * of service attacks.
8
+ * @dev Mock contract for testing purposes.
9
+ */
10
+ contract GasLimitReceiverMock {
11
+ string public a = "a string in storage.";
12
+
13
+ receive() external payable {
14
+ // infinite loop to burn all available gas
15
+ while (true) {
16
+ a = string.concat(a, " A longer string in storage to burn gas.");
17
+ }
18
+ }
19
+ }
@@ -3,7 +3,7 @@
3
3
 
4
4
  pragma solidity 0.8.17;
5
5
 
6
- import "../BasicRandomizerV2.sol";
6
+ import "../randomizer/RandomizerV2.sol";
7
7
 
8
8
  /// @title RandomizerV2_NoAssignMock
9
9
  /// @notice WARNING - This is a mock contract. Do not use it in production.
@@ -20,16 +20,7 @@ contract RandomizerV2_NoAssignMock is BasicRandomizerV2 {
20
20
  // on the core contract. Used for test purposes only.
21
21
  // @dev WARNING - THIS IS NOT SECURE AND SHOULD NOT BE USED IN PRODUCTION.
22
22
  function actuallyAssignTokenHash(uint256 _tokenId) external {
23
- uint256 time = block.timestamp;
24
- bytes32 hash = keccak256(
25
- abi.encodePacked(
26
- _tokenId,
27
- block.number,
28
- blockhash(block.number - 1),
29
- time,
30
- (time % 200) + 1
31
- )
32
- );
23
+ bytes32 hash = _getPseudorandom(_tokenId);
33
24
  genArt721Core.setTokenHash_8PT(_tokenId, hash);
34
25
  }
35
26
 
@@ -0,0 +1,36 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Created By: Art Blocks Inc.
3
+
4
+ import "../interfaces/0.8.x/IFilteredMinterSEAV0.sol";
5
+
6
+ pragma solidity ^0.8.0;
7
+
8
+ contract ReentrancySEAAutoBidderMock {
9
+ uint256 public targetTokenId;
10
+
11
+ /**
12
+ @notice This function can be called to induce controlled reentrency attacks
13
+ on AB minter filter suite.
14
+ Note that _priceToPay should be > project price per token to induce refund,
15
+ making reentrency possible via fallback function.
16
+ */
17
+ function attack(
18
+ uint256 _targetTokenId,
19
+ address _minterContractAddress,
20
+ uint256 _initialBidValue
21
+ ) external payable {
22
+ targetTokenId = _targetTokenId;
23
+ IFilteredMinterSEAV0(_minterContractAddress).createBid{
24
+ value: _initialBidValue
25
+ }(_targetTokenId);
26
+ }
27
+
28
+ // receiver is called when minter sends refunded Ether to this contract, when outbid
29
+ receive() external payable {
30
+ // auto-rebid
31
+ uint256 newBidValue = (msg.value * 110) / 100;
32
+ IFilteredMinterSEAV0(msg.sender).createBid{value: newBidValue}(
33
+ targetTokenId
34
+ );
35
+ }
36
+ }
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: LGPL-3.0-only
2
2
  // Creatd By: Art Blocks Inc.
3
3
 
4
- import "./interfaces/0.8.x/IRandomizer.sol";
4
+ import "../interfaces/0.8.x/IRandomizer.sol";
5
5
 
6
6
  pragma solidity 0.8.9;
7
7
 
@@ -0,0 +1,23 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Creatd By: Art Blocks Inc.
3
+
4
+ pragma solidity 0.8.17;
5
+
6
+ abstract contract RandomizerBase {
7
+ // base class that returns
8
+ function _getPseudorandom(
9
+ uint256 _tokenId
10
+ ) internal virtual returns (bytes32) {
11
+ uint256 time = block.timestamp;
12
+ return
13
+ keccak256(
14
+ abi.encodePacked(
15
+ _tokenId,
16
+ block.number,
17
+ blockhash(block.number - 1),
18
+ time,
19
+ (time % 200) + 1
20
+ )
21
+ );
22
+ }
23
+ }
@@ -0,0 +1,117 @@
1
+ // SPDX-License-Identifier: LGPL-3.0-only
2
+ // Creatd By: Art Blocks Inc.
3
+
4
+ pragma solidity 0.8.17;
5
+
6
+ import "../interfaces/0.8.x/IGenArt721CoreContractV3_Base.sol";
7
+ import "../interfaces/0.8.x/IRandomizerPolyptychV0.sol";
8
+ import "./BasicRandomizerBase_v0_0_0.sol";
9
+
10
+ import "@openzeppelin-4.7/contracts/access/Ownable.sol";
11
+
12
+ /**
13
+ * @title Basic Polytych Randomizer contract that enables the copying of token hash seeds.
14
+ * @notice This contract requires several configuration options to be set properly before
15
+ * it enables the copying of token hashes from an original token (the first panel of a polyptych)
16
+ * to subsequent diptych, triptych, or polyptych panels.
17
+ *
18
+ * Requirements to use the polyptych randomizer:
19
+ * - Core contract must be an instance of `GenArt721CoreV3_Engine`
20
+ * - The initial project used as the first panel should be minted with a pseudo random token hash
21
+ * - An `MinterPolyptychV0` contract or similar must be deployed and configured as the `hashSeedSetterContract`
22
+ * - The `projectDuplicateHashSeedLimit` should be configured for each project
23
+ *
24
+ * Once the contract is configured, it will enable newly-minted tokens to use a copy of the hash
25
+ * seed from a previously-minted token.
26
+ */
27
+ contract BasicPolyptychRandomizerV0 is
28
+ IRandomizerPolyptychV0,
29
+ RandomizerBase,
30
+ Ownable
31
+ {
32
+ // The core contract that may interact with this randomizer contract.
33
+ IGenArt721CoreContractV3_Base public genArt721Core;
34
+
35
+ // Used to obtain the project ID from the token ID
36
+ uint256 constant ONE_MILLION = 1_000_000;
37
+
38
+ // Mapping of token IDs to hash seeds
39
+ mapping(uint256 => bytes12) public polyptychHashSeeds;
40
+
41
+ // Configures the maximum number of hash seed copies that can exist per project (default zero)
42
+ mapping(uint256 => bool) public projectIsPolyptych;
43
+
44
+ // The contract allowed to assign hash seeds (e.g. PolyptychMinterV0)
45
+ address public hashSeedSetterContract;
46
+
47
+ function assignCoreAndRenounce(address _genArt721Core) external onlyOwner {
48
+ renounceOwnership();
49
+ genArt721Core = IGenArt721CoreContractV3_Base(_genArt721Core);
50
+ }
51
+
52
+ // modifier to restrict access to only AdminACL allowed calls
53
+ // @dev defers which ACL contract is used to the core contract
54
+ function _onlyCoreAdminACL(bytes4 _selector) internal {
55
+ require(
56
+ genArt721Core.adminACLAllowed(msg.sender, address(this), _selector),
57
+ "Only Core AdminACL allowed"
58
+ );
59
+ }
60
+
61
+ function _onlyArtist(uint256 _projectId) internal view {
62
+ require(
63
+ msg.sender == genArt721Core.projectIdToArtistAddress(_projectId),
64
+ "Only Artist"
65
+ );
66
+ }
67
+
68
+ // Allows the owner of the core contract to set the minter that is allowed to assign hash seeds
69
+ function setHashSeedSetterContract(address _contractAddress) external {
70
+ _onlyCoreAdminACL(this.setHashSeedSetterContract.selector);
71
+ hashSeedSetterContract = _contractAddress;
72
+ emit HashSeedSetterUpdated(_contractAddress);
73
+ }
74
+
75
+ /**
76
+ * @notice Allows the owner of the core contract to configure a project as a polyptych
77
+ * @param _projectId - The ID of the project that has a polyptych panel (second, third, etc.)
78
+ */
79
+ function toggleProjectIsPolyptych(uint256 _projectId) external {
80
+ _onlyArtist(_projectId);
81
+ projectIsPolyptych[_projectId] = !projectIsPolyptych[_projectId];
82
+ emit ProjectIsPolyptychUpdated(
83
+ _projectId,
84
+ projectIsPolyptych[_projectId]
85
+ );
86
+ }
87
+
88
+ // Sets the token hash seed to be re-used in the subsequent panels of a polyptych
89
+ function setPolyptychHashSeed(
90
+ uint256 _tokenId,
91
+ bytes12 _hashSeed
92
+ ) external {
93
+ require(
94
+ msg.sender == hashSeedSetterContract,
95
+ "Only hashSeedSetterContract"
96
+ );
97
+ polyptychHashSeeds[_tokenId] = _hashSeed;
98
+ // @dev event indicating token hash seed assigned is not required for subgraph indexing
99
+ // because token hash seeds are still assigned atomically in `assignTokenHash` function.
100
+ // If token hash seeds were assigned async, event emission may be required to support
101
+ // subgraph indexing.
102
+ }
103
+
104
+ // When `genArt721Core` calls this, it can be assured that the randomizer
105
+ // will set a bytes32 hash for tokenId `_tokenId` on the core contract.
106
+ function assignTokenHash(uint256 _tokenId) external virtual {
107
+ require(msg.sender == address(genArt721Core), "Only core may call");
108
+ bytes32 hash;
109
+ if (projectIsPolyptych[_tokenId / ONE_MILLION]) {
110
+ hash = polyptychHashSeeds[_tokenId];
111
+ } else {
112
+ hash = _getPseudorandom(_tokenId);
113
+ }
114
+ require(hash != 0, "Only non-zero hash seed");
115
+ genArt721Core.setTokenHash_8PT(_tokenId, hash);
116
+ }
117
+ }
@@ -3,34 +3,26 @@
3
3
 
4
4
  pragma solidity 0.8.17;
5
5
 
6
- import "./interfaces/0.8.x/IRandomizerV2.sol";
7
- import "./interfaces/0.8.x/IGenArt721CoreContractV3.sol";
6
+ import "../interfaces/0.8.x/IRandomizerV2.sol";
7
+ import "../interfaces/0.8.x/IGenArt721CoreContractV3_Base.sol";
8
+ import "./BasicRandomizerBase_v0_0_0.sol";
8
9
 
9
10
  import "@openzeppelin-4.7/contracts/access/Ownable.sol";
10
11
 
11
- contract BasicRandomizerV2 is IRandomizerV2, Ownable {
12
+ contract BasicRandomizerV2 is IRandomizerV2, RandomizerBase, Ownable {
12
13
  // The core contract that may interact with this randomizer contract.
13
- IGenArt721CoreContractV3 public genArt721Core;
14
+ IGenArt721CoreContractV3_Base public genArt721Core;
14
15
 
15
16
  function assignCoreAndRenounce(address _genArt721Core) external onlyOwner {
16
17
  renounceOwnership();
17
- genArt721Core = IGenArt721CoreContractV3(_genArt721Core);
18
+ genArt721Core = IGenArt721CoreContractV3_Base(_genArt721Core);
18
19
  }
19
20
 
20
21
  // When `genArt721Core` calls this, it can be assured that the randomizer
21
22
  // will set a bytes32 hash for tokenId `_tokenId` on the core contract.
22
23
  function assignTokenHash(uint256 _tokenId) external virtual {
23
24
  require(msg.sender == address(genArt721Core), "Only core may call");
24
- uint256 time = block.timestamp;
25
- bytes32 hash = keccak256(
26
- abi.encodePacked(
27
- _tokenId,
28
- block.number,
29
- blockhash(block.number - 1),
30
- time,
31
- (time % 200) + 1
32
- )
33
- );
25
+ bytes32 hash = _getPseudorandom(_tokenId);
34
26
  genArt721Core.setTokenHash_8PT(_tokenId, hash);
35
27
  }
36
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artblocks/contracts",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Smart contracts used by Art Blocks",
5
5
  "files": [
6
6
  "/contracts/**/*.sol",
@@ -17,7 +17,15 @@
17
17
  "coverage": "hardhat coverage",
18
18
  "format": "prettier --write 'contracts/**/*.sol' && prettier --write 'scripts/**/*.ts' && prettier --write 'test/**/*.ts'",
19
19
  "lint": "prettier --check 'contracts/**/*.sol' && prettier --check 'scripts/**/*.ts' && prettier --check 'test/**/*.ts' && npx eslint 'test/**/*.ts'",
20
- "remix": "remixd -s ./ --remix-ide https://remix.ethereum.org"
20
+ "remix": "remixd -s ./ --remix-ide https://remix.ethereum.org",
21
+ "codegen:dev": "NODE_ENV=dev yarn graphql-codegen --require dotenv/config --config ./graphql.config.js dotenv_config_path=./.env",
22
+ "codegen:staging": "NODE_ENV=staging yarn graphql-codegen --require dotenv/config --config ./graphql.config.js dotenv_config_path=./.env",
23
+ "codegen:mainnet": "NODE_ENV=mainnet yarn graphql-codegen --require dotenv/config --config ./graphql.config.js dotenv_config_path=./.env",
24
+ "deploy:dev:v3-engine": "yarn codegen:dev && NODE_ENV=dev yarn hardhat run --network goerli scripts/engine/V3/generic-engine-deployer.ts",
25
+ "deploy:staging:v3-engine": "yarn codegen:staging && NODE_ENV=staging yarn hardhat run --network goerli scripts/engine/V3/generic-engine-deployer.ts",
26
+ "deploy:mainnet:v3-engine": "yarn codegen:mainnet && NODE_ENV=mainnet yarn hardhat run --network mainnet scripts/engine/V3/generic-engine-deployer.ts",
27
+ "deploy:goerli:minter": "yarn hardhat run --network goerli scripts/minter-deployments/generic-minter-deployer-v3core.ts",
28
+ "deploy:mainnet:minter": "yarn hardhat run --network mainnet scripts/minter-deployments/generic-minter-deployer-v3core.ts"
21
29
  },
22
30
  "husky": {
23
31
  "hooks": {
@@ -34,43 +42,51 @@
34
42
  "@gnosis.pm/safe-core-sdk-types": "^1.7.0",
35
43
  "@gnosis.pm/safe-ethers-lib": "1.1.0",
36
44
  "@gnosis.pm/safe-service-client": "^1.4.0",
45
+ "@graphql-codegen/cli": "^3.0.0",
46
+ "@graphql-codegen/typescript": "^3.0.0",
47
+ "@graphql-codegen/typescript-document-nodes": "^3.0.0",
48
+ "@graphql-codegen/typescript-operations": "^3.0.0",
49
+ "@graphql-codegen/typescript-urql": "^3.7.3",
50
+ "@nomicfoundation/hardhat-network-helpers": "^1.0.8",
37
51
  "@nomiclabs/hardhat-ethers": "^2.2.1",
38
52
  "@nomiclabs/hardhat-etherscan": "^3.1.4",
39
- "@nomiclabs/hardhat-solhint": "^2.0.0",
53
+ "@nomiclabs/hardhat-solhint": "^3.0.0",
40
54
  "@nomiclabs/hardhat-truffle5": "^2.0.7",
41
55
  "@nomiclabs/hardhat-waffle": "^2.0.3",
42
56
  "@nomiclabs/hardhat-web3": "^2.0.0",
43
57
  "@openzeppelin/hardhat-upgrades": "^1.22.0",
44
58
  "@openzeppelin/test-helpers": "^0.5.16",
45
- "@remix-project/remixd": "^0.5.6",
59
+ "@remix-project/remixd": "^0.6.12",
46
60
  "@typechain/ethers-v5": "^6.0.5",
47
- "@types/jest": "^27.0.3",
48
- "@types/mocha": "^9.1.1",
61
+ "@types/jest": "^29.4.0",
62
+ "@types/mocha": "^10.0.1",
63
+ "@types/prompt": "^1.1.5",
49
64
  "@typescript-eslint/eslint-plugin": "^5.48.0",
50
65
  "@typescript-eslint/parser": "^5.48.0",
51
- "aws-sdk-client-mock": "^0.6.2",
66
+ "aws-sdk-client-mock": "^2.1.1",
52
67
  "chai": "^4.3.7",
53
68
  "coveralls": "^3.1.1",
54
- "dotenv": "^8.2.0",
69
+ "dotenv": "^16.0.3",
55
70
  "eslint": "^8.31.0",
56
71
  "eslint-plugin-mocha": "^10.1.0",
57
- "ethereum-waffle": "^3.4.4",
72
+ "ethereum-waffle": "^4.0.10",
58
73
  "ethers": "^5.7.2",
59
74
  "hardhat": "^2.12.5",
60
75
  "hardhat-contract-sizer": "^2.6.1",
61
76
  "hardhat-docgen": "^1.3.0",
62
77
  "hardhat-gas-reporter": "^1.0.9",
63
- "husky": "^7.0.4",
78
+ "husky": "^8.0.3",
64
79
  "istanbul-combine": "^0.3.0",
65
80
  "keccak256": "^1.0.6",
66
- "merkletreejs": "^0.2.31",
81
+ "merkletreejs": "^0.3.9",
67
82
  "prettier": "^2.8.1",
68
83
  "prettier-plugin-solidity": "^1.1.1",
84
+ "prompt": "^1.3.0",
69
85
  "prompt-sync": "^4.2.0",
70
86
  "solidity-coverage": "^0.8.0",
71
87
  "ts-node": "^9.1.1",
72
88
  "typechain": "^4.0.3",
73
- "typescript": "^4.9.4"
89
+ "typescript": "^5.0.2"
74
90
  },
75
91
  "author": "Art Blocks, Inc",
76
92
  "license": "LGPL-3.0-only",
@@ -78,6 +94,9 @@
78
94
  "@openzeppelin-0.5/contracts": "npm:@openzeppelin/contracts@2.5.1",
79
95
  "@openzeppelin-4.5/contracts": "npm:@openzeppelin/contracts@4.5.0",
80
96
  "@openzeppelin-4.7/contracts": "npm:@openzeppelin/contracts@4.7.1",
81
- "@openzeppelin-4.8/contracts-upgradeable": "npm:@openzeppelin/contracts-upgradeable@4.8.0"
97
+ "@openzeppelin-4.8/contracts-upgradeable": "npm:@openzeppelin/contracts-upgradeable@4.8.0",
98
+ "@urql/exchange-retry": "^1.0.0",
99
+ "graphql": "^16.6.0",
100
+ "urql": "^3.0.3"
82
101
  }
83
102
  }