Skip to content

Commit

Permalink
handle merging status
Browse files Browse the repository at this point in the history
  • Loading branch information
hvthhien committed Jun 19, 2024
1 parent 9e86016 commit 907370f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contracts/FeralfileArtworkV4.sol
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ contract FeralfileExhibitionV4 is
// initialize max supply map
for (uint256 i = 0; i < seriesIds_.length; i++) {
require(
_seriesMaxSupplies[i] == 0,
_seriesMaxSupplies[seriesIds_[i]] == 0,
"FeralfileExhibitionV4: duplicate seriesId"
);

require(
seriesMaxSupplies_[i] > 0,
"FeralfileExhibitionV4: zero max supply"
Expand Down
26 changes: 26 additions & 0 deletions contracts/FeralfileArtworkV4_3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ contract FeralfileExhibitionV4_3 is FeralfileExhibitionV4_1 {
error InvalidOwner();
error TokenIsNonMergeable();
error InvalidLength();
error InvalidMergingStatus();

struct MergeArtworkInfo {
uint256 singleSeriesId;
Expand All @@ -15,6 +16,9 @@ contract FeralfileExhibitionV4_3 is FeralfileExhibitionV4_1 {
}
MergeArtworkInfo private mergeArtworkInfo;

// merging
bool internal _merging;

constructor(
string memory name_,
string memory symbol_,
Expand Down Expand Up @@ -47,6 +51,10 @@ contract FeralfileExhibitionV4_3 is FeralfileExhibitionV4_1 {
/// @notice burns multiples mergeable artworks and mint a new artworks
/// @param tokenIds - list of tokenIds to be burned
function mergeArtworks(uint256[] calldata tokenIds) external {
if (!_merging) {
revert InvalidMergingStatus();
}

if (tokenIds.length < 2) {
revert InvalidLength();
}
Expand Down Expand Up @@ -78,4 +86,22 @@ contract FeralfileExhibitionV4_3 is FeralfileExhibitionV4_1 {
);
mergeArtworkInfo.nextTokenId++;
}

/// @notice Start token merging
function startMerging() external onlyOwner {
if (_merging) {
revert InvalidMergingStatus();
}

_merging = true;
}

/// @notice Pause token merging
function pauseMerging() public onlyOwner {
if (!_merging) {
revert InvalidMergingStatus();
}

_merging = false;
}
}

0 comments on commit 907370f

Please sign in to comment.