From 05ce0c45a705a326b013d6e4ec2dfcaff00b0697 Mon Sep 17 00:00:00 2001 From: Aleksandar Marinkovic Date: Tue, 19 Mar 2024 16:09:41 +0100 Subject: [PATCH] feat: add ERC-1271 interface to the package --- package.json | 3 ++- src/init/InitDiamond.sol | 4 ++-- src/interfaces/IERC1271.sol | 17 +++++++++++++++++ src/interfaces/IERC165.sol | 12 ------------ src/interfaces/IERC173.sol | 18 ------------------ 5 files changed, 21 insertions(+), 33 deletions(-) create mode 100644 src/interfaces/IERC1271.sol delete mode 100644 src/interfaces/IERC165.sol delete mode 100644 src/interfaces/IERC173.sol diff --git a/package.json b/package.json index 6f01065b..28ec8e6b 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "src/generated/abi.json", "src/generated/naymsDiamond.json", "forge-artifacts/LibConstants.sol/LibConstants.json", - "forge-artifacts/IERC20.sol/IERC20.json" + "forge-artifacts/IERC20.sol/IERC20.json", + "forge-artifacts/IERC1271.sol/IERC1271.json" ], "scripts": { "prettier": "yarn prettier:test && yarn prettier:src && yarn prettier:script", diff --git a/src/init/InitDiamond.sol b/src/init/InitDiamond.sol index 6fbb9b7f..f5c3f0fb 100644 --- a/src/init/InitDiamond.sol +++ b/src/init/InitDiamond.sol @@ -11,8 +11,8 @@ import { LibAdmin } from "../libs/LibAdmin.sol"; import { LibACL } from "../libs/LibACL.sol"; import { LibInitDiamond } from "../libs/LibInitDiamond.sol"; import { LibEIP712 } from "../libs/LibEIP712.sol"; -import { IERC165 } from "../interfaces/IERC165.sol"; -import { IERC173 } from "../interfaces/IERC173.sol"; +import { IERC165 } from "lib/diamond-2-hardhat/contracts/interfaces/IERC165.sol"; +import { IERC173 } from "lib/diamond-2-hardhat/contracts/interfaces/IERC173.sol"; import { IERC20 } from "../interfaces/IERC20.sol"; import { FeeSchedule } from "../shared/FreeStructs.sol"; diff --git a/src/interfaces/IERC1271.sol b/src/interfaces/IERC1271.sol new file mode 100644 index 00000000..a56057ba --- /dev/null +++ b/src/interfaces/IERC1271.sol @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: MIT +// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1271.sol) + +pragma solidity ^0.8.20; + +/** + * @dev Interface of the ERC1271 standard signature validation method for + * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271]. + */ +interface IERC1271 { + /** + * @dev Should return whether the signature provided is valid for the provided data + * @param hash Hash of the data to be signed + * @param signature Signature byte array associated with _data + */ + function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); +} diff --git a/src/interfaces/IERC165.sol b/src/interfaces/IERC165.sol deleted file mode 100644 index d1d345e1..00000000 --- a/src/interfaces/IERC165.sol +++ /dev/null @@ -1,12 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.20; - -interface IERC165 { - /// @notice Query if a contract implements an interface - /// @param interfaceId The interface identifier, as specified in ERC-165 - /// @dev Interface identification is specified in ERC-165. This function - /// uses less than 30,000 gas. - /// @return `true` if the contract implements `interfaceID` and - /// `interfaceID` is not 0xffffffff, `false` otherwise - function supportsInterface(bytes4 interfaceId) external view returns (bool); -} diff --git a/src/interfaces/IERC173.sol b/src/interfaces/IERC173.sol deleted file mode 100644 index 4f62a7bb..00000000 --- a/src/interfaces/IERC173.sol +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.20; - -/// @title ERC-173 Contract Ownership Standard -/// Note: the ERC-165 identifier for this interface is 0x7f5828d0 is ERC165 -interface IERC173 { - /// @dev This emits when ownership of a contract changes. - event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); - - /// @notice Get the address of the owner - /// @return owner_ The address of the owner. - function owner() external view returns (address owner_); - - /// @notice Set the address of the new owner of the contract - /// @dev Set _newOwner to address(0) to renounce any ownership. - /// @param _newOwner The address of the new owner of the contract - function transferOwnership(address _newOwner) external; -}