From 4ae7c2f027a51556e2d40fce2e1d3d30b9eb1c70 Mon Sep 17 00:00:00 2001 From: hvthhien Date: Wed, 22 May 2024 15:36:08 +0700 Subject: [PATCH] add FeralfileArtworkV4_2 contract --- contracts/FeralfileArtworkV4_2.sol | 60 ++++++++++++++++++++++++++++++ contracts/FeralfileToken.sol | 7 +++- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 contracts/FeralfileArtworkV4_2.sol diff --git a/contracts/FeralfileArtworkV4_2.sol b/contracts/FeralfileArtworkV4_2.sol new file mode 100644 index 0000000..07d76fe --- /dev/null +++ b/contracts/FeralfileArtworkV4_2.sol @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.13; + +import { FeralfileExhibitionV4_1 } from "./FeralfileArtworkV4_1.sol"; + +contract FeralfileExhibitionV4_2 is FeralfileExhibitionV4_1 { + + error ArtworkEditionNotFound(); + + mapping(uint256 => string) public artworkParameters; // artworkEditionID => parameters as string + + constructor( + string memory name_, + string memory symbol_, + bool burnable_, + bool bridgeable_, + address signer_, + address vault_, + address costReceiver_, + string memory contractURI_, + uint256[] memory seriesIds_, + uint256[] memory seriesMaxSupplies_ + ) + FeralfileExhibitionV4_1( + name_, + symbol_, + burnable_, + bridgeable_, + signer_, + vault_, + costReceiver_, + contractURI_, + seriesIds_, + seriesMaxSupplies_ + ) + {} + + /// @notice Update the parameters of an edition to a new value + function updateArtworkParameters(uint256 tokenId, string calldata parameters) + external + onlyAuthorized + { + if (!_exists(tokenId)) { + revert ArtworkEditionNotFound(); + } + + artworkParameters[tokenId] = parameters; + } + + /// @notice Get the parameters of an edition + function getArtworkParameters( + uint256 tokenId + ) public view virtual returns (string memory) { + if (!_exists(tokenId)) { + revert ArtworkEditionNotFound(); + } + + return artworkParameters[tokenId]; + } +} diff --git a/contracts/FeralfileToken.sol b/contracts/FeralfileToken.sol index b6f67f3..406253f 100644 --- a/contracts/FeralfileToken.sol +++ b/contracts/FeralfileToken.sol @@ -6,6 +6,8 @@ import { Authorizable } from "./Authorizable.sol"; contract FeralfileToken is ERC20, Authorizable { + error InvalidOwnersAndAmounts(); + // Constructor to initialize the token with a name and symbol constructor(string memory name_, string memory symbol_) ERC20(name_, symbol_) {} @@ -20,7 +22,10 @@ contract FeralfileToken is ERC20, Authorizable { /// @param owners An array of addresses to receive the minted tokens /// @param amounts An array of amounts of tokens to mint for each respective owner function batchMint(address[] calldata owners, uint256[] calldata amounts) external virtual onlyAuthorized { - require(owners.length == amounts.length, "FeralfileToken: owners and amounts length mismatch"); + if (owners.length != amounts.length) { + revert InvalidOwnersAndAmounts(); + } + for (uint256 i = 0; i < owners.length; i++) { _mint(owners[i], amounts[i]); }