Skip to content

Commit

Permalink
[Certora Audit] G-06. `ExtensibleFallbackHandler._supportsInterface()…
Browse files Browse the repository at this point in the history
…`: save gas via short-circuit evaluation (#893)

This pull request includes a change to the `ExtensibleFallbackHandler`
contract in the `contracts/handler/ExtensibleFallbackHandler.sol` file.
The change modifies the `_supportsInterface` function to reorder the
interface checks for `ERC721TokenReceiver`, `ERC1155TokenReceiver`, and
`IFallbackHandler`. This helps in taking advantage of the short-circuit
evaluation.

Changes to interface support order:

*
[`contracts/handler/ExtensibleFallbackHandler.sol`](diffhunk://#diff-aa345618c4d3f173b09e211d0bd0eec0747177aab345bf8b9f5bbc874a765fe3R21-R26):
Reordered the interface checks in the `_supportsInterface` function to
place `ERC721TokenReceiver` and `ERC1155TokenReceiver` before
`IFallbackHandler`.
  • Loading branch information
remedcu authored Jan 9, 2025
1 parent 0e061e2 commit e35793d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions contracts/handler/ExtensibleFallbackHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ contract ExtensibleFallbackHandler is FallbackHandler, SignatureVerifierMuxer, T
*/
function _supportsInterface(bytes4 interfaceId) internal pure override returns (bool) {
return
interfaceId == type(ERC721TokenReceiver).interfaceId ||
interfaceId == type(ERC1155TokenReceiver).interfaceId ||
interfaceId == type(ERC1271).interfaceId ||
interfaceId == type(ISignatureVerifierMuxer).interfaceId ||
interfaceId == type(ERC165Handler).interfaceId ||
interfaceId == type(IFallbackHandler).interfaceId ||
interfaceId == type(ERC721TokenReceiver).interfaceId ||
interfaceId == type(ERC1155TokenReceiver).interfaceId;
interfaceId == type(IFallbackHandler).interfaceId;
}
}

0 comments on commit e35793d

Please sign in to comment.