@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.
- package/README.md +2 -2
- package/artifacts/contracts/AdminACLV1.sol/AdminACLV1.json +2 -2
- package/artifacts/contracts/DependencyRegistryV0.sol/DependencyRegistryV0.json +97 -10
- package/artifacts/contracts/GenArt721CoreV3.sol/GenArt721CoreV3.json +4 -4
- package/artifacts/contracts/engine/V3/GenArt721CoreV3_Engine.sol/GenArt721CoreV3_Engine.json +4 -9
- package/artifacts/contracts/engine/V3/GenArt721CoreV3_Engine_Flex.sol/GenArt721CoreV3_Engine_Flex.json +4 -9
- package/artifacts/contracts/engine/V3/forks/GenArt721CoreV3_Engine_Flex_PROOF.sol/GenArt721CoreV3_Engine_Flex_PROOF.json +4 -9
- package/artifacts/contracts/engine/V3/forks/PROHIBITION/GenArt721CoreV3_Engine_Flex_PROHIBITION.sol/GenArt721CoreV3_Engine_Flex_PROHIBITION.json +4 -9
- package/artifacts/contracts/engine-registry/CoreRegistryV1.sol/CoreRegistryV1.json +12 -12
- package/artifacts/contracts/explorations/GenArt721CoreV3_Explorations.sol/GenArt721CoreV3_Explorations.json +4 -4
- package/artifacts/contracts/interfaces/v0.8.x/ICoreRegistryV1.sol/ICoreRegistryV1.json +6 -6
- package/artifacts/contracts/interfaces/v0.8.x/IDependencyRegistryV0.sol/IDependencyRegistryV0.json +19 -0
- package/artifacts/contracts/interfaces/v0.8.x/IMinterFilterV1.sol/IMinterFilterV1.json +22 -22
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterDAExpSettlementV0.sol/ISharedMinterDAExpSettlementV0.json +8 -101
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterDAExpV0.sol/ISharedMinterDAExpV0.json +1 -57
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterDALinV0.sol/ISharedMinterDALinV0.json +1 -57
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterDAV0.sol/ISharedMinterDAV0.json +2 -21
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterHolderERC20V0.sol/ISharedMinterHolderERC20V0.json +158 -0
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterHolderV0.sol/ISharedMinterHolderV0.json +15 -90
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterMerkleV0.sol/ISharedMinterMerkleV0.json +10 -36
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterSEAV0.sol/ISharedMinterSEAV0.json +4 -236
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterSimplePurchaseV0.sol/ISharedMinterSimplePurchaseV0.json +5 -5
- package/artifacts/contracts/interfaces/v0.8.x/ISharedMinterV0.sol/ISharedMinterV0.json +7 -423
- package/artifacts/contracts/interfaces/v0.8.x/ISharedRandomizerV0.sol/ISharedRandomizerV0.json +17 -17
- package/artifacts/contracts/libs/v0.8.x/ABHelpers.sol/ABHelpers.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/AuthLib.sol/AuthLib.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/Bytes32Strings.sol/Bytes32Strings.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/minter-libs/DAExpLib.sol/DAExpLib.json +60 -3
- package/artifacts/contracts/libs/v0.8.x/minter-libs/DALib.sol/DALib.json +30 -0
- package/artifacts/contracts/libs/v0.8.x/minter-libs/DALinLib.sol/DALinLib.json +60 -3
- package/artifacts/contracts/libs/v0.8.x/minter-libs/GenericMinterEventsLib.sol/GenericMinterEventsLib.json +346 -0
- package/artifacts/contracts/libs/v0.8.x/minter-libs/MaxInvocationsLib.sol/MaxInvocationsLib.json +29 -3
- package/artifacts/contracts/libs/v0.8.x/minter-libs/MerkleLib.sol/MerkleLib.json +30 -3
- package/artifacts/contracts/libs/v0.8.x/minter-libs/PolyptychLib.sol/PolyptychLib.json +2 -2
- package/artifacts/contracts/libs/v0.8.x/minter-libs/SEALib.sol/SEALib.json +254 -3
- package/artifacts/contracts/libs/v0.8.x/minter-libs/SetPriceLib.sol/SetPriceLib.json +48 -3
- package/artifacts/contracts/libs/v0.8.x/minter-libs/SettlementExpLib.sol/SettlementExpLib.json +41 -3
- package/artifacts/contracts/libs/v0.8.x/minter-libs/SplitFundsLib.sol/SplitFundsLib.json +35 -3
- package/artifacts/contracts/libs/v0.8.x/minter-libs/TokenHolderLib.sol/TokenHolderLib.json +79 -3
- package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV1.sol/MinterFilterV1.json +2 -2
- package/artifacts/contracts/minter-suite/MinterFilter/MinterFilterV2.sol/MinterFilterV2.json +41 -41
- package/artifacts/contracts/minter-suite/Minters/MinterDAExpHolderV5.sol/MinterDAExpHolderV5.json +66 -632
- package/artifacts/contracts/minter-suite/Minters/MinterDAExpSettlementV2.sol/MinterDAExpSettlementV2.json +2 -20
- package/artifacts/contracts/minter-suite/Minters/MinterDAExpSettlementV3.sol/MinterDAExpSettlementV3.json +67 -594
- package/artifacts/contracts/minter-suite/Minters/MinterDAExpV5.sol/MinterDAExpV5.json +33 -524
- package/artifacts/contracts/minter-suite/Minters/MinterDALinHolderV5.sol/MinterDALinHolderV5.json +66 -632
- package/artifacts/contracts/minter-suite/Minters/MinterDALinV5.sol/MinterDALinV5.json +33 -524
- package/artifacts/contracts/minter-suite/Minters/MinterSEAV1.sol/MinterSEAV1.json +51 -717
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceERC20V5.sol/MinterSetPriceERC20V5.json +58 -454
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceHolderV5.sol/MinterSetPriceHolderV5.json +61 -552
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceMerkleV5.sol/MinterSetPriceMerkleV5.json +55 -497
- package/artifacts/contracts/minter-suite/Minters/MinterSetPricePolyptychERC20V5.sol/MinterSetPricePolyptychERC20V5.json +110 -571
- package/artifacts/contracts/minter-suite/Minters/MinterSetPricePolyptychV5.sol/MinterSetPricePolyptychV5.json +69 -560
- package/artifacts/contracts/minter-suite/Minters/MinterSetPriceV5.sol/MinterSetPriceV5.json +28 -444
- package/artifacts/contracts/mock/DummySharedMinter.sol/DummySharedMinter.json +2 -2
- package/artifacts/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol/GenArt721CoreV3_Engine_IncorrectCoreType.json +4 -9
- package/artifacts/contracts/mock/OriginRegisterMock.sol/OriginRegisterMock.json +2 -2
- package/artifacts/contracts/mock/ReentrancyHolderMockShared.sol/ReentrancyHolderMockShared.json +136 -0
- package/artifacts/contracts/mock/ReentrancyMerkleMockShared.sol/ReentrancyMerkleMockShared.json +105 -0
- package/artifacts/contracts/mock/ReentrancyMockShared.sol/ReentrancyMockShared.json +100 -0
- package/artifacts/contracts/mock/ReentrancySEAMockShared.sol/ReentrancySEAAutoBidderMockShared.json +69 -0
- package/artifacts/contracts/randomizer/shared/SharedRandomizerV0.sol/SharedRandomizerV0.json +19 -19
- package/contracts/DependencyRegistryV0.sol +84 -16
- package/contracts/archive/readme.md +16 -0
- package/contracts/engine/README.md +21 -0
- package/contracts/engine/V3/GenArt721CoreV3_Engine.sol +4 -10
- package/contracts/engine/V3/GenArt721CoreV3_Engine_Flex.sol +4 -10
- package/contracts/engine/V3/forks/GenArt721CoreV3_Engine_Flex_PROOF.sol +4 -10
- package/contracts/engine/V3/forks/PROHIBITION/GenArt721CoreV3_Engine_Flex_PROHIBITION.sol +4 -10
- package/contracts/engine-registry/CoreRegistryV1.sol +58 -65
- package/contracts/interfaces/v0.8.x/ICoreRegistryV1.sol +6 -8
- package/contracts/interfaces/v0.8.x/IDependencyRegistryV0.sol +3 -0
- package/contracts/interfaces/v0.8.x/IMinterFilterV1.sol +25 -25
- package/contracts/interfaces/v0.8.x/ISharedMinterDAExpSettlementV0.sol +11 -20
- package/contracts/interfaces/v0.8.x/ISharedMinterDAExpV0.sol +1 -14
- package/contracts/interfaces/v0.8.x/ISharedMinterDALinV0.sol +1 -15
- package/contracts/interfaces/v0.8.x/ISharedMinterDAV0.sol +2 -8
- package/contracts/interfaces/v0.8.x/ISharedMinterHolderERC20V0.sol +47 -0
- package/contracts/interfaces/v0.8.x/ISharedMinterHolderV0.sol +15 -43
- package/contracts/interfaces/v0.8.x/ISharedMinterMerkleV0.sol +10 -20
- package/contracts/interfaces/v0.8.x/ISharedMinterSEAV0.sol +4 -67
- package/contracts/interfaces/v0.8.x/ISharedMinterSimplePurchaseV0.sol +5 -5
- package/contracts/interfaces/v0.8.x/ISharedMinterV0.sol +7 -155
- package/contracts/interfaces/v0.8.x/ISharedRandomizerV0.sol +37 -37
- package/contracts/libs/v0.8.x/ABHelpers.sol +14 -14
- package/contracts/libs/v0.8.x/AuthLib.sol +101 -102
- package/contracts/libs/v0.8.x/Bytes32Strings.sol +5 -5
- package/contracts/libs/v0.8.x/minter-libs/DAExpLib.sol +163 -38
- package/contracts/libs/v0.8.x/minter-libs/DALib.sol +26 -0
- package/contracts/libs/v0.8.x/minter-libs/DALinLib.sol +144 -37
- package/contracts/libs/v0.8.x/minter-libs/GenericMinterEventsLib.sol +171 -0
- package/contracts/libs/v0.8.x/minter-libs/MaxInvocationsLib.sol +250 -110
- package/contracts/libs/v0.8.x/minter-libs/MerkleLib.sol +257 -48
- package/contracts/libs/v0.8.x/minter-libs/PolyptychLib.sol +138 -58
- package/contracts/libs/v0.8.x/minter-libs/SEALib.sol +778 -103
- package/contracts/libs/v0.8.x/minter-libs/SetPriceLib.sol +135 -13
- package/contracts/libs/v0.8.x/minter-libs/SettlementExpLib.sol +567 -187
- package/contracts/libs/v0.8.x/minter-libs/SplitFundsLib.sol +480 -322
- package/contracts/libs/v0.8.x/minter-libs/TokenHolderLib.sol +214 -76
- package/contracts/minter-suite/MinterFilter/MinterFilterV2.sol +347 -304
- package/contracts/minter-suite/Minters/MinterDAExpHolderV5.sol +391 -491
- package/contracts/minter-suite/Minters/MinterDAExpSettlementV2.sol +1 -54
- package/contracts/minter-suite/Minters/MinterDAExpSettlementV3.sol +388 -628
- package/contracts/minter-suite/Minters/MinterDAExpV5.sol +212 -273
- package/contracts/minter-suite/Minters/MinterDALinHolderV5.sol +393 -488
- package/contracts/minter-suite/Minters/MinterDALinV5.sol +220 -277
- package/contracts/minter-suite/Minters/MinterSEAV1.sol +327 -664
- package/contracts/minter-suite/Minters/MinterSetPriceERC20V5.sol +278 -303
- package/contracts/minter-suite/Minters/MinterSetPriceHolderV5.sol +355 -446
- package/contracts/minter-suite/Minters/MinterSetPriceMerkleV5.sol +328 -416
- package/contracts/minter-suite/Minters/MinterSetPricePolyptychERC20V5.sol +538 -622
- package/contracts/minter-suite/Minters/MinterSetPricePolyptychV5.sol +429 -553
- package/contracts/minter-suite/Minters/MinterSetPriceV5.sol +180 -227
- package/contracts/mock/GenArt721CoreV3_Engine_IncorrectCoreType.sol +3 -10
- package/contracts/mock/ReentrancyHolderMockShared.sol +59 -0
- package/contracts/mock/ReentrancyMerkleMockShared.sol +58 -0
- package/contracts/mock/ReentrancyMockShared.sol +48 -0
- package/contracts/mock/ReentrancySEAMockShared.sol +40 -0
- package/contracts/randomizer/shared/SharedRandomizerV0.sol +78 -70
- package/package.json +39 -33
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
// SPDX-License-Identifier: LGPL-3.0-only
|
|
2
2
|
// Created By: Art Blocks Inc.
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
// @dev fixed to specific solidity version for clarity and for more clear
|
|
5
|
+
// source code verification purposes.
|
|
6
|
+
pragma solidity 0.8.19;
|
|
7
7
|
|
|
8
|
-
import "../../
|
|
9
|
-
import "../../
|
|
10
|
-
import "../../libs/v0.8.x/minter-libs/MaxInvocationsLib.sol";
|
|
11
|
-
import "../../libs/v0.8.x/minter-libs/SetPriceLib.sol";
|
|
8
|
+
import {ISharedMinterV0} from "../../interfaces/v0.8.x/ISharedMinterV0.sol";
|
|
9
|
+
import {IMinterFilterV1} from "../../interfaces/v0.8.x/IMinterFilterV1.sol";
|
|
12
10
|
|
|
13
|
-
import "
|
|
11
|
+
import {AuthLib} from "../../libs/v0.8.x/AuthLib.sol";
|
|
12
|
+
import {SplitFundsLib} from "../../libs/v0.8.x/minter-libs/SplitFundsLib.sol";
|
|
13
|
+
import {MaxInvocationsLib} from "../../libs/v0.8.x/minter-libs/MaxInvocationsLib.sol";
|
|
14
|
+
import {SetPriceLib} from "../../libs/v0.8.x/minter-libs/SetPriceLib.sol";
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
import {ReentrancyGuard} from "@openzeppelin-4.5/contracts/security/ReentrancyGuard.sol";
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* @title Shared, filtered Minter contract that allows tokens to be minted with
|
|
@@ -37,17 +38,20 @@ pragma solidity 0.8.19;
|
|
|
37
38
|
* ----------------------------------------------------------------------------
|
|
38
39
|
* Additional admin and artist privileged roles may be described on other
|
|
39
40
|
* contracts that this minter integrates with.
|
|
41
|
+
* ----------------------------------------------------------------------------
|
|
42
|
+
* @notice Caution: While Engine projects must be registered on the Art Blocks
|
|
43
|
+
* Core Registry to assign this minter, this minter does not enforce that a
|
|
44
|
+
* project is registered when configured or queried. This is primarily for gas
|
|
45
|
+
* optimization purposes. It is, therefore, possible that fake projects may be
|
|
46
|
+
* configured on this minter, but they will not be able to mint tokens due to
|
|
47
|
+
* checks performed by this minter's Minter Filter.
|
|
40
48
|
*/
|
|
41
|
-
contract MinterSetPriceERC20V5 is
|
|
42
|
-
ReentrancyGuard,
|
|
43
|
-
ISharedMinterSimplePurchaseV0,
|
|
44
|
-
ISharedMinterV0
|
|
45
|
-
{
|
|
49
|
+
contract MinterSetPriceERC20V5 is ReentrancyGuard, ISharedMinterV0 {
|
|
46
50
|
/// Minter filter address this minter interacts with
|
|
47
51
|
address public immutable minterFilterAddress;
|
|
48
52
|
|
|
49
53
|
/// Minter filter this minter may interact with.
|
|
50
|
-
IMinterFilterV1 private immutable
|
|
54
|
+
IMinterFilterV1 private immutable _minterFilter;
|
|
51
55
|
|
|
52
56
|
/// minterType for this minter
|
|
53
57
|
string public constant minterType = "MinterSetPriceERC20V5";
|
|
@@ -55,45 +59,6 @@ contract MinterSetPriceERC20V5 is
|
|
|
55
59
|
/// minter version for this minter
|
|
56
60
|
string public constant minterVersion = "v5.0.0";
|
|
57
61
|
|
|
58
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
59
|
-
// STATE VARIABLES FOR SetPriceLib begin here
|
|
60
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
61
|
-
|
|
62
|
-
/// contractAddress => projectId => set price project config
|
|
63
|
-
mapping(address => mapping(uint256 => SetPriceLib.SetPriceProjectConfig))
|
|
64
|
-
private _setPriceProjectConfigMapping;
|
|
65
|
-
|
|
66
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
67
|
-
// STATE VARIABLES FOR SetPriceLib end here
|
|
68
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
69
|
-
|
|
70
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
71
|
-
// STATE VARIABLES FOR SplitFundsLib begin here
|
|
72
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
73
|
-
|
|
74
|
-
// contractAddress => IsEngineCache
|
|
75
|
-
mapping(address => SplitFundsLib.IsEngineCache) private _isEngineCaches;
|
|
76
|
-
|
|
77
|
-
// contractAddress => projectId => SplitFundsProjectConfig
|
|
78
|
-
mapping(address => mapping(uint256 => SplitFundsLib.SplitFundsProjectConfig))
|
|
79
|
-
private _splitFundsProjectConfigs;
|
|
80
|
-
|
|
81
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
82
|
-
// STATE VARIABLES FOR SplitFundsLib end here
|
|
83
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
84
|
-
|
|
85
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
86
|
-
// STATE VARIABLES FOR MaxInvocationsLib begin here
|
|
87
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
88
|
-
|
|
89
|
-
// contractAddress => projectId => max invocations specific project config
|
|
90
|
-
mapping(address => mapping(uint256 => MaxInvocationsLib.MaxInvocationsProjectConfig))
|
|
91
|
-
private _maxInvocationsProjectConfigMapping;
|
|
92
|
-
|
|
93
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
94
|
-
// STATE VARIABLES FOR MaxInvocationsLib end here
|
|
95
|
-
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
96
|
-
|
|
97
62
|
// MODIFIERS
|
|
98
63
|
// @dev contract uses modifier-like internal functions instead of modifiers
|
|
99
64
|
// to reduce contract bytecode size
|
|
@@ -101,209 +66,218 @@ contract MinterSetPriceERC20V5 is
|
|
|
101
66
|
|
|
102
67
|
/**
|
|
103
68
|
* @notice Initializes contract to be a Filtered Minter for
|
|
104
|
-
* `
|
|
105
|
-
* @param
|
|
69
|
+
* `minterFilter` minter filter.
|
|
70
|
+
* @param minterFilter Minter filter for which this will be a
|
|
106
71
|
* filtered minter.
|
|
107
72
|
*/
|
|
108
|
-
constructor(address
|
|
109
|
-
minterFilterAddress =
|
|
110
|
-
|
|
73
|
+
constructor(address minterFilter) ReentrancyGuard() {
|
|
74
|
+
minterFilterAddress = minterFilter;
|
|
75
|
+
_minterFilter = IMinterFilterV1(minterFilter);
|
|
111
76
|
}
|
|
112
77
|
|
|
113
78
|
/**
|
|
114
|
-
* @notice Manually sets the local maximum invocations of project `
|
|
115
|
-
* with the provided `
|
|
116
|
-
* than or equal to the value of project `
|
|
79
|
+
* @notice Manually sets the local maximum invocations of project `projectId`
|
|
80
|
+
* with the provided `maxInvocations`, checking that `maxInvocations` is less
|
|
81
|
+
* than or equal to the value of project `project_id`'s maximum invocations that is
|
|
117
82
|
* set on the core contract.
|
|
118
|
-
* @dev Note that a `
|
|
83
|
+
* @dev Note that a `maxInvocations` of 0 can only be set if the current `invocations`
|
|
119
84
|
* value is also 0 and this would also set `maxHasBeenInvoked` to true, correctly short-circuiting
|
|
120
85
|
* this minter's purchase function, avoiding extra gas costs from the core contract's maxInvocations check.
|
|
121
|
-
* @param
|
|
122
|
-
* @param
|
|
123
|
-
* @param
|
|
86
|
+
* @param projectId Project ID to set the maximum invocations for.
|
|
87
|
+
* @param coreContract Core contract address for the given project.
|
|
88
|
+
* @param maxInvocations Maximum invocations to set for the project.
|
|
124
89
|
*/
|
|
125
90
|
function manuallyLimitProjectMaxInvocations(
|
|
126
|
-
uint256
|
|
127
|
-
address
|
|
128
|
-
uint24
|
|
91
|
+
uint256 projectId,
|
|
92
|
+
address coreContract,
|
|
93
|
+
uint24 maxInvocations
|
|
129
94
|
) external {
|
|
130
95
|
AuthLib.onlyArtist({
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
96
|
+
projectId: projectId,
|
|
97
|
+
coreContract: coreContract,
|
|
98
|
+
sender: msg.sender
|
|
99
|
+
});
|
|
100
|
+
MaxInvocationsLib.manuallyLimitProjectMaxInvocations({
|
|
101
|
+
projectId: projectId,
|
|
102
|
+
coreContract: coreContract,
|
|
103
|
+
maxInvocations: maxInvocations
|
|
134
104
|
});
|
|
135
|
-
MaxInvocationsLib.manuallyLimitProjectMaxInvocations(
|
|
136
|
-
_projectId,
|
|
137
|
-
_coreContract,
|
|
138
|
-
_maxInvocations,
|
|
139
|
-
_maxInvocationsProjectConfigMapping[_coreContract][_projectId]
|
|
140
|
-
);
|
|
141
|
-
emit ProjectMaxInvocationsLimitUpdated(
|
|
142
|
-
_projectId,
|
|
143
|
-
_coreContract,
|
|
144
|
-
_maxInvocations
|
|
145
|
-
);
|
|
146
105
|
}
|
|
147
106
|
|
|
148
107
|
/**
|
|
149
|
-
* @notice Updates this minter's price per token of project `
|
|
150
|
-
* to be
|
|
108
|
+
* @notice Updates this minter's price per token of project `projectId`
|
|
109
|
+
* to be `pricePerTokenInWei`. Note that "in wei" is a misnomer on this
|
|
110
|
+
* ERC20 minter, but is used for consistency with the ETH minters. The
|
|
111
|
+
* price value represents the ERC20 token price without decimals.
|
|
151
112
|
* @dev Note that it is intentionally supported here that the configured
|
|
152
113
|
* price may be explicitly set to `0`.
|
|
153
|
-
* @param
|
|
154
|
-
* @param
|
|
155
|
-
* @param
|
|
114
|
+
* @param projectId Project ID to set the price per token for.
|
|
115
|
+
* @param coreContract Core contract address for the given project.
|
|
116
|
+
* @param pricePerTokenInWei Price per token to set for the project.
|
|
117
|
+
* Represents the ERC20 token price without decimals.
|
|
156
118
|
*/
|
|
157
119
|
function updatePricePerTokenInWei(
|
|
158
|
-
uint256
|
|
159
|
-
address
|
|
160
|
-
uint248
|
|
120
|
+
uint256 projectId,
|
|
121
|
+
address coreContract,
|
|
122
|
+
uint248 pricePerTokenInWei
|
|
161
123
|
) external {
|
|
162
124
|
AuthLib.onlyArtist({
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
125
|
+
projectId: projectId,
|
|
126
|
+
coreContract: coreContract,
|
|
127
|
+
sender: msg.sender
|
|
128
|
+
});
|
|
129
|
+
SetPriceLib.updatePricePerToken({
|
|
130
|
+
projectId: projectId,
|
|
131
|
+
coreContract: coreContract,
|
|
132
|
+
pricePerToken: pricePerTokenInWei
|
|
166
133
|
});
|
|
167
|
-
SetPriceLib.SetPriceProjectConfig
|
|
168
|
-
storage _setPriceProjectConfig = _setPriceProjectConfigMapping[
|
|
169
|
-
_coreContract
|
|
170
|
-
][_projectId];
|
|
171
|
-
SetPriceLib.updatePricePerTokenInWei(
|
|
172
|
-
_pricePerTokenInWei,
|
|
173
|
-
_setPriceProjectConfig
|
|
174
|
-
);
|
|
175
|
-
emit PricePerTokenInWeiUpdated(
|
|
176
|
-
_projectId,
|
|
177
|
-
_coreContract,
|
|
178
|
-
_pricePerTokenInWei
|
|
179
|
-
);
|
|
180
134
|
|
|
181
135
|
// for convenience, sync local max invocations to the core contract if
|
|
182
136
|
// and only if max invocations have not already been synced.
|
|
183
137
|
// @dev do not sync if max invocations have already been synced, as
|
|
184
138
|
// local max invocations could have been manually set to be
|
|
185
139
|
// intentionally less than the core contract's max invocations.
|
|
186
|
-
MaxInvocationsLib.MaxInvocationsProjectConfig
|
|
187
|
-
storage _maxInvocationsProjectConfig = _maxInvocationsProjectConfigMapping[
|
|
188
|
-
_coreContract
|
|
189
|
-
][_projectId];
|
|
190
140
|
// @dev if local maxInvocations and maxHasBeenInvoked are both
|
|
191
141
|
// initial values, we know they have not been populated on this minter
|
|
192
142
|
if (
|
|
193
|
-
MaxInvocationsLib.maxInvocationsIsUnconfigured(
|
|
194
|
-
|
|
195
|
-
|
|
143
|
+
MaxInvocationsLib.maxInvocationsIsUnconfigured({
|
|
144
|
+
projectId: projectId,
|
|
145
|
+
coreContract: coreContract
|
|
146
|
+
})
|
|
196
147
|
) {
|
|
197
|
-
syncProjectMaxInvocationsToCore(
|
|
148
|
+
syncProjectMaxInvocationsToCore({
|
|
149
|
+
projectId: projectId,
|
|
150
|
+
coreContract: coreContract
|
|
151
|
+
});
|
|
198
152
|
}
|
|
199
153
|
}
|
|
200
154
|
|
|
201
155
|
/**
|
|
202
|
-
* @notice Updates payment currency of project `
|
|
203
|
-
* contract `
|
|
204
|
-
* `
|
|
156
|
+
* @notice Updates payment currency of project `projectId` on core
|
|
157
|
+
* contract `coreContract` to be `currencySymbol` at address
|
|
158
|
+
* `currencyAddress`.
|
|
205
159
|
* Only supports ERC20 tokens - for ETH minting, use a different minter.
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
* @
|
|
160
|
+
* Resets price to be unconfigured if currency was previously configured,
|
|
161
|
+
* as a safeguard against accidentally setting a price in one currency
|
|
162
|
+
* and then changing the currency but not the price.
|
|
163
|
+
* @dev nonReentrant because no reentrant use cases, and to eliminate an
|
|
164
|
+
* entire branch of reentrancy attack vectors.
|
|
165
|
+
* @param projectId Project ID to update.
|
|
166
|
+
* @param coreContract Core contract address for the given project.
|
|
167
|
+
* @param currencySymbol Currency symbol.
|
|
168
|
+
* @param currencyAddress Currency address.
|
|
210
169
|
*/
|
|
211
170
|
function updateProjectCurrencyInfo(
|
|
212
|
-
uint256
|
|
213
|
-
address
|
|
214
|
-
string memory
|
|
215
|
-
address
|
|
171
|
+
uint256 projectId,
|
|
172
|
+
address coreContract,
|
|
173
|
+
string memory currencySymbol,
|
|
174
|
+
address currencyAddress
|
|
216
175
|
) external nonReentrant {
|
|
217
176
|
AuthLib.onlyArtist({
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
});
|
|
222
|
-
SplitFundsLib.SplitFundsProjectConfig
|
|
223
|
-
storage _splitFundsProjectConfig = _splitFundsProjectConfigs[
|
|
224
|
-
_coreContract
|
|
225
|
-
][_projectId];
|
|
226
|
-
SplitFundsLib.updateProjectCurrencyInfoERC20({
|
|
227
|
-
_splitFundsProjectConfig: _splitFundsProjectConfig,
|
|
228
|
-
_currencySymbol: _currencySymbol,
|
|
229
|
-
_currencyAddress: _currencyAddress
|
|
230
|
-
});
|
|
231
|
-
emit ProjectCurrencyInfoUpdated({
|
|
232
|
-
_projectId: _projectId,
|
|
233
|
-
_coreContract: _coreContract,
|
|
234
|
-
_currencyAddress: _currencyAddress,
|
|
235
|
-
_currencySymbol: _currencySymbol
|
|
177
|
+
projectId: projectId,
|
|
178
|
+
coreContract: coreContract,
|
|
179
|
+
sender: msg.sender
|
|
236
180
|
});
|
|
181
|
+
bool recommendPriceReset = SplitFundsLib
|
|
182
|
+
.updateProjectCurrencyInfoERC20({
|
|
183
|
+
projectId: projectId,
|
|
184
|
+
coreContract: coreContract,
|
|
185
|
+
currencySymbol: currencySymbol,
|
|
186
|
+
currencyAddress: currencyAddress
|
|
187
|
+
});
|
|
188
|
+
if (recommendPriceReset) {
|
|
189
|
+
SetPriceLib.resetPricePerToken({
|
|
190
|
+
projectId: projectId,
|
|
191
|
+
coreContract: coreContract
|
|
192
|
+
});
|
|
193
|
+
}
|
|
237
194
|
}
|
|
238
195
|
|
|
239
196
|
/**
|
|
240
|
-
* @notice Purchases a token from project `
|
|
241
|
-
* @param
|
|
242
|
-
* @param
|
|
197
|
+
* @notice Purchases a token from project `projectId`.
|
|
198
|
+
* @param projectId Project ID to mint a token on.
|
|
199
|
+
* @param coreContract Core contract address for the given project.
|
|
200
|
+
* @param maxPricePerToken Maximum price of token being allowed by the purchaser, no decimal places
|
|
201
|
+
* @param currencyAddress Currency address of token.
|
|
243
202
|
* @return tokenId Token ID of minted token
|
|
244
203
|
*/
|
|
245
204
|
function purchase(
|
|
246
|
-
uint256
|
|
247
|
-
address
|
|
248
|
-
|
|
249
|
-
|
|
205
|
+
uint256 projectId,
|
|
206
|
+
address coreContract,
|
|
207
|
+
uint256 maxPricePerToken,
|
|
208
|
+
address currencyAddress
|
|
209
|
+
) external returns (uint256 tokenId) {
|
|
210
|
+
tokenId = purchaseTo({
|
|
211
|
+
to: msg.sender,
|
|
212
|
+
projectId: projectId,
|
|
213
|
+
coreContract: coreContract,
|
|
214
|
+
maxPricePerToken: maxPricePerToken,
|
|
215
|
+
currencyAddress: currencyAddress
|
|
216
|
+
});
|
|
250
217
|
return tokenId;
|
|
251
218
|
}
|
|
252
219
|
|
|
253
220
|
// public getter functions
|
|
254
221
|
/**
|
|
255
222
|
* @notice Gets the maximum invocations project configuration.
|
|
256
|
-
* @param
|
|
257
|
-
* @param
|
|
223
|
+
* @param projectId The ID of the project whose data needs to be fetched.
|
|
224
|
+
* @param coreContract The address of the core contract.
|
|
258
225
|
* @return MaxInvocationsLib.MaxInvocationsProjectConfig instance with the
|
|
259
226
|
* configuration data.
|
|
260
227
|
*/
|
|
261
228
|
function maxInvocationsProjectConfig(
|
|
262
|
-
uint256
|
|
263
|
-
address
|
|
229
|
+
uint256 projectId,
|
|
230
|
+
address coreContract
|
|
264
231
|
)
|
|
265
232
|
external
|
|
266
233
|
view
|
|
267
234
|
returns (MaxInvocationsLib.MaxInvocationsProjectConfig memory)
|
|
268
235
|
{
|
|
269
|
-
return
|
|
236
|
+
return
|
|
237
|
+
MaxInvocationsLib.getMaxInvocationsProjectConfig({
|
|
238
|
+
projectId: projectId,
|
|
239
|
+
coreContract: coreContract
|
|
240
|
+
});
|
|
270
241
|
}
|
|
271
242
|
|
|
272
243
|
/**
|
|
273
244
|
* @notice Gets the set price project configuration.
|
|
274
|
-
* @param
|
|
275
|
-
* @param
|
|
245
|
+
* @param projectId The ID of the project whose data needs to be fetched.
|
|
246
|
+
* @param coreContract The address of the core contract.
|
|
276
247
|
* @return SetPriceProjectConfig struct with the fixed price project
|
|
277
248
|
* configuration data.
|
|
278
249
|
*/
|
|
279
250
|
function setPriceProjectConfig(
|
|
280
|
-
uint256
|
|
281
|
-
address
|
|
251
|
+
uint256 projectId,
|
|
252
|
+
address coreContract
|
|
282
253
|
) external view returns (SetPriceLib.SetPriceProjectConfig memory) {
|
|
283
|
-
return
|
|
254
|
+
return
|
|
255
|
+
SetPriceLib.getSetPriceProjectConfig({
|
|
256
|
+
projectId: projectId,
|
|
257
|
+
coreContract: coreContract
|
|
258
|
+
});
|
|
284
259
|
}
|
|
285
260
|
|
|
286
261
|
/**
|
|
287
|
-
* @notice Checks if the specified `
|
|
288
|
-
* @dev This function retrieves the cached value of `
|
|
262
|
+
* @notice Checks if the specified `coreContract` is a valid engine contract.
|
|
263
|
+
* @dev This function retrieves the cached value of `isEngine` from
|
|
289
264
|
* the `isEngineCache` mapping. If the cached value is already set, it
|
|
290
|
-
* returns the cached value. Otherwise, it calls the `
|
|
291
|
-
* function from the `SplitFundsLib` library to check if `
|
|
265
|
+
* returns the cached value. Otherwise, it calls the `getV3CoreIsEngineView`
|
|
266
|
+
* function from the `SplitFundsLib` library to check if `coreContract`
|
|
292
267
|
* is a valid engine contract.
|
|
293
|
-
* @dev This function will revert if the provided `
|
|
268
|
+
* @dev This function will revert if the provided `coreContract` is not
|
|
294
269
|
* a valid Engine or V3 Flagship contract.
|
|
295
|
-
* @param
|
|
296
|
-
* @return bool indicating if `
|
|
270
|
+
* @param coreContract The address of the contract to check.
|
|
271
|
+
* @return bool indicating if `coreContract` is a valid engine contract.
|
|
297
272
|
*/
|
|
298
|
-
function isEngineView(address
|
|
299
|
-
SplitFundsLib.IsEngineCache storage isEngineCache =
|
|
300
|
-
|
|
301
|
-
];
|
|
273
|
+
function isEngineView(address coreContract) external view returns (bool) {
|
|
274
|
+
SplitFundsLib.IsEngineCache storage isEngineCache = SplitFundsLib
|
|
275
|
+
.getIsEngineCacheConfig(coreContract);
|
|
302
276
|
if (isEngineCache.isCached) {
|
|
303
277
|
return isEngineCache.isEngine;
|
|
304
278
|
} else {
|
|
305
|
-
// @dev this calls the non-modifying variant of
|
|
306
|
-
return SplitFundsLib.getV3CoreIsEngineView(
|
|
279
|
+
// @dev this calls the non-state-modifying variant of isEngine
|
|
280
|
+
return SplitFundsLib.getV3CoreIsEngineView(coreContract);
|
|
307
281
|
}
|
|
308
282
|
}
|
|
309
283
|
|
|
@@ -318,17 +292,18 @@ contract MinterSetPriceERC20V5 is
|
|
|
318
292
|
* possible because the V3 core contract only allows maximum invocations
|
|
319
293
|
* to be reduced, not increased. Based on this rationale, we intentionally
|
|
320
294
|
* do not do input validation in this method as to whether or not the input
|
|
321
|
-
* @param
|
|
322
|
-
* @param
|
|
295
|
+
* @param projectId is an existing project ID.
|
|
296
|
+
* @param coreContract is an existing core contract address.
|
|
323
297
|
*/
|
|
324
298
|
function projectMaxHasBeenInvoked(
|
|
325
|
-
uint256
|
|
326
|
-
address
|
|
299
|
+
uint256 projectId,
|
|
300
|
+
address coreContract
|
|
327
301
|
) external view returns (bool) {
|
|
328
302
|
return
|
|
329
|
-
MaxInvocationsLib.getMaxHasBeenInvoked(
|
|
330
|
-
|
|
331
|
-
|
|
303
|
+
MaxInvocationsLib.getMaxHasBeenInvoked({
|
|
304
|
+
projectId: projectId,
|
|
305
|
+
coreContract: coreContract
|
|
306
|
+
});
|
|
332
307
|
}
|
|
333
308
|
|
|
334
309
|
/**
|
|
@@ -347,79 +322,83 @@ contract MinterSetPriceERC20V5 is
|
|
|
347
322
|
* increased. When this happens, the minter will enable minting, allowing
|
|
348
323
|
* the core contract to enforce the max invocations check. Based on this
|
|
349
324
|
* rationale, we intentionally do not do input validation in this method as
|
|
350
|
-
* to whether or not the input `
|
|
351
|
-
* @param
|
|
352
|
-
* @param
|
|
325
|
+
* to whether or not the input `projectId` is an existing project ID.
|
|
326
|
+
* @param projectId is an existing project ID.
|
|
327
|
+
* @param coreContract is an existing core contract address.
|
|
353
328
|
*/
|
|
354
329
|
function projectMaxInvocations(
|
|
355
|
-
uint256
|
|
356
|
-
address
|
|
330
|
+
uint256 projectId,
|
|
331
|
+
address coreContract
|
|
357
332
|
) external view returns (uint256) {
|
|
358
333
|
return
|
|
359
|
-
MaxInvocationsLib.getMaxInvocations(
|
|
360
|
-
|
|
361
|
-
|
|
334
|
+
MaxInvocationsLib.getMaxInvocations({
|
|
335
|
+
projectId: projectId,
|
|
336
|
+
coreContract: coreContract
|
|
337
|
+
});
|
|
362
338
|
}
|
|
363
339
|
|
|
364
340
|
/**
|
|
365
341
|
* @notice Gets your balance of the ERC20 token currently set
|
|
366
|
-
* as the payment currency for project `
|
|
367
|
-
* contract `
|
|
368
|
-
* @param
|
|
369
|
-
* @param
|
|
342
|
+
* as the payment currency for project `projectId` in the core
|
|
343
|
+
* contract `coreContract`.
|
|
344
|
+
* @param projectId Project ID to be queried.
|
|
345
|
+
* @param coreContract The address of the core contract.
|
|
370
346
|
* @return balance Balance of ERC20
|
|
371
347
|
*/
|
|
372
348
|
function getYourBalanceOfProjectERC20(
|
|
373
|
-
uint256
|
|
374
|
-
address
|
|
349
|
+
uint256 projectId,
|
|
350
|
+
address coreContract
|
|
375
351
|
) external view returns (uint256 balance) {
|
|
376
|
-
SplitFundsLib.
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
balance = SplitFundsLib.getERC20Balance(
|
|
381
|
-
|
|
382
|
-
msg.sender
|
|
383
|
-
);
|
|
352
|
+
(address currencyAddress, ) = SplitFundsLib.getCurrencyInfoERC20({
|
|
353
|
+
projectId: projectId,
|
|
354
|
+
coreContract: coreContract
|
|
355
|
+
});
|
|
356
|
+
balance = SplitFundsLib.getERC20Balance({
|
|
357
|
+
currencyAddress: currencyAddress,
|
|
358
|
+
walletAddress: msg.sender
|
|
359
|
+
});
|
|
384
360
|
return balance;
|
|
385
361
|
}
|
|
386
362
|
|
|
387
363
|
/**
|
|
388
364
|
* @notice Gets your allowance for this minter of the ERC20
|
|
389
365
|
* token currently set as the payment currency for project
|
|
390
|
-
* `
|
|
391
|
-
* @param
|
|
392
|
-
* @param
|
|
366
|
+
* `projectId`.
|
|
367
|
+
* @param projectId Project ID to be queried.
|
|
368
|
+
* @param coreContract The address of the core contract.
|
|
393
369
|
* @return remaining Remaining allowance of ERC20
|
|
394
370
|
*/
|
|
395
371
|
function checkYourAllowanceOfProjectERC20(
|
|
396
|
-
uint256
|
|
397
|
-
address
|
|
372
|
+
uint256 projectId,
|
|
373
|
+
address coreContract
|
|
398
374
|
) external view returns (uint256 remaining) {
|
|
399
|
-
SplitFundsLib.
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
375
|
+
(address currencyAddress, ) = SplitFundsLib.getCurrencyInfoERC20({
|
|
376
|
+
projectId: projectId,
|
|
377
|
+
coreContract: coreContract
|
|
378
|
+
});
|
|
403
379
|
remaining = SplitFundsLib.getERC20Allowance({
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
380
|
+
currencyAddress: currencyAddress,
|
|
381
|
+
walletAddress: msg.sender,
|
|
382
|
+
spenderAddress: address(this)
|
|
407
383
|
});
|
|
408
384
|
return remaining;
|
|
409
385
|
}
|
|
410
386
|
|
|
411
387
|
/**
|
|
412
388
|
* @notice Gets if price of token is configured, price of minting a
|
|
413
|
-
* token on project `
|
|
389
|
+
* token on project `projectId`, and currency symbol and address to be
|
|
414
390
|
* used as payment.
|
|
415
391
|
* `isConfigured` is only true if a price has been configured, and an ERC20
|
|
416
392
|
* token has been configured.
|
|
417
|
-
* @param
|
|
418
|
-
* @param
|
|
393
|
+
* @param projectId Project ID to get price information for
|
|
394
|
+
* @param coreContract Contract address of the core contract
|
|
419
395
|
* @return isConfigured true only if token price has been configured on
|
|
420
396
|
* this minter and an ERC20 token has been configured
|
|
421
397
|
* @return tokenPriceInWei current price of token on this minter - invalid
|
|
422
|
-
* if price has not yet been configured
|
|
398
|
+
* if price has not yet been configured. Note that "in wei" is a misnomer
|
|
399
|
+
* for ERC20 tokens, but is used here for ABI consistency with the ETH
|
|
400
|
+
* minters. The value returned represents the price per token, with no
|
|
401
|
+
* decimals.
|
|
423
402
|
* @return currencySymbol currency symbol for purchases of project on this
|
|
424
403
|
* minter. "UNCONFIG" if not yet configured. Note that currency symbol is
|
|
425
404
|
* defined by the artist, and is not necessarily the same as the ERC20
|
|
@@ -428,8 +407,8 @@ contract MinterSetPriceERC20V5 is
|
|
|
428
407
|
* this minter. Null address if not yet configured.
|
|
429
408
|
*/
|
|
430
409
|
function getPriceInfo(
|
|
431
|
-
uint256
|
|
432
|
-
address
|
|
410
|
+
uint256 projectId,
|
|
411
|
+
address coreContract
|
|
433
412
|
)
|
|
434
413
|
external
|
|
435
414
|
view
|
|
@@ -441,128 +420,124 @@ contract MinterSetPriceERC20V5 is
|
|
|
441
420
|
)
|
|
442
421
|
{
|
|
443
422
|
SetPriceLib.SetPriceProjectConfig
|
|
444
|
-
storage
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
_splitFundsProjectConfig
|
|
455
|
-
);
|
|
423
|
+
storage setPriceProjectConfig_ = SetPriceLib
|
|
424
|
+
.getSetPriceProjectConfig({
|
|
425
|
+
projectId: projectId,
|
|
426
|
+
coreContract: coreContract
|
|
427
|
+
});
|
|
428
|
+
tokenPriceInWei = setPriceProjectConfig_.pricePerToken;
|
|
429
|
+
(currencyAddress, currencySymbol) = SplitFundsLib.getCurrencyInfoERC20({
|
|
430
|
+
projectId: projectId,
|
|
431
|
+
coreContract: coreContract
|
|
432
|
+
});
|
|
456
433
|
// report if price and ERC20 token are configured
|
|
457
434
|
// @dev currencyAddress is non-zero if an ERC20 token is configured
|
|
458
435
|
isConfigured =
|
|
459
|
-
|
|
436
|
+
setPriceProjectConfig_.priceIsConfigured &&
|
|
460
437
|
currencyAddress != address(0);
|
|
461
438
|
}
|
|
462
439
|
|
|
463
440
|
/**
|
|
464
|
-
* @notice Syncs local maximum invocations of project `
|
|
441
|
+
* @notice Syncs local maximum invocations of project `projectId` based on
|
|
465
442
|
* the value currently defined in the core contract.
|
|
466
|
-
* @param
|
|
467
|
-
* @param
|
|
443
|
+
* @param projectId Project ID to set the maximum invocations for.
|
|
444
|
+
* @param coreContract Core contract address for the given project.
|
|
468
445
|
* @dev this enables gas reduction after maxInvocations have been reached -
|
|
469
446
|
* core contracts shall still enforce a maxInvocation check during mint.
|
|
470
447
|
*/
|
|
471
448
|
function syncProjectMaxInvocationsToCore(
|
|
472
|
-
uint256
|
|
473
|
-
address
|
|
449
|
+
uint256 projectId,
|
|
450
|
+
address coreContract
|
|
474
451
|
) public {
|
|
475
452
|
AuthLib.onlyArtist({
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
453
|
+
projectId: projectId,
|
|
454
|
+
coreContract: coreContract,
|
|
455
|
+
sender: msg.sender
|
|
479
456
|
});
|
|
480
457
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
_maxInvocationsProjectConfigMapping[_coreContract][_projectId]
|
|
486
|
-
);
|
|
487
|
-
emit ProjectMaxInvocationsLimitUpdated(
|
|
488
|
-
_projectId,
|
|
489
|
-
_coreContract,
|
|
490
|
-
maxInvocations
|
|
491
|
-
);
|
|
458
|
+
MaxInvocationsLib.syncProjectMaxInvocationsToCore({
|
|
459
|
+
projectId: projectId,
|
|
460
|
+
coreContract: coreContract
|
|
461
|
+
});
|
|
492
462
|
}
|
|
493
463
|
|
|
494
464
|
/**
|
|
495
|
-
* @notice Purchases a token from project `
|
|
496
|
-
* the token's owner to `
|
|
497
|
-
* @param
|
|
498
|
-
* @param
|
|
499
|
-
* @param
|
|
465
|
+
* @notice Purchases a token from project `projectId` and sets
|
|
466
|
+
* the token's owner to `to`.
|
|
467
|
+
* @param to Address to be the new token's owner.
|
|
468
|
+
* @param projectId Project ID to mint a token on.
|
|
469
|
+
* @param coreContract Core contract address for the given project.
|
|
470
|
+
* @param maxPricePerToken Maximum price of token being allowed by the purchaser, no decimal places
|
|
471
|
+
* @param currencyAddress Currency address of token.
|
|
500
472
|
* @return tokenId Token ID of minted token
|
|
501
473
|
*/
|
|
502
474
|
function purchaseTo(
|
|
503
|
-
address
|
|
504
|
-
uint256
|
|
505
|
-
address
|
|
506
|
-
|
|
475
|
+
address to,
|
|
476
|
+
uint256 projectId,
|
|
477
|
+
address coreContract,
|
|
478
|
+
uint256 maxPricePerToken,
|
|
479
|
+
address currencyAddress
|
|
480
|
+
) public nonReentrant returns (uint256 tokenId) {
|
|
507
481
|
// CHECKS
|
|
508
|
-
|
|
509
|
-
storage _setPriceProjectConfig = _setPriceProjectConfigMapping[
|
|
510
|
-
_coreContract
|
|
511
|
-
][_projectId];
|
|
512
|
-
MaxInvocationsLib.MaxInvocationsProjectConfig
|
|
513
|
-
storage _maxInvocationsProjectConfig = _maxInvocationsProjectConfigMapping[
|
|
514
|
-
_coreContract
|
|
515
|
-
][_projectId];
|
|
516
|
-
|
|
482
|
+
// pre-mint MaxInvocationsLib checks
|
|
517
483
|
// Note that `maxHasBeenInvoked` is only checked here to reduce gas
|
|
518
484
|
// consumption after a project has been fully minted.
|
|
519
|
-
// `
|
|
485
|
+
// `maxInvocationsProjectConfig.maxHasBeenInvoked` is locally cached to reduce
|
|
520
486
|
// gas consumption, but if not in sync with the core contract's value,
|
|
521
487
|
// the core contract also enforces its own max invocation check during
|
|
522
488
|
// minting.
|
|
489
|
+
MaxInvocationsLib.preMintChecks({
|
|
490
|
+
projectId: projectId,
|
|
491
|
+
coreContract: coreContract
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
// pre-mint checks for set price lib, and get price per token
|
|
495
|
+
// @dev price per token is loaded into memory here for gas efficiency
|
|
496
|
+
uint256 pricePerToken = SetPriceLib.preMintChecksAndGetPrice({
|
|
497
|
+
projectId: projectId,
|
|
498
|
+
coreContract: coreContract
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
// get the currency address configured on the project
|
|
502
|
+
// @dev revert occurs during payment split if ERC20 token is not
|
|
503
|
+
// configured (i.e. address(0)), so check is not performed here
|
|
504
|
+
(address configuredCurrencyAddress, ) = SplitFundsLib
|
|
505
|
+
.getCurrencyInfoERC20({
|
|
506
|
+
projectId: projectId,
|
|
507
|
+
coreContract: coreContract
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
// validate that the currency address matches the project configured currency
|
|
523
511
|
require(
|
|
524
|
-
|
|
525
|
-
"
|
|
512
|
+
currencyAddress == configuredCurrencyAddress,
|
|
513
|
+
"Currency addresses must match"
|
|
526
514
|
);
|
|
527
515
|
|
|
528
|
-
//
|
|
516
|
+
// validate that the specified maximum price is greater than or equal to the price per token
|
|
529
517
|
require(
|
|
530
|
-
|
|
531
|
-
"
|
|
518
|
+
maxPricePerToken >= pricePerToken,
|
|
519
|
+
"Only max price gte token price"
|
|
532
520
|
);
|
|
533
|
-
// @dev revert occurs during payment split if ERC20 token is not
|
|
534
|
-
// configured (i.e. address(0)), so check is not performed here
|
|
535
521
|
|
|
536
522
|
// EFFECTS
|
|
537
|
-
tokenId =
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
msg.sender
|
|
542
|
-
);
|
|
523
|
+
tokenId = _minterFilter.mint_joo({
|
|
524
|
+
to: to,
|
|
525
|
+
projectId: projectId,
|
|
526
|
+
coreContract: coreContract,
|
|
527
|
+
sender: msg.sender
|
|
528
|
+
});
|
|
543
529
|
|
|
544
|
-
MaxInvocationsLib.validatePurchaseEffectsInvocations(
|
|
545
|
-
tokenId,
|
|
546
|
-
|
|
547
|
-
);
|
|
530
|
+
MaxInvocationsLib.validatePurchaseEffectsInvocations({
|
|
531
|
+
tokenId: tokenId,
|
|
532
|
+
coreContract: coreContract
|
|
533
|
+
});
|
|
548
534
|
|
|
549
535
|
// INTERACTIONS
|
|
550
536
|
// split ERC20 funds
|
|
551
|
-
bool isEngine = SplitFundsLib.isEngine(
|
|
552
|
-
_coreContract,
|
|
553
|
-
_isEngineCaches[_coreContract]
|
|
554
|
-
);
|
|
555
|
-
// process payment in ERC20
|
|
556
|
-
SplitFundsLib.SplitFundsProjectConfig
|
|
557
|
-
storage _splitFundsProjectConfig = _splitFundsProjectConfigs[
|
|
558
|
-
_coreContract
|
|
559
|
-
][_projectId];
|
|
560
537
|
SplitFundsLib.splitFundsERC20({
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
_coreContract: _coreContract,
|
|
565
|
-
_isEngine: isEngine
|
|
538
|
+
projectId: projectId,
|
|
539
|
+
pricePerToken: pricePerToken,
|
|
540
|
+
coreContract: coreContract
|
|
566
541
|
});
|
|
567
542
|
|
|
568
543
|
return tokenId;
|