@artblocks/contracts 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/artifacts/contracts/interfaces/v0.8.x/IFormPaletteBindingHooks.sol/IFormPaletteBindingHooks.json +723 -0
- package/artifacts/contracts/interfaces/v0.8.x/IMintTimeAndTransferCountHooks.sol/IMintTimeAndTransferCountHooks.json +356 -0
- package/artifacts/contracts/interfaces/v0.8.x/IPMPProjectViewsV0.sol/IPMPProjectViewsV0.json +126 -0
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterRequiredPMPV0.sol/ISharedMinterRequiredPMPV0.json +36 -0
- package/artifacts/contracts/libs/v0.8.x/minter-libs/RequiredPMPLib.sol/RequiredPMPLib.json +10 -0
- package/artifacts/contracts/minter-suite/Minters/MinterSetPricePMPV0.sol/MinterSetPricePMPV0.json +613 -0
- package/artifacts/contracts/mock/MockPMPMinterReentrantConfigureHook.sol/IMinterPMPPurchase.json +91 -0
- package/artifacts/contracts/mock/MockPMPMinterReentrantConfigureHook.sol/MockPMPMinterReentrantConfigureHook.json +180 -0
- package/artifacts/contracts/mock/MockPMPReentrantConfigureHook.sol/MockPMPReentrantConfigureHook.json +158 -0
- package/artifacts/contracts/mock/ReentrancyPMPMockShared.sol/IMinterPurchaseWithPMPs.json +67 -0
- package/artifacts/contracts/mock/ReentrancyPMPMockShared.sol/ReentrancyPMPMockShared.json +154 -0
- package/artifacts/contracts/web3call/combined-hooks/FormPaletteBindingHooks.sol/FormPaletteBindingHooks.json +919 -0
- package/artifacts/contracts/web3call/combined-hooks/MintTimeAndTransferCountHooks.sol/MintTimeAndTransferCountHooks.json +435 -0
- package/contracts/interfaces/v0.8.x/IFormPaletteBindingHooks.sol +339 -0
- package/contracts/interfaces/v0.8.x/IMintTimeAndTransferCountHooks.sol +125 -0
- package/contracts/interfaces/v0.8.x/IPMPProjectViewsV0.sol +59 -0
- package/contracts/interfaces/v0.8.x/ISharedMinterRequiredPMPV0.sol +27 -0
- package/contracts/libs/v0.8.x/minter-libs/RequiredPMPLib.sol +336 -0
- package/contracts/minter-suite/Minters/MinterSetPricePMPV0.sol +664 -0
- package/contracts/mock/MockPMPMinterReentrantConfigureHook.sol +85 -0
- package/contracts/mock/MockPMPReentrantConfigureHook.sol +59 -0
- package/contracts/mock/ReentrancyPMPMockShared.sol +81 -0
- package/contracts/web3call/combined-hooks/FormPaletteBindingHooks.sol +1392 -0
- package/contracts/web3call/combined-hooks/MintTimeAndTransferCountHooks.sol +483 -0
- package/package.json +2 -1
|
@@ -0,0 +1,664 @@
|
|
|
1
|
+
// SPDX-License-Identifier: LGPL-3.0-only
|
|
2
|
+
// Created By: Art Blocks Inc.
|
|
3
|
+
|
|
4
|
+
// @dev fixed to specific solidity version for clarity and for more clear
|
|
5
|
+
// source code verification purposes.
|
|
6
|
+
// @dev 0.8.22 rather than 0.8.19 used by other set price minters, as the PMP
|
|
7
|
+
// interfaces depend on OpenZeppelin 5.0, which requires >=0.8.20.
|
|
8
|
+
pragma solidity 0.8.22;
|
|
9
|
+
|
|
10
|
+
import {ISharedMinterSimplePurchaseV0} from "../../interfaces/v0.8.x/ISharedMinterSimplePurchaseV0.sol";
|
|
11
|
+
import {ISharedMinterV0} from "../../interfaces/v0.8.x/ISharedMinterV0.sol";
|
|
12
|
+
import {IMinterFilterV1} from "../../interfaces/v0.8.x/IMinterFilterV1.sol";
|
|
13
|
+
import {IPMPV0} from "../../interfaces/v0.8.x/IPMPV0.sol";
|
|
14
|
+
|
|
15
|
+
import {AuthLib} from "../../libs/v0.8.x/AuthLib.sol";
|
|
16
|
+
import {SplitFundsLib} from "../../libs/v0.8.x/minter-libs/SplitFundsLib.sol";
|
|
17
|
+
import {MaxInvocationsLib} from "../../libs/v0.8.x/minter-libs/MaxInvocationsLib.sol";
|
|
18
|
+
import {SetPriceLib} from "../../libs/v0.8.x/minter-libs/SetPriceLib.sol";
|
|
19
|
+
import {RequiredPMPLib} from "../../libs/v0.8.x/minter-libs/RequiredPMPLib.sol";
|
|
20
|
+
|
|
21
|
+
import {ReentrancyGuard} from "@openzeppelin-4.5/contracts/security/ReentrancyGuard.sol";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @title Shared, filtered Minter contract that allows tokens to be minted with
|
|
25
|
+
* ETH, optionally configuring one or more of the project's post-mint parameters
|
|
26
|
+
* (PMPs) in the same transaction as the mint.
|
|
27
|
+
* This is designed to be used with GenArt721CoreContractV3 flagship or
|
|
28
|
+
* engine contracts.
|
|
29
|
+
* @author Art Blocks Inc.
|
|
30
|
+
* @notice PMP configuration during purchase:
|
|
31
|
+
* In addition to the standard `purchase` and `purchaseTo` functions, this
|
|
32
|
+
* minter exposes `purchaseWithPMPs` and `purchaseToWithPMPs`, which accept an
|
|
33
|
+
* array of PMP inputs and forward them to the PMP contract configured on this
|
|
34
|
+
* minter, in the same transaction as the mint. Any number of PMPs may be
|
|
35
|
+
* configured in a single purchase, but the PMP-accepting functions require at
|
|
36
|
+
* least one input and reject repeated keys; use `purchase` or `purchaseTo` to
|
|
37
|
+
* mint without configuring any PMPs.
|
|
38
|
+
* @dev Repeated keys are rejected because the PMP contract applies inputs in
|
|
39
|
+
* order with no duplicate guard, so a later input silently overwrites an
|
|
40
|
+
* earlier one for the same key.
|
|
41
|
+
* @notice Required PMP keys:
|
|
42
|
+
* A project's artist may additionally require that specific PMP keys be
|
|
43
|
+
* configured during every mint, via `setProjectRequiredPMPKeys`. Each required
|
|
44
|
+
* key is validated at the time it is set: it must be part of the project's
|
|
45
|
+
* active PMP config, must authenticate this minter (see below), and must never
|
|
46
|
+
* lock, because a locked key could no longer be configured and would
|
|
47
|
+
* permanently halt minting. While a project has required keys, `purchase` and
|
|
48
|
+
* `purchaseTo` revert, as they would otherwise bypass the requirement, and the
|
|
49
|
+
* PMP-accepting functions revert unless every required key is present in the
|
|
50
|
+
* submitted inputs. Additional non-required keys may still be submitted.
|
|
51
|
+
* @notice WARNING - required keys depend on the project's PMP config:
|
|
52
|
+
* The validation performed when required keys are set is a setup-time
|
|
53
|
+
* guardrail, not a durable guarantee - the artist may reconfigure the project
|
|
54
|
+
* on the PMP contract at any time afterwards. An artist who invalidates a
|
|
55
|
+
* required key's PMP configuration will halt all minting on the project until
|
|
56
|
+
* either the PMP configuration or the project's required keys are corrected.
|
|
57
|
+
* @notice IMPORTANT - required artist setup:
|
|
58
|
+
* PMP authenticates the caller of `configureTokenParams`, which is this minter
|
|
59
|
+
* contract (not the purchaser). For a PMP key to be configurable during
|
|
60
|
+
* purchase, the project's artist must therefore configure that key on the PMP
|
|
61
|
+
* contract with an `authOption` that includes `Address`, and with `authAddress`
|
|
62
|
+
* set to this minter's address. `TokenOwnerAndAddress` is the expected
|
|
63
|
+
* configuration, as it additionally allows the collector to update the value
|
|
64
|
+
* after the mint. Purchases that pass a PMP key which is not part of the
|
|
65
|
+
* project's active PMP config, or which does not authenticate this minter,
|
|
66
|
+
* will revert.
|
|
67
|
+
* @notice WARNING - implications of granting this minter address auth:
|
|
68
|
+
* A PMP key configured with `authAddress` set to this minter may be written by
|
|
69
|
+
* this minter for any token of that project, at any time before the key's
|
|
70
|
+
* `pmpLockedAfterTimestamp`, not only during a purchase. Artists should only
|
|
71
|
+
* grant this auth for keys that are intended to be set at mint time.
|
|
72
|
+
* @notice WARNING - artist-configured PMP hooks:
|
|
73
|
+
* Configuring a token's PMPs may invoke the project's artist-configured
|
|
74
|
+
* post-configuration hook, which may execute arbitrary code and may revert,
|
|
75
|
+
* causing the entire purchase to revert. The artist is solely responsible for
|
|
76
|
+
* configuring hooks and validating their behavior.
|
|
77
|
+
* @notice Privileged Roles and Ownership:
|
|
78
|
+
* This contract is designed to be managed, with limited powers.
|
|
79
|
+
* Privileged roles and abilities are controlled by the project's artist, which
|
|
80
|
+
* can be modified by the core contract's Admin ACL contract. Both of these
|
|
81
|
+
* roles hold extensive power and can modify minter details.
|
|
82
|
+
* Care must be taken to ensure that the admin ACL contract and artist
|
|
83
|
+
* addresses are secure behind a multi-sig or other access control mechanism.
|
|
84
|
+
* ----------------------------------------------------------------------------
|
|
85
|
+
* The following functions are restricted to a project's artist:
|
|
86
|
+
* - updatePricePerTokenInWei
|
|
87
|
+
* - syncProjectMaxInvocationsToCore
|
|
88
|
+
* - manuallyLimitProjectMaxInvocations
|
|
89
|
+
* - setProjectRequiredPMPKeys
|
|
90
|
+
* ----------------------------------------------------------------------------
|
|
91
|
+
* Additional admin and artist privileged roles may be described on other
|
|
92
|
+
* contracts that this minter integrates with.
|
|
93
|
+
* ----------------------------------------------------------------------------
|
|
94
|
+
* @notice Caution: While Engine projects must be registered on the Art Blocks
|
|
95
|
+
* Core Registry to assign this minter, this minter does not enforce that a
|
|
96
|
+
* project is registered when configured or queried. This is primarily for gas
|
|
97
|
+
* optimization purposes. It is, therefore, possible that fake projects may be
|
|
98
|
+
* configured on this minter, but they will not be able to mint tokens due to
|
|
99
|
+
* checks performed by this minter's Minter Filter.
|
|
100
|
+
*/
|
|
101
|
+
contract MinterSetPricePMPV0 is
|
|
102
|
+
ReentrancyGuard,
|
|
103
|
+
ISharedMinterSimplePurchaseV0,
|
|
104
|
+
ISharedMinterV0
|
|
105
|
+
{
|
|
106
|
+
/// Minter filter address this minter interacts with
|
|
107
|
+
address public immutable minterFilterAddress;
|
|
108
|
+
|
|
109
|
+
/// Minter filter this minter may interact with.
|
|
110
|
+
IMinterFilterV1 private immutable _minterFilter;
|
|
111
|
+
|
|
112
|
+
/// PMP contract this minter configures token params on.
|
|
113
|
+
IPMPV0 public immutable pmpContract;
|
|
114
|
+
|
|
115
|
+
/// minterType for this minter
|
|
116
|
+
string public constant minterType = "MinterSetPricePMPV0";
|
|
117
|
+
|
|
118
|
+
/// minter version for this minter
|
|
119
|
+
string public constant minterVersion = "v0.1.0";
|
|
120
|
+
|
|
121
|
+
// MODIFIERS
|
|
122
|
+
// @dev contract uses modifier-like internal functions instead of modifiers
|
|
123
|
+
// to reduce contract bytecode size
|
|
124
|
+
// @dev contract uses AuthLib for some modifier-like functions
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @notice Initializes contract to be a Filtered Minter for
|
|
128
|
+
* `minterFilter` minter filter.
|
|
129
|
+
* @param minterFilter Minter filter for which this will be a
|
|
130
|
+
* filtered minter.
|
|
131
|
+
* @param pmpContract_ PMP contract on which this minter will configure
|
|
132
|
+
* token params during purchases.
|
|
133
|
+
*/
|
|
134
|
+
constructor(address minterFilter, address pmpContract_) ReentrancyGuard() {
|
|
135
|
+
minterFilterAddress = minterFilter;
|
|
136
|
+
_minterFilter = IMinterFilterV1(minterFilter);
|
|
137
|
+
pmpContract = IPMPV0(pmpContract_);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @notice Manually sets the local maximum invocations of project `projectId`
|
|
142
|
+
* with the provided `maxInvocations`, checking that `maxInvocations` is less
|
|
143
|
+
* than or equal to the value of project `project_id`'s maximum invocations that is
|
|
144
|
+
* set on the core contract.
|
|
145
|
+
* @dev Note that a `maxInvocations` of 0 can only be set if the current `invocations`
|
|
146
|
+
* value is also 0 and this would also set `maxHasBeenInvoked` to true, correctly short-circuiting
|
|
147
|
+
* this minter's purchase function, avoiding extra gas costs from the core contract's maxInvocations check.
|
|
148
|
+
* @param projectId Project ID to set the maximum invocations for.
|
|
149
|
+
* @param coreContract Core contract address for the given project.
|
|
150
|
+
* @param maxInvocations Maximum invocations to set for the project.
|
|
151
|
+
*/
|
|
152
|
+
function manuallyLimitProjectMaxInvocations(
|
|
153
|
+
uint256 projectId,
|
|
154
|
+
address coreContract,
|
|
155
|
+
uint24 maxInvocations
|
|
156
|
+
) external {
|
|
157
|
+
AuthLib.onlyArtist({
|
|
158
|
+
projectId: projectId,
|
|
159
|
+
coreContract: coreContract,
|
|
160
|
+
sender: msg.sender
|
|
161
|
+
});
|
|
162
|
+
MaxInvocationsLib.manuallyLimitProjectMaxInvocations({
|
|
163
|
+
projectId: projectId,
|
|
164
|
+
coreContract: coreContract,
|
|
165
|
+
maxInvocations: maxInvocations
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @notice Updates this minter's price per token of project `projectId`
|
|
171
|
+
* to be '_pricePerTokenInWei`, in Wei.
|
|
172
|
+
* @dev Note that it is intentionally supported here that the configured
|
|
173
|
+
* price may be explicitly set to `0`.
|
|
174
|
+
* @param projectId Project ID to set the price per token for.
|
|
175
|
+
* @param coreContract Core contract address for the given project.
|
|
176
|
+
* @param pricePerTokenInWei Price per token to set for the project, in Wei.
|
|
177
|
+
*/
|
|
178
|
+
function updatePricePerTokenInWei(
|
|
179
|
+
uint256 projectId,
|
|
180
|
+
address coreContract,
|
|
181
|
+
uint248 pricePerTokenInWei
|
|
182
|
+
) external {
|
|
183
|
+
AuthLib.onlyArtist({
|
|
184
|
+
projectId: projectId,
|
|
185
|
+
coreContract: coreContract,
|
|
186
|
+
sender: msg.sender
|
|
187
|
+
});
|
|
188
|
+
SetPriceLib.updatePricePerToken({
|
|
189
|
+
projectId: projectId,
|
|
190
|
+
coreContract: coreContract,
|
|
191
|
+
pricePerToken: pricePerTokenInWei
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// for convenience, sync local max invocations to the core contract if
|
|
195
|
+
// and only if max invocations have not already been synced.
|
|
196
|
+
// @dev do not sync if max invocations have already been synced, as
|
|
197
|
+
// local max invocations could have been manually set to be
|
|
198
|
+
// intentionally less than the core contract's max invocations.
|
|
199
|
+
// @dev if local maxInvocations and maxHasBeenInvoked are both
|
|
200
|
+
// initial values, we know they have not been populated on this minter
|
|
201
|
+
if (
|
|
202
|
+
MaxInvocationsLib.maxInvocationsIsUnconfigured({
|
|
203
|
+
projectId: projectId,
|
|
204
|
+
coreContract: coreContract
|
|
205
|
+
})
|
|
206
|
+
) {
|
|
207
|
+
MaxInvocationsLib.syncProjectMaxInvocationsToCore({
|
|
208
|
+
projectId: projectId,
|
|
209
|
+
coreContract: coreContract
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* @notice Sets the PMP keys that project `projectId` requires to be
|
|
216
|
+
* configured during every mint, replacing any previously set keys.
|
|
217
|
+
* @dev Each key must be part of the project's active config on this
|
|
218
|
+
* minter's PMP contract, must authenticate this minter as a configuring
|
|
219
|
+
* address, and must never lock. Duplicate keys are rejected.
|
|
220
|
+
* @dev While a project has required keys, `purchase` and `purchaseTo`
|
|
221
|
+
* revert, and the PMP-accepting purchase functions require every required
|
|
222
|
+
* key to be submitted.
|
|
223
|
+
* @dev Pass an empty array to clear the project's required keys.
|
|
224
|
+
* @param projectId Project ID to set the required PMP keys for.
|
|
225
|
+
* @param coreContract Core contract address for the given project.
|
|
226
|
+
* @param requiredPMPKeys PMP keys to require during mint.
|
|
227
|
+
*/
|
|
228
|
+
function setProjectRequiredPMPKeys(
|
|
229
|
+
uint256 projectId,
|
|
230
|
+
address coreContract,
|
|
231
|
+
string[] calldata requiredPMPKeys
|
|
232
|
+
) external {
|
|
233
|
+
AuthLib.onlyArtist({
|
|
234
|
+
projectId: projectId,
|
|
235
|
+
coreContract: coreContract,
|
|
236
|
+
sender: msg.sender
|
|
237
|
+
});
|
|
238
|
+
RequiredPMPLib.setRequiredPMPKeys({
|
|
239
|
+
projectId: projectId,
|
|
240
|
+
coreContract: coreContract,
|
|
241
|
+
pmpContract: address(pmpContract),
|
|
242
|
+
requiredPMPKeys: requiredPMPKeys
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* @notice Purchases a token from project `projectId`.
|
|
248
|
+
* @param projectId Project ID to mint a token on.
|
|
249
|
+
* @param coreContract Core contract address for the given project.
|
|
250
|
+
* @return tokenId Token ID of minted token
|
|
251
|
+
*/
|
|
252
|
+
function purchase(
|
|
253
|
+
uint256 projectId,
|
|
254
|
+
address coreContract
|
|
255
|
+
) external payable returns (uint256 tokenId) {
|
|
256
|
+
tokenId = purchaseTo({
|
|
257
|
+
to: msg.sender,
|
|
258
|
+
projectId: projectId,
|
|
259
|
+
coreContract: coreContract
|
|
260
|
+
});
|
|
261
|
+
return tokenId;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* @notice Purchases a token from project `projectId` and configures the
|
|
266
|
+
* token's post-mint params `pmpInputs` in the same transaction.
|
|
267
|
+
* @param projectId Project ID to mint a token on.
|
|
268
|
+
* @param coreContract Core contract address for the given project.
|
|
269
|
+
* @param pmpInputs PMP inputs to configure for the minted token. Must be
|
|
270
|
+
* non-empty, must not contain the same key more than once, and each key
|
|
271
|
+
* must be part of the project's active PMP config and authenticate this
|
|
272
|
+
* minter.
|
|
273
|
+
* @return tokenId Token ID of minted token
|
|
274
|
+
*/
|
|
275
|
+
function purchaseWithPMPs(
|
|
276
|
+
uint256 projectId,
|
|
277
|
+
address coreContract,
|
|
278
|
+
IPMPV0.PMPInput[] calldata pmpInputs
|
|
279
|
+
) external payable returns (uint256 tokenId) {
|
|
280
|
+
tokenId = purchaseToWithPMPs({
|
|
281
|
+
to: msg.sender,
|
|
282
|
+
projectId: projectId,
|
|
283
|
+
coreContract: coreContract,
|
|
284
|
+
pmpInputs: pmpInputs
|
|
285
|
+
});
|
|
286
|
+
return tokenId;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// public getter functions
|
|
290
|
+
/**
|
|
291
|
+
* @notice Gets the maximum invocations project configuration.
|
|
292
|
+
* @param projectId The ID of the project whose data needs to be fetched.
|
|
293
|
+
* @param coreContract The address of the core contract.
|
|
294
|
+
* @return MaxInvocationsLib.MaxInvocationsProjectConfig instance with the
|
|
295
|
+
* configuration data.
|
|
296
|
+
*/
|
|
297
|
+
function maxInvocationsProjectConfig(
|
|
298
|
+
uint256 projectId,
|
|
299
|
+
address coreContract
|
|
300
|
+
)
|
|
301
|
+
external
|
|
302
|
+
view
|
|
303
|
+
returns (MaxInvocationsLib.MaxInvocationsProjectConfig memory)
|
|
304
|
+
{
|
|
305
|
+
return
|
|
306
|
+
MaxInvocationsLib.getMaxInvocationsProjectConfig({
|
|
307
|
+
projectId: projectId,
|
|
308
|
+
coreContract: coreContract
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* @notice Gets the set price project configuration.
|
|
314
|
+
* @param projectId The ID of the project whose data needs to be fetched.
|
|
315
|
+
* @param coreContract The address of the core contract.
|
|
316
|
+
* @return SetPriceProjectConfig struct with the fixed price project
|
|
317
|
+
* configuration data.
|
|
318
|
+
*/
|
|
319
|
+
function setPriceProjectConfig(
|
|
320
|
+
uint256 projectId,
|
|
321
|
+
address coreContract
|
|
322
|
+
) external view returns (SetPriceLib.SetPriceProjectConfig memory) {
|
|
323
|
+
return
|
|
324
|
+
SetPriceLib.getSetPriceProjectConfig({
|
|
325
|
+
projectId: projectId,
|
|
326
|
+
coreContract: coreContract
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* @notice Gets the PMP keys that project `projectId` requires to be
|
|
332
|
+
* configured during every mint.
|
|
333
|
+
* @param projectId The ID of the project whose data needs to be fetched.
|
|
334
|
+
* @param coreContract The address of the core contract.
|
|
335
|
+
* @return The project's required PMP keys. Empty if none are required.
|
|
336
|
+
*/
|
|
337
|
+
function projectRequiredPMPKeys(
|
|
338
|
+
uint256 projectId,
|
|
339
|
+
address coreContract
|
|
340
|
+
) external view returns (string[] memory) {
|
|
341
|
+
return
|
|
342
|
+
RequiredPMPLib.getRequiredPMPKeys({
|
|
343
|
+
projectId: projectId,
|
|
344
|
+
coreContract: coreContract
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* @notice Checks if the specified `coreContract` is a valid engine contract.
|
|
350
|
+
* @dev This function retrieves the cached value of `isEngine` from
|
|
351
|
+
* the `isEngineCache` mapping. If the cached value is already set, it
|
|
352
|
+
* returns the cached value. Otherwise, it calls the `getV3CoreIsEngineView`
|
|
353
|
+
* function from the `SplitFundsLib` library to check if `coreContract`
|
|
354
|
+
* is a valid engine contract.
|
|
355
|
+
* @dev This function will revert if the provided `coreContract` is not
|
|
356
|
+
* a valid Engine or V3 Flagship contract.
|
|
357
|
+
* @param coreContract The address of the contract to check.
|
|
358
|
+
* @return bool indicating if `coreContract` is a valid engine contract.
|
|
359
|
+
*/
|
|
360
|
+
function isEngineView(address coreContract) external view returns (bool) {
|
|
361
|
+
SplitFundsLib.IsEngineCache storage isEngineCache = SplitFundsLib
|
|
362
|
+
.getIsEngineCacheConfig(coreContract);
|
|
363
|
+
if (isEngineCache.isCached) {
|
|
364
|
+
return isEngineCache.isEngine;
|
|
365
|
+
} else {
|
|
366
|
+
// @dev this calls the non-state-modifying variant of isEngine
|
|
367
|
+
return SplitFundsLib.getV3CoreIsEngineView(coreContract);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* @notice projectId => has project reached its maximum number of
|
|
373
|
+
* invocations? Note that this returns a local cache of the core contract's
|
|
374
|
+
* state, and may be out of sync with the core contract. This is
|
|
375
|
+
* intentional, as it only enables gas optimization of mints after a
|
|
376
|
+
* project's maximum invocations has been reached. A false negative will
|
|
377
|
+
* only result in a gas cost increase, since the core contract will still
|
|
378
|
+
* enforce a maxInvocation check during minting. A false positive is not
|
|
379
|
+
* possible because the V3 core contract only allows maximum invocations
|
|
380
|
+
* to be reduced, not increased. Based on this rationale, we intentionally
|
|
381
|
+
* do not do input validation in this method as to whether or not the input
|
|
382
|
+
* @param projectId is an existing project ID.
|
|
383
|
+
* @param coreContract is an existing core contract address.
|
|
384
|
+
*/
|
|
385
|
+
function projectMaxHasBeenInvoked(
|
|
386
|
+
uint256 projectId,
|
|
387
|
+
address coreContract
|
|
388
|
+
) external view returns (bool) {
|
|
389
|
+
return
|
|
390
|
+
MaxInvocationsLib.getMaxHasBeenInvoked({
|
|
391
|
+
projectId: projectId,
|
|
392
|
+
coreContract: coreContract
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* @notice projectId => project's maximum number of invocations.
|
|
398
|
+
* Optionally synced with core contract value, for gas optimization.
|
|
399
|
+
* Note that this returns a local cache of the core contract's
|
|
400
|
+
* state, and may be out of sync with the core contract. This is
|
|
401
|
+
* intentional, as it only enables gas optimization of mints after a
|
|
402
|
+
* project's maximum invocations has been reached.
|
|
403
|
+
* @dev A number greater than the core contract's project max invocations
|
|
404
|
+
* will only result in a gas cost increase, since the core contract will
|
|
405
|
+
* still enforce a maxInvocation check during minting. A number less than
|
|
406
|
+
* the core contract's project max invocations is only possible when the
|
|
407
|
+
* project's max invocations have not been synced on this minter, since the
|
|
408
|
+
* V3 core contract only allows maximum invocations to be reduced, not
|
|
409
|
+
* increased. When this happens, the minter will enable minting, allowing
|
|
410
|
+
* the core contract to enforce the max invocations check. Based on this
|
|
411
|
+
* rationale, we intentionally do not do input validation in this method as
|
|
412
|
+
* to whether or not the input `projectId` is an existing project ID.
|
|
413
|
+
* @param projectId is an existing project ID.
|
|
414
|
+
* @param coreContract is an existing core contract address.
|
|
415
|
+
*/
|
|
416
|
+
function projectMaxInvocations(
|
|
417
|
+
uint256 projectId,
|
|
418
|
+
address coreContract
|
|
419
|
+
) external view returns (uint256) {
|
|
420
|
+
return
|
|
421
|
+
MaxInvocationsLib.getMaxInvocations({
|
|
422
|
+
projectId: projectId,
|
|
423
|
+
coreContract: coreContract
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* @notice Gets if price of token is configured, price of minting a
|
|
429
|
+
* token on project `projectId`, and currency symbol and address to be
|
|
430
|
+
* used as payment.
|
|
431
|
+
* @param projectId Project ID to get price information for
|
|
432
|
+
* @param coreContract Contract address of the core contract
|
|
433
|
+
* @return isConfigured true only if token price has been configured on
|
|
434
|
+
* this minter
|
|
435
|
+
* @return tokenPriceInWei current price of token on this minter - invalid
|
|
436
|
+
* if price has not yet been configured
|
|
437
|
+
* @return currencySymbol currency symbol for purchases of project on this
|
|
438
|
+
* minter. This minter always returns "ETH"
|
|
439
|
+
* @return currencyAddress currency address for purchases of project on
|
|
440
|
+
* this minter. This minter always returns null address, reserved for ether
|
|
441
|
+
*/
|
|
442
|
+
function getPriceInfo(
|
|
443
|
+
uint256 projectId,
|
|
444
|
+
address coreContract
|
|
445
|
+
)
|
|
446
|
+
external
|
|
447
|
+
view
|
|
448
|
+
returns (
|
|
449
|
+
bool isConfigured,
|
|
450
|
+
uint256 tokenPriceInWei,
|
|
451
|
+
string memory currencySymbol,
|
|
452
|
+
address currencyAddress
|
|
453
|
+
)
|
|
454
|
+
{
|
|
455
|
+
SetPriceLib.SetPriceProjectConfig
|
|
456
|
+
storage setPriceProjectConfig_ = SetPriceLib
|
|
457
|
+
.getSetPriceProjectConfig({
|
|
458
|
+
projectId: projectId,
|
|
459
|
+
coreContract: coreContract
|
|
460
|
+
});
|
|
461
|
+
isConfigured = setPriceProjectConfig_.priceIsConfigured;
|
|
462
|
+
tokenPriceInWei = setPriceProjectConfig_.pricePerToken;
|
|
463
|
+
currencySymbol = "ETH";
|
|
464
|
+
currencyAddress = address(0);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* @notice Syncs local maximum invocations of project `projectId` based on
|
|
469
|
+
* the value currently defined in the core contract.
|
|
470
|
+
* @param projectId Project ID to set the maximum invocations for.
|
|
471
|
+
* @param coreContract Core contract address for the given project.
|
|
472
|
+
* @dev this enables gas reduction after maxInvocations have been reached -
|
|
473
|
+
* core contracts shall still enforce a maxInvocation check during mint.
|
|
474
|
+
*/
|
|
475
|
+
function syncProjectMaxInvocationsToCore(
|
|
476
|
+
uint256 projectId,
|
|
477
|
+
address coreContract
|
|
478
|
+
) public {
|
|
479
|
+
AuthLib.onlyArtist({
|
|
480
|
+
projectId: projectId,
|
|
481
|
+
coreContract: coreContract,
|
|
482
|
+
sender: msg.sender
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
MaxInvocationsLib.syncProjectMaxInvocationsToCore({
|
|
486
|
+
projectId: projectId,
|
|
487
|
+
coreContract: coreContract
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* @notice Purchases a token from project `projectId` and sets
|
|
493
|
+
* the token's owner to `to`.
|
|
494
|
+
* @dev Reverts if the project has required PMP keys, which this function
|
|
495
|
+
* would otherwise bypass. Use `purchaseToWithPMPs` for such projects.
|
|
496
|
+
* @param to Address to be the new token's owner.
|
|
497
|
+
* @param projectId Project ID to mint a token on.
|
|
498
|
+
* @param coreContract Core contract address for the given project.
|
|
499
|
+
* @return tokenId Token ID of minted token
|
|
500
|
+
*/
|
|
501
|
+
function purchaseTo(
|
|
502
|
+
address to,
|
|
503
|
+
uint256 projectId,
|
|
504
|
+
address coreContract
|
|
505
|
+
) public payable nonReentrant returns (uint256 tokenId) {
|
|
506
|
+
// CHECKS
|
|
507
|
+
uint256 pricePerTokenInWei = _preMintChecks({
|
|
508
|
+
projectId: projectId,
|
|
509
|
+
coreContract: coreContract
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
// require the project to have no required PMP keys, which this
|
|
513
|
+
// function would otherwise bypass
|
|
514
|
+
RequiredPMPLib.requireNoRequiredPMPKeys({
|
|
515
|
+
projectId: projectId,
|
|
516
|
+
coreContract: coreContract
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
// EFFECTS
|
|
520
|
+
tokenId = _mintToken({
|
|
521
|
+
to: to,
|
|
522
|
+
projectId: projectId,
|
|
523
|
+
coreContract: coreContract
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
// INTERACTIONS
|
|
527
|
+
SplitFundsLib.splitFundsETHRefundSender({
|
|
528
|
+
projectId: projectId,
|
|
529
|
+
pricePerTokenInWei: pricePerTokenInWei,
|
|
530
|
+
coreContract: coreContract
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
return tokenId;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* @notice Purchases a token from project `projectId`, sets the token's
|
|
538
|
+
* owner to `to`, and configures the token's post-mint params `pmpInputs`
|
|
539
|
+
* in the same transaction.
|
|
540
|
+
* @param to Address to be the new token's owner.
|
|
541
|
+
* @param projectId Project ID to mint a token on.
|
|
542
|
+
* @param coreContract Core contract address for the given project.
|
|
543
|
+
* @param pmpInputs PMP inputs to configure for the minted token. Must be
|
|
544
|
+
* non-empty, must not contain the same key more than once, and each key
|
|
545
|
+
* must be part of the project's active PMP config and authenticate this
|
|
546
|
+
* minter.
|
|
547
|
+
* @return tokenId Token ID of minted token
|
|
548
|
+
*/
|
|
549
|
+
function purchaseToWithPMPs(
|
|
550
|
+
address to,
|
|
551
|
+
uint256 projectId,
|
|
552
|
+
address coreContract,
|
|
553
|
+
IPMPV0.PMPInput[] calldata pmpInputs
|
|
554
|
+
) public payable nonReentrant returns (uint256 tokenId) {
|
|
555
|
+
// CHECKS
|
|
556
|
+
// @dev use `purchase` or `purchaseTo` to mint without configuring PMPs
|
|
557
|
+
require(pmpInputs.length > 0, "No PMP inputs");
|
|
558
|
+
|
|
559
|
+
uint256 pricePerTokenInWei = _preMintChecks({
|
|
560
|
+
projectId: projectId,
|
|
561
|
+
coreContract: coreContract
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
// require every PMP key the project requires at mint to be submitted
|
|
565
|
+
RequiredPMPLib.preMintChecks({
|
|
566
|
+
projectId: projectId,
|
|
567
|
+
coreContract: coreContract,
|
|
568
|
+
pmpInputs: pmpInputs
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
// EFFECTS
|
|
572
|
+
tokenId = _mintToken({
|
|
573
|
+
to: to,
|
|
574
|
+
projectId: projectId,
|
|
575
|
+
coreContract: coreContract
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
// INTERACTIONS
|
|
579
|
+
// configure the minted token's PMPs
|
|
580
|
+
// @dev reverts if any key is not part of the project's active PMP
|
|
581
|
+
// config, or does not authenticate this minter's address
|
|
582
|
+
// @dev may invoke the project's artist-configured post-config hook
|
|
583
|
+
pmpContract.configureTokenParams({
|
|
584
|
+
coreContract: coreContract,
|
|
585
|
+
tokenId: tokenId,
|
|
586
|
+
pmpInputs: pmpInputs
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
SplitFundsLib.splitFundsETHRefundSender({
|
|
590
|
+
projectId: projectId,
|
|
591
|
+
pricePerTokenInWei: pricePerTokenInWei,
|
|
592
|
+
coreContract: coreContract
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
return tokenId;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* @notice Internal function to perform pre-mint checks for project
|
|
600
|
+
* `projectId` and return its price per token.
|
|
601
|
+
* @dev Any additional, minter-specific checks are performed by the calling
|
|
602
|
+
* function after this one, so that callers of a sold-out or unconfigured
|
|
603
|
+
* project receive the more relevant revert reason.
|
|
604
|
+
* @param projectId Project ID to mint a token on.
|
|
605
|
+
* @param coreContract Core contract address for the given project.
|
|
606
|
+
* @return pricePerTokenInWei Price per token of the project, in Wei
|
|
607
|
+
*/
|
|
608
|
+
function _preMintChecks(
|
|
609
|
+
uint256 projectId,
|
|
610
|
+
address coreContract
|
|
611
|
+
) private view returns (uint256 pricePerTokenInWei) {
|
|
612
|
+
// pre-mint MaxInvocationsLib checks
|
|
613
|
+
// Note that `maxHasBeenInvoked` is only checked here to reduce gas
|
|
614
|
+
// consumption after a project has been fully minted.
|
|
615
|
+
// `maxInvocationsProjectConfig.maxHasBeenInvoked` is locally cached to reduce
|
|
616
|
+
// gas consumption, but if not in sync with the core contract's value,
|
|
617
|
+
// the core contract also enforces its own max invocation check during
|
|
618
|
+
// minting.
|
|
619
|
+
MaxInvocationsLib.preMintChecks({
|
|
620
|
+
projectId: projectId,
|
|
621
|
+
coreContract: coreContract
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
// pre-mint checks for set price lib, and get price per token in wei
|
|
625
|
+
// @dev price per token is loaded into memory here for gas efficiency
|
|
626
|
+
pricePerTokenInWei = SetPriceLib.preMintChecksAndGetPrice({
|
|
627
|
+
projectId: projectId,
|
|
628
|
+
coreContract: coreContract
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
require(msg.value >= pricePerTokenInWei, "Min value to mint req.");
|
|
632
|
+
|
|
633
|
+
return pricePerTokenInWei;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* @notice Internal function to mint a token from project `projectId` to
|
|
638
|
+
* `to`. Does not perform pre-mint checks or split funds, both of which
|
|
639
|
+
* must be handled by the calling function.
|
|
640
|
+
* @param to Address to be the new token's owner.
|
|
641
|
+
* @param projectId Project ID to mint a token on.
|
|
642
|
+
* @param coreContract Core contract address for the given project.
|
|
643
|
+
* @return tokenId Token ID of minted token
|
|
644
|
+
*/
|
|
645
|
+
function _mintToken(
|
|
646
|
+
address to,
|
|
647
|
+
uint256 projectId,
|
|
648
|
+
address coreContract
|
|
649
|
+
) private returns (uint256 tokenId) {
|
|
650
|
+
tokenId = _minterFilter.mint_joo({
|
|
651
|
+
to: to,
|
|
652
|
+
projectId: projectId,
|
|
653
|
+
coreContract: coreContract,
|
|
654
|
+
sender: msg.sender
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
MaxInvocationsLib.validateMintEffectsInvocations({
|
|
658
|
+
tokenId: tokenId,
|
|
659
|
+
coreContract: coreContract
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
return tokenId;
|
|
663
|
+
}
|
|
664
|
+
}
|