Skip to content

Commit a65f0d2

Browse files
authored
[L-4] Wrong function selector returned for the transfer validation function (#150)
* [L-4] Wrong function selector returned for the transfer validation function * [Q-3] Move interface identifier for ERC165 to Core * [Q-5] Royalty modules should inherit ICreatorToken interface * [Q-6] Nitpicks
1 parent 7f81f04 commit a65f0d2

File tree

10 files changed

+25
-26
lines changed

10 files changed

+25
-26
lines changed

src/Core.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ abstract contract Core is ICore, OwnableRoles, ReentrancyGuard {
150150
if (interfaceId == 0xffffffff) {
151151
return false;
152152
}
153+
if (interfaceId == 0x01ffc9a7) {
154+
// ERC165 Interface ID for ERC165
155+
return true;
156+
}
153157
if (supportedInterfaceRefCounter[interfaceId] > 0) {
154158
return true;
155159
}

src/core/token/ERC1155Core.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ contract ERC1155Core is ERC1155, Core, Multicallable {
109109
* @param interfaceId The interface ID of the interface to check for
110110
*/
111111
function supportsInterface(bytes4 interfaceId) public view override(ERC1155, Core) returns (bool) {
112-
return interfaceId == 0x01ffc9a7 // ERC165 Interface ID for ERC165
113-
|| interfaceId == 0xd9b67a26 // ERC165 Interface ID for ERC1155
112+
return interfaceId == 0xd9b67a26 // ERC165 Interface ID for ERC1155
114113
|| interfaceId == 0x0e89341c // ERC165 Interface ID for ERC1155MetadataURI
115114
|| interfaceId == 0xe8a3d485 // ERC-7572
116115
|| interfaceId == 0x7f5828d0 // ERC-173

src/core/token/ERC1155CoreInitializable.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ contract ERC1155CoreInitializable is ERC1155, Core, Multicallable, Initializable
114114
* @param interfaceId The interface ID of the interface to check for
115115
*/
116116
function supportsInterface(bytes4 interfaceId) public view override(ERC1155, Core) returns (bool) {
117-
return interfaceId == 0x01ffc9a7 // ERC165 Interface ID for ERC165
118-
|| interfaceId == 0xd9b67a26 // ERC165 Interface ID for ERC1155
117+
return interfaceId == 0xd9b67a26 // ERC165 Interface ID for ERC1155
119118
|| interfaceId == 0x0e89341c // ERC165 Interface ID for ERC1155MetadataURI
120119
|| interfaceId == 0xe8a3d485 // ERC-7572
121120
|| interfaceId == 0x7f5828d0 // ERC-173

src/core/token/ERC20Core.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {Core} from "../../Core.sol";
55

66
import {ERC20} from "@solady/tokens/ERC20.sol";
77
import {Multicallable} from "@solady/utils/Multicallable.sol";
8-
import {ReentrancyGuard} from "@solady/utils/ReentrancyGuard.sol";
98

109
import {IERC20} from "../../interface/IERC20.sol";
1110

@@ -111,8 +110,7 @@ contract ERC20Core is ERC20, Multicallable, Core {
111110

112111
/// @notice Returns whether a given interface is implemented by the contract.
113112
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
114-
return interfaceId == 0x01ffc9a7 // ERC165 Interface ID for ERC165
115-
|| interfaceId == 0xe8a3d485 // ERC-7572
113+
return interfaceId == 0xe8a3d485 // ERC-7572
116114
|| interfaceId == 0x7f5828d0 // ERC-173
117115
|| interfaceId == type(IERC20).interfaceId || _supportsInterfaceViaModules(interfaceId);
118116
}

src/core/token/ERC20CoreInitializable.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ contract ERC20CoreInitializable is ERC20, Core, Multicallable, Initializable {
116116

117117
/// @notice Returns whether a given interface is implemented by the contract.
118118
function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
119-
return interfaceId == 0x01ffc9a7 // ERC165 Interface ID for ERC165
120-
|| interfaceId == 0xe8a3d485 // ERC-7572
119+
return interfaceId == 0xe8a3d485 // ERC-7572
121120
|| interfaceId == 0x7f5828d0 // ERC-173
122121
|| interfaceId == type(IERC20).interfaceId || _supportsInterfaceViaModules(interfaceId);
123122
}

src/core/token/ERC721Core.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ contract ERC721Core is ERC721AQueryable, Core, Multicallable {
9090
* @param interfaceId The interface ID of the interface to check for
9191
*/
9292
function supportsInterface(bytes4 interfaceId) public view override(ERC721A, IERC721A, Core) returns (bool) {
93-
return interfaceId == 0x01ffc9a7 // ERC165 Interface ID for ERC165
94-
|| interfaceId == 0x80ac58cd // ERC165 Interface ID for ERC721
93+
return interfaceId == 0x80ac58cd // ERC165 Interface ID for ERC721
9594
|| interfaceId == 0x5b5e139f // ERC165 Interface ID for ERC721Metadata
9695
|| interfaceId == 0xe8a3d485 // ERC-7572
9796
|| interfaceId == 0x7f5828d0 // ERC-173

src/core/token/ERC721CoreInitializable.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ contract ERC721CoreInitializable is ERC721AQueryableUpgradeable, Core, Multicall
110110
override(ERC721AUpgradeable, IERC721AUpgradeable, Core)
111111
returns (bool)
112112
{
113-
return interfaceId == 0x01ffc9a7 // ERC165 Interface ID for ERC165
114-
|| interfaceId == 0x80ac58cd // ERC165 Interface ID for ERC721
113+
return interfaceId == 0x80ac58cd // ERC165 Interface ID for ERC721
115114
|| interfaceId == 0x5b5e139f // ERC165 Interface ID for ERC721Metadata
116115
|| interfaceId == 0xe8a3d485 // ERC-7572
117116
|| interfaceId == 0x7f5828d0 // ERC-173

src/module/token/royalty/RoyaltyERC1155.sol

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ contract RoyaltyERC1155 is
4444
Module,
4545
IInstallationCallback,
4646
BeforeTransferCallbackERC1155,
47-
BeforeBatchTransferCallbackERC1155
47+
BeforeBatchTransferCallbackERC1155,
48+
ICreatorToken
4849
{
4950

5051
/*//////////////////////////////////////////////////////////////
@@ -71,9 +72,6 @@ contract RoyaltyERC1155 is
7172
/// @notice Emitted when the royalty info for a specific NFT is updated.
7273
event TokenRoyaltyUpdated(uint256 indexed tokenId, address indexed recipient, uint16 bps);
7374

74-
/// @notice Emitted when the transfer validator is updated.
75-
event TransferValidatorUpdated(address oldValidator, address newValidator);
76-
7775
/*//////////////////////////////////////////////////////////////
7876
ERRORS
7977
//////////////////////////////////////////////////////////////*/
@@ -118,6 +116,11 @@ contract RoyaltyERC1155 is
118116
config.supportedInterfaces = new bytes4[](1);
119117
config.supportedInterfaces[0] = 0x2a55205a; // IERC2981.
120118

119+
config.supportedInterfaces = new bytes4[](3);
120+
config.supportedInterfaces[0] = 0x2a55205a; // IERC2981.
121+
config.supportedInterfaces[1] = 0xad0d7f6c; // ICreatorToken
122+
config.supportedInterfaces[2] = 0xa07d229a; // ICreatorTokenLegacy
123+
121124
config.registerInstallationCallback = true;
122125
}
123126

@@ -234,7 +237,7 @@ contract RoyaltyERC1155 is
234237

235238
/// @notice Returns the transfer validator contract address for this token contract.
236239
function getTransferValidator() public view returns (address validator) {
237-
return _royaltyStorage().transferValidator;
240+
validator = _royaltyStorage().transferValidator;
238241
}
239242

240243
/**

src/module/token/royalty/RoyaltyERC721.sol

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ library RoyaltyStorage {
3939

4040
}
4141

42-
contract RoyaltyERC721 is Module, IInstallationCallback, BeforeTransferCallbackERC721 {
42+
contract RoyaltyERC721 is Module, IInstallationCallback, BeforeTransferCallbackERC721, ICreatorToken {
4343

4444
/*//////////////////////////////////////////////////////////////
4545
STRUCTS
@@ -65,9 +65,6 @@ contract RoyaltyERC721 is Module, IInstallationCallback, BeforeTransferCallbackE
6565
/// @notice Emitted when the royalty info for a specific NFT is updated.
6666
event TokenRoyaltyUpdated(uint256 indexed tokenId, address indexed recipient, uint16 bps);
6767

68-
/// @notice Emitted when the transfer validator is updated.
69-
event TransferValidatorUpdated(address oldValidator, address newValidator);
70-
7168
/*//////////////////////////////////////////////////////////////
7269
ERRORS
7370
//////////////////////////////////////////////////////////////*/
@@ -108,8 +105,10 @@ contract RoyaltyERC721 is Module, IInstallationCallback, BeforeTransferCallbackE
108105
config.requiredInterfaces = new bytes4[](1);
109106
config.requiredInterfaces[0] = 0x80ac58cd; // ERC721.
110107

111-
config.supportedInterfaces = new bytes4[](1);
108+
config.supportedInterfaces = new bytes4[](3);
112109
config.supportedInterfaces[0] = 0x2a55205a; // IERC2981.
110+
config.supportedInterfaces[1] = 0xad0d7f6c; // ICreatorToken
111+
config.supportedInterfaces[2] = 0xa07d229a; // ICreatorTokenLegacy
113112

114113
config.registerInstallationCallback = true;
115114
}
@@ -212,7 +211,7 @@ contract RoyaltyERC721 is Module, IInstallationCallback, BeforeTransferCallbackE
212211

213212
/// @notice Returns the transfer validator contract address for this token contract.
214213
function getTransferValidator() public view returns (address validator) {
215-
return _royaltyStorage().transferValidator;
214+
validator = _royaltyStorage().transferValidator;
216215
}
217216

218217
/**

src/module/token/transferable/CreatorTokenERC20.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ contract CreatorTokenERC20 is Module, BeforeTransferCallbackERC20, ICreatorToken
8383

8484
/// @notice Returns the transfer validator contract address for this token contract.
8585
function getTransferValidator() public view returns (address validator) {
86-
return _creatorTokenStorage().transferValidator;
86+
validator = _creatorTokenStorage().transferValidator;
8787
}
8888

8989
/**
9090
* @notice Returns the function selector for the transfer validator's validation function to be called
9191
* @notice for transaction simulation.
9292
*/
9393
function getTransferValidationFunction() external pure returns (bytes4 functionSignature, bool isViewFunction) {
94-
functionSignature = bytes4(keccak256("validateTransfer(address,address,address,uint256, uint256)"));
94+
functionSignature = bytes4(keccak256("validateTransfer(address,address,address,uint256,uint256)"));
9595
isViewFunction = true;
9696
}
9797

0 commit comments

Comments
 (0)