Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat support kcu kroman #48

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contracts/token/ERC721/ERC721TypedUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pragma solidity ^0.8.0;
import { IERC721Metadata, IERC721Burnable, IERC721Typed } from "./IERC721.sol";

import { ERC721Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import { ERC721URIStorageUpgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol";
import { EcoERC721Base } from "./EcoERC721Base.sol";
import { ERC721SequencialMintUpbradeable } from "./ERC721SequencialMintUpbradeable.sol";

import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
Expand Down Expand Up @@ -38,7 +38,7 @@ abstract contract ERC721TypedUpgradeable is IERC721Typed, ERC721SequencialMintUp

function tokenURI(
uint256 tokenId
) public view virtual override(IERC721Metadata, ERC721Upgradeable) returns (string memory) {
) public view virtual override(EcoERC721Base, IERC721Metadata) returns (string memory) {
string memory baseURI = _baseURI();

return bytes(baseURI).length > 0 ? baseURI.concat(tokenType(tokenId).toString()).concat(".json") : "";
Expand Down
32 changes: 26 additions & 6 deletions contracts/token/ERC721/EcoERC721Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,31 @@ pragma solidity ^0.8.0;

import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
Martin-ryunseok marked this conversation as resolved.
Show resolved Hide resolved

import { IERC721Burnable } from "./IERC721.sol";
import { IEcoERC721Base, IERC721Burnable, IERC721Metadata } from "./IERC721.sol";

import { ERC721Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import { ERC721PausableUpgradeable } from "./ERC721PausableUpgradeable.sol";
import { ERC721BurnableUpgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol";
import { EcoERC721URIStorageUpgradeable, ERC721URIStorageUpgradeable } from "./EcoERC721URIStorageUpgradeable.sol";
import { ERC721EnumerableUpgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol";
import { ERC721PausableUpgradeable } from "./ERC721PausableUpgradeable.sol";

abstract contract EcoERC721Base is
IERC721Burnable,
IEcoERC721Base,
ERC721Upgradeable,
ERC721PausableUpgradeable,
ERC721BurnableUpgradeable,
ERC721EnumerableUpgradeable,
ERC721PausableUpgradeable
EcoERC721URIStorageUpgradeable,
ERC721EnumerableUpgradeable
{
function supportsInterface(
bytes4 interfaceId
) public view virtual override(ERC721EnumerableUpgradeable, ERC721Upgradeable, IERC165) returns (bool) {
)
public
view
virtual
override(ERC721EnumerableUpgradeable, ERC721Upgradeable, EcoERC721URIStorageUpgradeable, IERC165)
returns (bool)
{
return super.supportsInterface(interfaceId);
}

Expand All @@ -48,4 +56,16 @@ abstract contract EcoERC721Base is
) internal virtual override(ERC721EnumerableUpgradeable, ERC721Upgradeable) {
return super._increaseBalance(account, amount);
}

function tokenURI(
uint256 tokenId
)
public
view
virtual
override(ERC721Upgradeable, EcoERC721URIStorageUpgradeable, IERC721Metadata)
returns (string memory)
{
return super.tokenURI(tokenId);
}
}
37 changes: 37 additions & 0 deletions contracts/token/ERC721/EcoERC721URIStorageUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/ERC721Pausable.sol)

pragma solidity ^0.8.20;

import { SelectorRoleControlUpgradeable, AccessControlEnumerableUpgradeable } from "../../access/SelectorRoleControlUpgradeable.sol";

import { IERC165, IERC721Metadata, IEcoERC721URIStorage } from "./IERC721.sol";
import { ERC721URIStorageUpgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol";

abstract contract EcoERC721URIStorageUpgradeable is
IEcoERC721URIStorage,
SelectorRoleControlUpgradeable,
ERC721URIStorageUpgradeable
{
function supportsInterface(
bytes4 interfaceId
)
public
view
virtual
override(AccessControlEnumerableUpgradeable, ERC721URIStorageUpgradeable, IERC165)
returns (bool)
{
return super.supportsInterface(interfaceId);
}

function tokenURI(
uint256 tokenId
) public view virtual override(ERC721URIStorageUpgradeable, IERC721Metadata) returns (string memory) {
return string.concat(super.tokenURI(tokenId), ".json");
}

function setTokenURI(uint256 tokenId, string memory _tokenURI) public virtual override onlyAdmin {
return _setTokenURI(tokenId, _tokenURI);
}
}
14 changes: 10 additions & 4 deletions contracts/token/ERC721/IERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ import { IERC721Receiver } from "@openzeppelin/contracts/token/ERC721/IERC721Rec

import { ISelectorRoleControl } from "../../access/SelectorRoleControlUpgradeable.sol";

interface IEcoERC721Base is IERC165, IERC721, IERC4906, IERC721Metadata, IERC721Errors {}
interface IERC721Base is IERC165, IERC721, IERC4906, IERC721Metadata, IERC721Errors {}

interface IERC721Burnable is IEcoERC721Base {
interface IERC721Burnable is IERC721Base {
function burn(uint256 tokenId) external;
}

interface IERC721SequencialMintUpbradeable is ISelectorRoleControl, IERC721Burnable {
interface IEcoERC721URIStorage is IERC721Base {
function setTokenURI(uint256 tokenId, string memory _tokenURI) external;
}

interface IEcoERC721Base is IERC721Burnable, IEcoERC721URIStorage {}

interface IERC721SequencialMintUpbradeable is ISelectorRoleControl, IEcoERC721Base {
function nextMintId() external view returns (uint256 tokeId);

function nextMint(address to) external returns (uint256 tokenId);
Expand Down Expand Up @@ -55,4 +61,4 @@ interface IERC721Queryable is IERC721SequencialMintUpbradeable {
function tokensOfOwner(address owner) external view returns (uint256[] memory);
}

interface IEcoERC721 is IERC721SequencialMintUpbradeable {}
interface IEcoERC721 is IERC721Queryable {}
9 changes: 7 additions & 2 deletions contracts/token/NFT/NFT_Mintable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

pragma solidity ^0.8.0;

import { IERC721Burnable, IERC721Queryable } from "../ERC721/IERC721.sol";
import { IEcoERC721, IERC721Burnable, IERC721Queryable } from "../ERC721/IERC721.sol";
import { ERC721SequencialMintUpbradeable } from "../ERC721/ERC721SequencialMintUpbradeable.sol";
import { ERC721QueryableUpgradeable } from "../ERC721/ERC721QueryableUpgradeable.sol";

interface INFT_Mintable is IERC721Queryable {}
interface INFT_Mintable is IEcoERC721 {}

// INFT_Mintable,
contract NFT_Mintable is INFT_Mintable, ERC721SequencialMintUpbradeable, ERC721QueryableUpgradeable {
Expand All @@ -17,6 +17,11 @@ contract NFT_Mintable is INFT_Mintable, ERC721SequencialMintUpbradeable, ERC721Q
__ERC721Burnable_init();
__ERC721Enumerable_init();
__Pausable_init();
_checkBaseURI();
}

function _checkBaseURI() internal view virtual {
require(bytes(_baseURI()).length != 0);
}

function burn(
Expand Down
5 changes: 4 additions & 1 deletion contracts/token/NFT/NFT_Typed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { INFT_Mintable, NFT_Mintable } from "./NFT_Mintable.sol";
import { SelectorRoleControlUpgradeable } from "../../access/SelectorRoleControlUpgradeable.sol";

import { ERC721Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import { EcoERC721Base } from "../ERC721/EcoERC721Base.sol";
import { ERC721SequencialMintUpbradeable } from "../ERC721/ERC721SequencialMintUpbradeable.sol";
import { ERC721TypedUpgradeable } from "../ERC721/ERC721TypedUpgradeable.sol";

Expand All @@ -22,6 +23,8 @@ contract NFT_Typed is INFT_Typed, NFT_Mintable, ERC721TypedUpgradeable {
return super.supportsInterface(interfaceId);
}

function _checkBaseURI() internal view override {}

function _baseURI()
internal
view
Expand All @@ -34,7 +37,7 @@ contract NFT_Typed is INFT_Typed, NFT_Mintable, ERC721TypedUpgradeable {

function tokenURI(
uint256 tokenId
) public view virtual override(IERC721Metadata, ERC721Upgradeable, ERC721TypedUpgradeable) returns (string memory) {
) public view virtual override(IERC721Metadata, EcoERC721Base, ERC721TypedUpgradeable) returns (string memory) {
return super.tokenURI(tokenId);
}

Expand Down
7 changes: 7 additions & 0 deletions contracts/token/NFT/SBT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol

import { ERC721Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";

import { IERC721Metadata } from "../ERC721/IERC721.sol";
import { EcoERC721Base } from "../ERC721/EcoERC721Base.sol";
import { ERC721SequencialMintUpbradeable } from "../ERC721/ERC721SequencialMintUpbradeable.sol";
import { ERC721SoulBoundUpgradeable } from "../ERC721/ERC721SoulBoundUpgradeable.sol";
Expand Down Expand Up @@ -34,4 +35,10 @@ contract SBT is NFT_Mintable, ERC721SoulBoundUpgradeable {
) internal virtual override(ERC721SoulBoundUpgradeable, EcoERC721Base) returns (address) {
return super._update(to, tokenId, auth);
}

function tokenURI(
uint256 tokenId
) public view virtual override(ERC721Upgradeable, EcoERC721Base, IERC721Metadata) returns (string memory) {
return super.tokenURI(tokenId);
}
}
26 changes: 26 additions & 0 deletions contracts/token/NFT/test.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

import { EcoERC721Base } from "../ERC721/EcoERC721Base.sol";

import { NFT_Mintable } from "./NFT_Mintable.sol";
import { NFT_Typed } from "./NFT_Typed.sol";
import { SBT } from "./SBT.sol";

contract Test_NFT_Mintable is NFT_Mintable {
function _baseURI() internal pure override returns (string memory) {
return "https://test.com/";
}
}

contract Test_NFT_Typed is NFT_Typed {

} // already provide base uri

contract Test_SBT is SBT {
function _baseURI() internal pure override returns (string memory) {
return "https://test.com/";
}
}
2 changes: 1 addition & 1 deletion test/token/NFT/NFT_Mintable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("NFT Mintable", function () {
async function NFT_Mintable_Fixture() {
const [owner, admin, user0, user1] = await hre.ethers.getSigners();

const NFT = await hre.ethers.getContractFactory("NFT_Mintable");
const NFT = await hre.ethers.getContractFactory("Test_NFT_Mintable");
const nft = await NFT.connect(owner).deploy();
await nft.initNFT_Mintable(owner.address, name, symbol);

Expand Down
2 changes: 1 addition & 1 deletion test/token/NFT/NFT_Typed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("NFT Typed", function () {
async function NFT_Typed_Fixture() {
const [owner, admin, user0, user1] = await hre.ethers.getSigners();

const NFT = await hre.ethers.getContractFactory("NFT_Typed");
const NFT = await hre.ethers.getContractFactory("Test_NFT_Typed");
const nft = await NFT.connect(owner).deploy();
await nft.initNFT_Mintable(owner.address, name, symbol);

Expand Down
2 changes: 1 addition & 1 deletion test/token/NFT/SBT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("SBT", function () {
async function SBT_Mintable_Fixture() {
const [owner, admin, user0, user1] = await hre.ethers.getSigners();

const SBT = await hre.ethers.getContractFactory("SBT");
const SBT = await hre.ethers.getContractFactory("Test_SBT");
const sbt = await SBT.connect(owner).deploy();
await sbt.initNFT_Mintable(owner.address, name, symbol);

Expand Down
Loading