From a6f730cf85635ff5c7ed4f8c669bfabb7cc9230b Mon Sep 17 00:00:00 2001 From: EmperorOrokuSaki Date: Wed, 12 Jul 2023 16:09:08 +0330 Subject: [PATCH] feat: optimize the mint function and add support for the category field, BREAKING CHANGES FOR FRONT-END --- contracts/contracts/FleekERC721.sol | 67 ++++++++++++++++------------- contracts/contracts/IERCX.sol | 3 +- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/contracts/contracts/FleekERC721.sol b/contracts/contracts/FleekERC721.sol index cbd8bc2d..2fac4c10 100644 --- a/contracts/contracts/FleekERC721.sol +++ b/contracts/contracts/FleekERC721.sol @@ -43,7 +43,7 @@ contract FleekERC721 is string ipfsHash, string logo, uint24 color, - bool accessPointAutoApproval, + Categories category, address indexed minter, address indexed owner, address verifier @@ -106,14 +106,11 @@ contract FleekERC721 is address to, string memory name, string memory description, - string memory externalURL, string calldata ens, - string memory commitHash, - string memory gitRepository, - string memory ipfsHash, string memory logo, uint24 color, - bool accessPointAutoApproval, + Categories category, + Build memory buildParams, address verifier ) public payable requirePayment(Billing.Mint) returns (uint256) { if (!hasCollectionRole(CollectionRoles.Verifier, verifier)) @@ -127,27 +124,33 @@ contract FleekERC721 is Token storage app = _apps[tokenId]; app.name = name; app.description = description; - app.externalURL = externalURL; + app.externalURL = buildParams.domain; app.ENS = ens; app.logo = logo; app.color = color; + app.category = category; // The mint interaction is considered to be the first build of the site. Updates from now on all increment the currentBuild by one and update the mapping. app.currentBuild = 0; - app.builds[0] = Build(commitHash, gitRepository, ipfsHash, externalURL); + app.builds[0] = Build( + buildParams.commitHash, + buildParams.gitRepository, + buildParams.ipfsHash, + buildParams.domain + ); emit NewMint( tokenId, name, description, - externalURL, + buildParams.domain, ens, - commitHash, - gitRepository, - ipfsHash, + buildParams.commitHash, + buildParams.gitRepository, + buildParams.ipfsHash, logo, color, - accessPointAutoApproval, + category, msg.sender, to, verifier @@ -155,7 +158,6 @@ contract FleekERC721 is _tokenVerifier[tokenId] = verifier; _tokenVerified[tokenId] = false; - _setAccessPointAutoApproval(tokenId, accessPointAutoApproval); return tokenId; } @@ -387,6 +389,26 @@ contract FleekERC721 is emit MetadataUpdate(tokenId, "color", _tokenColor, msg.sender); } + /** + * @dev Updates the `category` metadata field of a minted `tokenId`. + * + * May emit a {NewTokenCategory} event. + * + * Requirements: + * + * - the tokenId must be minted and valid. + * - the sender must have the `tokenController` role. + * + */ + function setTokenCategory( + uint256 tokenId, + Categories category + ) public virtual requireTokenRole(tokenId, TokenRoles.Controller) { + _requireMinted(tokenId); + _apps[tokenId].category = category; + emit MetadataUpdate(tokenId, "category", category, msg.sender); + } + /** * @dev Updates the `logo` and `color` metadata fields of a minted `tokenId`. * @@ -558,23 +580,6 @@ contract FleekERC721 is _removeAccessPoint(apName); } - /** - * @dev Updates the `accessPointAutoApproval` settings on minted `tokenId`. - * - * May emit a {MetadataUpdate} event. - * - * Requirements: - * - * - the tokenId must be minted and valid. - * - the sender must have the `tokenController` role. - * - */ - function setAccessPointAutoApproval(uint256 tokenId, bool _apAutoApproval) public requireTokenOwner(tokenId) { - _requireMinted(tokenId); - _setAccessPointAutoApproval(tokenId, _apAutoApproval); - emit MetadataUpdate(tokenId, "accessPointAutoApproval", _apAutoApproval, msg.sender); - } - /** * @dev Set approval settings for an access point. * It will add the access point to the token's AP list, if `approved` is true. diff --git a/contracts/contracts/IERCX.sol b/contracts/contracts/IERCX.sol index ddff721e..06eb278b 100644 --- a/contracts/contracts/IERCX.sol +++ b/contracts/contracts/IERCX.sol @@ -26,6 +26,7 @@ interface IERCX { event MetadataUpdate(uint256 indexed _tokenId, string key, uint24 value, address indexed triggeredBy); event MetadataUpdate(uint256 indexed _tokenId, string key, string[4] value, address indexed triggeredBy); event MetadataUpdate(uint256 indexed _tokenId, string key, bool value, address indexed triggeredBy); + event MetadataUpdate(uint256 indexed _tokenId, string key, Categories value, address indexed triggeredBy); /** * The metadata that is stored for each build. @@ -60,7 +61,7 @@ interface IERCX { string ENS; // ENS for the site string logo; // Branding logo uint24 color; // Branding color - Categories tokenCategory; // The category trait associated with the token + Categories category; // The category trait associated with the token uint256 currentBuild; // The current build number (Increments by one with each change, starts at zero) mapping(uint256 => Build) builds; // Mapping to build details for each build number }