diff --git a/src/core/token/ERC20Core.sol b/src/core/token/ERC20Core.sol index dfc232f8..bfa956d8 100644 --- a/src/core/token/ERC20Core.sol +++ b/src/core/token/ERC20Core.sol @@ -6,6 +6,8 @@ import {ModularCoreUpgradeable} from "../../ModularCoreUpgradeable.sol"; import {ERC20} from "@solady/tokens/ERC20.sol"; import {Multicallable} from "@solady/utils/Multicallable.sol"; +import {IERC20} from "../../interface/IERC20.sol"; + import {BeforeMintCallbackERC20} from "../../callback/BeforeMintCallbackERC20.sol"; import {BeforeBurnCallbackERC20} from "../../callback/BeforeBurnCallbackERC20.sol"; import {BeforeApproveCallbackERC20} from "../../callback/BeforeApproveCallbackERC20.sol"; @@ -105,6 +107,11 @@ contract ERC20Core is ERC20, ModularCoreUpgradeable, Multicallable { }); } + /// @notice Returns whether a given interface is implemented by the contract. + function supportsInterface(bytes4 interfaceID) public view override returns (bool) { + return interfaceID == type(IERC20).interfaceId || super.supportsInterface(interfaceID); + } + /*////////////////////////////////////////////////////////////// EXTERNAL FUNCTIONS //////////////////////////////////////////////////////////////*/ diff --git a/src/core/token/ERC20CoreInitializable.sol b/src/core/token/ERC20CoreInitializable.sol index 1950b72d..c386a8f7 100644 --- a/src/core/token/ERC20CoreInitializable.sol +++ b/src/core/token/ERC20CoreInitializable.sol @@ -8,6 +8,8 @@ import {ModularCoreUpgradeable} from "../../ModularCoreUpgradeable.sol"; import {ERC20} from "@solady/tokens/ERC20.sol"; import {Multicallable} from "@solady/utils/Multicallable.sol"; +import {IERC20} from "../../interface/IERC20.sol"; + import {BeforeMintCallbackERC20} from "../../callback/BeforeMintCallbackERC20.sol"; import {BeforeBurnCallbackERC20} from "../../callback/BeforeBurnCallbackERC20.sol"; import {BeforeApproveCallbackERC20} from "../../callback/BeforeApproveCallbackERC20.sol"; @@ -110,6 +112,11 @@ contract ERC20CoreInitializable is ERC20, ModularCoreUpgradeable, Multicallable, }); } + /// @notice Returns whether a given interface is implemented by the contract. + function supportsInterface(bytes4 interfaceID) public view override returns (bool) { + return interfaceID == type(IERC20).interfaceId || super.supportsInterface(interfaceID); + } + /*////////////////////////////////////////////////////////////// EXTERNAL FUNCTIONS //////////////////////////////////////////////////////////////*/ diff --git a/src/interface/IERC20.sol b/src/interface/IERC20.sol new file mode 100644 index 00000000..3f5c75bc --- /dev/null +++ b/src/interface/IERC20.sol @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.23; + +interface IERC20 { + event Transfer(address indexed from, address indexed to, uint256 value); + event Approval(address indexed owner, address indexed spender, uint256 value); + + function totalSupply() external view returns (uint256); + + function balanceOf(address account) external view returns (uint256); + + function transfer(address to, uint256 value) external returns (bool); + + function allowance(address owner, address spender) external view returns (uint256); + + function approve(address spender, uint256 value) external returns (bool); + + function transferFrom(address from, address to, uint256 value) external returns (bool); +}