-
Notifications
You must be signed in to change notification settings - Fork 508
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
[Do Not Merge] benchmark tokenerc721 alt #625
base: main
Are you sure you want to change the base?
Conversation
function initialize( | ||
address _defaultAdmin, | ||
string memory _name, | ||
string memory _symbol, |
Check notice
Code scanning / Slither
Local variable shadowing Low
- ERC721Upgradeable._symbol (state variable)
/// @dev Initializes the contract, like a constructor. | ||
function initialize( | ||
address _defaultAdmin, | ||
string memory _name, |
Check notice
Code scanning / Slither
Local variable shadowing Low
- ERC721Upgradeable._name (state variable)
- EIP712Upgradeable._name (state variable)
tokenIdToMint = nextTokenIdToMint; | ||
nextTokenIdToMint += 1; | ||
|
||
_safeMint(_to, tokenIdToMint); | ||
|
||
emit TokensMinted(_to, tokenIdToMint, ""); | ||
} | ||
|
||
/// @dev Returns the address of the signer of the mint request. | ||
function recoverAddress(MintRequest calldata _req, bytes calldata _signature) private view returns (address) { | ||
return _hashTypedDataV4(keccak256(_encodeRequest(_req))).recover(_signature); | ||
} | ||
|
||
/// @dev Resolves 'stack too deep' error in `recoverAddress`. | ||
function _encodeRequest(MintRequest calldata _req) private pure returns (bytes memory) { | ||
return abi.encode(TYPEHASH, _req.to, _req.validityStartTimestamp, _req.validityEndTimestamp, _req.uid); | ||
} | ||
|
||
/// @dev Verifies that a mint request is valid. | ||
function verifyRequest(MintRequest calldata _req, bytes calldata _signature) internal returns (address) { | ||
(bool success, address signer) = verify(_req, _signature); | ||
require(success, "invalid signature"); | ||
|
||
require( | ||
_req.validityStartTimestamp <= block.timestamp && _req.validityEndTimestamp >= block.timestamp, | ||
"request expired" | ||
); | ||
require(_req.to != address(0), "recipient undefined"); | ||
|
||
minted[_req.uid] = true; | ||
|
||
return signer; | ||
} | ||
|
||
/// ===== Low-level overrides ===== | ||
|
||
/// @dev Burns `tokenId`. See {ERC721-_burn}. | ||
function burn(uint256 tokenId) public virtual { | ||
//solhint-disable-next-line max-line-length | ||
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); | ||
_burn(tokenId); | ||
} | ||
|
||
/// @dev See {ERC721-_beforeTokenTransfer}. | ||
function _beforeTokenTransfer( | ||
address from, | ||
address to, | ||
uint256 tokenId, | ||
uint256 batchSize | ||
) internal virtual override(ERC721EnumerableUpgradeable) { | ||
super._beforeTokenTransfer(from, to, tokenId, batchSize); | ||
|
||
// if transfer is restricted on the contract, we still want to allow burning and minting | ||
if (!hasRole(TRANSFER_ROLE, address(0)) && from != address(0) && to != address(0)) { | ||
require(hasRole(TRANSFER_ROLE, from) || hasRole(TRANSFER_ROLE, to), "restricted to TRANSFER_ROLE holders"); | ||
} | ||
} | ||
|
||
/// @dev Returns whether metadata can be set in the given execution context. | ||
function _canSetMetadata() internal view virtual override returns (bool) { | ||
return hasRole(METADATA_ROLE, _msgSender()); | ||
} | ||
|
||
/// @dev Returns whether metadata can be frozen in the given execution context. | ||
function _canFreezeMetadata() internal view virtual override returns (bool) { | ||
return hasRole(METADATA_ROLE, _msgSender()); | ||
} | ||
|
||
function supportsInterface( | ||
bytes4 interfaceId | ||
) | ||
public | ||
view | ||
virtual | ||
override(AccessControlEnumerableUpgradeable, ERC721EnumerableUpgradeable, IERC165Upgradeable, IERC165) | ||
returns (bool) | ||
{ | ||
return super.supportsInterface(interfaceId) || interfaceId == type(IERC2981Upgradeable).interfaceId; | ||
} | ||
|
||
function _msgSender() | ||
internal | ||
view | ||
virtual | ||
override(ContextUpgradeable, ERC2771ContextUpgradeable, Multicall) | ||
returns (address sender) | ||
{ | ||
return ERC2771ContextUpgradeable._msgSender(); | ||
} | ||
|
||
function _msgData() | ||
internal | ||
view | ||
virtual | ||
override(ContextUpgradeable, ERC2771ContextUpgradeable) | ||
returns (bytes calldata) | ||
{ | ||
return ERC2771ContextUpgradeable._msgData(); | ||
} | ||
} |
Check warning
Code scanning / Slither
Missing inheritance Warning
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #625 +/- ##
==========================================
- Coverage 64.72% 64.58% -0.14%
==========================================
Files 216 217 +1
Lines 6702 6772 +70
==========================================
+ Hits 4338 4374 +36
- Misses 2364 2398 +34 ☔ View full report in Codecov by Sentry. |
No description provided.