You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description: PermitERC721 makes use of chainid inline assembly to get the current chain id used in DOMAIN_SEPARATOR.
Recommendation:
Consider removing inline assembly chainid and the function _chainId in favour of passing directly the pre-defined global variable block.chainid, introduced in solidity version 0.8.0, that retrieves the current chain id from the block header of the current block.
The recommendation takes into account gas optimization, readability and complexity reduction benefits as well as maintainability.
diff --git a/src/base/PermitERC721.sol b/src/base/PermitERC721.sol
index a92acaf..0fcfc65 100644
--- a/src/base/PermitERC721.sol+++ b/src/base/PermitERC721.sol@@ -59,7 +59,7 @@ abstract contract PermitERC721 is ERC721, IPermit {
0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f,
_nameHash,
_versionHash,
- _chainId(),+ block.chainid,
address(this)
)
);
@@ -112,14 +112,4 @@ abstract contract PermitERC721 is ERC721, IPermit {
_approve(spender_, tokenId_);
}
- /**- * @dev Gets the current chain id- * @return chainId_ The current chain id- */- function _chainId() internal view returns (uint256 chainId_) {- assembly {- chainId_ := chainid()- }- }-
}
Tests PASS (removing _chainId function and passing block.chainid to DOMAIN_SEPARATOR)
Context: PermitERC721.sol#L119-L122
Description:
PermitERC721
makes use ofchainid
inline assembly to get the current chain id used inDOMAIN_SEPARATOR
.Recommendation:
Consider removing inline assembly
chainid
and the function_chainId
in favour of passing directly the pre-defined global variableblock.chainid
, introduced in solidity version0.8.0
, that retrieves the current chain id from the block header of the current block.The recommendation takes into account gas optimization, readability and complexity reduction benefits as well as maintainability.
_chainId
function and passingblock.chainid
toDOMAIN_SEPARATOR
)Ajna:
Prototech:
The text was updated successfully, but these errors were encountered: