Merge pull request #59 from fleekxyz/docs/modifier-headers
Add header docs for modifiers and constructors.
This commit is contained in:
commit
f2db3ff0c6
|
|
@ -30,10 +30,16 @@ contract FleekAccessControl {
|
||||||
// _tokenRoles[tokenId][version][role]
|
// _tokenRoles[tokenId][version][role]
|
||||||
mapping(uint256 => mapping(uint256 => mapping(Roles => Role))) private _tokenRoles;
|
mapping(uint256 => mapping(uint256 => mapping(Roles => Role))) private _tokenRoles;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Initializes the contract by granting the `Owner` role to the deployer.
|
||||||
|
*/
|
||||||
constructor() {
|
constructor() {
|
||||||
_grantCollectionRole(Roles.Owner, msg.sender);
|
_grantCollectionRole(Roles.Owner, msg.sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Checks if the `msg.sender` has a certain role.
|
||||||
|
*/
|
||||||
modifier requireCollectionRole(Roles role) {
|
modifier requireCollectionRole(Roles role) {
|
||||||
require(
|
require(
|
||||||
hasCollectionRole(role, msg.sender) || hasCollectionRole(Roles.Owner, msg.sender),
|
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) {
|
modifier requireTokenRole(uint256 tokenId, Roles role) {
|
||||||
require(
|
require(
|
||||||
hasTokenRole(tokenId, role, msg.sender) || hasTokenRole(tokenId, Roles.Owner, msg.sender),
|
hasTokenRole(tokenId, role, msg.sender) || hasTokenRole(tokenId, Roles.Owner, msg.sender),
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,10 @@ contract FleekERC721 is ERC721, FleekAccessControl {
|
||||||
event NewTokenExternalURL(uint256 indexed token, string indexed externalURL, address indexed triggeredBy);
|
event NewTokenExternalURL(uint256 indexed token, string indexed externalURL, address indexed triggeredBy);
|
||||||
event NewTokenENS(uint256 indexed token, string indexed ENS, 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
|
* The properties are stored as string to keep consistency with
|
||||||
* other token contracts, we might consider changing for bytes32
|
* 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 {
|
struct App {
|
||||||
string name; // Name of the site
|
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
|
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;
|
Counters.Counter private _tokenIds;
|
||||||
mapping(uint256 => App) private _apps;
|
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) {}
|
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) {
|
modifier requireTokenOwner(uint256 tokenId) {
|
||||||
require(msg.sender == ownerOf(tokenId), "FleekERC721: must be token owner");
|
require(msg.sender == ownerOf(tokenId), "FleekERC721: must be token owner");
|
||||||
_;
|
_;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue