From 90dc8c3bfc046360830b88132dd07306d9d369dc Mon Sep 17 00:00:00 2001 From: EmperorOrokuSaki Date: Thu, 22 Dec 2022 17:38:24 +0330 Subject: [PATCH] add header docs for modifiers and constructors. --- contracts/FleekAccessControl.sol | 9 +++++++++ contracts/FleekERC721.sol | 21 +++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/contracts/FleekAccessControl.sol b/contracts/FleekAccessControl.sol index 74febe1..7003e3e 100644 --- a/contracts/FleekAccessControl.sol +++ b/contracts/FleekAccessControl.sol @@ -30,10 +30,16 @@ contract FleekAccessControl { // _tokenRoles[tokenId][version][role] mapping(uint256 => mapping(uint256 => mapping(Roles => Role))) private _tokenRoles; + /** + * @dev Initializes the contract by granting the `Owner` role to the deployer. + */ constructor() { _grantCollectionRole(Roles.Owner, msg.sender); } + /** + * @dev Checks if the `msg.sender` has a certain role. + */ modifier requireCollectionRole(Roles role) { require( hasCollectionRole(role, msg.sender) || hasCollectionRole(Roles.Owner, msg.sender), @@ -42,6 +48,9 @@ contract FleekAccessControl { _; } + /** + * @dev Checks if the `msg.sender` has the `Token` role for a certain `tokenId`. + */ modifier requireTokenRole(uint256 tokenId, Roles role) { require( hasTokenRole(tokenId, role, msg.sender) || hasTokenRole(tokenId, Roles.Owner, msg.sender), diff --git a/contracts/FleekERC721.sol b/contracts/FleekERC721.sol index 49fc5b6..9c8f6d1 100644 --- a/contracts/FleekERC721.sol +++ b/contracts/FleekERC721.sol @@ -18,15 +18,10 @@ contract FleekERC721 is ERC721, FleekAccessControl { event NewTokenExternalURL(uint256 indexed token, string indexed externalURL, address indexed triggeredBy); event NewTokenENS(uint256 indexed token, string indexed ENS, address indexed triggeredBy); - struct Build { - string commitHash; - string gitRepository; - } - /** * The properties are stored as string to keep consistency with * other token contracts, we might consider changing for bytes32 - * in the future due to gas optimization + * in the future due to gas optimization. */ struct App { string name; // Name of the site @@ -38,11 +33,25 @@ contract FleekERC721 is ERC721, FleekAccessControl { mapping(uint256 => Build) builds; // Mapping to build details for each build number } + /** + * The metadata that is stored for each build. + */ + struct Build { + string commitHash; + string gitRepository; + } + Counters.Counter private _tokenIds; mapping(uint256 => App) private _apps; + /** + * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. + */ constructor(string memory _name, string memory _symbol) ERC721(_name, _symbol) {} + /** + * @dev Checks if msg.sender has the role of tokenOwner for a certain tokenId. + */ modifier requireTokenOwner(uint256 tokenId) { require(msg.sender == ownerOf(tokenId), "FleekERC721: must be token owner"); _;