wip: refactor on current nft contract
This commit is contained in:
parent
3a316a6fea
commit
3f37d82aca
|
|
@ -4,38 +4,22 @@ pragma solidity ^0.8.7;
|
|||
|
||||
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
|
||||
import "@openzeppelin/contracts/utils/Counters.sol";
|
||||
import "@openzeppelin/contracts/access/AccessControl.sol";
|
||||
import "./FleekAccessControl.sol";
|
||||
import "../interfaces/ISitesNFTs.sol";
|
||||
|
||||
contract SitesNFTs is ISitesNFTs, ERC721URIStorage, AccessControl {
|
||||
contract SitesNFTs is ISitesNFTs, ERC721URIStorage, FleekAccessControl {
|
||||
using Counters for Counters.Counter;
|
||||
Counters.Counter private _tokenIds;
|
||||
string private baseURI;
|
||||
|
||||
bytes32 public constant MINTER_ROLE =
|
||||
0x4d494e5445525f524f4c45000000000000000000000000000000000000000000; // "MINTER_ROLE"
|
||||
|
||||
modifier canMint() {
|
||||
bool isMinterOrAdmin = hasRole(MINTER_ROLE, msg.sender) ||
|
||||
hasRole(DEFAULT_ADMIN_ROLE, msg.sender);
|
||||
require(isMinterOrAdmin, "Caller has no permission to mint.");
|
||||
_;
|
||||
}
|
||||
|
||||
modifier canChangeBaseURI() {
|
||||
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender));
|
||||
_;
|
||||
}
|
||||
|
||||
constructor(string memory name, string memory symbol) ERC721(name, symbol) {
|
||||
baseURI = "data:application/json;base64,";
|
||||
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
|
||||
}
|
||||
constructor(
|
||||
string memory name,
|
||||
string memory symbol
|
||||
) ERC721(name, symbol) {}
|
||||
|
||||
function mint(
|
||||
string memory base64EncodedMetadata,
|
||||
address account
|
||||
) public override canMint returns (uint256) {
|
||||
) public override requireController returns (uint256) {
|
||||
uint256 newItemId = _tokenIds.current();
|
||||
_safeMint(account, newItemId);
|
||||
_setTokenURI(newItemId, base64EncodedMetadata);
|
||||
|
|
@ -48,7 +32,7 @@ contract SitesNFTs is ISitesNFTs, ERC721URIStorage, AccessControl {
|
|||
address tokenHolderAddress,
|
||||
uint256 tokenId,
|
||||
string memory base64EncodedMetadata
|
||||
) public override canMint {
|
||||
) public override requireController {
|
||||
address tokenOwner = ownerOf(tokenId);
|
||||
require(
|
||||
tokenOwner == tokenHolderAddress,
|
||||
|
|
@ -57,6 +41,10 @@ contract SitesNFTs is ISitesNFTs, ERC721URIStorage, AccessControl {
|
|||
_setTokenURI(tokenId, base64EncodedMetadata);
|
||||
}
|
||||
|
||||
function getCurrentTokenId() public view override returns (uint256) {
|
||||
return _tokenIds.current();
|
||||
}
|
||||
|
||||
function supportsInterface(
|
||||
bytes4 interfaceId
|
||||
)
|
||||
|
|
@ -68,19 +56,4 @@ contract SitesNFTs is ISitesNFTs, ERC721URIStorage, AccessControl {
|
|||
{
|
||||
return super.supportsInterface(interfaceId);
|
||||
}
|
||||
|
||||
function setBaseURI(
|
||||
string memory _newBbaseURI
|
||||
) public override canChangeBaseURI returns (string memory) {
|
||||
baseURI = _newBbaseURI;
|
||||
return baseURI;
|
||||
}
|
||||
|
||||
function getCurrentTokenId() public view override returns (uint256) {
|
||||
return _tokenIds.current();
|
||||
}
|
||||
|
||||
function _baseURI() internal view override returns (string memory) {
|
||||
return baseURI;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,12 @@ import "@openzeppelin/contracts/access/IAccessControl.sol";
|
|||
/// @title SitesNFTs - A contract for managing sites NFTs
|
||||
/// @dev See
|
||||
interface ISitesNFTs is IERC721 {
|
||||
enum FleekContract {
|
||||
Site
|
||||
}
|
||||
|
||||
function mint(
|
||||
FleekContract memory fleekContract,
|
||||
string memory base64EncodedMetadata,
|
||||
address account
|
||||
) external returns (uint256);
|
||||
|
|
@ -19,9 +24,5 @@ interface ISitesNFTs is IERC721 {
|
|||
string memory base64EncodedMetadata
|
||||
) external;
|
||||
|
||||
function setBaseURI(
|
||||
string memory _newBbaseURI
|
||||
) external returns (string memory);
|
||||
|
||||
function getCurrentTokenId() external view returns (uint256);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue