-
Notifications
You must be signed in to change notification settings - Fork 513
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
OpenEditionERC721 flat platform fee #614
Conversation
f3f566b
to
ee7774b
Compare
if (getPlatformFeeType() == IPlatformFee.PlatformFeeType.Flat) { | ||
(platformFeeRecipient, platformFees) = getFlatPlatformFeeInfo(); | ||
} else { | ||
(address recipient, uint16 platformFeeBps) = getPlatformFeeInfo(); |
Check notice
Code scanning / Slither
Local variable shadowing Low
if (getPlatformFeeType() == IPlatformFee.PlatformFeeType.Flat) { | ||
(platformFeeRecipient, platformFees) = getFlatPlatformFeeInfo(); | ||
} else { | ||
(address recipient, uint16 platformFeeBps) = getPlatformFeeInfo(); |
Check notice
Code scanning / Slither
Local variable shadowing Low
- PrimarySale.recipient (state variable)
|
||
uint256 totalPrice = _quantityToClaim * _pricePerToken; | ||
uint256 platformFees; | ||
address platformFeeRecipient; |
Check notice
Code scanning / Slither
Local variable shadowing Low
|
||
/// @dev Checks whether primary sale recipient can be set in the given execution context. | ||
function _canSetPrimarySaleRecipient() internal view override returns (bool) { | ||
return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); | ||
} | ||
|
||
/// @dev Checks whether owner can be set in the given execution context. | ||
function _canSetOwner() internal view override returns (bool) { | ||
return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); | ||
} | ||
|
||
/// @dev Checks whether royalty info can be set in the given execution context. | ||
function _canSetRoyaltyInfo() internal view override returns (bool) { | ||
return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); | ||
} | ||
|
||
/// @dev Checks whether contract metadata can be set in the given execution context. | ||
function _canSetContractURI() internal view override returns (bool) { | ||
return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); | ||
} | ||
|
||
/// @dev Checks whether platform fee info can be set in the given execution context. | ||
function _canSetClaimConditions() internal view override returns (bool) { | ||
return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); | ||
} | ||
|
||
/// @dev Returns whether the shared metadata of tokens can be set in the given execution context. | ||
function _canSetSharedMetadata() internal view virtual override returns (bool) { | ||
return hasRole(minterRole, _msgSender()); | ||
} | ||
|
||
/// @dev Checks whether platform fee info can be set in the given execution context. | ||
function _canSetPlatformFeeInfo() internal view override returns (bool) { | ||
return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); | ||
} | ||
|
||
/*/////////////////////////////////////////////////////////////// | ||
Miscellaneous | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
/** | ||
* Returns the total amount of tokens minted in the contract. | ||
*/ | ||
function totalMinted() external view returns (uint256) { | ||
unchecked { | ||
return _nextTokenId() - _startTokenId(); | ||
} | ||
} | ||
|
||
/// @dev The tokenId of the next NFT that will be minted / lazy minted. | ||
function nextTokenIdToMint() external view returns (uint256) { | ||
return _nextTokenId(); | ||
} | ||
|
||
/// @dev The next token ID of the NFT that can be claimed. | ||
function nextTokenIdToClaim() external view returns (uint256) { | ||
return _nextTokenId(); | ||
} | ||
|
||
/// @dev Burns `tokenId`. See {ERC721-_burn}. | ||
function burn(uint256 tokenId) external virtual { | ||
// note: ERC721AUpgradeable's `_burn(uint256,bool)` internally checks for token approvals. | ||
_burn(tokenId, true); | ||
} | ||
|
||
/// @dev See {ERC721-_beforeTokenTransfer}. | ||
function _beforeTokenTransfers( | ||
address from, | ||
address to, | ||
uint256 startTokenId_, | ||
uint256 quantity | ||
) internal virtual override { | ||
super._beforeTokenTransfers(from, to, startTokenId_, quantity); | ||
|
||
// if transfer is restricted on the contract, we still want to allow burning and minting | ||
if (!hasRole(transferRole, address(0)) && from != address(0) && to != address(0)) { | ||
if (!hasRole(transferRole, from) && !hasRole(transferRole, to)) { | ||
revert("!T"); | ||
} | ||
} | ||
} | ||
|
||
function _dropMsgSender() internal view virtual override returns (address) { | ||
return _msgSender(); | ||
} | ||
|
||
function _msgSenderERC721A() internal view virtual override returns (address) { | ||
return _msgSender(); | ||
} | ||
|
||
function _msgSender() | ||
internal | ||
view | ||
virtual | ||
override(ERC2771ContextUpgradeable, Multicall) | ||
returns (address sender) | ||
{ | ||
return ERC2771ContextUpgradeable._msgSender(); | ||
} | ||
} |
Check warning
Code scanning / Slither
Missing inheritance Warning
|
||
/// @dev Checks whether primary sale recipient can be set in the given execution context. | ||
function _canSetPrimarySaleRecipient() internal view override returns (bool) { | ||
return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); | ||
} | ||
|
||
/// @dev Checks whether owner can be set in the given execution context. | ||
function _canSetOwner() internal view override returns (bool) { | ||
return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); | ||
} | ||
|
||
/// @dev Checks whether royalty info can be set in the given execution context. | ||
function _canSetRoyaltyInfo() internal view override returns (bool) { | ||
return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); | ||
} | ||
|
||
/// @dev Checks whether contract metadata can be set in the given execution context. | ||
function _canSetContractURI() internal view override returns (bool) { | ||
return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); | ||
} | ||
|
||
/// @dev Checks whether platform fee info can be set in the given execution context. | ||
function _canSetClaimConditions() internal view override returns (bool) { | ||
return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); | ||
} | ||
|
||
/// @dev Returns whether the shared metadata of tokens can be set in the given execution context. | ||
function _canSetSharedMetadata() internal view virtual override returns (bool) { | ||
return hasRole(minterRole, _msgSender()); | ||
} | ||
|
||
/// @dev Checks whether platform fee info can be set in the given execution context. | ||
function _canSetPlatformFeeInfo() internal view override returns (bool) { | ||
return hasRole(DEFAULT_ADMIN_ROLE, _msgSender()); | ||
} | ||
|
||
/*/////////////////////////////////////////////////////////////// | ||
Miscellaneous | ||
//////////////////////////////////////////////////////////////*/ | ||
|
||
/** | ||
* Returns the total amount of tokens minted in the contract. | ||
*/ | ||
function totalMinted() external view returns (uint256) { | ||
unchecked { | ||
return _nextTokenId() - _startTokenId(); | ||
} | ||
} | ||
|
||
/// @dev The tokenId of the next NFT that will be minted / lazy minted. | ||
function nextTokenIdToMint() external view returns (uint256) { | ||
return _nextTokenId(); | ||
} | ||
|
||
/// @dev The next token ID of the NFT that can be claimed. | ||
function nextTokenIdToClaim() external view returns (uint256) { | ||
return _nextTokenId(); | ||
} | ||
|
||
/// @dev Burns `tokenId`. See {ERC721-_burn}. | ||
function burn(uint256 tokenId) external virtual { | ||
// note: ERC721AUpgradeable's `_burn(uint256,bool)` internally checks for token approvals. | ||
_burn(tokenId, true); | ||
} | ||
|
||
/// @dev See {ERC721-_beforeTokenTransfer}. | ||
function _beforeTokenTransfers( | ||
address from, | ||
address to, | ||
uint256 startTokenId_, | ||
uint256 quantity | ||
) internal virtual override { | ||
super._beforeTokenTransfers(from, to, startTokenId_, quantity); | ||
|
||
// if transfer is restricted on the contract, we still want to allow burning and minting | ||
if (!hasRole(transferRole, address(0)) && from != address(0) && to != address(0)) { | ||
if (!hasRole(transferRole, from) && !hasRole(transferRole, to)) { | ||
revert("!T"); | ||
} | ||
} | ||
} | ||
|
||
function _dropMsgSender() internal view virtual override returns (address) { | ||
return _msgSender(); | ||
} | ||
|
||
function _msgSenderERC721A() internal view virtual override returns (address) { | ||
return _msgSender(); | ||
} | ||
|
||
function _msgSender() | ||
internal | ||
view | ||
virtual | ||
override(ERC2771ContextUpgradeable, Multicall) | ||
returns (address sender) | ||
{ | ||
return ERC2771ContextUpgradeable._msgSender(); | ||
} | ||
} |
Check warning
Code scanning / Slither
Missing inheritance Warning
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #614 +/- ##
==========================================
+ Coverage 64.26% 64.55% +0.29%
==========================================
Files 215 216 +1
Lines 6640 6701 +61
==========================================
+ Hits 4267 4326 +59
- Misses 2373 2375 +2 ☔ View full report in Codecov by Sentry. |
No description provided.