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

Sherlock-31 Final: EIP 4494 compliance #907

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/base/PermitERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ interface IPermit {
/*** External Functions ***/
/**************************/

function DOMAIN_SEPARATOR() external view returns (bytes32);

/**
* @notice Allows to retrieve current nonce for token.
* @param tokenId token id
* @return current token nonce
*/
function nonces(uint256 tokenId) external view returns (uint256);

/**
* @notice `EIP-4494` permit to approve by way of owner signature.
*/
Expand Down Expand Up @@ -156,6 +165,19 @@ abstract contract PermitERC721 is ERC721, IPermit {
_approve(spender_, tokenId_);
}

/**
* @notice Query if a contract implements an interface.
* @param interfaceId The interface identifier.
* @return `true` if the contract implements `interfaceId` and `interfaceId` is not 0xffffffff, `false` otherwise
*/
function supportsInterface(
bytes4 interfaceId
) public view virtual override returns (bool) {
return
interfaceId == type(IPermit).interfaceId || // 0x5604e225
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can just use the constant bytes4 in the equality check and have the derivation in the comment to save gas.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is less likely to be called from a contract in a transaction, I'm happy with it as-is for readability tradeoff.

super.supportsInterface(interfaceId);
}

/**************************/
/*** Internal Functions ***/
/**************************/
Expand Down