@artblocks/contracts 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +2 -2
  2. package/artifacts/contracts/AdminACLV1.sol/AdminACLV1.json +2 -2
  3. package/artifacts/contracts/DependencyRegistryV0.sol/DependencyRegistryV0.json +97 -10
  4. package/artifacts/contracts/GenArt721CoreV3.sol/GenArt721CoreV3.json +4 -4
  5. package/artifacts/contracts/engine/V3/GenArt721CoreV3_Engine.sol/GenArt721CoreV3_Engine.json +4 -9
  6. package/artifacts/contracts/engine/V3/GenArt721CoreV3_Engine_Flex.sol/GenArt721CoreV3_Engine_Flex.json +4 -9
  7. package/artifacts/contracts/engine/V3/forks/GenArt721CoreV3_Engine_Flex_PROOF.sol/GenArt721CoreV3_Engine_Flex_PROOF.json +4 -9
  8. package/artifacts/contracts/engine/V3/forks/PROHIBITION/GenArt721CoreV3_Engine_Flex_PROHIBITION.sol/GenArt721CoreV3_Engine_Flex_PROHIBITION.json +4 -9
  9. package/artifacts/contracts/engine-registry/CoreRegistryV1.sol/CoreRegistryV1.json +12 -12
  10. package/artifacts/contracts/explorations/GenArt721CoreV3_Explorations.sol/GenArt721CoreV3_Explorations.json +4 -4
  11. package/artifacts/contracts/interfaces/v0.8.x/ICoreRegistryV1.sol/ICoreRegistryV1.json +6 -6
  12. package/artifacts/contracts/interfaces/v0.8.x/IDependencyRegistryV0.sol/IDependencyRegistryV0.json +19 -0
  13. package/artifacts/contracts/interfaces/v0.8.x/IMinterFilterV1.sol/IMinterFilterV1.json +22 -22
  14. package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterDAExpSettlementV0.sol/ISharedMinterDAExpSettlementV0.json +8 -101
  15. package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterDAExpV0.sol/ISharedMinterDAExpV0.json +1 -57
  16. package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterDALinV0.sol/ISharedMinterDALinV0.json +1 -57
  17. package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterDAV0.sol/ISharedMinterDAV0.json +2 -21
  18. package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterHolderERC20V0.sol/ISharedMinterHolderERC20V0.json +158 -0
  19. package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterHolderV0.sol/ISharedMinterHolderV0.json +15 -90
  20. package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterMerkleV0.sol/ISharedMinterMerkleV0.json +10 -36
  21. package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterSEAV0.sol/ISharedMinterSEAV0.json +4 -236
  22. package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterSimplePurchaseV0.sol/ISharedMinterSimplePurchaseV0.json +5 -5
  23. package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterV0.sol/ISharedMinterV0.json +7 -423
  24. package/artifacts/contracts/interfaces/v0.8.x/ISharedRandomizerV0.sol/ISharedRandomizerV0.json +17 -17
  25. package/artifacts/contracts/libs/v0.8.x/ABHelpers.sol/ABHelpers.json +2 -2
  26. package/artifacts/contracts/libs/v0.8.x/AuthLib.sol/AuthLib.json +2 -2
  27. package/artifacts/contracts/libs/v0.8.x/Bytes32Strings.sol/Bytes32Strings.json +2 -2
  28. package/artifacts/contracts/libs/v0.8.x/minter-libs/DAExpLib.sol/DAExpLib.json +60 -3
  29. package/artifacts/contracts/libs/v0.8.x/minter-libs/DALib.sol/DALib.json +30 -0
  30. package/artifacts/contracts/libs/v0.8.x/minter-libs/DALinLib.sol/DALinLib.json +60 -3
  31. package/artifacts/contracts/libs/v0.8.x/minter-libs/GenericMinterEventsLib.sol/GenericMinterEventsLib.json +346 -0
  32. package/artifacts/contracts/libs/v0.8.x/minter-libs/MaxInvocationsLib.sol/MaxInvocationsLib.json +29 -3
  33. package/artifacts/contracts/libs/v0.8.x/minter-libs/MerkleLib.sol/MerkleLib.json +30 -3
  34. package/artifacts/contracts/libs/v0.8.x/minter-libs/PolyptychLib.sol/PolyptychLib.json +2 -2
  35. package/artifacts/contracts/libs/v0.8.x/minter-libs/SEALib.sol/SEALib.json +254 -3
  36. package/artifacts/contracts/libs/v0.8.x/minter-libs/SetPriceLib.sol/SetPriceLib.json +48 -3
  37. package/artifacts/contracts/libs/v0.8.x/minter-libs/SettlementExpLib.sol/SettlementExpLib.json +41 -3
  38. package/artifacts/contracts/libs/v0.8.x/minter-libs/SplitFundsLib.sol/SplitFundsLib.json +35 -3
  39. package/artifacts/contracts/libs/v0.8.x/minter-libs/TokenHolderLib.sol/TokenHolderLib.json +79 -3
  40. package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV1.sol/MinterFilterV1.json +2 -2
  41. package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV2.sol/MinterFilterV2.json +41 -41
  42. package/artifacts/contracts/minter-suite/Minters/MinterDAExpHolderV5.sol/MinterDAExpHolderV5.json +66 -632
  43. package/artifacts/contracts/minter-suite/Minters/MinterDAExpSettlementV2.sol/MinterDAExpSettlementV2.json +2 -20
  44. package/artifacts/contracts/minter-suite/Minters/MinterDAExpSettlementV3.sol/MinterDAExpSettlementV3.json +67 -594
  45. package/artifacts/contracts/minter-suite/Minters/MinterDAExpV5.sol/MinterDAExpV5.json +33 -524
  46. package/artifacts/contracts/minter-suite/Minters/MinterDALinHolderV5.sol/MinterDALinHolderV5.json +66 -632
  47. package/artifacts/contracts/minter-suite/Minters/MinterDALinV5.sol/MinterDALinV5.json +33 -524
  48. package/artifacts/contracts/minter-suite/Minters/MinterSEAV1.sol/MinterSEAV1.json +51 -717
  49. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20V5.sol/MinterSetPriceERC20V5.json +58 -454
  50. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceHolderV5.sol/MinterSetPriceHolderV5.json +61 -552
  51. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceMerkleV5.sol/MinterSetPriceMerkleV5.json +55 -497
  52. package/artifacts/contracts/minter-suite/Minters/MinterSetPricePolyptychERC20V5.sol/MinterSetPricePolyptychERC20V5.json +110 -571
  53. package/artifacts/contracts/minter-suite/Minters/MinterSetPricePolyptychV5.sol/MinterSetPricePolyptychV5.json +69 -560
  54. package/artifacts/contracts/minter-suite/Minters/MinterSetPriceV5.sol/MinterSetPriceV5.json +28 -444
  55. package/artifacts/contracts/mock/DummySharedMinter.sol/DummySharedMinter.json +2 -2
  56. package/artifacts/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol/GenArt721CoreV3_Engine_IncorrectCoreType.json +4 -9
  57. package/artifacts/contracts/mock/OriginRegisterMock.sol/OriginRegisterMock.json +2 -2
  58. package/artifacts/contracts/mock/ReentrancyHolderMockShared.sol/ReentrancyHolderMockShared.json +136 -0
  59. package/artifacts/contracts/mock/ReentrancyMerkleMockShared.sol/ReentrancyMerkleMockShared.json +105 -0
  60. package/artifacts/contracts/mock/ReentrancyMockShared.sol/ReentrancyMockShared.json +100 -0
  61. package/artifacts/contracts/mock/ReentrancySEAMockShared.sol/ReentrancySEAAutoBidderMockShared.json +69 -0
  62. package/artifacts/contracts/randomizer/shared/SharedRandomizerV0.sol/SharedRandomizerV0.json +19 -19
  63. package/contracts/DependencyRegistryV0.sol +84 -16
  64. package/contracts/archive/readme.md +16 -0
  65. package/contracts/engine/README.md +21 -0
  66. package/contracts/engine/V3/GenArt721CoreV3_Engine.sol +4 -10
  67. package/contracts/engine/V3/GenArt721CoreV3_Engine_Flex.sol +4 -10
  68. package/contracts/engine/V3/forks/GenArt721CoreV3_Engine_Flex_PROOF.sol +4 -10
  69. package/contracts/engine/V3/forks/PROHIBITION/GenArt721CoreV3_Engine_Flex_PROHIBITION.sol +4 -10
  70. package/contracts/engine-registry/CoreRegistryV1.sol +58 -65
  71. package/contracts/interfaces/v0.8.x/ICoreRegistryV1.sol +6 -8
  72. package/contracts/interfaces/v0.8.x/IDependencyRegistryV0.sol +3 -0
  73. package/contracts/interfaces/v0.8.x/IMinterFilterV1.sol +25 -25
  74. package/contracts/interfaces/v0.8.x/ISharedMinterDAExpSettlementV0.sol +11 -20
  75. package/contracts/interfaces/v0.8.x/ISharedMinterDAExpV0.sol +1 -14
  76. package/contracts/interfaces/v0.8.x/ISharedMinterDALinV0.sol +1 -15
  77. package/contracts/interfaces/v0.8.x/ISharedMinterDAV0.sol +2 -8
  78. package/contracts/interfaces/v0.8.x/ISharedMinterHolderERC20V0.sol +47 -0
  79. package/contracts/interfaces/v0.8.x/ISharedMinterHolderV0.sol +15 -43
  80. package/contracts/interfaces/v0.8.x/ISharedMinterMerkleV0.sol +10 -20
  81. package/contracts/interfaces/v0.8.x/ISharedMinterSEAV0.sol +4 -67
  82. package/contracts/interfaces/v0.8.x/ISharedMinterSimplePurchaseV0.sol +5 -5
  83. package/contracts/interfaces/v0.8.x/ISharedMinterV0.sol +7 -155
  84. package/contracts/interfaces/v0.8.x/ISharedRandomizerV0.sol +37 -37
  85. package/contracts/libs/v0.8.x/ABHelpers.sol +14 -14
  86. package/contracts/libs/v0.8.x/AuthLib.sol +101 -102
  87. package/contracts/libs/v0.8.x/Bytes32Strings.sol +5 -5
  88. package/contracts/libs/v0.8.x/minter-libs/DAExpLib.sol +163 -38
  89. package/contracts/libs/v0.8.x/minter-libs/DALib.sol +26 -0
  90. package/contracts/libs/v0.8.x/minter-libs/DALinLib.sol +144 -37
  91. package/contracts/libs/v0.8.x/minter-libs/GenericMinterEventsLib.sol +171 -0
  92. package/contracts/libs/v0.8.x/minter-libs/MaxInvocationsLib.sol +250 -110
  93. package/contracts/libs/v0.8.x/minter-libs/MerkleLib.sol +257 -48
  94. package/contracts/libs/v0.8.x/minter-libs/PolyptychLib.sol +138 -58
  95. package/contracts/libs/v0.8.x/minter-libs/SEALib.sol +778 -103
  96. package/contracts/libs/v0.8.x/minter-libs/SetPriceLib.sol +135 -13
  97. package/contracts/libs/v0.8.x/minter-libs/SettlementExpLib.sol +567 -187
  98. package/contracts/libs/v0.8.x/minter-libs/SplitFundsLib.sol +480 -322
  99. package/contracts/libs/v0.8.x/minter-libs/TokenHolderLib.sol +214 -76
  100. package/contracts/minter-suite/MinterFilter/MinterFilterV2.sol +347 -304
  101. package/contracts/minter-suite/Minters/MinterDAExpHolderV5.sol +391 -491
  102. package/contracts/minter-suite/Minters/MinterDAExpSettlementV2.sol +1 -54
  103. package/contracts/minter-suite/Minters/MinterDAExpSettlementV3.sol +388 -628
  104. package/contracts/minter-suite/Minters/MinterDAExpV5.sol +212 -273
  105. package/contracts/minter-suite/Minters/MinterDALinHolderV5.sol +393 -488
  106. package/contracts/minter-suite/Minters/MinterDALinV5.sol +220 -277
  107. package/contracts/minter-suite/Minters/MinterSEAV1.sol +327 -664
  108. package/contracts/minter-suite/Minters/MinterSetPriceERC20V5.sol +278 -303
  109. package/contracts/minter-suite/Minters/MinterSetPriceHolderV5.sol +355 -446
  110. package/contracts/minter-suite/Minters/MinterSetPriceMerkleV5.sol +328 -416
  111. package/contracts/minter-suite/Minters/MinterSetPricePolyptychERC20V5.sol +538 -622
  112. package/contracts/minter-suite/Minters/MinterSetPricePolyptychV5.sol +429 -553
  113. package/contracts/minter-suite/Minters/MinterSetPriceV5.sol +180 -227
  114. package/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol +3 -10
  115. package/contracts/mock/ReentrancyHolderMockShared.sol +59 -0
  116. package/contracts/mock/ReentrancyMerkleMockShared.sol +58 -0
  117. package/contracts/mock/ReentrancyMockShared.sol +48 -0
  118. package/contracts/mock/ReentrancySEAMockShared.sol +40 -0
  119. package/contracts/randomizer/shared/SharedRandomizerV0.sol +78 -70
  120. package/package.json +39 -33
@@ -1,23 +1,25 @@
1
1
  // SPDX-License-Identifier: LGPL-3.0-only
2
2
  // Created By: Art Blocks Inc.
3
3
 
4
- import "../../interfaces/v0.8.x/IGenArt721CoreContractV3_Base.sol";
5
- import "../../interfaces/v0.8.x/IDelegationRegistry.sol";
6
- import "../../interfaces/v0.8.x/ISharedMinterV0.sol";
7
- import "../../interfaces/v0.8.x/ISharedMinterHolderV0.sol";
8
- import "../../interfaces/v0.8.x/IMinterFilterV1.sol";
4
+ // @dev fixed to specific solidity version for clarity and for more clear
5
+ // source code verification purposes.
6
+ pragma solidity 0.8.19;
9
7
 
10
- import "../../libs/v0.8.x/AuthLib.sol";
11
- import "../../libs/v0.8.x/minter-libs/SplitFundsLib.sol";
12
- import "../../libs/v0.8.x/minter-libs/MaxInvocationsLib.sol";
13
- import "../../libs/v0.8.x/minter-libs/SetPriceLib.sol";
14
- import "../../libs/v0.8.x/minter-libs/TokenHolderLib.sol";
15
- import "../../libs/v0.8.x/minter-libs/PolyptychLib.sol";
8
+ import {IGenArt721CoreContractV3_Base} from "../../interfaces/v0.8.x/IGenArt721CoreContractV3_Base.sol";
9
+ import {IDelegationRegistry} from "../../interfaces/v0.8.x/IDelegationRegistry.sol";
10
+ import {ISharedMinterV0} from "../../interfaces/v0.8.x/ISharedMinterV0.sol";
11
+ import {ISharedMinterHolderERC20V0} from "../../interfaces/v0.8.x/ISharedMinterHolderERC20V0.sol";
12
+ import {IMinterFilterV1} from "../../interfaces/v0.8.x/IMinterFilterV1.sol";
16
13
 
17
- import "@openzeppelin-4.5/contracts/security/ReentrancyGuard.sol";
18
- import "@openzeppelin-4.5/contracts/utils/structs/EnumerableSet.sol";
14
+ import {AuthLib} from "../../libs/v0.8.x/AuthLib.sol";
15
+ import {SplitFundsLib} from "../../libs/v0.8.x/minter-libs/SplitFundsLib.sol";
16
+ import {MaxInvocationsLib} from "../../libs/v0.8.x/minter-libs/MaxInvocationsLib.sol";
17
+ import {SetPriceLib} from "../../libs/v0.8.x/minter-libs/SetPriceLib.sol";
18
+ import {TokenHolderLib} from "../../libs/v0.8.x/minter-libs/TokenHolderLib.sol";
19
+ import {PolyptychLib} from "../../libs/v0.8.x/minter-libs/PolyptychLib.sol";
19
20
 
20
- pragma solidity 0.8.19;
21
+ import {ReentrancyGuard} from "@openzeppelin-4.5/contracts/security/ReentrancyGuard.sol";
22
+ import {EnumerableSet} from "@openzeppelin-4.5/contracts/utils/structs/EnumerableSet.sol";
21
23
 
22
24
  /**
23
25
  * @title Shared, filtered Minter contract that allows tokens to be minted with
@@ -72,11 +74,18 @@ pragma solidity 0.8.19;
72
74
  * Token-level delegations are configured by the vault owner, and contract-
73
75
  * level delegations must be configured for the core token contract as returned
74
76
  * by the public immutable variable `genArt721CoreAddress`.
77
+ * ----------------------------------------------------------------------------
78
+ * @notice Caution: While Engine projects must be registered on the Art Blocks
79
+ * Core Registry to assign this minter, this minter does not enforce that a
80
+ * project is registered when configured or queried. This is primarily for gas
81
+ * optimization purposes. It is, therefore, possible that fake projects may be
82
+ * configured on this minter, but they will not be able to mint tokens due to
83
+ * checks performed by this minter's Minter Filter.
75
84
  */
76
85
  contract MinterSetPricePolyptychERC20V5 is
77
86
  ReentrancyGuard,
78
87
  ISharedMinterV0,
79
- ISharedMinterHolderV0
88
+ ISharedMinterHolderERC20V0
80
89
  {
81
90
  // add Enumerable Set methods
82
91
  using EnumerableSet for EnumerableSet.AddressSet;
@@ -85,13 +94,13 @@ contract MinterSetPricePolyptychERC20V5 is
85
94
  address public immutable minterFilterAddress;
86
95
 
87
96
  /// Minter filter this minter may interact with.
88
- IMinterFilterV1 private immutable minterFilter;
97
+ IMinterFilterV1 private immutable _minterFilter;
89
98
 
90
99
  /// Delegation registry address
91
100
  address public immutable delegationRegistryAddress;
92
101
 
93
102
  /// Delegation registry address
94
- IDelegationRegistry private immutable delegationRegistryContract;
103
+ IDelegationRegistry private immutable _delegationRegistryContract;
95
104
 
96
105
  /// minterType for this minter
97
106
  string public constant minterType = "MinterSetPricePolyptychERC20V5";
@@ -99,73 +108,7 @@ contract MinterSetPricePolyptychERC20V5 is
99
108
  /// minter version for this minter
100
109
  string public constant minterVersion = "v5.0.0";
101
110
 
102
- uint256 constant ONE_MILLION = 1_000_000;
103
-
104
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
105
- // STATE VARIABLES FOR SetPriceLib begin here
106
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
107
-
108
- /// contractAddress => projectId => set price project config
109
- mapping(address => mapping(uint256 => SetPriceLib.SetPriceProjectConfig))
110
- private _setPriceProjectConfigMapping;
111
-
112
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
113
- // STATE VARIABLES FOR SetPriceLib end here
114
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
115
-
116
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
117
- // STATE VARIABLES FOR SplitFundsLib begin here
118
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
119
-
120
- // contractAddress => IsEngineCache
121
- mapping(address => SplitFundsLib.IsEngineCache) private _isEngineCaches;
122
-
123
- // contractAddress => projectId => SplitFundsProjectConfig
124
- mapping(address => mapping(uint256 => SplitFundsLib.SplitFundsProjectConfig))
125
- private _splitFundsProjectConfigs;
126
-
127
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
128
- // STATE VARIABLES FOR SplitFundsLib end here
129
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
130
-
131
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
132
- // STATE VARIABLES FOR MaxInvocationsLib begin here
133
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
134
-
135
- // contractAddress => projectId => max invocations specific project config
136
- mapping(address => mapping(uint256 => MaxInvocationsLib.MaxInvocationsProjectConfig))
137
- private _maxInvocationsProjectConfigMapping;
138
-
139
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
140
- // STATE VARIABLES FOR MaxInvocationsLib end here
141
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
142
-
143
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
144
- // STATE VARIABLES FOR PolyptychLib begin here
145
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
146
-
147
- // contractAddress => projectId => polyptych project config
148
- mapping(address => mapping(uint256 => PolyptychLib.PolyptychProjectConfig))
149
- private _polyptychProjectConfigs;
150
-
151
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
152
- // STATE VARIABLES FOR PolyptychLib end here
153
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
154
-
155
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
156
- // STATE VARIABLES FOR TokenHolderLib begin here
157
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
158
-
159
- /**
160
- * coreContract => projectId => ownedNFTAddress => ownedNFTProjectIds => bool
161
- * projects whose holders are allowed to purchase a token on `projectId`
162
- */
163
- mapping(address => mapping(uint256 => TokenHolderLib.HolderProjectConfig))
164
- private _allowedProjectHoldersMapping;
165
-
166
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
167
- // STATE VARIABLES FOR TokenHolderLib end here
168
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
111
+ uint256 internal constant ONE_MILLION = 1_000_000;
169
112
 
170
113
  // MODIFIERS
171
114
  // @dev contract uses modifier-like internal functions instead of modifiers
@@ -174,498 +117,474 @@ contract MinterSetPricePolyptychERC20V5 is
174
117
 
175
118
  /**
176
119
  * @notice Initializes contract to be a Filtered Minter for
177
- * `_minterFilter` minter filter.
178
- * @param _minterFilter Minter filter for which this will be a
120
+ * `minterFilter` minter filter.
121
+ * @param minterFilter Minter filter for which this will be a
179
122
  * filtered minter.
180
- * @param _delegationRegistryAddress Delegation registry contract address.
123
+ * @param delegationRegistryAddress_ Delegation registry contract address.
181
124
  */
182
125
  constructor(
183
- address _minterFilter,
184
- address _delegationRegistryAddress
126
+ address minterFilter,
127
+ address delegationRegistryAddress_
185
128
  ) ReentrancyGuard() {
186
- minterFilterAddress = _minterFilter;
187
- minterFilter = IMinterFilterV1(_minterFilter);
129
+ minterFilterAddress = minterFilter;
130
+ _minterFilter = IMinterFilterV1(minterFilter);
188
131
 
189
- delegationRegistryAddress = _delegationRegistryAddress;
190
- delegationRegistryContract = IDelegationRegistry(
191
- _delegationRegistryAddress
132
+ delegationRegistryAddress = delegationRegistryAddress_;
133
+ _delegationRegistryContract = IDelegationRegistry(
134
+ delegationRegistryAddress_
135
+ );
136
+ emit TokenHolderLib.DelegationRegistryUpdated(
137
+ delegationRegistryAddress_
192
138
  );
193
- emit DelegationRegistryUpdated(_delegationRegistryAddress);
194
139
  }
195
140
 
196
141
  /**
197
- * @notice Manually sets the local maximum invocations of project `_projectId`
198
- * with the provided `_maxInvocations`, checking that `_maxInvocations` is less
199
- * than or equal to the value of project `_project_id`'s maximum invocations that is
142
+ * @notice Manually sets the local maximum invocations of project `projectId`
143
+ * with the provided `maxInvocations`, checking that `maxInvocations` is less
144
+ * than or equal to the value of project `project_id`'s maximum invocations that is
200
145
  * set on the core contract.
201
- * @dev Note that a `_maxInvocations` of 0 can only be set if the current `invocations`
146
+ * @dev Note that a `maxInvocations` of 0 can only be set if the current `invocations`
202
147
  * value is also 0 and this would also set `maxHasBeenInvoked` to true, correctly short-circuiting
203
148
  * this minter's purchase function, avoiding extra gas costs from the core contract's maxInvocations check.
204
- * @param _projectId Project ID to set the maximum invocations for.
205
- * @param _coreContract Core contract address for the given project.
206
- * @param _maxInvocations Maximum invocations to set for the project.
149
+ * @param projectId Project ID to set the maximum invocations for.
150
+ * @param coreContract Core contract address for the given project.
151
+ * @param maxInvocations Maximum invocations to set for the project.
207
152
  */
208
153
  function manuallyLimitProjectMaxInvocations(
209
- uint256 _projectId,
210
- address _coreContract,
211
- uint24 _maxInvocations
154
+ uint256 projectId,
155
+ address coreContract,
156
+ uint24 maxInvocations
212
157
  ) external {
213
158
  AuthLib.onlyArtist({
214
- _projectId: _projectId,
215
- _coreContract: _coreContract,
216
- _sender: msg.sender
159
+ projectId: projectId,
160
+ coreContract: coreContract,
161
+ sender: msg.sender
162
+ });
163
+ MaxInvocationsLib.manuallyLimitProjectMaxInvocations({
164
+ projectId: projectId,
165
+ coreContract: coreContract,
166
+ maxInvocations: maxInvocations
217
167
  });
218
- MaxInvocationsLib.manuallyLimitProjectMaxInvocations(
219
- _projectId,
220
- _coreContract,
221
- _maxInvocations,
222
- _maxInvocationsProjectConfigMapping[_coreContract][_projectId]
223
- );
224
- emit ProjectMaxInvocationsLimitUpdated(
225
- _projectId,
226
- _coreContract,
227
- _maxInvocations
228
- );
229
168
  }
230
169
 
231
170
  /**
232
- * @notice Updates this minter's price per token of project `_projectId`
233
- * to be '_pricePerTokenInWei`, in Wei.
171
+ * @notice Updates this minter's price per token of project `projectId`
172
+ * to be `pricePerTokenInWei`. Note that "in wei" is a misnomer on this
173
+ * ERC20 minter, but is used for consistency with the ETH minters. The
174
+ * price value represents the ERC20 token price without decimals.
234
175
  * @dev Note that it is intentionally supported here that the configured
235
176
  * price may be explicitly set to `0`.
236
- * @param _projectId Project ID to set the price per token for.
237
- * @param _coreContract Core contract address for the given project.
238
- * @param _pricePerTokenInWei Price per token to set for the project, in Wei.
177
+ * @param projectId Project ID to set the price per token for.
178
+ * @param coreContract Core contract address for the given project.
179
+ * @param pricePerTokenInWei Price per token to set for the project.
180
+ * Represents the ERC20 token price without decimals.
239
181
  */
240
182
  function updatePricePerTokenInWei(
241
- uint256 _projectId,
242
- address _coreContract,
243
- uint248 _pricePerTokenInWei
183
+ uint256 projectId,
184
+ address coreContract,
185
+ uint248 pricePerTokenInWei
244
186
  ) external {
245
187
  AuthLib.onlyArtist({
246
- _projectId: _projectId,
247
- _coreContract: _coreContract,
248
- _sender: msg.sender
188
+ projectId: projectId,
189
+ coreContract: coreContract,
190
+ sender: msg.sender
191
+ });
192
+ SetPriceLib.updatePricePerToken({
193
+ projectId: projectId,
194
+ coreContract: coreContract,
195
+ pricePerToken: pricePerTokenInWei
249
196
  });
250
- SetPriceLib.SetPriceProjectConfig
251
- storage _setPriceProjectConfig = _setPriceProjectConfigMapping[
252
- _coreContract
253
- ][_projectId];
254
- SetPriceLib.updatePricePerTokenInWei(
255
- _pricePerTokenInWei,
256
- _setPriceProjectConfig
257
- );
258
- emit PricePerTokenInWeiUpdated(
259
- _projectId,
260
- _coreContract,
261
- _pricePerTokenInWei
262
- );
263
197
 
264
198
  // for convenience, sync local max invocations to the core contract if
265
199
  // and only if max invocations have not already been synced.
266
200
  // @dev do not sync if max invocations have already been synced, as
267
201
  // local max invocations could have been manually set to be
268
202
  // intentionally less than the core contract's max invocations.
269
- MaxInvocationsLib.MaxInvocationsProjectConfig
270
- storage _maxInvocationsProjectConfig = _maxInvocationsProjectConfigMapping[
271
- _coreContract
272
- ][_projectId];
273
203
  // @dev if local maxInvocations and maxHasBeenInvoked are both
274
204
  // initial values, we know they have not been populated on this minter
275
205
  if (
276
- MaxInvocationsLib.maxInvocationsIsUnconfigured(
277
- _maxInvocationsProjectConfig
278
- )
206
+ MaxInvocationsLib.maxInvocationsIsUnconfigured({
207
+ projectId: projectId,
208
+ coreContract: coreContract
209
+ })
279
210
  ) {
280
- syncProjectMaxInvocationsToCore(_projectId, _coreContract);
211
+ syncProjectMaxInvocationsToCore({
212
+ projectId: projectId,
213
+ coreContract: coreContract
214
+ });
281
215
  }
282
216
  }
283
217
 
284
218
  /**
285
- * @notice Updates payment currency of project `_projectId` on core
286
- * contract `_coreContract` to be `_currencySymbol` at address
287
- * `_currencyAddress`.
219
+ * @notice Updates payment currency of project `projectId` on core
220
+ * contract `coreContract` to be `currencySymbol` at address
221
+ * `currencyAddress`.
288
222
  * Only supports ERC20 tokens - for ETH minting, use a different minter.
289
- * @param _projectId Project ID to update.
290
- * @param _coreContract Core contract address for the given project.
291
- * @param _currencySymbol Currency symbol.
292
- * @param _currencyAddress Currency address.
223
+ * Resets price to be unconfigured if currency was previously configured,
224
+ * as a safeguard against accidentally setting a price in one currency
225
+ * and then changing the currency but not the price.
226
+ * @dev nonReentrant because no reentrant use cases, and to eliminate an
227
+ * entire branch of reentrancy attack vectors.
228
+ * @param projectId Project ID to update.
229
+ * @param coreContract Core contract address for the given project.
230
+ * @param currencySymbol Currency symbol.
231
+ * @param currencyAddress Currency address.
293
232
  */
294
233
  function updateProjectCurrencyInfo(
295
- uint256 _projectId,
296
- address _coreContract,
297
- string memory _currencySymbol,
298
- address _currencyAddress
234
+ uint256 projectId,
235
+ address coreContract,
236
+ string memory currencySymbol,
237
+ address currencyAddress
299
238
  ) external nonReentrant {
300
239
  AuthLib.onlyArtist({
301
- _projectId: _projectId,
302
- _coreContract: _coreContract,
303
- _sender: msg.sender
304
- });
305
- SplitFundsLib.SplitFundsProjectConfig
306
- storage _splitFundsProjectConfig = _splitFundsProjectConfigs[
307
- _coreContract
308
- ][_projectId];
309
- SplitFundsLib.updateProjectCurrencyInfoERC20({
310
- _splitFundsProjectConfig: _splitFundsProjectConfig,
311
- _currencySymbol: _currencySymbol,
312
- _currencyAddress: _currencyAddress
313
- });
314
- emit ProjectCurrencyInfoUpdated({
315
- _projectId: _projectId,
316
- _coreContract: _coreContract,
317
- _currencyAddress: _currencyAddress,
318
- _currencySymbol: _currencySymbol
240
+ projectId: projectId,
241
+ coreContract: coreContract,
242
+ sender: msg.sender
319
243
  });
244
+ bool recommendPriceReset = SplitFundsLib
245
+ .updateProjectCurrencyInfoERC20({
246
+ projectId: projectId,
247
+ coreContract: coreContract,
248
+ currencySymbol: currencySymbol,
249
+ currencyAddress: currencyAddress
250
+ });
251
+ if (recommendPriceReset) {
252
+ SetPriceLib.resetPricePerToken({
253
+ projectId: projectId,
254
+ coreContract: coreContract
255
+ });
256
+ }
320
257
  }
321
258
 
322
259
  /**
323
- * @notice Allows holders of NFTs at addresses `_ownedNFTAddresses`,
324
- * project IDs `_ownedNFTProjectIds` to mint on project `_projectId`.
325
- * `_ownedNFTAddresses` assumed to be aligned with `_ownedNFTProjectIds`.
326
- * e.g. Allows holders of project `_ownedNFTProjectIds[0]` on token
327
- * contract `_ownedNFTAddresses[0]` to mint `_projectId`.
260
+ * @notice Allows holders of NFTs at addresses `ownedNFTAddresses`,
261
+ * project IDs `ownedNFTProjectIds` to mint on project `projectId`.
262
+ * `ownedNFTAddresses` assumed to be aligned with `ownedNFTProjectIds`.
263
+ * e.g. Allows holders of project `ownedNFTProjectIds[0]` on token
264
+ * contract `ownedNFTAddresses[0]` to mint `projectId`.
328
265
  * WARNING: Only Art Blocks Core contracts are compatible with holder allowlisting,
329
266
  * due to assumptions about tokenId and projectId relationships.
330
- * @param _projectId Project ID to enable minting on.
331
- * @param _coreContract Core contract address for the given project.
332
- * @param _ownedNFTAddresses NFT core addresses of projects to be
333
- * allowlisted. Indexes must align with `_ownedNFTProjectIds`.
334
- * @param _ownedNFTProjectIds Project IDs on `_ownedNFTAddresses` whose
335
- * holders shall be allowlisted to mint project `_projectId`. Indexes must
336
- * align with `_ownedNFTAddresses`.
267
+ * @param projectId Project ID to enable minting on.
268
+ * @param coreContract Core contract address for the given project.
269
+ * @param ownedNFTAddresses NFT core addresses of projects to be
270
+ * allowlisted. Indexes must align with `ownedNFTProjectIds`.
271
+ * @param ownedNFTProjectIds Project IDs on `ownedNFTAddresses` whose
272
+ * holders shall be allowlisted to mint project `projectId`. Indexes must
273
+ * align with `ownedNFTAddresses`.
337
274
  */
338
275
  function allowHoldersOfProjects(
339
- uint256 _projectId,
340
- address _coreContract,
341
- address[] memory _ownedNFTAddresses,
342
- uint256[] memory _ownedNFTProjectIds
276
+ uint256 projectId,
277
+ address coreContract,
278
+ address[] calldata ownedNFTAddresses,
279
+ uint256[] calldata ownedNFTProjectIds
343
280
  ) external {
344
281
  AuthLib.onlyArtist({
345
- _projectId: _projectId,
346
- _coreContract: _coreContract,
347
- _sender: msg.sender
282
+ projectId: projectId,
283
+ coreContract: coreContract,
284
+ sender: msg.sender
348
285
  });
349
286
  TokenHolderLib.allowHoldersOfProjects({
350
- holderProjectConfig: _allowedProjectHoldersMapping[_coreContract][
351
- _projectId
352
- ],
353
- _ownedNFTAddresses: _ownedNFTAddresses,
354
- _ownedNFTProjectIds: _ownedNFTProjectIds
287
+ projectId: projectId,
288
+ coreContract: coreContract,
289
+ ownedNFTAddresses: ownedNFTAddresses,
290
+ ownedNFTProjectIds: ownedNFTProjectIds
355
291
  });
356
-
357
- // emit approve event
358
- emit AllowedHoldersOfProjects(
359
- _projectId,
360
- _coreContract,
361
- _ownedNFTAddresses,
362
- _ownedNFTProjectIds
363
- );
364
292
  }
365
293
 
366
294
  /**
367
- * @notice Removes holders of NFTs at addresses `_ownedNFTAddresses`,
368
- * project IDs `_ownedNFTProjectIds` to mint on project `_projectId`. If
295
+ * @notice Removes holders of NFTs at addresses `ownedNFTAddresses`,
296
+ * project IDs `ownedNFTProjectIds` to mint on project `projectId`. If
369
297
  * other projects owned by a holder are still allowed to mint, holder will
370
298
  * maintain ability to purchase.
371
- * `_ownedNFTAddresses` assumed to be aligned with `_ownedNFTProjectIds`.
372
- * e.g. Removes holders of project `_ownedNFTProjectIds[0]` on token
373
- * contract `_ownedNFTAddresses[0]` from mint allowlist of `_projectId`.
374
- * @param _projectId Project ID to enable minting on.
375
- * @param _coreContract Core contract address for the given project.
376
- * @param _ownedNFTAddresses NFT core addresses of projects to be removed
377
- * from allowlist. Indexes must align with `_ownedNFTProjectIds`.
378
- * @param _ownedNFTProjectIds Project IDs on `_ownedNFTAddresses` whose
379
- * holders will be removed from allowlist to mint project `_projectId`.
380
- * Indexes must align with `_ownedNFTAddresses`.
299
+ * `ownedNFTAddresses` assumed to be aligned with `ownedNFTProjectIds`.
300
+ * e.g. Removes holders of project `ownedNFTProjectIds[0]` on token
301
+ * contract `ownedNFTAddresses[0]` from mint allowlist of `projectId`.
302
+ * @param projectId Project ID to enable minting on.
303
+ * @param coreContract Core contract address for the given project.
304
+ * @param ownedNFTAddresses NFT core addresses of projects to be removed
305
+ * from allowlist. Indexes must align with `ownedNFTProjectIds`.
306
+ * @param ownedNFTProjectIds Project IDs on `ownedNFTAddresses` whose
307
+ * holders will be removed from allowlist to mint project `projectId`.
308
+ * Indexes must align with `ownedNFTAddresses`.
381
309
  */
382
310
  function removeHoldersOfProjects(
383
- uint256 _projectId,
384
- address _coreContract,
385
- address[] memory _ownedNFTAddresses,
386
- uint256[] memory _ownedNFTProjectIds
311
+ uint256 projectId,
312
+ address coreContract,
313
+ address[] calldata ownedNFTAddresses,
314
+ uint256[] calldata ownedNFTProjectIds
387
315
  ) external {
388
316
  AuthLib.onlyArtist({
389
- _projectId: _projectId,
390
- _coreContract: _coreContract,
391
- _sender: msg.sender
317
+ projectId: projectId,
318
+ coreContract: coreContract,
319
+ sender: msg.sender
392
320
  });
393
321
  // require same length arrays
394
322
  TokenHolderLib.removeHoldersOfProjects({
395
- holderProjectConfig: _allowedProjectHoldersMapping[_coreContract][
396
- _projectId
397
- ],
398
- _ownedNFTAddresses: _ownedNFTAddresses,
399
- _ownedNFTProjectIds: _ownedNFTProjectIds
323
+ projectId: projectId,
324
+ coreContract: coreContract,
325
+ ownedNFTAddresses: ownedNFTAddresses,
326
+ ownedNFTProjectIds: ownedNFTProjectIds
400
327
  });
401
- // emit removed event
402
- emit RemovedHoldersOfProjects(
403
- _projectId,
404
- _coreContract,
405
- _ownedNFTAddresses,
406
- _ownedNFTProjectIds
407
- );
408
328
  }
409
329
 
410
330
  /**
411
- * @notice Allows holders of NFTs at addresses `_ownedNFTAddressesAdd`,
412
- * project IDs `_ownedNFTProjectIdsAdd` to mint on project `_projectId`.
413
- * Also removes holders of NFTs at addresses `_ownedNFTAddressesRemove`,
414
- * project IDs `_ownedNFTProjectIdsRemove` from minting on project
415
- * `_projectId`.
416
- * `_ownedNFTAddressesAdd` assumed to be aligned with
417
- * `_ownedNFTProjectIdsAdd`.
418
- * e.g. Allows holders of project `_ownedNFTProjectIdsAdd[0]` on token
419
- * contract `_ownedNFTAddressesAdd[0]` to mint `_projectId`.
420
- * `_ownedNFTAddressesRemove` also assumed to be aligned with
421
- * `_ownedNFTProjectIdsRemove`.
331
+ * @notice Allows holders of NFTs at addresses `ownedNFTAddressesAdd`,
332
+ * project IDs `ownedNFTProjectIdsAdd` to mint on project `projectId`.
333
+ * Also removes holders of NFTs at addresses `ownedNFTAddressesRemove`,
334
+ * project IDs `ownedNFTProjectIdsRemove` from minting on project
335
+ * `projectId`.
336
+ * `ownedNFTAddressesAdd` assumed to be aligned with
337
+ * `ownedNFTProjectIdsAdd`.
338
+ * e.g. Allows holders of project `ownedNFTProjectIdsAdd[0]` on token
339
+ * contract `ownedNFTAddressesAdd[0]` to mint `projectId`.
340
+ * `ownedNFTAddressesRemove` also assumed to be aligned with
341
+ * `ownedNFTProjectIdsRemove`.
422
342
  * WARNING: Only Art Blocks Core contracts are compatible with holder allowlisting,
423
343
  * due to assumptions about tokenId and projectId relationships.
424
- * @param _projectId Project ID to enable minting on.
425
- * @param _coreContract Core contract address for the given project.
426
- * @param _ownedNFTAddressesAdd NFT core addresses of projects to be
427
- * allowlisted. Indexes must align with `_ownedNFTProjectIdsAdd`.
428
- * @param _ownedNFTProjectIdsAdd Project IDs on `_ownedNFTAddressesAdd`
429
- * whose holders shall be allowlisted to mint project `_projectId`. Indexes
430
- * must align with `_ownedNFTAddressesAdd`.
431
- * @param _ownedNFTAddressesRemove NFT core addresses of projects to be
344
+ * @param projectId Project ID to enable minting on.
345
+ * @param coreContract Core contract address for the given project.
346
+ * @param ownedNFTAddressesAdd NFT core addresses of projects to be
347
+ * allowlisted. Indexes must align with `ownedNFTProjectIdsAdd`.
348
+ * @param ownedNFTProjectIdsAdd Project IDs on `ownedNFTAddressesAdd`
349
+ * whose holders shall be allowlisted to mint project `projectId`. Indexes
350
+ * must align with `ownedNFTAddressesAdd`.
351
+ * @param ownedNFTAddressesRemove NFT core addresses of projects to be
432
352
  * removed from allowlist. Indexes must align with
433
- * `_ownedNFTProjectIdsRemove`.
434
- * @param _ownedNFTProjectIdsRemove Project IDs on
435
- * `_ownedNFTAddressesRemove` whose holders will be removed from allowlist
436
- * to mint project `_projectId`. Indexes must align with
437
- * `_ownedNFTAddressesRemove`.
353
+ * `ownedNFTProjectIdsRemove`.
354
+ * @param ownedNFTProjectIdsRemove Project IDs on
355
+ * `ownedNFTAddressesRemove` whose holders will be removed from allowlist
356
+ * to mint project `projectId`. Indexes must align with
357
+ * `ownedNFTAddressesRemove`.
438
358
  * @dev if a project is included in both add and remove arrays, it will be
439
359
  * removed.
440
360
  */
441
361
  function allowAndRemoveHoldersOfProjects(
442
- uint256 _projectId,
443
- address _coreContract,
444
- address[] memory _ownedNFTAddressesAdd,
445
- uint256[] memory _ownedNFTProjectIdsAdd,
446
- address[] memory _ownedNFTAddressesRemove,
447
- uint256[] memory _ownedNFTProjectIdsRemove
362
+ uint256 projectId,
363
+ address coreContract,
364
+ address[] calldata ownedNFTAddressesAdd,
365
+ uint256[] calldata ownedNFTProjectIdsAdd,
366
+ address[] calldata ownedNFTAddressesRemove,
367
+ uint256[] calldata ownedNFTProjectIdsRemove
448
368
  ) external {
449
369
  AuthLib.onlyArtist({
450
- _projectId: _projectId,
451
- _coreContract: _coreContract,
452
- _sender: msg.sender
370
+ projectId: projectId,
371
+ coreContract: coreContract,
372
+ sender: msg.sender
453
373
  });
454
374
  TokenHolderLib.allowAndRemoveHoldersOfProjects({
455
- holderProjectConfig: _allowedProjectHoldersMapping[_coreContract][
456
- _projectId
457
- ],
458
- _ownedNFTAddressesAdd: _ownedNFTAddressesAdd,
459
- _ownedNFTProjectIdsAdd: _ownedNFTProjectIdsAdd,
460
- _ownedNFTAddressesRemove: _ownedNFTAddressesRemove,
461
- _ownedNFTProjectIdsRemove: _ownedNFTProjectIdsRemove
375
+ projectId: projectId,
376
+ coreContract: coreContract,
377
+ ownedNFTAddressesAdd: ownedNFTAddressesAdd,
378
+ ownedNFTProjectIdsAdd: ownedNFTProjectIdsAdd,
379
+ ownedNFTAddressesRemove: ownedNFTAddressesRemove,
380
+ ownedNFTProjectIdsRemove: ownedNFTProjectIdsRemove
462
381
  });
463
-
464
- // emit events
465
- emit AllowedHoldersOfProjects(
466
- _projectId,
467
- _coreContract,
468
- _ownedNFTAddressesAdd,
469
- _ownedNFTProjectIdsAdd
470
- );
471
- emit RemovedHoldersOfProjects(
472
- _projectId,
473
- _coreContract,
474
- _ownedNFTAddressesRemove,
475
- _ownedNFTProjectIdsRemove
476
- );
477
382
  }
478
383
 
479
384
  /**
480
385
  * @notice Allows the artist to increment the minter to the next polyptych panel
481
- * @param _projectId Project ID to increment to its next polyptych panel
482
- * @param _coreContract Core contract address for the given project.
386
+ * @param projectId Project ID to increment to its next polyptych panel
387
+ * @param coreContract Core contract address for the given project.
483
388
  */
484
389
  function incrementPolyptychProjectPanelId(
485
- uint256 _projectId,
486
- address _coreContract
390
+ uint256 projectId,
391
+ address coreContract
487
392
  ) public {
488
393
  AuthLib.onlyArtist({
489
- _projectId: _projectId,
490
- _coreContract: _coreContract,
491
- _sender: msg.sender
394
+ projectId: projectId,
395
+ coreContract: coreContract,
396
+ sender: msg.sender
397
+ });
398
+ PolyptychLib.incrementPolyptychProjectPanelId({
399
+ projectId: projectId,
400
+ coreContract: coreContract
492
401
  });
493
- PolyptychLib.PolyptychProjectConfig
494
- storage _polyptychProjectConfig = _polyptychProjectConfigs[
495
- _coreContract
496
- ][_projectId];
497
- PolyptychLib.incrementPolyptychProjectPanelId(_polyptychProjectConfig);
498
- // index the update
499
- emit ConfigValueSet(
500
- _projectId,
501
- _coreContract,
502
- PolyptychLib.POLYPTYCH_PANEL_ID,
503
- _polyptychProjectConfig.polyptychPanelId
504
- );
505
402
  }
506
403
 
507
404
  /**
508
- * @notice Purchases a token from project `_projectId` on core contract
509
- * `_coreContract` using an owned NFT at address `_ownedNFTAddress` and
510
- * token ID `_ownedNFTTokenId` as the parent token.
511
- * @param _projectId Project ID to mint a token on.
512
- * @param _coreContract Core contract address for the given project.
513
- * @param _ownedNFTAddress ERC-721 NFT address holding the project token
405
+ * @notice Purchases a token from project `projectId` on core contract
406
+ * `coreContract` using an owned NFT at address `ownedNFTAddress` and
407
+ * token ID `ownedNFTTokenId` as the parent token.
408
+ * @param projectId Project ID to mint a token on.
409
+ * @param coreContract Core contract address for the given project.
410
+ * @param maxPricePerToken Maximum price of token being allowed by the purchaser, no decimal places
411
+ * @param currencyAddress Currency address of token.
412
+ * @param ownedNFTAddress ERC-721 NFT address holding the project token
514
413
  * owned by msg.sender being used as the parent token.
515
- * @param _ownedNFTTokenId ERC-721 NFT token ID owned by msg.sender to be
414
+ * @param ownedNFTTokenId ERC-721 NFT token ID owned by msg.sender to be
516
415
  * used as the parent token.
517
416
  * @return tokenId Token ID of minted token
518
417
  */
519
418
  function purchase(
520
- uint256 _projectId,
521
- address _coreContract,
522
- address _ownedNFTAddress,
523
- uint256 _ownedNFTTokenId
524
- ) external payable returns (uint256 tokenId) {
525
- tokenId = purchaseTo(
526
- msg.sender,
527
- _projectId,
528
- _coreContract,
529
- _ownedNFTAddress,
530
- _ownedNFTTokenId,
531
- address(0)
532
- );
419
+ uint256 projectId,
420
+ address coreContract,
421
+ uint256 maxPricePerToken,
422
+ address currencyAddress,
423
+ address ownedNFTAddress,
424
+ uint256 ownedNFTTokenId
425
+ ) external returns (uint256 tokenId) {
426
+ tokenId = purchaseTo({
427
+ to: msg.sender,
428
+ projectId: projectId,
429
+ coreContract: coreContract,
430
+ maxPricePerToken: maxPricePerToken,
431
+ currencyAddress: currencyAddress,
432
+ ownedNFTAddress: ownedNFTAddress,
433
+ ownedNFTTokenId: ownedNFTTokenId,
434
+ vault: address(0)
435
+ });
533
436
  return tokenId;
534
437
  }
535
438
 
536
439
  /**
537
- * @notice Purchases a token from project `_projectId` on core contract
538
- * `_coreContract` using an owned NFT at address `_ownedNFTAddress` and
539
- * token ID `_ownedNFTTokenId` as the parent token.
540
- * Sets the token's owner to `_to`.
541
- * @param _to Address to be the new token's owner.
542
- * @param _projectId Project ID to mint a token on.
543
- * @param _coreContract Core contract address for the given project.
544
- * @param _ownedNFTAddress ERC-721 NFT holding the project token owned by
440
+ * @notice Purchases a token from project `projectId` on core contract
441
+ * `coreContract` using an owned NFT at address `ownedNFTAddress` and
442
+ * token ID `ownedNFTTokenId` as the parent token.
443
+ * Sets the token's owner to `to`.
444
+ * @param to Address to be the new token's owner.
445
+ * @param projectId Project ID to mint a token on.
446
+ * @param coreContract Core contract address for the given project.
447
+ * @param maxPricePerToken Maximum price of token being allowed by the purchaser, no decimal places
448
+ * @param currencyAddress Currency address of token.
449
+ * @param ownedNFTAddress ERC-721 NFT holding the project token owned by
545
450
  * msg.sender being used as the parent token.
546
- * @param _ownedNFTTokenId ERC-721 NFT token ID owned by msg.sender being used
451
+ * @param ownedNFTTokenId ERC-721 NFT token ID owned by msg.sender being used
547
452
  * as the parent token.
548
453
  * @return tokenId Token ID of minted token
549
454
  */
550
455
  function purchaseTo(
551
- address _to,
552
- uint256 _projectId,
553
- address _coreContract,
554
- address _ownedNFTAddress,
555
- uint256 _ownedNFTTokenId
556
- ) external payable returns (uint256 tokenId) {
456
+ address to,
457
+ uint256 projectId,
458
+ address coreContract,
459
+ uint256 maxPricePerToken,
460
+ address currencyAddress,
461
+ address ownedNFTAddress,
462
+ uint256 ownedNFTTokenId
463
+ ) external returns (uint256 tokenId) {
557
464
  return
558
- purchaseTo(
559
- _to,
560
- _projectId,
561
- _coreContract,
562
- _ownedNFTAddress,
563
- _ownedNFTTokenId,
564
- address(0)
565
- );
465
+ purchaseTo({
466
+ to: to,
467
+ projectId: projectId,
468
+ coreContract: coreContract,
469
+ maxPricePerToken: maxPricePerToken,
470
+ currencyAddress: currencyAddress,
471
+ ownedNFTAddress: ownedNFTAddress,
472
+ ownedNFTTokenId: ownedNFTTokenId,
473
+ vault: address(0)
474
+ });
566
475
  }
567
476
 
568
477
  // public getter functions
569
478
  /**
570
479
  * @notice Gets the maximum invocations project configuration.
571
- * @param _projectId The ID of the project whose data needs to be fetched.
572
- * @param _coreContract The address of the core contract.
480
+ * @param projectId The ID of the project whose data needs to be fetched.
481
+ * @param coreContract The address of the core contract.
573
482
  * @return MaxInvocationsLib.MaxInvocationsProjectConfig instance with the
574
483
  * configuration data.
575
484
  */
576
485
  function maxInvocationsProjectConfig(
577
- uint256 _projectId,
578
- address _coreContract
486
+ uint256 projectId,
487
+ address coreContract
579
488
  )
580
489
  external
581
490
  view
582
491
  returns (MaxInvocationsLib.MaxInvocationsProjectConfig memory)
583
492
  {
584
- return _maxInvocationsProjectConfigMapping[_coreContract][_projectId];
493
+ return
494
+ MaxInvocationsLib.getMaxInvocationsProjectConfig({
495
+ projectId: projectId,
496
+ coreContract: coreContract
497
+ });
585
498
  }
586
499
 
587
500
  /**
588
501
  * @notice Gets the set price project configuration.
589
- * @param _projectId The ID of the project whose data needs to be fetched.
590
- * @param _coreContract The address of the core contract.
502
+ * @param projectId The ID of the project whose data needs to be fetched.
503
+ * @param coreContract The address of the core contract.
591
504
  * @return SetPriceProjectConfig struct with the fixed price project
592
505
  * configuration data.
593
506
  */
594
507
  function setPriceProjectConfig(
595
- uint256 _projectId,
596
- address _coreContract
508
+ uint256 projectId,
509
+ address coreContract
597
510
  ) external view returns (SetPriceLib.SetPriceProjectConfig memory) {
598
- return _setPriceProjectConfigMapping[_coreContract][_projectId];
511
+ return
512
+ SetPriceLib.getSetPriceProjectConfig({
513
+ projectId: projectId,
514
+ coreContract: coreContract
515
+ });
599
516
  }
600
517
 
601
518
  /**
602
519
  * @notice Checks if a specific NFT owner is allowed in a given project.
603
520
  * @dev This function retrieves the allowance status of an NFT owner
604
521
  * within a specific project from the allowedProjectHoldersMapping.
605
- * @param _projectId The ID of the project to check.
606
- * @param _coreContract Core contract address for the given project.
607
- * @param _ownedNFTAddress The address of the owned NFT contract.
608
- * @param _ownedNFTProjectId The ID of the owned NFT project.
522
+ * @param projectId The ID of the project to check.
523
+ * @param coreContract Core contract address for the given project.
524
+ * @param ownedNFTAddress The address of the owned NFT contract.
525
+ * @param ownedNFTProjectId The ID of the owned NFT project.
609
526
  * @return bool True if the NFT owner is allowed in the given project, False otherwise.
610
527
  */
611
528
  function allowedProjectHolders(
612
- uint256 _projectId,
613
- address _coreContract,
614
- address _ownedNFTAddress,
615
- uint256 _ownedNFTProjectId
529
+ uint256 projectId,
530
+ address coreContract,
531
+ address ownedNFTAddress,
532
+ uint256 ownedNFTProjectId
616
533
  ) external view returns (bool) {
617
534
  return
618
- _allowedProjectHoldersMapping[_coreContract][_projectId]
619
- .allowedProjectHolders[_ownedNFTAddress][_ownedNFTProjectId];
535
+ TokenHolderLib
536
+ .getHolderProjectConfig({
537
+ projectId: projectId,
538
+ coreContract: coreContract
539
+ })
540
+ .allowedProjectHolders[ownedNFTAddress][ownedNFTProjectId];
620
541
  }
621
542
 
622
543
  /**
623
- * @notice Returns if token is an allowlisted NFT for project `_projectId`.
624
- * @param _projectId Project ID to be checked.
625
- * @param _coreContract Core contract address for the given project.
626
- * @param _ownedNFTAddress ERC-721 NFT token address to be checked.
627
- * @param _ownedNFTTokenId ERC-721 NFT token ID to be checked.
544
+ * @notice Returns if token is an allowlisted NFT for project `projectId`.
545
+ * @param projectId Project ID to be checked.
546
+ * @param coreContract Core contract address for the given project.
547
+ * @param ownedNFTAddress ERC-721 NFT token address to be checked.
548
+ * @param ownedNFTTokenId ERC-721 NFT token ID to be checked.
628
549
  * @return bool Token is allowlisted
629
550
  * @dev does not check if token has been used to purchase
630
551
  * @dev assumes project ID can be derived from tokenId / 1_000_000
631
552
  */
632
553
  function isAllowlistedNFT(
633
- uint256 _projectId,
634
- address _coreContract,
635
- address _ownedNFTAddress,
636
- uint256 _ownedNFTTokenId
554
+ uint256 projectId,
555
+ address coreContract,
556
+ address ownedNFTAddress,
557
+ uint256 ownedNFTTokenId
637
558
  ) external view returns (bool) {
638
559
  return
639
560
  TokenHolderLib.isAllowlistedNFT({
640
- holderProjectConfig: _allowedProjectHoldersMapping[
641
- _coreContract
642
- ][_projectId],
643
- _ownedNFTAddress: _ownedNFTAddress,
644
- _ownedNFTTokenId: _ownedNFTTokenId
561
+ projectId: projectId,
562
+ coreContract: coreContract,
563
+ ownedNFTAddress: ownedNFTAddress,
564
+ ownedNFTTokenId: ownedNFTTokenId
645
565
  });
646
566
  }
647
567
 
648
568
  /**
649
- * @notice Checks if the specified `_coreContract` is a valid engine contract.
650
- * @dev This function retrieves the cached value of `_isEngine` from
569
+ * @notice Checks if the specified `coreContract` is a valid engine contract.
570
+ * @dev This function retrieves the cached value of `isEngine` from
651
571
  * the `isEngineCache` mapping. If the cached value is already set, it
652
- * returns the cached value. Otherwise, it calls the `getV3CoreIsEngine`
653
- * function from the `SplitFundsLib` library to check if `_coreContract`
572
+ * returns the cached value. Otherwise, it calls the `getV3CoreIsEngineView`
573
+ * function from the `SplitFundsLib` library to check if `coreContract`
654
574
  * is a valid engine contract.
655
- * @dev This function will revert if the provided `_coreContract` is not
575
+ * @dev This function will revert if the provided `coreContract` is not
656
576
  * a valid Engine or V3 Flagship contract.
657
- * @param _coreContract The address of the contract to check.
658
- * @return bool indicating if `_coreContract` is a valid engine contract.
577
+ * @param coreContract The address of the contract to check.
578
+ * @return bool indicating if `coreContract` is a valid engine contract.
659
579
  */
660
- function isEngineView(address _coreContract) external view returns (bool) {
661
- SplitFundsLib.IsEngineCache storage isEngineCache = _isEngineCaches[
662
- _coreContract
663
- ];
580
+ function isEngineView(address coreContract) external view returns (bool) {
581
+ SplitFundsLib.IsEngineCache storage isEngineCache = SplitFundsLib
582
+ .getIsEngineCacheConfig(coreContract);
664
583
  if (isEngineCache.isCached) {
665
584
  return isEngineCache.isEngine;
666
585
  } else {
667
- // @dev this calls the non-modifying variant of getV3CoreIsEngine
668
- return SplitFundsLib.getV3CoreIsEngineView(_coreContract);
586
+ // @dev this calls the non-state-modifying variant of isEngine
587
+ return SplitFundsLib.getV3CoreIsEngineView(coreContract);
669
588
  }
670
589
  }
671
590
 
@@ -680,17 +599,18 @@ contract MinterSetPricePolyptychERC20V5 is
680
599
  * possible because the V3 core contract only allows maximum invocations
681
600
  * to be reduced, not increased. Based on this rationale, we intentionally
682
601
  * do not do input validation in this method as to whether or not the input
683
- * @param `_projectId` is an existing project ID.
684
- * @param `_coreContract` is an existing core contract address.
602
+ * @param projectId is an existing project ID.
603
+ * @param coreContract is an existing core contract address.
685
604
  */
686
605
  function projectMaxHasBeenInvoked(
687
- uint256 _projectId,
688
- address _coreContract
606
+ uint256 projectId,
607
+ address coreContract
689
608
  ) external view returns (bool) {
690
609
  return
691
- MaxInvocationsLib.getMaxHasBeenInvoked(
692
- _maxInvocationsProjectConfigMapping[_coreContract][_projectId]
693
- );
610
+ MaxInvocationsLib.getMaxHasBeenInvoked({
611
+ projectId: projectId,
612
+ coreContract: coreContract
613
+ });
694
614
  }
695
615
 
696
616
  /**
@@ -709,79 +629,83 @@ contract MinterSetPricePolyptychERC20V5 is
709
629
  * increased. When this happens, the minter will enable minting, allowing
710
630
  * the core contract to enforce the max invocations check. Based on this
711
631
  * rationale, we intentionally do not do input validation in this method as
712
- * to whether or not the input `_projectId` is an existing project ID.
713
- * @param `_projectId` is an existing project ID.
714
- * @param `_coreContract` is an existing core contract address.
632
+ * to whether or not the input `projectId` is an existing project ID.
633
+ * @param projectId is an existing project ID.
634
+ * @param coreContract is an existing core contract address.
715
635
  */
716
636
  function projectMaxInvocations(
717
- uint256 _projectId,
718
- address _coreContract
637
+ uint256 projectId,
638
+ address coreContract
719
639
  ) external view returns (uint256) {
720
640
  return
721
- MaxInvocationsLib.getMaxInvocations(
722
- _maxInvocationsProjectConfigMapping[_coreContract][_projectId]
723
- );
641
+ MaxInvocationsLib.getMaxInvocations({
642
+ projectId: projectId,
643
+ coreContract: coreContract
644
+ });
724
645
  }
725
646
 
726
647
  /**
727
648
  * @notice Gets your balance of the ERC20 token currently set
728
- * as the payment currency for project `_projectId` in the core
729
- * contract `_coreContract`.
730
- * @param _projectId Project ID to be queried.
731
- * @param _coreContract The address of the core contract.
649
+ * as the payment currency for project `projectId` in the core
650
+ * contract `coreContract`.
651
+ * @param projectId Project ID to be queried.
652
+ * @param coreContract The address of the core contract.
732
653
  * @return balance Balance of ERC20
733
654
  */
734
655
  function getYourBalanceOfProjectERC20(
735
- uint256 _projectId,
736
- address _coreContract
656
+ uint256 projectId,
657
+ address coreContract
737
658
  ) external view returns (uint256 balance) {
738
- SplitFundsLib.SplitFundsProjectConfig
739
- storage _splitFundsProjectConfig = _splitFundsProjectConfigs[
740
- _coreContract
741
- ][_projectId];
742
- balance = SplitFundsLib.getERC20Balance(
743
- _splitFundsProjectConfig.currencyAddress,
744
- msg.sender
659
+ (address currencyAddress, ) = SplitFundsLib.getCurrencyInfoERC20(
660
+ projectId,
661
+ coreContract
745
662
  );
663
+ balance = SplitFundsLib.getERC20Balance({
664
+ currencyAddress: currencyAddress,
665
+ walletAddress: msg.sender
666
+ });
746
667
  return balance;
747
668
  }
748
669
 
749
670
  /**
750
671
  * @notice Gets your allowance for this minter of the ERC20
751
672
  * token currently set as the payment currency for project
752
- * `_projectId`.
753
- * @param _projectId Project ID to be queried.
754
- * @param _coreContract The address of the core contract.
673
+ * `projectId`.
674
+ * @param projectId Project ID to be queried.
675
+ * @param coreContract The address of the core contract.
755
676
  * @return remaining Remaining allowance of ERC20
756
677
  */
757
678
  function checkYourAllowanceOfProjectERC20(
758
- uint256 _projectId,
759
- address _coreContract
679
+ uint256 projectId,
680
+ address coreContract
760
681
  ) external view returns (uint256 remaining) {
761
- SplitFundsLib.SplitFundsProjectConfig
762
- storage _splitFundsProjectConfig = _splitFundsProjectConfigs[
763
- _coreContract
764
- ][_projectId];
682
+ (address currencyAddress, ) = SplitFundsLib.getCurrencyInfoERC20({
683
+ projectId: projectId,
684
+ coreContract: coreContract
685
+ });
765
686
  remaining = SplitFundsLib.getERC20Allowance({
766
- _currencyAddress: _splitFundsProjectConfig.currencyAddress,
767
- _walletAddress: msg.sender,
768
- _spenderAddress: address(this)
687
+ currencyAddress: currencyAddress,
688
+ walletAddress: msg.sender,
689
+ spenderAddress: address(this)
769
690
  });
770
691
  return remaining;
771
692
  }
772
693
 
773
694
  /**
774
695
  * @notice Gets if price of token is configured, price of minting a
775
- * token on project `_projectId`, and currency symbol and address to be
696
+ * token on project `projectId`, and currency symbol and address to be
776
697
  * used as payment.
777
698
  * `isConfigured` is only true if a price has been configured, and an ERC20
778
699
  * token has been configured.
779
- * @param _projectId Project ID to get price information for
780
- * @param _coreContract Contract address of the core contract
700
+ * @param projectId Project ID to get price information for
701
+ * @param coreContract Contract address of the core contract
781
702
  * @return isConfigured true only if token price has been configured on
782
703
  * this minter and an ERC20 token has been configured
783
704
  * @return tokenPriceInWei current price of token on this minter - invalid
784
- * if price has not yet been configured
705
+ * if price has not yet been configured. Note that "in wei" is a misnomer
706
+ * for ERC20 tokens, but is used here for ABI consistency with the ETH
707
+ * minters. The value returned represents the price per token, with no
708
+ * decimals.
785
709
  * @return currencySymbol currency symbol for purchases of project on this
786
710
  * minter. "UNCONFIG" if not yet configured. Note that currency symbol is
787
711
  * defined by the artist, and is not necessarily the same as the ERC20
@@ -790,8 +714,8 @@ contract MinterSetPricePolyptychERC20V5 is
790
714
  * this minter. Null address if not yet configured.
791
715
  */
792
716
  function getPriceInfo(
793
- uint256 _projectId,
794
- address _coreContract
717
+ uint256 projectId,
718
+ address coreContract
795
719
  )
796
720
  external
797
721
  view
@@ -803,164 +727,170 @@ contract MinterSetPricePolyptychERC20V5 is
803
727
  )
804
728
  {
805
729
  SetPriceLib.SetPriceProjectConfig
806
- storage _setPriceProjectConfig = _setPriceProjectConfigMapping[
807
- _coreContract
808
- ][_projectId];
809
- tokenPriceInWei = _setPriceProjectConfig.pricePerTokenInWei;
730
+ storage setPriceProjectConfig_ = SetPriceLib
731
+ .getSetPriceProjectConfig({
732
+ projectId: projectId,
733
+ coreContract: coreContract
734
+ });
735
+ tokenPriceInWei = setPriceProjectConfig_.pricePerToken;
810
736
  // get currency info from SplitFundsLib
811
- SplitFundsLib.SplitFundsProjectConfig
812
- storage _splitFundsProjectConfig = _splitFundsProjectConfigs[
813
- _coreContract
814
- ][_projectId];
815
- (currencyAddress, currencySymbol) = SplitFundsLib.getCurrencyInfoERC20(
816
- _splitFundsProjectConfig
817
- );
737
+ (currencyAddress, currencySymbol) = SplitFundsLib.getCurrencyInfoERC20({
738
+ projectId: projectId,
739
+ coreContract: coreContract
740
+ });
818
741
  // report if price and ERC20 token are configured
819
742
  // @dev currencyAddress is non-zero if an ERC20 token is configured
820
743
  isConfigured =
821
- _setPriceProjectConfig.priceIsConfigured &&
744
+ setPriceProjectConfig_.priceIsConfigured &&
822
745
  currencyAddress != address(0);
823
746
  }
824
747
 
825
748
  /**
826
749
  * Gets the current polyptych panel ID for the given project.
827
- * @param _projectId Project ID to be queried
828
- * @param _coreContract Contract address of the core contract
750
+ * @param projectId Project ID to be queried
751
+ * @param coreContract Contract address of the core contract
829
752
  * @return uint256 representing the current polyptych panel ID for the
830
753
  * given project
831
754
  */
832
755
  function getCurrentPolyptychPanelId(
833
- uint256 _projectId,
834
- address _coreContract
756
+ uint256 projectId,
757
+ address coreContract
835
758
  ) external view returns (uint256) {
836
- PolyptychLib.PolyptychProjectConfig
837
- storage _polyptychProjectConfig = _polyptychProjectConfigs[
838
- _coreContract
839
- ][_projectId];
840
- return PolyptychLib.getPolyptychPanelId(_polyptychProjectConfig);
759
+ return
760
+ PolyptychLib.getPolyptychPanelId({
761
+ projectId: projectId,
762
+ coreContract: coreContract
763
+ });
841
764
  }
842
765
 
843
766
  /**
844
767
  * Gets if the hash seed for the given project has been used on a given
845
768
  * polyptych panel id. The current polyptych panel ID for a given project
846
769
  * can be queried via the view function `getCurrentPolyptychPanelId`.
847
- * @param _projectId Project ID to be queried
848
- * @param _coreContract Contract address of the core contract
849
- * @param _panelId Panel ID to be queried
850
- * @param _hashSeed Hash seed to be queried
770
+ * @param projectId Project ID to be queried
771
+ * @param coreContract Contract address of the core contract
772
+ * @param panelId Panel ID to be queried
773
+ * @param hashSeed Hash seed to be queried
851
774
  * @return bool representing if the hash seed has been used on the given
852
775
  * polyptych panel ID
853
776
  */
854
777
  function getPolyptychPanelHashSeedIsMinted(
855
- uint256 _projectId,
856
- address _coreContract,
857
- uint256 _panelId,
858
- bytes12 _hashSeed
778
+ uint256 projectId,
779
+ address coreContract,
780
+ uint256 panelId,
781
+ bytes12 hashSeed
859
782
  ) external view returns (bool) {
860
- PolyptychLib.PolyptychProjectConfig
861
- storage _polyptychProjectConfig = _polyptychProjectConfigs[
862
- _coreContract
863
- ][_projectId];
864
783
  return
865
- PolyptychLib.getPolyptychPanelHashSeedIsMinted(
866
- _polyptychProjectConfig,
867
- _panelId,
868
- _hashSeed
869
- );
784
+ PolyptychLib.getPolyptychPanelHashSeedIsMinted({
785
+ projectId: projectId,
786
+ coreContract: coreContract,
787
+ panelId: panelId,
788
+ hashSeed: hashSeed
789
+ });
870
790
  }
871
791
 
872
792
  /**
873
- * @notice Syncs local maximum invocations of project `_projectId` based on
793
+ * @notice Syncs local maximum invocations of project `projectId` based on
874
794
  * the value currently defined in the core contract.
875
- * @param _projectId Project ID to set the maximum invocations for.
876
- * @param _coreContract Core contract address for the given project.
795
+ * @param projectId Project ID to set the maximum invocations for.
796
+ * @param coreContract Core contract address for the given project.
877
797
  * @dev this enables gas reduction after maxInvocations have been reached -
878
798
  * core contracts shall still enforce a maxInvocation check during mint.
879
799
  */
880
800
  function syncProjectMaxInvocationsToCore(
881
- uint256 _projectId,
882
- address _coreContract
801
+ uint256 projectId,
802
+ address coreContract
883
803
  ) public {
884
804
  AuthLib.onlyArtist({
885
- _projectId: _projectId,
886
- _coreContract: _coreContract,
887
- _sender: msg.sender
805
+ projectId: projectId,
806
+ coreContract: coreContract,
807
+ sender: msg.sender
888
808
  });
889
809
 
890
- uint256 maxInvocations = MaxInvocationsLib
891
- .syncProjectMaxInvocationsToCore(
892
- _projectId,
893
- _coreContract,
894
- _maxInvocationsProjectConfigMapping[_coreContract][_projectId]
895
- );
896
- emit ProjectMaxInvocationsLimitUpdated(
897
- _projectId,
898
- _coreContract,
899
- maxInvocations
900
- );
810
+ MaxInvocationsLib.syncProjectMaxInvocationsToCore({
811
+ projectId: projectId,
812
+ coreContract: coreContract
813
+ });
901
814
  }
902
815
 
903
816
  /**
904
- * @notice Purchases a token from project `_projectId` on core contract
905
- * `_coreContract` using an owned NFT at address `_ownedNFTAddress` and
906
- * token ID `_ownedNFTTokenId` as the parent token.
907
- * Sets the token's owner to `_to`.
908
- * Parent token must be owned by `msg.sender`, or `_vault` if `msg.sender`
909
- * is a valid delegate for `_vault`.
910
- * @param _to Address to be the new token's owner.
911
- * @param _projectId Project ID to mint a token on.
912
- * @param _coreContract Core contract address for the given project.
913
- * @param _ownedNFTAddress ERC-721 NFT holding the project token owned by
914
- * msg.sender or `_vault` being used as the parent token.
915
- * @param _ownedNFTTokenId ERC-721 NFT token ID owned by msg.sender or
916
- * `_vault` being used as the parent token.
817
+ * @notice Purchases a token from project `projectId` on core contract
818
+ * `coreContract` using an owned NFT at address `ownedNFTAddress` and
819
+ * token ID `ownedNFTTokenId` as the parent token.
820
+ * Sets the token's owner to `to`.
821
+ * Parent token must be owned by `msg.sender`, or `vault` if `msg.sender`
822
+ * is a valid delegate for `vault`.
823
+ * @param to Address to be the new token's owner.
824
+ * @param projectId Project ID to mint a token on.
825
+ * @param coreContract Core contract address for the given project.
826
+ * @param maxPricePerToken Maximum price of token being allowed by the purchaser, no decimal places
827
+ * @param currencyAddress Currency address of token.
828
+ * @param ownedNFTAddress ERC-721 NFT holding the project token owned by
829
+ * msg.sender or `vault` being used as the parent token.
830
+ * @param ownedNFTTokenId ERC-721 NFT token ID owned by msg.sender or
831
+ * `vault` being used as the parent token.
917
832
  * @return tokenId Token ID of minted token
918
833
  */
919
834
  function purchaseTo(
920
- address _to,
921
- uint256 _projectId,
922
- address _coreContract,
923
- address _ownedNFTAddress,
924
- uint256 _ownedNFTTokenId,
925
- address _vault
926
- ) public payable nonReentrant returns (uint256 tokenId) {
835
+ address to,
836
+ uint256 projectId,
837
+ address coreContract,
838
+ uint256 maxPricePerToken,
839
+ address currencyAddress,
840
+ address ownedNFTAddress,
841
+ uint256 ownedNFTTokenId,
842
+ address vault
843
+ ) public nonReentrant returns (uint256 tokenId) {
927
844
  // CHECKS
928
- SetPriceLib.SetPriceProjectConfig
929
- storage _setPriceProjectConfig = _setPriceProjectConfigMapping[
930
- _coreContract
931
- ][_projectId];
932
- MaxInvocationsLib.MaxInvocationsProjectConfig
933
- storage _maxInvocationsProjectConfig = _maxInvocationsProjectConfigMapping[
934
- _coreContract
935
- ][_projectId];
936
-
845
+ // pre-mint MaxInvocationsLib checks
937
846
  // Note that `maxHasBeenInvoked` is only checked here to reduce gas
938
847
  // consumption after a project has been fully minted.
939
- // `_maxInvocationsProjectConfig.maxHasBeenInvoked` is locally cached to reduce
848
+ // `maxInvocationsProjectConfig.maxHasBeenInvoked` is locally cached to reduce
940
849
  // gas consumption, but if not in sync with the core contract's value,
941
850
  // the core contract also enforces its own max invocation check during
942
851
  // minting.
943
- require(
944
- !_maxInvocationsProjectConfig.maxHasBeenInvoked,
945
- "Max invocations reached"
946
- );
852
+ MaxInvocationsLib.preMintChecks({
853
+ projectId: projectId,
854
+ coreContract: coreContract
855
+ });
856
+
857
+ // pre-mint checks for set price lib, and get price per token
858
+ // @dev price per token is loaded into memory here for gas efficiency
859
+ uint256 pricePerToken = SetPriceLib.preMintChecksAndGetPrice({
860
+ projectId: projectId,
861
+ coreContract: coreContract
862
+ });
863
+
864
+ // @dev block scope to avoid stack too deep error
865
+ {
866
+ // get the currency address configured on the project
867
+ // @dev revert occurs during payment split if ERC20 token is not
868
+ // configured (i.e. address(0)), so check is not performed here
869
+ (address configuredCurrencyAddress, ) = SplitFundsLib
870
+ .getCurrencyInfoERC20({
871
+ projectId: projectId,
872
+ coreContract: coreContract
873
+ });
874
+ // validate that the currency address and symbols matches the project configured currency
875
+ require(
876
+ currencyAddress == configuredCurrencyAddress,
877
+ "Currency addresses must match"
878
+ );
879
+ }
947
880
 
948
- // require artist to have configured price of token on this minter
881
+ // validate that the specified maximum price is greater than or equal to the price per token
949
882
  require(
950
- _setPriceProjectConfig.priceIsConfigured,
951
- "Price not configured"
883
+ maxPricePerToken >= pricePerToken,
884
+ "Only max price gte token price"
952
885
  );
953
- // @dev revert occurs during payment split if ERC20 token is not
954
- // configured (i.e. address(0)), so check is not performed here
955
886
 
956
887
  // require token used to claim to be in set of allowlisted NFTs
957
888
  require(
958
889
  TokenHolderLib.isAllowlistedNFT({
959
- holderProjectConfig: _allowedProjectHoldersMapping[
960
- _coreContract
961
- ][_projectId],
962
- _ownedNFTAddress: _ownedNFTAddress,
963
- _ownedNFTTokenId: _ownedNFTTokenId
890
+ projectId: projectId,
891
+ coreContract: coreContract,
892
+ ownedNFTAddress: ownedNFTAddress,
893
+ ownedNFTTokenId: ownedNFTTokenId
964
894
  }),
965
895
  "Only allowlisted NFTs"
966
896
  );
@@ -968,90 +898,86 @@ contract MinterSetPricePolyptychERC20V5 is
968
898
  // NOTE: delegate-vault handling **begins here**.
969
899
 
970
900
  // handle that the vault may be either the `msg.sender` in the case
971
- // that there is not a true vault, or may be `_vault` if one is
901
+ // that there is not a true vault, or may be `vault` if one is
972
902
  // provided explicitly (and it is valid).
973
- address vault = msg.sender;
974
- if (_vault != address(0)) {
903
+ address vault_ = msg.sender;
904
+ if (vault != address(0)) {
975
905
  // If a vault is provided, it must be valid, otherwise throw rather
976
906
  // than optimistically-minting with original `msg.sender`.
977
907
  // Note, we do not check `checkDelegateForAll` or `checkDelegateForContract` as well,
978
908
  // as they are known to be implicitly checked by calling `checkDelegateForToken`.
979
- bool isValidVault = delegationRegistryContract
980
- .checkDelegateForToken(
981
- msg.sender, // delegate
982
- _vault, // vault
983
- _coreContract, // contract
984
- _ownedNFTTokenId // tokenId
985
- );
909
+ bool isValidVault = _delegationRegistryContract
910
+ .checkDelegateForToken({
911
+ delegate: msg.sender,
912
+ vault: vault,
913
+ contract_: coreContract,
914
+ tokenId: ownedNFTTokenId
915
+ });
986
916
  require(isValidVault, "Invalid delegate-vault pairing");
987
- vault = _vault;
917
+ vault_ = vault;
988
918
  }
989
919
 
990
920
  // we need the new token ID in advance of the randomizer setting a token hash
991
921
  IGenArt721CoreContractV3_Base genArtCoreContract = IGenArt721CoreContractV3_Base(
992
- _coreContract
922
+ coreContract
993
923
  );
994
- (uint256 _invocations, , , , , ) = genArtCoreContract.projectStateData(
995
- _projectId
924
+ (uint256 invocations, , , , , ) = genArtCoreContract.projectStateData(
925
+ projectId
996
926
  );
997
927
 
998
928
  // EFFECTS
999
929
 
1000
930
  // we need to store the new token ID before it is minted so the randomizer can query it
1001
- // block scope to avoid stack too deep error
931
+ // @dev block scope to avoid stack too deep error
1002
932
  {
1003
- bytes12 _targetHashSeed = PolyptychLib.getTokenHashSeed(
1004
- _ownedNFTAddress,
1005
- _ownedNFTTokenId
1006
- );
933
+ bytes12 targetHashSeed = PolyptychLib.getTokenHashSeed({
934
+ coreContract: ownedNFTAddress,
935
+ tokenId: ownedNFTTokenId
936
+ });
937
+
938
+ PolyptychLib.validatePolyptychEffects({
939
+ projectId: projectId,
940
+ coreContract: coreContract,
941
+ tokenHashSeed: targetHashSeed
942
+ });
1007
943
 
1008
- // block scope to avoid stack too deep error (nested)
944
+ // @dev block scope to avoid stack too deep error
1009
945
  {
1010
- // validates hash seed and ensures each hash seed used max once per panel
1011
- PolyptychLib.PolyptychProjectConfig
1012
- storage _polyptychProjectConfig = _polyptychProjectConfigs[
1013
- _coreContract
1014
- ][_projectId];
1015
- PolyptychLib.validatePolyptychEffects(
1016
- _polyptychProjectConfig,
1017
- _targetHashSeed
1018
- );
946
+ uint256 newTokenId = (projectId * ONE_MILLION) + invocations;
947
+ PolyptychLib.setPolyptychHashSeed({
948
+ coreContract: coreContract,
949
+ tokenId: newTokenId, // new token ID
950
+ hashSeed: targetHashSeed
951
+ });
1019
952
  }
1020
953
 
1021
- uint256 _newTokenId = (_projectId * ONE_MILLION) + _invocations;
1022
- PolyptychLib.setPolyptychHashSeed({
1023
- _coreContract: _coreContract,
1024
- _tokenId: _newTokenId, // new token ID
1025
- _hashSeed: _targetHashSeed
1026
- });
1027
-
1028
954
  // once mint() is called, the polyptych randomizer will either:
1029
955
  // 1) assign a random token hash
1030
956
  // 2) if configured, obtain the token hash from the `polyptychSeedHashes` mapping
1031
- tokenId = minterFilter.mint_joo(
1032
- _to,
1033
- _projectId,
1034
- _coreContract,
1035
- vault
1036
- );
957
+ tokenId = _minterFilter.mint_joo({
958
+ to: to,
959
+ projectId: projectId,
960
+ coreContract: coreContract,
961
+ sender: vault_
962
+ });
1037
963
 
1038
964
  // NOTE: delegate-vault handling **ends here**.
1039
965
 
1040
966
  // redundant check against reentrancy
1041
967
  PolyptychLib.validateAssignedHashSeed({
1042
- _coreContract: _coreContract,
1043
- _tokenId: tokenId,
1044
- _targetHashSeed: _targetHashSeed
968
+ coreContract: coreContract,
969
+ tokenId: tokenId,
970
+ targetHashSeed: targetHashSeed
1045
971
  });
1046
972
  }
1047
973
 
1048
- MaxInvocationsLib.validatePurchaseEffectsInvocations(
1049
- tokenId,
1050
- _maxInvocationsProjectConfig
1051
- );
974
+ MaxInvocationsLib.validatePurchaseEffectsInvocations({
975
+ tokenId: tokenId,
976
+ coreContract: coreContract
977
+ });
1052
978
 
1053
979
  // INTERACTIONS
1054
- // block scope to avoid stack too deep error
980
+ // @dev block scope to avoid stack too deep error
1055
981
  {
1056
982
  // require proper ownership of NFT used to redeem
1057
983
  /**
@@ -1061,34 +987,24 @@ contract MinterSetPricePolyptychERC20V5 is
1061
987
  * function is non-reentrant, so this is extra cautious.
1062
988
  */
1063
989
  // @dev if the artist is the sender, then the NFT must be owned by the
1064
- // recipient, otherwise the NFT must be owned by the vault
990
+ // recipient, otherwise the NFT must be owned by the vault_
1065
991
  address _artist = genArtCoreContract.projectIdToArtistAddress(
1066
- _projectId
992
+ projectId
1067
993
  );
1068
- address targetOwner = (msg.sender == _artist) ? _to : vault;
994
+ address targetOwner = (msg.sender == _artist) ? to : vault_;
1069
995
  TokenHolderLib.validateNFTOwnership({
1070
- _ownedNFTAddress: _ownedNFTAddress,
1071
- _ownedNFTTokenId: _ownedNFTTokenId,
1072
- _targetOwner: targetOwner
996
+ ownedNFTAddress: ownedNFTAddress,
997
+ ownedNFTTokenId: ownedNFTTokenId,
998
+ targetOwner: targetOwner
1073
999
  });
1074
1000
  }
1075
1001
 
1076
1002
  // split funds
1077
- bool isEngine = SplitFundsLib.isEngine(
1078
- _coreContract,
1079
- _isEngineCaches[_coreContract]
1080
- );
1081
1003
  // process payment in ERC20
1082
- SplitFundsLib.SplitFundsProjectConfig
1083
- storage _splitFundsProjectConfig = _splitFundsProjectConfigs[
1084
- _coreContract
1085
- ][_projectId];
1086
1004
  SplitFundsLib.splitFundsERC20({
1087
- _splitFundsProjectConfig: _splitFundsProjectConfig,
1088
- _projectId: _projectId,
1089
- _pricePerTokenInWei: _setPriceProjectConfig.pricePerTokenInWei,
1090
- _coreContract: _coreContract,
1091
- _isEngine: isEngine
1005
+ projectId: projectId,
1006
+ pricePerToken: pricePerToken,
1007
+ coreContract: coreContract
1092
1008
  });
1093
1009
 
1094
1010
  return tokenId;