-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove duplicate code to make contract fit #145
Changes from all commits
ce66a42
6b9ac3d
943cd74
d8f6939
bbe8f11
21c7bbe
4e6a9aa
9ae43f0
55403c9
49f3adf
a19b9a7
54d322f
b811ac7
8e6b82c
79555ea
f796d1e
1ea8b27
77ab5c3
a907094
16f9300
573cb33
b3e725d
51aef58
606197d
80446d8
1d916cb
6f14c57
c21c8a3
aff942d
8b9f79b
f3a9c01
630c4c3
517fea9
115fc54
c8876f3
821491e
8d85761
bdf9a7f
a879d55
56bbac5
3221408
8a69a89
d8a66df
24030ec
48197ec
f5b995e
c7cd561
7107a68
7644578
ab68524
ec70925
c009127
cffe9e3
f638164
01e284a
99c5bea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,11 @@ | |
}, | ||
"dependencies": { | ||
"@dotenv/cli": "^2.2.2", | ||
<<<<<<< HEAD | ||
"@zoralabs/protocol-rewards": "^1.0.1", | ||
======= | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. broken rebase |
||
"@zoralabs/protocol-rewards": "^1.0.2", | ||
>>>>>>> origin/main | ||
"ds-test": "https://github.com/dapphub/ds-test#cd98eff28324bfac652e63a239a60632a761790b", | ||
"forge-std": "https://github.com/foundry-rs/forge-std#cd7d533f9a0ee0ec02ad81e0a8f262bc4203c653" | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,7 +94,7 @@ contract ERC721Drop is | |
uint8 constant SUPPLY_ROYALTY_FOR_EVERY_MINT = 1; | ||
|
||
// /// @notice Empty string for blank comments | ||
// string constant EMPTY_STRING = ""; | ||
string constant EMPTY_STRING = ""; | ||
|
||
/// @notice Only allow for users with admin access | ||
modifier onlyAdmin() { | ||
|
@@ -452,7 +452,7 @@ contract ERC721Drop is | |
onlyPublicSaleActive | ||
returns (uint256) | ||
{ | ||
return _handlePurchase(msg.sender, quantity, ""); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we remove this _handlePurchase function? |
||
return _handleMintWithRewards(msg.sender, quantity, "", address(0)); | ||
} | ||
|
||
/// @notice Purchase a quantity of tokens with a comment | ||
|
@@ -466,7 +466,7 @@ contract ERC721Drop is | |
onlyPublicSaleActive | ||
returns (uint256) | ||
{ | ||
return _handlePurchase(msg.sender, quantity, comment); | ||
return _handleMintWithRewards(msg.sender, quantity, comment, address(0)); | ||
} | ||
|
||
/// @notice Purchase a quantity of tokens to a specified recipient, with an optional comment | ||
|
@@ -481,7 +481,7 @@ contract ERC721Drop is | |
onlyPublicSaleActive | ||
returns (uint256) | ||
{ | ||
return _handlePurchase(recipient, quantity, comment); | ||
return _handleMintWithRewards(recipient, quantity, comment, address(0)); | ||
} | ||
|
||
/// @notice Mint a quantity of tokens with a comment that will pay out rewards | ||
|
@@ -528,9 +528,8 @@ contract ERC721Drop is | |
_requireLegacyFee(msg.value, salePrice, quantity); | ||
|
||
_mintNFTs(recipient, quantity); | ||
uint256 firstMintedTokenId = _lastMintedTokenId() - quantity; | ||
|
||
_payoutZoraFee(quantity); | ||
uint256 firstMintedTokenId = _lastMintedTokenId() - quantity; | ||
|
||
_emitSaleEvents(_msgSender(), recipient, quantity, salePrice, firstMintedTokenId, comment); | ||
|
||
|
@@ -630,7 +629,7 @@ contract ERC721Drop is | |
onlyPresaleActive | ||
returns (uint256) | ||
{ | ||
return _handlePurchasePresale(quantity, maxQuantity, pricePerToken, merkleProof, ""); | ||
return _handlePurchasePresaleWithRewards(quantity, maxQuantity, pricePerToken, merkleProof, "", address(0)); | ||
} | ||
|
||
/// @notice Merkle-tree based presale purchase function with a comment | ||
|
@@ -652,15 +651,40 @@ contract ERC721Drop is | |
onlyPresaleActive | ||
returns (uint256) | ||
{ | ||
return _handlePurchasePresale(quantity, maxQuantity, pricePerToken, merkleProof, comment); | ||
return _handlePurchasePresaleWithRewards(quantity, maxQuantity, pricePerToken, merkleProof, comment, address(0)); | ||
} | ||
|
||
function _handlePurchasePresale( | ||
/// @notice Merkle-tree based presale purchase function with a comment and protocol rewards | ||
/// @param quantity quantity to purchase | ||
/// @param maxQuantity max quantity that can be purchased via merkle proof # | ||
/// @param pricePerToken price that each token is purchased at | ||
/// @param merkleProof proof for presale mint | ||
/// @param comment comment to include in the IERC721Drop.Sale event | ||
/// @param mintReferral The facilitator of the mint | ||
function purchasePresaleWithRewards( | ||
uint256 quantity, | ||
uint256 maxQuantity, | ||
uint256 pricePerToken, | ||
bytes32[] calldata merkleProof, | ||
string memory comment | ||
string calldata comment, | ||
address mintReferral | ||
) | ||
external | ||
payable | ||
nonReentrant | ||
onlyPresaleActive | ||
returns (uint256) | ||
{ | ||
return _handlePurchasePresaleWithRewards(quantity, maxQuantity, pricePerToken, merkleProof, comment, mintReferral); | ||
} | ||
|
||
function _handlePurchasePresaleWithRewards( | ||
uint256 quantity, | ||
uint256 maxQuantity, | ||
uint256 pricePerToken, | ||
bytes32[] calldata merkleProof, | ||
string memory comment, | ||
address mintReferral | ||
) internal returns (uint256) { | ||
_mintSupplyRoyalty(quantity); | ||
_requireCanMintQuantity(quantity); | ||
|
@@ -669,15 +693,15 @@ contract ERC721Drop is | |
|
||
_requireMerkleApproval(msgSender, maxQuantity, pricePerToken, merkleProof); | ||
|
||
_requireLegacyFee(msg.value, pricePerToken, quantity); | ||
|
||
_requireCanPurchasePresale(msgSender, quantity, maxQuantity); | ||
|
||
_handleRewards(msg.value, quantity, pricePerToken, config.fundsRecipient, mintReferral, createReferral); | ||
|
||
_mintNFTs(msgSender, quantity); | ||
uint256 firstMintedTokenId = _lastMintedTokenId() - quantity; | ||
|
||
_payoutZoraFee(quantity); | ||
uint256 firstMintedTokenId = _lastMintedTokenId() - quantity; | ||
|
||
|
||
emit IERC721Drop.Sale({ | ||
to: msgSender, | ||
quantity: quantity, | ||
|
@@ -732,21 +756,29 @@ contract ERC721Drop is | |
_mintSupplyRoyalty(quantity); | ||
_requireCanMintQuantity(quantity); | ||
|
||
address msgSender = _msgSender(); | ||
|
||
_requireMerkleApproval(msgSender, maxQuantity, pricePerToken, merkleProof); | ||
|
||
_requireCanPurchasePresale(msgSender, quantity, maxQuantity); | ||
|
||
_handleRewards(msg.value, quantity, pricePerToken, config.fundsRecipient != address(0) ? config.fundsRecipient : address(this), createReferral, mintReferral); | ||
|
||
_mintNFTs(msgSender, quantity); | ||
|
||
uint256 firstMintedTokenId = _lastMintedTokenId() - quantity; | ||
|
||
_emitSaleEvents(msgSender, msgSender, quantity, pricePerToken, firstMintedTokenId, comment); | ||
|
||
return firstMintedTokenId; | ||
<<<<<<< HEAD | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. broken rebase :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was trying to get this diff better, didn't work, ignore for now |
||
/// @notice Hook to filter operators (no-op if no filters are registered) | ||
/// @dev Part of ERC721A token hooks | ||
/// @param from Transfer from user | ||
function _beforeTokenTransfers( | ||
address from, | ||
address, | ||
uint256, | ||
uint256 | ||
) internal virtual override { | ||
if ( | ||
from != address(0) && // skip on mints | ||
from != msg.sender // skip on transfers from sender | ||
) { | ||
if ( | ||
!operatorFilterRegistry.isOperatorAllowed( | ||
address(this), | ||
msg.sender | ||
) | ||
) { | ||
revert OperatorNotAllowed(msg.sender); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -1272,6 +1304,8 @@ contract ERC721Drop is | |
} | ||
} | ||
|
||
<<<<<<< HEAD | ||
======= | ||
function _payoutZoraFee(uint256 quantity) internal { | ||
// Transfer ZORA fee to recipient | ||
(, uint256 zoraFee) = zoraFeeForAmount(quantity); | ||
|
@@ -1287,6 +1321,7 @@ contract ERC721Drop is | |
} | ||
} | ||
|
||
>>>>>>> origin/main | ||
function _requireCanMintQuantity(uint256 quantity) internal view { | ||
if (quantity + _totalMinted() > config.editionSize) { | ||
revert Mint_SoldOut(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice