-
Notifications
You must be signed in to change notification settings - Fork 6
/
NFTDropMarket.sol
151 lines (139 loc) · 5.27 KB
/
NFTDropMarket.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
・
* ★
・ 。
・ ゚☆ 。
* ★ ゚・。 * 。
* ☆ 。・゚*.。
゚ *.。☆。★ ・
` .-:::::-.` `-::---...```
`-:` .:+ssssoooo++//:.` .-/+shhhhhhhhhhhhhyyyssooo:
.--::. .+ossso+/////++/:://-` .////+shhhhhhhhhhhhhhhhhhhhhy
`-----::. `/+////+++///+++/:--:/+/- -////+shhhhhhhhhhhhhhhhhhhhhy
`------:::-` `//-.``.-/+ooosso+:-.-/oso- -////+shhhhhhhhhhhhhhhhhhhhhy
.--------:::-` :+:.` .-/osyyyyyyso++syhyo.-////+shhhhhhhhhhhhhhhhhhhhhy
`-----------:::-. +o+:-.-:/oyhhhhhhdhhhhhdddy:-////+shhhhhhhhhhhhhhhhhhhhhy
.------------::::-- `oys+/::/+shhhhhhhdddddddddy/-////+shhhhhhhhhhhhhhhhhhhhhy
.--------------:::::-` +ys+////+yhhhhhhhddddddddhy:-////+yhhhhhhhhhhhhhhhhhhhhhy
`----------------::::::-`.ss+/:::+oyhhhhhhhhhhhhhhho`-////+shhhhhhhhhhhhhhhhhhhhhy
.------------------:::::::.-so//::/+osyyyhhhhhhhhhys` -////+shhhhhhhhhhhhhhhhhhhhhy
`.-------------------::/:::::..+o+////+oosssyyyyyyys+` .////+shhhhhhhhhhhhhhhhhhhhhy
.--------------------::/:::.` -+o++++++oooosssss/. `-//+shhhhhhhhhhhhhhhhhhhhyo
.------- ``````.......--` `-/+ooooosso+/-` `./++++///:::--...``hhhhyo
`````
*
・ 。
・ ゚☆ 。
* ★ ゚・。 * 。
* ☆ 。・゚*.。
゚ *.。☆。★ ・
* ゚。·*・。 ゚*
☆゚・。°*. ゚
・ ゚*。・゚★。
・ *゚。 *
・゚*。★・
☆∴。 *
・ 。
*/
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.12;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "./mixins/shared/Constants.sol";
import "./mixins/shared/FETHNode.sol";
import "./mixins/shared/FoundationTreasuryNode.sol";
import "./mixins/shared/Gap10000.sol";
import "./mixins/shared/MarketFees.sol";
import "./mixins/shared/MarketSharedCore.sol";
import "./mixins/shared/SendValueWithFallbackWithdraw.sol";
import "./mixins/nftDropMarket/NFTDropMarketCore.sol";
import "./mixins/nftDropMarket/NFTDropMarketFixedPriceSale.sol";
error NFTDropMarket_NFT_Already_Minted();
/**
* @title A market for minting NFTs with Foundation.
*/
contract NFTDropMarket is
Initializable,
FoundationTreasuryNode,
FETHNode,
MarketSharedCore,
NFTDropMarketCore,
ReentrancyGuardUpgradeable,
SendValueWithFallbackWithdraw,
MarketFees,
Gap10000,
NFTDropMarketFixedPriceSale
{
/**
* @notice Set immutable variables for the implementation contract.
* @dev Using immutable instead of constants allows us to use different values on testnet.
* @param _treasury The Foundation Treasury contract address.
* @param _feth The FETH ERC-20 token contract address.
* @param _royaltyRegistry The Royalty Registry contract address.
*/
constructor(
address payable _treasury,
address _feth,
address _royaltyRegistry
)
FoundationTreasuryNode(_treasury)
FETHNode(_feth)
MarketFees(
_royaltyRegistry,
/*assumePrimarySale=*/
true
) // solhint-disable-next-line no-empty-blocks
{}
/**
* @notice Called once to configure the contract after the initial proxy deployment.
* @dev This farms the initialize call out to inherited contracts as needed to initialize mutable variables.
*/
function initialize() external initializer {
ReentrancyGuardUpgradeable.__ReentrancyGuard_init();
}
/**
* @inheritdoc MarketSharedCore
* @dev Returns address(0) if the NFT has already been sold, otherwise checks for a listing in this market.
*/
function _getSellerOf(address nftContract, uint256 tokenId)
internal
view
override(MarketSharedCore, NFTDropMarketFixedPriceSale)
returns (address payable seller)
{
// Check the current owner first in case it has been sold.
try IERC721(nftContract).ownerOf(tokenId) returns (address owner) {
if (owner != address(0)) {
// If sold, return address(0) since that owner cannot sell via this market.
return payable(address(0));
}
} catch // solhint-disable-next-line no-empty-blocks
{
// Fall through
}
return super._getSellerOf(nftContract, tokenId);
}
/**
* @inheritdoc MarketSharedCore
* @dev Reverts if the NFT has already been sold, otherwise checks for a listing in this market.
*/
function _getSellerOrOwnerOf(address nftContract, uint256 tokenId)
internal
view
override
returns (address payable sellerOrOwner)
{
// Check the current owner first in case it has been sold.
try IERC721(nftContract).ownerOf(tokenId) returns (address owner) {
if (owner != address(0)) {
// Once an NFT has been minted, it cannot be sold through this contract.
revert NFTDropMarket_NFT_Already_Minted();
}
} catch // solhint-disable-next-line no-empty-blocks
{
// Fall through
}
return super._getSellerOf(nftContract, tokenId);
}
}