Skip to content

Commit

Permalink
G-03. ERC165Handler.setSupportedInterface(): Logic and storage access…
Browse files Browse the repository at this point in the history
… optimization
  • Loading branch information
remedcu committed Jan 9, 2025
1 parent 77bab0d commit 749601b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions contracts/handler/extensible/ERC165Handler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ abstract contract ERC165Handler is ExtensibleBase, IERC165Handler {
ISafe safe = ISafe(payable(_manager()));
// invalid interface id per ERC165 spec
require(interfaceId != 0xffffffff, "invalid interface id");
bool current = safeInterfaces[safe][interfaceId];
if (supported && !current) {
safeInterfaces[safe][interfaceId] = true;
emit AddedInterface(safe, interfaceId);
} else if (!supported && current) {
delete safeInterfaces[safe][interfaceId];
emit RemovedInterface(safe, interfaceId);
mapping(bytes4 => bool) storage safeInterface = safeInterfaces[safe];
bool current = safeInterface[interfaceId];
if (supported != current) {
safeInterface[interfaceId] = supported;
if (supported) {
emit AddedInterface(safe, interfaceId);
} else {
emit RemovedInterface(safe, interfaceId);
}
}
}

Expand Down

0 comments on commit 749601b

Please sign in to comment.