Skip to content

Commit

Permalink
add getTransferValidationFunction()
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanio committed Apr 1, 2024
1 parent 1f33f03 commit 0d5e060
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/ERC1155SeaDrop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import {
* @author Ryan Ghods (ralxz.eth)
* @author Stephan Min (stephanm.eth)
* @author Michael Cohen (notmichael.eth)
* @contributor Limit Break (@limitbreak)
* @notice An ERC1155 token contract that can mint as a
* Seaport contract offerer.
* Implements Limit Break's Creator Token Standards transfer
* validation for royalty enforcement.
*/
contract ERC1155SeaDrop is ERC1155SeaDropContractOfferer {
/**
Expand Down
3 changes: 3 additions & 0 deletions src/ERC721SeaDrop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ import { ERC721A } from "ERC721A/ERC721A.sol";
* @author Ryan Ghods (ralxz.eth)
* @author Stephan Min (stephanm.eth)
* @author Michael Cohen (notmichael.eth)
* @contributor Limit Break (@limitbreak)
* @notice An ERC721 token contract based on ERC721A that can mint as a
* Seaport contract offerer.
* Implements Limit Break's Creator Token Standards transfer
* validation for royalty enforcement.
*/
contract ERC721SeaDrop is ERC721SeaDropContractOfferer {
/**
Expand Down
20 changes: 19 additions & 1 deletion src/clones/ERC1155ContractMetadataCloneable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import {
ERC1155ConduitPreapproved
} from "../lib/ERC1155ConduitPreapproved.sol";

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

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

Expand Down Expand Up @@ -313,6 +316,20 @@ contract ERC1155ContractMetadataCloneable is
return _baseURI;
}

/**
* @notice Returns the transfer validation function used.
*/
function getTransferValidationFunction()
external
pure
returns (bytes4 functionSignature, bool isViewFunction)
{
functionSignature = keccak256(
"validateTransfer(address,address,address,uint256,uint256)"
);
isViewFunction = true;
}

/**
* @notice Set the transfer validator. Only callable by the token owner.
*/
Expand Down Expand Up @@ -364,6 +381,7 @@ contract ERC1155ContractMetadataCloneable is
return
interfaceId == type(IERC1155ContractMetadata).interfaceId ||
interfaceId == type(ICreatorToken).interfaceId ||
interfaceId == type(ILegacyCreatorToken).interfaceId ||
interfaceId == 0x49064906 || // ERC-4906 (MetadataUpdate)
ERC2981.supportsInterface(interfaceId) ||
// ERC1155 returns supportsInterface true for
Expand Down
3 changes: 3 additions & 0 deletions src/clones/ERC1155SeaDropCloneable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import {
* @author Ryan Ghods (ralxz.eth)
* @author Stephan Min (stephanm.eth)
* @author Michael Cohen (notmichael.eth)
* @contributor Limit Break (@limitbreak)
* @notice A cloneable ERC1155 token contract that can mint as a
* Seaport contract offerer.
* Implements Limit Break's Creator Token Standards transfer
* validation for royalty enforcement.
*/
contract ERC1155SeaDropCloneable is ERC1155SeaDropContractOffererCloneable {
/**
Expand Down
13 changes: 13 additions & 0 deletions src/interfaces/ICreatorToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,18 @@ interface ICreatorToken {

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

function getTransferValidationFunction()
external
view
returns (bytes4 functionSignature, bool isViewFunction);

function setTransferValidator(address validator) external;
}

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

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

function setTransferValidator(address validator) external;
}
20 changes: 19 additions & 1 deletion src/lib/ERC1155ContractMetadata.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import {
ERC1155ConduitPreapproved
} from "../lib/ERC1155ConduitPreapproved.sol";

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

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

Expand Down Expand Up @@ -311,6 +314,20 @@ contract ERC1155ContractMetadata is
return _baseURI;
}

/**
* @notice Returns the transfer validation function used.
*/
function getTransferValidationFunction()
external
pure
returns (bytes4 functionSignature, bool isViewFunction)
{
functionSignature = keccak256(
"validateTransfer(address,address,address,uint256,uint256)"
);
isViewFunction = true;
}

/**
* @notice Set the transfer validator. Only callable by the token owner.
*/
Expand Down Expand Up @@ -362,6 +379,7 @@ contract ERC1155ContractMetadata is
return
interfaceId == type(IERC1155ContractMetadata).interfaceId ||
interfaceId == type(ICreatorToken).interfaceId ||
interfaceId == type(ILegacyCreatorToken).interfaceId ||
interfaceId == 0x49064906 || // ERC-4906 (MetadataUpdate)
ERC2981.supportsInterface(interfaceId) ||
// ERC1155 returns supportsInterface true for
Expand Down
20 changes: 19 additions & 1 deletion src/lib/ERC721ContractMetadata.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import {

import { ERC721AConduitPreapproved } from "./ERC721AConduitPreapproved.sol";

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

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

Expand Down Expand Up @@ -279,6 +282,20 @@ contract ERC721ContractMetadata is
return string.concat(theBaseURI, _toString(tokenId));
}

/**
* @notice Returns the transfer validation function used.
*/
function getTransferValidationFunction()
external
pure
returns (bytes4 functionSignature, bool isViewFunction)
{
functionSignature = keccak256(
"validateTransfer(address,address,address,uint256)"
);
isViewFunction = false;
}

/**
* @notice Set the transfer validator. Only callable by the token owner.
*/
Expand Down Expand Up @@ -321,6 +338,7 @@ contract ERC721ContractMetadata is
return
interfaceId == type(IERC721ContractMetadata).interfaceId ||
interfaceId == type(ICreatorToken).interfaceId ||
interfaceId == type(ILegacyCreatorToken).interfaceId ||
interfaceId == 0x49064906 || // ERC-4906 (MetadataUpdate)
ERC2981.supportsInterface(interfaceId) ||
// ERC721A returns supportsInterface true for
Expand Down
2 changes: 2 additions & 0 deletions test/ERC1155SeaDropContractOfferer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
IERC1155SeaDrop__factory,
IERC165__factory,
IERC2981__factory,
ILegacyCreatorToken__factory,
ISeaDropTokenContractMetadata__factory,
ISeaDropToken__factory,
} from "../typechain-types";
Expand Down Expand Up @@ -524,6 +525,7 @@ describe(`ERC1155SeaDropContractOfferer (v${VERSION})`, function () {
],
[IERC2981__factory, IERC165__factory],
[ICreatorToken__factory],
[ILegacyCreatorToken__factory],
];
const supportedInterfacesContractOffererInterface = [
[ContractOffererInterface__factory],
Expand Down
2 changes: 2 additions & 0 deletions test/ERC721SeaDropContractOfferer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
IERC2981__factory,
IERC721ContractMetadata__factory,
IERC721SeaDrop__factory,
ILegacyCreatorToken__factory,
ISeaDropTokenContractMetadata__factory,
ISeaDropToken__factory,
} from "../typechain-types";
Expand Down Expand Up @@ -615,6 +616,7 @@ describe(`ERC721SeaDropContractOfferer (v${VERSION})`, function () {
],
[IERC2981__factory, IERC165__factory],
[ICreatorToken__factory],
[ILegacyCreatorToken__factory],
];
const supportedInterfacesContractOffererInterface = [
[ContractOffererInterface__factory],
Expand Down

0 comments on commit 0d5e060

Please sign in to comment.