Skip to content

Commit

Permalink
feat: optimize the mint function and add support for the category fie…
Browse files Browse the repository at this point in the history
…ld, BREAKING CHANGES FOR FRONT-END
  • Loading branch information
EmperorOrokuSaki committed Jul 12, 2023
1 parent ffb74a8 commit a6f730c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 32 deletions.
67 changes: 36 additions & 31 deletions contracts/contracts/FleekERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -127,35 +124,40 @@ 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
);

_tokenVerifier[tokenId] = verifier;
_tokenVerified[tokenId] = false;
_setAccessPointAutoApproval(tokenId, accessPointAutoApproval);

return tokenId;
}
Expand Down Expand Up @@ -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`.
*
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion contracts/contracts/IERCX.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit a6f730c

Please sign in to comment.