Skip to content

Commit e35793d

Browse files
authored
[Certora Audit] G-06. ExtensibleFallbackHandler._supportsInterface(): save gas via short-circuit evaluation (safe-global#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`.
1 parent 0e061e2 commit e35793d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

contracts/handler/ExtensibleFallbackHandler.sol

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ contract ExtensibleFallbackHandler is FallbackHandler, SignatureVerifierMuxer, T
1818
*/
1919
function _supportsInterface(bytes4 interfaceId) internal pure override returns (bool) {
2020
return
21+
interfaceId == type(ERC721TokenReceiver).interfaceId ||
22+
interfaceId == type(ERC1155TokenReceiver).interfaceId ||
2123
interfaceId == type(ERC1271).interfaceId ||
2224
interfaceId == type(ISignatureVerifierMuxer).interfaceId ||
2325
interfaceId == type(ERC165Handler).interfaceId ||
24-
interfaceId == type(IFallbackHandler).interfaceId ||
25-
interfaceId == type(ERC721TokenReceiver).interfaceId ||
26-
interfaceId == type(ERC1155TokenReceiver).interfaceId;
26+
interfaceId == type(IFallbackHandler).interfaceId;
2727
}
2828
}

0 commit comments

Comments
 (0)