Skip to content

Commit

Permalink
add ICreatorToken
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanio committed Apr 1, 2024
1 parent d1e305c commit 21c2874
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src-upgradeable/src/ERC721ContractMetadataUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ import {
ERC721TransferValidatorUpgradeable
} from "./lib/ERC721TransferValidatorUpgradeable.sol";

import { ERC721AUpgradeable } from "../lib/ERC721A-Upgradeable/contracts/ERC721AUpgradeable.sol";
import { ICreatorToken } from "./interfaces/ICreatorToken.sol";

import { ITransferValidator } from "./interfaces/ITransferValidator.sol";

import {
ERC721AUpgradeable
} from "../lib/ERC721A-Upgradeable/contracts/ERC721AUpgradeable.sol";

import {
TwoStepOwnableUpgradeable
Expand Down Expand Up @@ -332,6 +338,7 @@ contract ERC721ContractMetadataUpgradeable is
{
return
interfaceId == type(IERC2981Upgradeable).interfaceId ||
interfaceId == type(ICreatorToken).interfaceId ||
interfaceId == 0x49064906 || // ERC-4906
super.supportsInterface(interfaceId);
}
Expand Down
10 changes: 10 additions & 0 deletions src-upgradeable/src/interfaces/ICreatorToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

interface ICreatorToken {
event TransferValidatorUpdated(address oldValidator, address newValidator);

function getTransferValidator() external view returns (address validator);

function setTransferValidator(address validator) external;
}
3 changes: 3 additions & 0 deletions src/ERC721ContractMetadata.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { ERC721AConduitPreapproved } from "./lib/ERC721AConduitPreapproved.sol";

import { ERC721TransferValidator } from "./lib/ERC721TransferValidator.sol";

import { ICreatorToken } from "./interfaces/ICreatorToken.sol";

import { ITransferValidator } from "./interfaces/ITransferValidator.sol";

import { TwoStepOwnable } from "utility-contracts/TwoStepOwnable.sol";
Expand Down Expand Up @@ -326,6 +328,7 @@ contract ERC721ContractMetadata is
{
return
interfaceId == type(IERC2981).interfaceId ||
interfaceId == type(ICreatorToken).interfaceId ||
interfaceId == 0x49064906 || // ERC-4906
super.supportsInterface(interfaceId);
}
Expand Down
3 changes: 3 additions & 0 deletions src/clones/ERC721ContractMetadataCloneable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { ERC721ACloneable } from "./ERC721ACloneable.sol";

import { ERC721TransferValidator } from "../lib/ERC721TransferValidator.sol";

import { ICreatorToken } from "../interfaces/ICreatorToken.sol";

import { ITransferValidator } from "../interfaces/ITransferValidator.sol";

import { TwoStepOwnable } from "utility-contracts/TwoStepOwnable.sol";
Expand Down Expand Up @@ -321,6 +323,7 @@ contract ERC721ContractMetadataCloneable is
{
return
interfaceId == type(IERC2981).interfaceId ||
interfaceId == type(ICreatorToken).interfaceId ||
interfaceId == 0x49064906 || // ERC-4906
super.supportsInterface(interfaceId);
}
Expand Down
10 changes: 10 additions & 0 deletions src/interfaces/ICreatorToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

interface ICreatorToken {
event TransferValidatorUpdated(address oldValidator, address newValidator);

function getTransferValidator() external view returns (address validator);

function setTransferValidator(address validator) external;

Check warning on line 9 in src/interfaces/ICreatorToken.sol

View workflow job for this annotation

GitHub Actions / Run Linters

Function order is incorrect, external function can not go after external view function (line 7)
}
7 changes: 3 additions & 4 deletions src/lib/ERC721TransferValidator.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import { ICreatorToken } from "../interfaces/ICreatorToken.sol";

/**
* @title ERC721TransferValidator
* @notice Functionality to use a transfer validator.
*/
contract ERC721TransferValidator {
abstract contract ERC721TransferValidator is ICreatorToken {
/// @dev Store the transfer validator. The null address means no transfer validator is set.
address internal _transferValidator;

/// @notice Emit an event when the transfer validator is updated.
event TransferValidatorUpdated(address oldValidator, address newValidator);

/// @notice Revert with an error if the transfer validator is being set to the same address.
error SameTransferValidator();

Expand Down
2 changes: 2 additions & 0 deletions test/ERC721SeaDrop.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { expect } from "chai";
import { ethers, network } from "hardhat";

import {
ICreatorToken__factory,
IERC165__factory,
IERC2981__factory,
IERC721__factory,
Expand Down Expand Up @@ -266,6 +267,7 @@ describe(`ERC721SeaDrop (v${VERSION})`, function () {
const supportedInterfacesERC721ContractMetadata = [
[ISeaDropTokenContractMetadata__factory, IERC2981__factory],
[IERC2981__factory, IERC165__factory],
[ICreatorToken__factory],
];
const supportedInterfacesERC721A = [
[IERC721__factory, IERC165__factory],
Expand Down

0 comments on commit 21c2874

Please sign in to comment.