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