Skip to content

Commit

Permalink
fix(protocol): fix LibAddress.supportsInterface to handle undecodeabl…
Browse files Browse the repository at this point in the history
…e return data (#18286)
  • Loading branch information
dantaik authored Oct 24, 2024
1 parent 5c371a1 commit 299b4c9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/protocol/contracts/shared/common/LibAddress.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "@openzeppelin/contracts/interfaces/IERC1271.sol";

/// @title LibAddress
/// @dev Provides utilities for address-related operations.
Expand Down Expand Up @@ -74,10 +72,10 @@ library LibAddress {
view
returns (bool result_)
{
if (!Address.isContract(_addr)) return false;

try IERC165(_addr).supportsInterface(_interfaceId) returns (bool _result) {
result_ = _result;
} catch { }
(bool success, bytes memory data) =
_addr.staticcall(abi.encodeCall(IERC165.supportsInterface, (_interfaceId)));
if (success && data.length == 32) {
result_ = abi.decode(data, (bool));
}
}
}

0 comments on commit 299b4c9

Please sign in to comment.