wip: FleekERC721 contract
This commit is contained in:
parent
3f37d82aca
commit
2c4c5ed59f
|
|
@ -7,6 +7,9 @@ import "./FleekBuilds.sol";
|
|||
import "./FleekAccessControl.sol";
|
||||
|
||||
abstract contract Fleek is IFleek, FleekBuilds {
|
||||
string public name;
|
||||
string public description;
|
||||
|
||||
constructor(string memory _name, string memory _description) {
|
||||
name = _name;
|
||||
description = _description;
|
||||
|
|
|
|||
|
|
@ -5,11 +5,14 @@ pragma solidity ^0.8.7;
|
|||
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
|
||||
import "@openzeppelin/contracts/utils/Counters.sol";
|
||||
import "./FleekAccessControl.sol";
|
||||
import "../interfaces/ISitesNFTs.sol";
|
||||
import "../interfaces/IFleekERC721.sol";
|
||||
import "./FleekSite.sol";
|
||||
|
||||
contract SitesNFTs is ISitesNFTs, ERC721URIStorage, FleekAccessControl {
|
||||
contract FleekERC721 is IFleekERC721, ERC721URIStorage, FleekAccessControl {
|
||||
using Counters for Counters.Counter;
|
||||
|
||||
Counters.Counter private _tokenIds;
|
||||
mapping(uint256 => address) private _contracts;
|
||||
|
||||
constructor(
|
||||
string memory name,
|
||||
|
|
@ -17,6 +20,7 @@ contract SitesNFTs is ISitesNFTs, ERC721URIStorage, FleekAccessControl {
|
|||
) ERC721(name, symbol) {}
|
||||
|
||||
function mint(
|
||||
uint8 fleekContract,
|
||||
string memory base64EncodedMetadata,
|
||||
address account
|
||||
) public override requireController returns (uint256) {
|
||||
|
|
@ -24,6 +28,11 @@ contract SitesNFTs is ISitesNFTs, ERC721URIStorage, FleekAccessControl {
|
|||
_safeMint(account, newItemId);
|
||||
_setTokenURI(newItemId, base64EncodedMetadata);
|
||||
|
||||
// it should be something like a switch
|
||||
if (fleekContract == FleekContract.Site) {
|
||||
_mintSite(newItemId, account);
|
||||
}
|
||||
|
||||
_tokenIds.increment();
|
||||
return newItemId;
|
||||
}
|
||||
|
|
@ -56,4 +65,24 @@ contract SitesNFTs is ISitesNFTs, ERC721URIStorage, FleekAccessControl {
|
|||
{
|
||||
return super.supportsInterface(interfaceId);
|
||||
}
|
||||
|
||||
function tokenContract(
|
||||
uint256 tokenId
|
||||
) public view override returns (address) {
|
||||
return _contracts[tokenId];
|
||||
}
|
||||
|
||||
function _mintSite(
|
||||
uint256 _newTokenId,
|
||||
address account
|
||||
) internal returns (address) {
|
||||
// it should receive the parameters from user request
|
||||
_contracts[_newTokenId] = FleekSite(
|
||||
"name",
|
||||
"description",
|
||||
"thumbnail",
|
||||
"external_url"
|
||||
);
|
||||
return _contracts[_newTokenId];
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,9 @@ import "./Fleek.sol";
|
|||
import "../interfaces/IFleekSite.sol";
|
||||
|
||||
contract FleekSite is IFleekSite, Fleek {
|
||||
string public thumbnail;
|
||||
string public external_url;
|
||||
|
||||
constructor(
|
||||
string memory _name,
|
||||
string memory _description,
|
||||
|
|
|
|||
|
|
@ -3,12 +3,9 @@
|
|||
pragma solidity ^0.8.7;
|
||||
|
||||
import "./IFleekBuilds.sol";
|
||||
import "@openzeppelin/contracts/access/IAccessControl.sol";
|
||||
import "../node_modules/@openzeppelin/contracts/access/IAccessControl.sol";
|
||||
|
||||
interface IFleek is IFleekBuilds, IAccessControl {
|
||||
string name;
|
||||
string description;
|
||||
|
||||
event MetadataUpdated(string name, string description);
|
||||
|
||||
function setName(string calldata _name) external;
|
||||
|
|
|
|||
|
|
@ -2,18 +2,17 @@
|
|||
|
||||
pragma solidity ^0.8.7;
|
||||
|
||||
import "@openzeppelin/contracts/interfaces/IERC721.sol";
|
||||
import "@openzeppelin/contracts/access/IAccessControl.sol";
|
||||
import "../node_modules/@openzeppelin/contracts/interfaces/IERC721.sol";
|
||||
import "../node_modules/@openzeppelin/contracts/access/IAccessControl.sol";
|
||||
|
||||
/// @title SitesNFTs - A contract for managing sites NFTs
|
||||
/// @dev See
|
||||
interface ISitesNFTs is IERC721 {
|
||||
/// @title IFleekERC721 - A contract for managing sites NFTs
|
||||
interface IFleekERC721 is IERC721 {
|
||||
enum FleekContract {
|
||||
Site
|
||||
}
|
||||
|
||||
function mint(
|
||||
FleekContract memory fleekContract,
|
||||
uint8 fleekContract,
|
||||
string memory base64EncodedMetadata,
|
||||
address account
|
||||
) external returns (uint256);
|
||||
|
|
@ -25,4 +24,6 @@ interface ISitesNFTs is IERC721 {
|
|||
) external;
|
||||
|
||||
function getCurrentTokenId() external view returns (uint256);
|
||||
|
||||
function tokenContract(uint256 tokenId) external view returns (address);
|
||||
}
|
||||
|
|
@ -5,9 +5,6 @@ pragma solidity ^0.8.7;
|
|||
import "./IFleek.sol";
|
||||
|
||||
interface IFleekSite is IFleek {
|
||||
string thumbnail;
|
||||
string external_url;
|
||||
|
||||
event MetadataUpdated(
|
||||
string name,
|
||||
string description,
|
||||
|
|
|
|||
Loading…
Reference in New Issue