Skip to content

Commit

Permalink
v1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
beshup committed Dec 2, 2023
1 parent b0bd191 commit 88a3e94
Show file tree
Hide file tree
Showing 51 changed files with 4,369 additions and 765 deletions.
42 changes: 42 additions & 0 deletions contracts/erc721/ERC721Editions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import "./interfaces/IERC721EditionMint.sol";
import "./MarketplaceFilterer/MarketplaceFiltererAbridged.sol";
import "../utils/ERC721/ERC721Upgradeable.sol";
import "../mint/interfaces/IAbridgedMintVector.sol";
import "../mint/mechanics/interfaces/IMechanicMintManager.sol";

/**
* @title ERC721 Editions
Expand Down Expand Up @@ -205,6 +206,47 @@ contract ERC721Editions is
return editionId;
}

/**
* @notice Create edition with a mechanic vector
* @param _editionInfo Info of the Edition
* @param _editionSize Size of the Edition
* @param _editionTokenManager Edition's token manager
* @param editionRoyalty Edition royalty object for contract (optional)
* @param mechanicVectorData Mechanic mint vector data
* @ param mechanicVectorId Global mechanic vector ID
* @ param mechanic Mechanic address
* @ param mintManager Mint manager address
* @ param vectorData Vector data
* @notice Used to create a new Edition within the Collection
*/
function createEditionWithMechanicVector(
bytes memory _editionInfo,
uint256 _editionSize,
address _editionTokenManager,
IRoyaltyManager.Royalty memory editionRoyalty,
bytes calldata mechanicVectorData
) external onlyOwner nonReentrant returns (uint256) {
uint256 editionId = _createEdition(_editionInfo, _editionSize, _editionTokenManager);
if (editionRoyalty.recipientAddress != address(0)) {
_royalties[editionId] = editionRoyalty;
}

if (mechanicVectorData.length != 0) {
(uint96 seed, address mechanic, address mintManager, bytes memory vectorData) = abi.decode(
mechanicVectorData,
(uint96, address, address, bytes)
);

IMechanicMintManager(mintManager).registerMechanicVector(
IMechanicData.MechanicVectorMetadata(address(this), uint96(editionId), mechanic, true, false, false),
seed,
vectorData
);
}

return editionId;
}

/**
* @notice Create edition with auction
* @param _editionInfo Info of the Edition
Expand Down
41 changes: 41 additions & 0 deletions contracts/erc721/ERC721EditionsDFS.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import "./interfaces/IERC721EditionMint.sol";
import "./MarketplaceFilterer/MarketplaceFiltererAbridged.sol";
import "../utils/ERC721/ERC721Upgradeable.sol";
import "../mint/interfaces/IAbridgedMintVector.sol";
import "../mint/mechanics/interfaces/IMechanicMintManager.sol";

/**
* @title ERC721 Editions
Expand Down Expand Up @@ -200,6 +201,46 @@ contract ERC721EditionsDFS is
return editionId;
}

/**
* @notice Used to create a new Edition within the Collection
* @param _editionUri Edition uri (metadata)
* @param _editionSize Size of the Edition
* @param _editionTokenManager Edition's token manager
* @param editionRoyalty Edition royalty object for contract (optional)
* @param mechanicVectorData Mechanic mint vector data
* @ param mechanicVectorId Global mechanic vector ID
* @ param mechanic Mechanic address
* @ param mintManager Mint manager address
* @ param vectorData Vector data
*/
function createEditionWithMechanicVector(
string memory _editionUri,
uint256 _editionSize,
address _editionTokenManager,
IRoyaltyManager.Royalty memory editionRoyalty,
bytes calldata mechanicVectorData
) external onlyOwner nonReentrant returns (uint256) {
uint256 editionId = _createEdition(_editionUri, _editionSize, _editionTokenManager);
if (editionRoyalty.recipientAddress != address(0)) {
_royalties[editionId] = editionRoyalty;
}

if (mechanicVectorData.length > 0) {
(uint96 seed, address mechanic, address mintManager, bytes memory vectorData) = abi.decode(
mechanicVectorData,
(uint96, address, address, bytes)
);

IMechanicMintManager(mintManager).registerMechanicVector(
IMechanicData.MechanicVectorMetadata(address(this), uint96(editionId), mechanic, true, false, false),
seed,
vectorData
);
}

return editionId;
}

