Skip to content
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

Merged
merged 3 commits into from
Jan 26, 2024

Conversation

kumaryash90
Copy link
Member

No description provided.

@kumaryash90 kumaryash90 force-pushed the yash/openedition-flatplatformfee branch from f3f566b to ee7774b Compare January 25, 2024 20:39
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


uint256 totalPrice = _quantityToClaim * _pricePerToken;
uint256 platformFees;
address platformFeeRecipient;

Check notice

Code scanning / Slither

Local variable shadowing Low

Comment on lines +39 to +290

/// @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

Comment on lines +39 to +290

/// @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

Copy link

codecov bot commented Jan 26, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (da53846) 64.26% compared to head (e4ab1eb) 64.55%.

Files Patch % Lines
...rebuilts/open-edition/OpenEditionERC721FlatFee.sol 96.72% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@kumaryash90 kumaryash90 merged commit effd208 into main Jan 26, 2024
9 checks passed
@kumaryash90 kumaryash90 deleted the yash/openedition-flatplatformfee branch January 26, 2024 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant