contracts-bedock: remove redundant ierc165 check #5541
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Building on top of #5521
The
supportsInterface
function in theOptimismMintableERC721
contract includes redundant codes withtype(IERC165).interfaceId
.OptimismMintableERC721.sol#L134-L146
bytes4 iface1 = type(IERC165).interfaceId;
and_interfaceId == iface1
are unnecessary. It's becauseOptimismMintableERC721
inheritsERC165
andsuper.supportsInterface(_interfaceId);
is being used.OpenZeppelin ERC721Enumerable.sol#L30-L32
OpenZeppelin ERC721.sol#L52-L57
OpenZeppelin ERC165.sol#L26-L28
Therefore, the unnecessary codes can be safely removed without affecting the functionality of the contract.
NOTE: this change costs
0.3%
more gas fortest_finalizeBridgeERC721_alreadyExists_reverts
(29128
->29218
)0.04%
more gas fortest_finalizeBridgeERC721_succeeds
(168970
->169045
)0.63%
less gas fortest_createOptimismMintableERC721_succeeds
(2336687
->2321842
)If this redundant
type(IERC165).interfaceId
check is intended,adding comment would be helpful for developers as the code can be more straightforward with comment.
Tests
This PR includes
supportsInterface
test for the following interfaces:IOptimismMintableERC721
IERC721Enumerable
IERC721
IERC165