/**
* @notice Create edition with auction
* @param _editionUri Edition uri (metadata)
Expand Down
91 changes: 73 additions & 18 deletions contracts/erc721/ERC721GeneralSequenceBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import "./ERC721Base.sol";
import "../metadata/MetadataEncryption.sol";
import "../tokenManager/interfaces/IPostTransfer.sol";
import "../tokenManager/interfaces/IPostBurn.sol";
import "./interfaces/IERC721GeneralMint.sol";
import "./interfaces/IERC721GeneralSequenceMint.sol";
import "./erc721a/ERC721AURIStorageUpgradeable.sol";
import "./custom/interfaces/IHighlightRenderer.sol";

/**
* @title Generalized Base ERC721
* @author highlight.xyz
* @notice Generalized Base NFT smart contract
*/
abstract contract ERC721GeneralSequenceBase is ERC721Base, ERC721AURIStorageUpgradeable, IERC721GeneralMint {
abstract contract ERC721GeneralSequenceBase is ERC721Base, ERC721AURIStorageUpgradeable, IERC721GeneralSequenceMint {
using EnumerableSet for EnumerableSet.AddressSet;

/**
Expand Down Expand Up @@ -41,6 +42,16 @@ abstract contract ERC721GeneralSequenceBase is ERC721Base, ERC721AURIStorageUpgr
*/
error EmptyString();

/**
* @notice Custom renderer config, used for collections where metadata is rendered "in-chain"
* @param renderer Renderer address
* @param processMintDataOnRenderer If true, process mint data on renderer
*/
struct CustomRendererConfig {
address renderer;
bool processMintDataOnRenderer;
}

/**
* @notice Contract metadata
*/
Expand All @@ -51,6 +62,11 @@ abstract contract ERC721GeneralSequenceBase is ERC721Base, ERC721AURIStorageUpgr
*/
uint256 public limitSupply;

/**
* @notice Custom renderer config
*/
CustomRendererConfig public customRendererConfig;

/**
* @notice Emitted when uris are set for tokens
* @param ids IDs of tokens to set uris for
Expand All @@ -67,7 +83,7 @@ abstract contract ERC721GeneralSequenceBase is ERC721Base, ERC721AURIStorageUpgr
/**
* @notice See {IERC721GeneralMint-mintOneToOneRecipient}
*/
function mintOneToOneRecipient(address recipient) external onlyMinter nonReentrant returns (uint256) {
function mintOneToOneRecipient(address recipient) external virtual onlyMinter nonReentrant returns (uint256) {
if (_mintFrozen == 1) {
_revert(MintFrozen.selector);
}
Expand All @@ -77,13 +93,19 @@ abstract contract ERC721GeneralSequenceBase is ERC721Base, ERC721AURIStorageUpgr

_mint(recipient, 1);

// process mint on custom renderer if present
CustomRendererConfig memory _customRendererConfig = customRendererConfig;
if (_customRendererConfig.processMintDataOnRenderer) {
IHighlightRenderer(_customRendererConfig.renderer).processOneRecipientMint(tempSupply, 1, recipient);
}

return tempSupply;
}

/**
* @notice See {IERC721GeneralMint-mintAmountToOneRecipient}
*/
function mintAmountToOneRecipient(address recipient, uint256 amount) external onlyMinter nonReentrant {
function mintAmountToOneRecipient(address recipient, uint256 amount) external virtual onlyMinter nonReentrant {
if (_mintFrozen == 1) {
_revert(MintFrozen.selector);
}
Expand All @@ -92,6 +114,16 @@ abstract contract ERC721GeneralSequenceBase is ERC721Base, ERC721AURIStorageUpgr
_mint(recipient, amount);

_requireLimitSupply(tempSupply + amount);

// process mint on custom renderer if present
CustomRendererConfig memory _customRendererConfig = customRendererConfig;
if (_customRendererConfig.processMintDataOnRenderer) {
IHighlightRenderer(_customRendererConfig.renderer).processOneRecipientMint(
tempSupply + 1,
amount,
recipient
);
}
}

/**
Expand All @@ -109,6 +141,16 @@ abstract contract ERC721GeneralSequenceBase is ERC721Base, ERC721AURIStorageUpgr
}

_requireLimitSupply(tempSupply + recipientsLength);

// process mint on custom renderer if present
CustomRendererConfig memory _customRendererConfig = customRendererConfig;
if (_customRendererConfig.processMintDataOnRenderer) {
IHighlightRenderer(_customRendererConfig.renderer).processMultipleRecipientMint(
tempSupply + 1,
1,
recipients
);
}
}

/**
Expand All @@ -129,23 +171,26 @@ abstract contract ERC721GeneralSequenceBase is ERC721Base, ERC721AURIStorageUpgr
}

_requireLimitSupply(tempSupply + recipientsLength * amount);
}

/* solhint-disable no-empty-blocks */

/**
* @notice Mint a chosen token id to a single recipient
* @dev Unavailable for ERC721GeneralSequenceBase, keep interface adhered for backwards compatiblity
*/
function mintSpecificTokenToOneRecipient(address recipient, uint256 tokenId) external {}
// process mint on custom renderer if present
CustomRendererConfig memory _customRendererConfig = customRendererConfig;
if (_customRendererConfig.processMintDataOnRenderer) {
IHighlightRenderer(_customRendererConfig.renderer).processMultipleRecipientMint(
tempSupply + 1,
amount,
recipients
);
}
}

/**
* @notice Mint chosen token ids to a single recipient
* @dev Unavailable for ERC721GeneralSequenceBase, keep interface adhered for backwards compatiblity
* @notice Set custom renderer and processing config
* @param _customRendererConfig New custom renderer config
*/
function mintSpecificTokensToOneRecipient(address recipient, uint256[] calldata tokenIds) external {}

/* solhint-enable no-empty-blocks */
function setCustomRenderer(CustomRendererConfig calldata _customRendererConfig) external onlyOwner {
require(_customRendererConfig.renderer != address(0), "Invalid input");
customRendererConfig = _customRendererConfig;
}

/**
* @notice Override base URI system for select tokens, with custom per-token metadata
Expand Down Expand Up @@ -220,6 +265,13 @@ abstract contract ERC721GeneralSequenceBase is ERC721Base, ERC721AURIStorageUpgr
observability.emitContractMetadataSet(newName, newSymbol, newContractUri);
}

/**
* @notice Return the total number of minted tokens on the collection
*/
function supply() external view returns (uint256) {
return ERC721AUpgradeable._totalMinted();
}

/**
* @notice See {IERC721-burn}. Overrides default behaviour to check associated tokenManager.
*/
Expand Down Expand Up @@ -247,6 +299,9 @@ abstract contract ERC721GeneralSequenceBase is ERC721Base, ERC721AURIStorageUpgr
* @param tokenId ID of token to get uri for
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (customRendererConfig.renderer != address(0)) {
return IHighlightRenderer(customRendererConfig.renderer).tokenURI(tokenId);
}
return ERC721AURIStorageUpgradeable.tokenURI(tokenId);
}

Expand Down Expand Up @@ -322,7 +377,7 @@ abstract contract ERC721GeneralSequenceBase is ERC721Base, ERC721AURIStorageUpgr
* @notice Require the new supply of tokens after mint to be less than limit supply
* @param newSupply New supply
*/
function _requireLimitSupply(uint256 newSupply) private view {
function _requireLimitSupply(uint256 newSupply) internal view {
uint256 _limitSupply = limitSupply;
if (_limitSupply != 0 && newSupply > _limitSupply) {
_revert(OverLimitSupply.selector);
Expand Down
Loading

0 comments on commit 88a3e94

Please sign in to comment.