// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)pragmasolidity ^0.8.1;/**
* @dev Collection of functions related to the address type
*/libraryAddress{
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/functionisContract(address account) internalviewreturns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0// for contracts in construction, since the code is only stored at the end// of the constructor execution.return account.code.length>0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/functionsendValue(addresspayable recipient, uint256 amount) internal{
require(address(this).balance>= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/functionfunctionCall(address target, bytesmemory data) internalreturns (bytesmemory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/functionfunctionCall(address target,
bytesmemory data,
stringmemory errorMessage
) internalreturns (bytesmemory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/functionfunctionCallWithValue(address target, bytesmemory data, uint256 value) internalreturns (bytesmemory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/functionfunctionCallWithValue(address target,
bytesmemory data,
uint256 value,
stringmemory errorMessage
) internalreturns (bytesmemory) {
require(address(this).balance>= value, "Address: insufficient balance for call");
(bool success, bytesmemory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/functionfunctionStaticCall(address target, bytesmemory data) internalviewreturns (bytesmemory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/functionfunctionStaticCall(address target,
bytesmemory data,
stringmemory errorMessage
) internalviewreturns (bytesmemory) {
(bool success, bytesmemory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/functionfunctionDelegateCall(address target, bytesmemory data) internalreturns (bytesmemory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/functionfunctionDelegateCall(address target,
bytesmemory data,
stringmemory errorMessage
) internalreturns (bytesmemory) {
(bool success, bytesmemory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/functionverifyCallResultFromTarget(address target,
bool success,
bytesmemory returndata,
stringmemory errorMessage
) internalviewreturns (bytesmemory) {
if (success) {
if (returndata.length==0) {
// only check isContract if the call was successful and the return data is empty// otherwise we already know that it was a contractrequire(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/functionverifyCallResult(bool success,
bytesmemory returndata,
stringmemory errorMessage
) internalpurereturns (bytesmemory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function_revert(bytesmemory returndata, stringmemory errorMessage) privatepure{
// Look for revert reason and bubble it up if presentif (returndata.length>0) {
// The easiest way to bubble the revert reason is using memory via assembly/// @solidity memory-safe-assemblyassembly {
let returndata_size :=mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
Contract Source Code
File 2 of 30: AddressUpgradeable.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)pragmasolidity ^0.8.1;/**
* @dev Collection of functions related to the address type
*/libraryAddressUpgradeable{
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/functionisContract(address account) internalviewreturns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0// for contracts in construction, since the code is only stored at the end// of the constructor execution.return account.code.length>0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/functionsendValue(addresspayable recipient, uint256 amount) internal{
require(address(this).balance>= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/functionfunctionCall(address target, bytesmemory data) internalreturns (bytesmemory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/functionfunctionCall(address target,
bytesmemory data,
stringmemory errorMessage
) internalreturns (bytesmemory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/functionfunctionCallWithValue(address target, bytesmemory data, uint256 value) internalreturns (bytesmemory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/functionfunctionCallWithValue(address target,
bytesmemory data,
uint256 value,
stringmemory errorMessage
) internalreturns (bytesmemory) {
require(address(this).balance>= value, "Address: insufficient balance for call");
(bool success, bytesmemory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/functionfunctionStaticCall(address target, bytesmemory data) internalviewreturns (bytesmemory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/functionfunctionStaticCall(address target,
bytesmemory data,
stringmemory errorMessage
) internalviewreturns (bytesmemory) {
(bool success, bytesmemory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/functionfunctionDelegateCall(address target, bytesmemory data) internalreturns (bytesmemory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/functionfunctionDelegateCall(address target,
bytesmemory data,
stringmemory errorMessage
) internalreturns (bytesmemory) {
(bool success, bytesmemory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/functionverifyCallResultFromTarget(address target,
bool success,
bytesmemory returndata,
stringmemory errorMessage
) internalviewreturns (bytesmemory) {
if (success) {
if (returndata.length==0) {
// only check isContract if the call was successful and the return data is empty// otherwise we already know that it was a contractrequire(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/functionverifyCallResult(bool success,
bytesmemory returndata,
stringmemory errorMessage
) internalpurereturns (bytesmemory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function_revert(bytesmemory returndata, stringmemory errorMessage) privatepure{
// Look for revert reason and bubble it up if presentif (returndata.length>0) {
// The easiest way to bubble the revert reason is using memory via assembly/// @solidity memory-safe-assemblyassembly {
let returndata_size :=mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
Contract Source Code
File 3 of 30: AdminControl.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/// @author: manifold.xyzimport"@openzeppelin/contracts/utils/introspection/ERC165.sol";
import"@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import"@openzeppelin/contracts/access/Ownable.sol";
import"./IAdminControl.sol";
abstractcontractAdminControlisOwnable, IAdminControl, ERC165{
usingEnumerableSetforEnumerableSet.AddressSet;
// Track registered admins
EnumerableSet.AddressSet private _admins;
/**
* @dev See {IERC165-supportsInterface}.
*/functionsupportsInterface(bytes4 interfaceId) publicviewvirtualoverride(ERC165, IERC165) returns (bool) {
return interfaceId ==type(IAdminControl).interfaceId||super.supportsInterface(interfaceId);
}
/**
* @dev Only allows approved admins to call the specified function
*/modifieradminRequired() {
require(owner() ==msg.sender|| _admins.contains(msg.sender), "AdminControl: Must be owner or admin");
_;
}
/**
* @dev See {IAdminControl-getAdmins}.
*/functiongetAdmins() externalviewoverridereturns (address[] memory admins) {
admins =newaddress[](_admins.length());
for (uint i =0; i < _admins.length(); i++) {
admins[i] = _admins.at(i);
}
return admins;
}
/**
* @dev See {IAdminControl-approveAdmin}.
*/functionapproveAdmin(address admin) externaloverrideonlyOwner{
if (!_admins.contains(admin)) {
emit AdminApproved(admin, msg.sender);
_admins.add(admin);
}
}
/**
* @dev See {IAdminControl-revokeAdmin}.
*/functionrevokeAdmin(address admin) externaloverrideonlyOwner{
if (_admins.contains(admin)) {
emit AdminRevoked(admin, msg.sender);
_admins.remove(admin);
}
}
/**
* @dev See {IAdminControl-isAdmin}.
*/functionisAdmin(address admin) publicoverrideviewreturns (bool) {
return (owner() == admin || _admins.contains(admin));
}
}
Contract Source Code
File 4 of 30: ClickToken.sol
//SPDX-License-Identifier: NONEpragmasolidity ^0.8.18;import"./manifold-creator-core/ERC1155Creator.sol";
errorClickIsSoulbound();
errorMarketplaceCanOnlyMoveClick();
contractClickTokenisERC1155Creator{
uint256publicconstant CLICK_TOKEN_ID =1;
addresspublicimmutable MARKETPLACE;
mapping(address=>uint256) public allowedOperators;
constructor(address owner, address _marketplace) ERC1155Creator ("ClickCreate Marketplace", "CLICKSART") {
_transferOwnership(owner);
MARKETPLACE = _marketplace;
}
// Adds an immutable pre-approval for CLICK marketplace contract.functionsafeTransferFrom(addressfrom,
address to,
uint256 id,
uint256 amount,
bytesmemory data
) publicvirtualoverride{
if (msg.sender!= MARKETPLACE) {
require(
from==msg.sender|| isApprovedForAll(from, msg.sender),
"ERC1155: caller is not token owner or approved"
);
} elseif (id != CLICK_TOKEN_ID) {
revert MarketplaceCanOnlyMoveClick();
}
_safeTransferFrom(from, to, id, amount, data);
}
functionsafeBatchTransferFrom(addressfrom,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytesmemory data
) publicvirtualoverride{
if (msg.sender!= MARKETPLACE) {
require(
from==msg.sender|| isApprovedForAll(from, msg.sender),
"ERC1155: caller is not token owner or approved"
);
} elseif (!(ids.length==1&& ids[0] == CLICK_TOKEN_ID)) {
revert MarketplaceCanOnlyMoveClick();
}
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
// Ensures CLICK is soulbound, except for approved operators.function_beforeTokenTransfer(address operator, addressfrom, address to, uint256[] memory ids, uint256[] memory amounts, bytesmemory data) internalvirtualoverride{
if (
from!=address(0) &&
operator != MARKETPLACE &&
_arrayHasClickToken(ids) &&
allowedOperators[operator] !=1
) {
revert ClickIsSoulbound();
}
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
}
function_arrayHasClickToken(uint256[] memory ids) internalpurereturns (bool) {
uint256 length = ids.length;
for (uint256 i; i < length; ++i) {
if (ids[i] == CLICK_TOKEN_ID) {
returntrue;
}
}
returnfalse;
}
functionsetAllowedOperator(address operator, uint256 status) externalonlyOwner{
allowedOperators[operator] = status;
}
functionairdropClicks(address[] calldata recipients, uint256[] calldata amounts) externalonlyOwner{
require(recipients.length== amounts.length, "ClickToken: recipients and amounts length mismatch");
uint256 length = recipients.length;
uint256 toAddToTotalSupply;
for (uint256 i; i < length; ++i) {
address to = recipients[i];
uint256 amount = amounts[i];
_balances[CLICK_TOKEN_ID][to] += amount;
emit TransferSingle(address(this), address(0), to, CLICK_TOKEN_ID, amount);
// Do not do safe transfer acceptance, saves lots of gas and if it gets locked, no biggie.
}
_totalSupply[CLICK_TOKEN_ID] += toAddToTotalSupply;
}
}
Contract Source Code
File 5 of 30: Context.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)pragmasolidity ^0.8.0;/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/abstractcontractContext{
function_msgSender() internalviewvirtualreturns (address) {
returnmsg.sender;
}
function_msgData() internalviewvirtualreturns (bytescalldata) {
returnmsg.data;
}
}
Contract Source Code
File 6 of 30: CreatorCore.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/// @author: manifold.xyzimport"@openzeppelin/contracts/security/ReentrancyGuard.sol";
import"@openzeppelin/contracts/utils/Strings.sol";
import"@openzeppelin/contracts/utils/introspection/ERC165.sol";
import"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
import"@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import"../extensions/ICreatorExtensionTokenURI.sol";
import"../extensions/ICreatorExtensionRoyalties.sol";
import"./ICreatorCore.sol";
/**
* @dev Core creator implementation
*/abstractcontractCreatorCoreisReentrancyGuard, ICreatorCore, ERC165{
usingStringsforuint256;
usingEnumerableSetforEnumerableSet.AddressSet;
usingAddressUpgradeableforaddress;
uint256internal _tokenCount =0;
// Base approve transfers address locationaddressinternal _approveTransferBase;
// Track registered extensions data
EnumerableSet.AddressSet internal _extensions;
EnumerableSet.AddressSet internal _blacklistedExtensions;
// The baseURI for a given extensionmapping (address=>string) private _extensionBaseURI;
mapping (address=>bool) private _extensionBaseURIIdentical;
// The prefix for any tokens with a uri configuredmapping (address=>string) private _extensionURIPrefix;
// Mapping for individual token URIsmapping (uint256=>string) internal _tokenURIs;
// Royalty configurationsstructRoyaltyConfig {
addresspayable receiver;
uint16 bps;
}
mapping (address=> RoyaltyConfig[]) internal _extensionRoyalty;
mapping (uint256=> RoyaltyConfig[]) internal _tokenRoyalty;
bytes4privateconstant _CREATOR_CORE_V1 =0x28f10a21;
/**
* External interface identifiers for royalties
*//**
* @dev CreatorCore
*
* bytes4(keccak256('getRoyalties(uint256)')) == 0xbb3bafd6
*
* => 0xbb3bafd6 = 0xbb3bafd6
*/bytes4privateconstant _INTERFACE_ID_ROYALTIES_CREATORCORE =0xbb3bafd6;
/**
* @dev Rarible: RoyaltiesV1
*
* bytes4(keccak256('getFeeRecipients(uint256)')) == 0xb9c4d9fb
* bytes4(keccak256('getFeeBps(uint256)')) == 0x0ebd4c7f
*
* => 0xb9c4d9fb ^ 0x0ebd4c7f = 0xb7799584
*/bytes4privateconstant _INTERFACE_ID_ROYALTIES_RARIBLE =0xb7799584;
/**
* @dev Foundation
*
* bytes4(keccak256('getFees(uint256)')) == 0xd5a06d4c
*
* => 0xd5a06d4c = 0xd5a06d4c
*/bytes4privateconstant _INTERFACE_ID_ROYALTIES_FOUNDATION =0xd5a06d4c;
/**
* @dev EIP-2981
*
* bytes4(keccak256("royaltyInfo(uint256,uint256)")) == 0x2a55205a
*
* => 0x2a55205a = 0x2a55205a
*/bytes4privateconstant _INTERFACE_ID_ROYALTIES_EIP2981 =0x2a55205a;
/**
* @dev See {IERC165-supportsInterface}.
*/functionsupportsInterface(bytes4 interfaceId) publicviewvirtualoverride(ERC165, IERC165) returns (bool) {
return interfaceId ==type(ICreatorCore).interfaceId|| interfaceId == _CREATOR_CORE_V1 ||super.supportsInterface(interfaceId)
|| interfaceId == _INTERFACE_ID_ROYALTIES_CREATORCORE || interfaceId == _INTERFACE_ID_ROYALTIES_RARIBLE
|| interfaceId == _INTERFACE_ID_ROYALTIES_FOUNDATION || interfaceId == _INTERFACE_ID_ROYALTIES_EIP2981;
}
/**
* @dev Only allows registered extensions to call the specified function
*/functionrequireExtension() internalview{
require(_extensions.contains(msg.sender), "Must be registered extension");
}
/**
* @dev Only allows non-blacklisted extensions
*/functionrequireNonBlacklist(address extension) internalview{
require(!_blacklistedExtensions.contains(extension), "Extension blacklisted");
}
/**
* @dev See {ICreatorCore-getExtensions}.
*/functiongetExtensions() externalviewoverridereturns (address[] memory extensions) {
extensions =newaddress[](_extensions.length());
for (uint i; i < _extensions.length();) {
extensions[i] = _extensions.at(i);
unchecked { ++i; }
}
return extensions;
}
/**
* @dev Register an extension
*/function_registerExtension(address extension, stringcalldata baseURI, bool baseURIIdentical) internalvirtual{
require(extension !=address(this) && extension.isContract(), "Invalid");
emit ExtensionRegistered(extension, msg.sender);
_extensionBaseURI[extension] = baseURI;
_extensionBaseURIIdentical[extension] = baseURIIdentical;
_extensions.add(extension);
_setApproveTransferExtension(extension, true);
}
/**
* @dev See {ICreatorCore-setApproveTransferExtension}.
*/functionsetApproveTransferExtension(bool enabled) externaloverride{
requireExtension();
_setApproveTransferExtension(msg.sender, enabled);
}
/**
* @dev Set whether or not tokens minted by the extension defers transfer approvals to the extension
*/function_setApproveTransferExtension(address extension, bool enabled) internalvirtual;
/**
* @dev Unregister an extension
*/function_unregisterExtension(address extension) internal{
emit ExtensionUnregistered(extension, msg.sender);
_extensions.remove(extension);
}
/**
* @dev Blacklist an extension
*/function_blacklistExtension(address extension) internal{
require(extension !=address(0) && extension !=address(this), "Cannot blacklist yourself");
if (_extensions.contains(extension)) {
emit ExtensionUnregistered(extension, msg.sender);
_extensions.remove(extension);
}
if (!_blacklistedExtensions.contains(extension)) {
emit ExtensionBlacklisted(extension, msg.sender);
_blacklistedExtensions.add(extension);
}
}
/**
* @dev Set base token uri for an extension
*/function_setBaseTokenURIExtension(stringcalldata uri, bool identical) internal{
_extensionBaseURI[msg.sender] = uri;
_extensionBaseURIIdentical[msg.sender] = identical;
}
/**
* @dev Set token uri prefix for an extension
*/function_setTokenURIPrefixExtension(stringcalldata prefix) internal{
_extensionURIPrefix[msg.sender] = prefix;
}
/**
* @dev Set token uri for a token of an extension
*/function_setTokenURIExtension(uint256 tokenId, stringcalldata uri) internal{
require(_tokenExtension(tokenId) ==msg.sender, "Invalid token");
_tokenURIs[tokenId] = uri;
}
/**
* @dev Set base token uri for tokens with no extension
*/function_setBaseTokenURI(stringcalldata uri) internal{
_extensionBaseURI[address(0)] = uri;
}
/**
* @dev Set token uri prefix for tokens with no extension
*/function_setTokenURIPrefix(stringcalldata prefix) internal{
_extensionURIPrefix[address(0)] = prefix;
}
/**
* @dev Set token uri for a token with no extension
*/function_setTokenURI(uint256 tokenId, stringcalldata uri) internal{
require(tokenId >0&& tokenId <= _tokenCount && _tokenExtension(tokenId) ==address(0), "Invalid token");
_tokenURIs[tokenId] = uri;
}
/**
* @dev Retrieve a token's URI
*/function_tokenURI(uint256 tokenId) internalviewreturns (stringmemory) {
require(tokenId >0&& tokenId <= _tokenCount, "Invalid token");
address extension = _tokenExtension(tokenId);
require(!_blacklistedExtensions.contains(extension), "Extension blacklisted");
if (bytes(_tokenURIs[tokenId]).length!=0) {
if (bytes(_extensionURIPrefix[extension]).length!=0) {
returnstring(abi.encodePacked(_extensionURIPrefix[extension], _tokenURIs[tokenId]));
}
return _tokenURIs[tokenId];
}
if (ERC165Checker.supportsInterface(extension, type(ICreatorExtensionTokenURI).interfaceId)) {
return ICreatorExtensionTokenURI(extension).tokenURI(address(this), tokenId);
}
if (!_extensionBaseURIIdentical[extension]) {
returnstring(abi.encodePacked(_extensionBaseURI[extension], tokenId.toString()));
} else {
return _extensionBaseURI[extension];
}
}
/**
* Helper to get royalties for a token
*/function_getRoyalties(uint256 tokenId) viewinternalreturns (addresspayable[] memory receivers, uint256[] memory bps) {
// Get token level royalties
RoyaltyConfig[] memory royalties = _tokenRoyalty[tokenId];
if (royalties.length==0) {
// Get extension specific royaltiesaddress extension = _tokenExtension(tokenId);
if (extension !=address(0)) {
if (ERC165Checker.supportsInterface(extension, type(ICreatorExtensionRoyalties).interfaceId)) {
(receivers, bps) = ICreatorExtensionRoyalties(extension).getRoyalties(address(this), tokenId);
// Extension override exists, just return thatif (receivers.length>0) return (receivers, bps);
}
royalties = _extensionRoyalty[extension];
}
}
if (royalties.length==0) {
// Get the default royalty
royalties = _extensionRoyalty[address(0)];
}
if (royalties.length>0) {
receivers =newaddresspayable[](royalties.length);
bps =newuint256[](royalties.length);
for (uint i; i < royalties.length;) {
receivers[i] = royalties[i].receiver;
bps[i] = royalties[i].bps;
unchecked { ++i; }
}
}
}
/**
* Helper to get royalty receivers for a token
*/function_getRoyaltyReceivers(uint256 tokenId) viewinternalreturns (addresspayable[] memory recievers) {
(recievers, ) = _getRoyalties(tokenId);
}
/**
* Helper to get royalty basis points for a token
*/function_getRoyaltyBPS(uint256 tokenId) viewinternalreturns (uint256[] memory bps) {
(, bps) = _getRoyalties(tokenId);
}
function_getRoyaltyInfo(uint256 tokenId, uint256 value) viewinternalreturns (address receiver, uint256 amount){
(addresspayable[] memory receivers, uint256[] memory bps) = _getRoyalties(tokenId);
require(receivers.length<=1, "More than 1 royalty receiver");
if (receivers.length==0) {
return (address(this), 0);
}
return (receivers[0], bps[0]*value/10000);
}
/**
* Set royalties for a token
*/function_setRoyalties(uint256 tokenId, addresspayable[] calldata receivers, uint256[] calldata basisPoints) internal{
_checkRoyalties(receivers, basisPoints);
delete _tokenRoyalty[tokenId];
_setRoyalties(receivers, basisPoints, _tokenRoyalty[tokenId]);
emit RoyaltiesUpdated(tokenId, receivers, basisPoints);
}
/**
* Set royalties for all tokens of an extension
*/function_setRoyaltiesExtension(address extension, addresspayable[] calldata receivers, uint256[] calldata basisPoints) internal{
_checkRoyalties(receivers, basisPoints);
delete _extensionRoyalty[extension];
_setRoyalties(receivers, basisPoints, _extensionRoyalty[extension]);
if (extension ==address(0)) {
emit DefaultRoyaltiesUpdated(receivers, basisPoints);
} else {
emit ExtensionRoyaltiesUpdated(extension, receivers, basisPoints);
}
}
/**
* Helper function to check that royalties provided are valid
*/function_checkRoyalties(addresspayable[] calldata receivers, uint256[] calldata basisPoints) privatepure{
require(receivers.length== basisPoints.length, "Invalid input");
uint256 totalBasisPoints;
for (uint i; i < basisPoints.length;) {
totalBasisPoints += basisPoints[i];
unchecked { ++i; }
}
require(totalBasisPoints <10000, "Invalid total royalties");
}
/**
* Helper function to set royalties
*/function_setRoyalties(addresspayable[] calldata receivers, uint256[] calldata basisPoints, RoyaltyConfig[] storage royalties) private{
for (uint i; i < basisPoints.length;) {
royalties.push(
RoyaltyConfig(
{
receiver: receivers[i],
bps: uint16(basisPoints[i])
}
)
);
unchecked { ++i; }
}
}
/**
* @dev Set the base contract's approve transfer contract location
*/function_setApproveTransferBase(address extension) internal{
_approveTransferBase = extension;
emit ApproveTransferUpdated(extension);
}
/**
* @dev See {ICreatorCore-getApproveTransfer}.
*/functiongetApproveTransfer() externalviewoverridereturns (address) {
return _approveTransferBase;
}
/**
* @dev Get the extension for the given token
*/function_tokenExtension(uint256 tokenId) internalvirtualviewreturns(address);
}
Contract Source Code
File 7 of 30: ERC1155Base.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;import"./ERC1155Core.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-1155[ERC1155] Non-Fungible Token Standard
*/abstractcontractERC1155BaseisERC1155Core{
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/constructor(stringmemory name_, stringmemory symbol_) {
_name = name_;
_symbol = symbol_;
}
}
Contract Source Code
File 8 of 30: ERC1155Core.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;import"@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import"@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol";
import"@openzeppelin/contracts/utils/Address.sol";
import"@openzeppelin/contracts/utils/Strings.sol";
import"@openzeppelin/contracts/utils/introspection/ERC165.sol";
/**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*
* _Available since v3.1._
*/abstractcontractERC1155CoreisERC165, IERC1155, IERC1155MetadataURI{
usingAddressforaddress;
// Token namestringinternal _name;
// Token symbolstringinternal _symbol;
// Mapping from token ID to account balancesmapping(uint256=>mapping(address=>uint256)) internal _balances;
// Mapping from account to operator approvalsmapping(address=>mapping(address=>bool)) private _operatorApprovals;
/**
* @dev See {IERC165-supportsInterface}.
*/functionsupportsInterface(bytes4 interfaceId) publicviewvirtualoverride(ERC165, IERC165) returns (bool) {
return
interfaceId ==type(IERC1155).interfaceId||
interfaceId ==type(IERC1155MetadataURI).interfaceId||super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/functionbalanceOf(address account, uint256 id) publicviewvirtualoverridereturns (uint256) {
require(account !=address(0), "ERC1155: address zero is not a valid owner");
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/functionbalanceOfBatch(address[] memory accounts, uint256[] memory ids)
publicviewvirtualoverridereturns (uint256[] memory)
{
require(accounts.length== ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory batchBalances =newuint256[](accounts.length);
for (uint256 i =0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
functionname() publicviewvirtualreturns (stringmemory) {
return _name;
}
functionsymbol() publicviewvirtualreturns (stringmemory) {
return _symbol;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/functionsetApprovalForAll(address operator, bool approved) publicvirtualoverride{
_setApprovalForAll(msg.sender, operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/functionisApprovedForAll(address account, address operator) publicviewvirtualoverridereturns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/functionsafeTransferFrom(addressfrom,
address to,
uint256 id,
uint256 amount,
bytesmemory data
) publicvirtualoverride{
require(
from==msg.sender|| isApprovedForAll(from, msg.sender),
"ERC1155: caller is not token owner or approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/functionsafeBatchTransferFrom(addressfrom,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytesmemory data
) publicvirtualoverride{
require(
from==msg.sender|| isApprovedForAll(from, msg.sender),
"ERC1155: caller is not token owner or approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/function_safeTransferFrom(addressfrom,
address to,
uint256 id,
uint256 amount,
bytesmemory data
) internalvirtual{
require(to !=address(0), "ERC1155: transfer to the zero address");
address operator =msg.sender;
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/function_safeBatchTransferFrom(addressfrom,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytesmemory data
) internalvirtual{
require(ids.length== amounts.length, "ERC1155: ids and amounts length mismatch");
require(to !=address(0), "ERC1155: transfer to the zero address");
address operator =msg.sender;
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i =0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/function_mint(address to,
uint256 id,
uint256 amount,
bytesmemory data
) internalvirtual{
require(to !=address(0), "ERC1155: mint to the zero address");
address operator =msg.sender;
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/function_mintBatch(address to,
uint256[] memory ids,
uint256[] memory amounts,
bytesmemory data
) internalvirtual{
require(to !=address(0), "ERC1155: mint to the zero address");
require(ids.length== amounts.length, "ERC1155: ids and amounts length mismatch");
address operator =msg.sender;
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i =0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/function_burn(addressfrom,
uint256 id,
uint256 amount
) internalvirtual{
require(from!=address(0), "ERC1155: burn from the zero address");
address operator =msg.sender;
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/function_burnBatch(addressfrom,
uint256[] memory ids,
uint256[] memory amounts
) internalvirtual{
require(from!=address(0), "ERC1155: burn from the zero address");
require(ids.length== amounts.length, "ERC1155: ids and amounts length mismatch");
address operator =msg.sender;
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
for (uint256 i =0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*/function_setApprovalForAll(address owner,
address operator,
bool approved
) internalvirtual{
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `ids` and `amounts` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/function_beforeTokenTransfer(address operator,
addressfrom,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytesmemory data
) internalvirtual{}
/**
* @dev Hook that is called after any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/function_afterTokenTransfer(address operator,
addressfrom,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytesmemory data
) internalvirtual{}
function_doSafeTransferAcceptanceCheck(address operator,
addressfrom,
address to,
uint256 id,
uint256 amount,
bytesmemory data
) private{
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catchError(stringmemory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non-ERC1155Receiver implementer");
}
}
}
function_doSafeBatchTransferAcceptanceCheck(address operator,
addressfrom,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytesmemory data
) private{
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catchError(stringmemory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non-ERC1155Receiver implementer");
}
}
}
function_asSingletonArray(uint256 element) privatepurereturns (uint256[] memory) {
uint256[] memory array =newuint256[](1);
array[0] = element;
return array;
}
}
Contract Source Code
File 9 of 30: ERC1155Creator.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/// @author: manifold.xyzimport"@manifoldxyz/libraries-solidity/contracts/access/AdminControl.sol";
import"./core/ERC1155CreatorCore.sol";
import"./token/ERC1155/ERC1155Base.sol";
/**
* @dev ERC1155Creator implementation
*/contractERC1155CreatorisAdminControl, ERC1155Base, ERC1155CreatorCore{
usingEnumerableSetforEnumerableSet.AddressSet;
mapping(uint256=>uint256) internal _totalSupply;
constructor (stringmemory _name, stringmemory _symbol) ERC1155Base(_name, _symbol) {}
/**
* @dev See {IERC165-supportsInterface}.
*/functionsupportsInterface(bytes4 interfaceId) publicviewvirtualoverride(ERC1155Core, ERC1155CreatorCore, AdminControl) returns (bool) {
return ERC1155CreatorCore.supportsInterface(interfaceId) || ERC1155Core.supportsInterface(interfaceId) || AdminControl.supportsInterface(interfaceId);
}
function_beforeTokenTransfer(address, addressfrom, address to, uint256[] memory ids, uint256[] memory amounts, bytesmemory) internalvirtualoverride{
_approveTransfer(from, to, ids, amounts);
}
/**
* @dev See {ICreatorCore-registerExtension}.
*/functionregisterExtension(address extension, stringcalldata baseURI) externaloverrideadminRequired{
requireNonBlacklist(extension);
_registerExtension(extension, baseURI, false);
}
/**
* @dev See {ICreatorCore-registerExtension}.
*/functionregisterExtension(address extension, stringcalldata baseURI, bool baseURIIdentical) externaloverrideadminRequired{
requireNonBlacklist(extension);
_registerExtension(extension, baseURI, baseURIIdentical);
}
/**
* @dev See {ICreatorCore-unregisterExtension}.
*/functionunregisterExtension(address extension) externaloverrideadminRequired{
_unregisterExtension(extension);
}
/**
* @dev See {ICreatorCore-blacklistExtension}.
*/functionblacklistExtension(address extension) externaloverrideadminRequired{
_blacklistExtension(extension);
}
/**
* @dev See {ICreatorCore-setBaseTokenURIExtension}.
*/functionsetBaseTokenURIExtension(stringcalldata uri_) externaloverride{
requireExtension();
_setBaseTokenURIExtension(uri_, false);
}
/**
* @dev See {ICreatorCore-setBaseTokenURIExtension}.
*/functionsetBaseTokenURIExtension(stringcalldata uri_, bool identical) externaloverride{
requireExtension();
_setBaseTokenURIExtension(uri_, identical);
}
/**
* @dev See {ICreatorCore-setTokenURIPrefixExtension}.
*/functionsetTokenURIPrefixExtension(stringcalldata prefix) externaloverride{
requireExtension();
_setTokenURIPrefixExtension(prefix);
}
/**
* @dev See {ICreatorCore-setTokenURIExtension}.
*/functionsetTokenURIExtension(uint256 tokenId, stringcalldata uri_) externaloverride{
requireExtension();
_setTokenURIExtension(tokenId, uri_);
}
/**
* @dev See {ICreatorCore-setTokenURIExtension}.
*/functionsetTokenURIExtension(uint256[] calldata tokenIds, string[] calldata uris) externaloverride{
requireExtension();
require(tokenIds.length== uris.length, "Invalid input");
for (uint i; i < tokenIds.length;) {
_setTokenURIExtension(tokenIds[i], uris[i]);
unchecked { ++i; }
}
}
/**
* @dev See {ICreatorCore-setBaseTokenURI}.
*/functionsetBaseTokenURI(stringcalldata uri_) externaloverrideadminRequired{
_setBaseTokenURI(uri_);
}
/**
* @dev See {ICreatorCore-setTokenURIPrefix}.
*/functionsetTokenURIPrefix(stringcalldata prefix) externaloverrideadminRequired{
_setTokenURIPrefix(prefix);
}
/**
* @dev See {ICreatorCore-setTokenURI}.
*/functionsetTokenURI(uint256 tokenId, stringcalldata uri_) externaloverrideadminRequired{
_setTokenURI(tokenId, uri_);
}
/**
* @dev See {ICreatorCore-setTokenURI}.
*/functionsetTokenURI(uint256[] calldata tokenIds, string[] calldata uris) externaloverrideadminRequired{
require(tokenIds.length== uris.length, "Invalid input");
for (uint i; i < tokenIds.length;) {
_setTokenURI(tokenIds[i], uris[i]);
unchecked { ++i; }
}
}
/**
* @dev See {ICreatorCore-setMintPermissions}.
*/functionsetMintPermissions(address extension, address permissions) externaloverrideadminRequired{
_setMintPermissions(extension, permissions);
}
/**
* @dev See {IERC1155CreatorCore-mintBaseNew}.
*/functionmintBaseNew(address[] calldata to, uint256[] calldata amounts, string[] calldata uris) publicvirtualoverridenonReentrantadminRequiredreturns(uint256[] memory) {
return _mintNew(address(0), to, amounts, uris);
}
/**
* @dev See {IERC1155CreatorCore-mintBaseExisting}.
*/functionmintBaseExisting(address[] calldata to, uint256[] calldata tokenIds, uint256[] calldata amounts) publicvirtualoverridenonReentrantadminRequired{
for (uint i; i < tokenIds.length;) {
uint256 tokenId = tokenIds[i];
require(tokenId >0&& tokenId <= _tokenCount);
require(_tokenExtension(tokenId) ==address(0));
unchecked { ++i; }
}
_mintExisting(address(0), to, tokenIds, amounts);
}
/**
* @dev See {IERC1155CreatorCore-mintExtensionNew}.
*/functionmintExtensionNew(address[] calldata to, uint256[] calldata amounts, string[] calldata uris) publicvirtualoverridenonReentrantreturns(uint256[] memory tokenIds) {
requireExtension();
return _mintNew(msg.sender, to, amounts, uris);
}
/**
* @dev See {IERC1155CreatorCore-mintExtensionExisting}.
*/functionmintExtensionExisting(address[] calldata to, uint256[] calldata tokenIds, uint256[] calldata amounts) publicvirtualoverridenonReentrant{
requireExtension();
for (uint i; i < tokenIds.length;) {
require(_tokenExtension(tokenIds[i]) ==address(msg.sender));
unchecked { ++i; }
}
_mintExisting(msg.sender, to, tokenIds, amounts);
}
/**
* @dev Mint new tokens
*/function_mintNew(address extension, address[] calldata to, uint256[] calldata amounts, string[] calldata uris) internalreturns(uint256[] memory tokenIds) {
if (to.length>1) {
// Multiple receiver. Give every receiver the same new token
tokenIds =newuint256[](1);
require(uris.length<=1&& (amounts.length==1|| to.length== amounts.length));
} else {
// Single receiver. Generating multiple tokens
tokenIds =newuint256[](amounts.length);
require(uris.length==0|| amounts.length== uris.length);
}
// Assign tokenIdsfor (uint i; i < tokenIds.length;) {
++_tokenCount;
tokenIds[i] = _tokenCount;
// Track the extension that minted the token
_tokensExtension[_tokenCount] = extension;
unchecked { ++i; }
}
if (extension !=address(0)) {
_checkMintPermissions(to, tokenIds, amounts);
}
if (to.length==1&& tokenIds.length==1) {
// Single mint
_mint(to[0], tokenIds[0], amounts[0], newbytes(0));
} elseif (to.length>1) {
// Multiple receivers. Receiving the same tokenif (amounts.length==1) {
// Everyone receiving the same amountfor (uint i; i < to.length;) {
_mint(to[i], tokenIds[0], amounts[0], newbytes(0));
unchecked { ++i; }
}
} else {
// Everyone receiving different amountsfor (uint i; i < to.length;) {
_mint(to[i], tokenIds[0], amounts[i], newbytes(0));
unchecked { ++i; }
}
}
} else {
_mintBatch(to[0], tokenIds, amounts, newbytes(0));
}
for (uint i; i < tokenIds.length;) {
if (i < uris.length&&bytes(uris[i]).length>0) {
_tokenURIs[tokenIds[i]] = uris[i];
}
unchecked { ++i; }
}
}
/**
* @dev Mint existing tokens
*/function_mintExisting(address extension, address[] calldata to, uint256[] calldata tokenIds, uint256[] calldata amounts) internal{
if (extension !=address(0)) {
_checkMintPermissions(to, tokenIds, amounts);
}
if (to.length==1&& tokenIds.length==1&& amounts.length==1) {
// Single mint
_mint(to[0], tokenIds[0], amounts[0], newbytes(0));
} elseif (to.length==1&& tokenIds.length== amounts.length) {
// Batch mint to same receiver
_mintBatch(to[0], tokenIds, amounts, newbytes(0));
} elseif (tokenIds.length==1&& amounts.length==1) {
// Mint of the same token/token amounts to various receiversfor (uint i; i < to.length;) {
_mint(to[i], tokenIds[0], amounts[0], newbytes(0));
unchecked { ++i; }
}
} elseif (tokenIds.length==1&& to.length== amounts.length) {
// Mint of the same token with different amounts to different receiversfor (uint i; i < to.length;) {
_mint(to[i], tokenIds[0], amounts[i], newbytes(0));
unchecked { ++i; }
}
} elseif (to.length== tokenIds.length&& to.length== amounts.length) {
// Mint of different tokens and different amounts to different receiversfor (uint i; i < to.length;) {
_mint(to[i], tokenIds[i], amounts[i], newbytes(0));
unchecked { ++i; }
}
} else {
revert("Invalid input");
}
}
/**
* @dev See {IERC1155CreatorCore-tokenExtension}.
*/functiontokenExtension(uint256 tokenId) publicviewvirtualoverridereturns (address extension) {
extension = _tokenExtension(tokenId);
require(extension !=address(0));
require(!_blacklistedExtensions.contains(extension));
}
/**
* @dev See {IERC1155CreatorCore-burn}.
*/functionburn(address account, uint256[] calldata tokenIds, uint256[] calldata amounts) publicvirtualoverridenonReentrant{
require(account ==msg.sender|| isApprovedForAll(account, msg.sender));
require(tokenIds.length== amounts.length);
if (tokenIds.length==1) {
_burn(account, tokenIds[0], amounts[0]);
} else {
_burnBatch(account, tokenIds, amounts);
}
_postBurn(account, tokenIds, amounts);
}
/**
* @dev See {ICreatorCore-setRoyalties}.
*/functionsetRoyalties(addresspayable[] calldata receivers, uint256[] calldata basisPoints) externaloverrideadminRequired{
_setRoyaltiesExtension(address(0), receivers, basisPoints);
}
/**
* @dev See {ICreatorCore-setRoyalties}.
*/functionsetRoyalties(uint256 tokenId, addresspayable[] calldata receivers, uint256[] calldata basisPoints) externaloverrideadminRequired{
_setRoyalties(tokenId, receivers, basisPoints);
}
/**
* @dev See {ICreatorCore-setRoyaltiesExtension}.
*/functionsetRoyaltiesExtension(address extension, addresspayable[] calldata receivers, uint256[] calldata basisPoints) externaloverrideadminRequired{
_setRoyaltiesExtension(extension, receivers, basisPoints);
}
/**
* @dev See {ICreatorCore-getRoyalties}.
*/functiongetRoyalties(uint256 tokenId) externalviewvirtualoverridereturns (addresspayable[] memory, uint256[] memory) {
return _getRoyalties(tokenId);
}
/**
* @dev See {ICreatorCore-getFees}.
*/functiongetFees(uint256 tokenId) externalviewvirtualoverridereturns (addresspayable[] memory, uint256[] memory) {
return _getRoyalties(tokenId);
}
/**
* @dev See {ICreatorCore-getFeeRecipients}.
*/functiongetFeeRecipients(uint256 tokenId) externalviewvirtualoverridereturns (addresspayable[] memory) {
return _getRoyaltyReceivers(tokenId);
}
/**
* @dev See {ICreatorCore-getFeeBps}.
*/functiongetFeeBps(uint256 tokenId) externalviewvirtualoverridereturns (uint[] memory) {
return _getRoyaltyBPS(tokenId);
}
/**
* @dev See {ICreatorCore-royaltyInfo}.
*/functionroyaltyInfo(uint256 tokenId, uint256 value) externalviewvirtualoverridereturns (address, uint256) {
return _getRoyaltyInfo(tokenId, value);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*/functionuri(uint256 tokenId) publicviewvirtualoverridereturns (stringmemory) {
return _tokenURI(tokenId);
}
/**
* @dev Total amount of tokens in with a given id.
*/functiontotalSupply(uint256 tokenId) externalviewvirtualoverridereturns (uint256) {
return _totalSupply[tokenId];
}
/**
* @dev See {ERC1155-_mint}.
*/function_mint(address account, uint256 id, uint256 amount, bytesmemory data) internalvirtualoverride{
super._mint(account, id, amount, data);
_totalSupply[id] += amount;
}
/**
* @dev See {ERC1155-_mintBatch}.
*/function_mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytesmemory data) internalvirtualoverride{
super._mintBatch(to, ids, amounts, data);
for (uint i; i < ids.length;) {
_totalSupply[ids[i]] += amounts[i];
unchecked { ++i; }
}
}
/**
* @dev See {ERC1155-_burn}.
*/function_burn(address account, uint256 id, uint256 amount) internalvirtualoverride{
super._burn(account, id, amount);
_totalSupply[id] -= amount;
}
/**
* @dev See {ERC1155-_burnBatch}.
*/function_burnBatch(address account, uint256[] memory ids, uint256[] memory amounts) internalvirtualoverride{
super._burnBatch(account, ids, amounts);
for (uint i; i < ids.length;) {
_totalSupply[ids[i]] -= amounts[i];
unchecked { ++i; }
}
}
/**
* @dev See {ICreatorCore-setApproveTransfer}.
*/functionsetApproveTransfer(address extension) externaloverrideadminRequired{
_setApproveTransferBase(extension);
}
}
Contract Source Code
File 10 of 30: ERC1155CreatorCore.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/// @author: manifold.xyzimport"@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import"../extensions/ERC1155/IERC1155CreatorExtensionApproveTransfer.sol";
import"../extensions/ERC1155/IERC1155CreatorExtensionBurnable.sol";
import"../permissions/ERC1155/IERC1155CreatorMintPermissions.sol";
import"./IERC1155CreatorCore.sol";
import"./CreatorCore.sol";
/**
* @dev Core ERC1155 creator implementation
*/abstractcontractERC1155CreatorCoreisCreatorCore, IERC1155CreatorCore{
uint256constantpublic VERSION =3;
usingEnumerableSetforEnumerableSet.AddressSet;
// Track registered extensions datamapping (address=>bool) internal _extensionApproveTransfers;
mapping (address=>address) internal _extensionPermissions;
// For tracking which extension a token was minted bymapping (uint256=>address) internal _tokensExtension;
/**
* @dev See {IERC165-supportsInterface}.
*/functionsupportsInterface(bytes4 interfaceId) publicviewvirtualoverride(CreatorCore, IERC165) returns (bool) {
return interfaceId ==type(IERC1155CreatorCore).interfaceId||super.supportsInterface(interfaceId);
}
/**
* @dev See {CreatorCore-_setApproveTransferExtension}
*/function_setApproveTransferExtension(address extension, bool enabled) internaloverride{
if (ERC165Checker.supportsInterface(extension, type(IERC1155CreatorExtensionApproveTransfer).interfaceId)) {
_extensionApproveTransfers[extension] = enabled;
emit ExtensionApproveTransferUpdated(extension, enabled);
}
}
/**
* @dev Set mint permissions for an extension
*/function_setMintPermissions(address extension, address permissions) internal{
require(_extensions.contains(extension), "Invalid extension");
require(permissions ==address(0) || ERC165Checker.supportsInterface(permissions, type(IERC1155CreatorMintPermissions).interfaceId), "Invalid address");
if (_extensionPermissions[extension] != permissions) {
_extensionPermissions[extension] = permissions;
emit MintPermissionsUpdated(extension, permissions, msg.sender);
}
}
/**
* If mint permissions have been set for an extension (extensions can mint by default),
* check if an extension can mint via the permission contract's approveMint function.
*/function_checkMintPermissions(address[] memory to, uint256[] memory tokenIds, uint256[] memory amounts) internal{
if (_extensionPermissions[msg.sender] !=address(0)) {
IERC1155CreatorMintPermissions(_extensionPermissions[msg.sender]).approveMint(msg.sender, to, tokenIds, amounts);
}
}
/**
* Post burn actions
*/function_postBurn(address owner, uint256[] calldata tokenIds, uint256[] calldata amounts) internalvirtual{
require(tokenIds.length>0, "Invalid input");
address extension = _tokensExtension[tokenIds[0]];
for (uint i; i < tokenIds.length;) {
require(_tokensExtension[tokenIds[i]] == extension, "Mismatched token originators");
unchecked { ++i; }
}
// Callback to originating extension if neededif (extension !=address(0)) {
if (ERC165Checker.supportsInterface(extension, type(IERC1155CreatorExtensionBurnable).interfaceId)) {
IERC1155CreatorExtensionBurnable(extension).onBurn(owner, tokenIds, amounts);
}
}
}
/**
* Approve a transfer
*/function_approveTransfer(addressfrom, address to, uint256[] memory tokenIds, uint256[] memory amounts) internal{
// Do not need to approve mintsif (from==address(0)) return;
address extension = _tokensExtension[tokenIds[0]];
for (uint i; i < tokenIds.length;) {
require(_tokensExtension[tokenIds[i]] == extension, "Mismatched token originators");
unchecked { ++i; }
}
if (extension !=address(0) && _extensionApproveTransfers[extension]) {
require(IERC1155CreatorExtensionApproveTransfer(extension).approveTransfer(msg.sender, from, to, tokenIds, amounts), "Extension approval failure");
} elseif (_approveTransferBase !=address(0)) {
require(IERC1155CreatorExtensionApproveTransfer(_approveTransferBase).approveTransfer(msg.sender, from, to, tokenIds, amounts), "Extension approval failure");
}
}
function_tokenExtension(uint256 tokenId) internalviewoverridereturns(address) {
return _tokensExtension[tokenId];
}
}
Contract Source Code
File 11 of 30: ERC165.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)pragmasolidity ^0.8.0;import"./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/abstractcontractERC165isIERC165{
/**
* @dev See {IERC165-supportsInterface}.
*/functionsupportsInterface(bytes4 interfaceId) publicviewvirtualoverridereturns (bool) {
return interfaceId ==type(IERC165).interfaceId;
}
}
Contract Source Code
File 12 of 30: ERC165Checker.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (utils/introspection/ERC165Checker.sol)pragmasolidity ^0.8.0;import"./IERC165.sol";
/**
* @dev Library used to query support of an interface declared via {IERC165}.
*
* Note that these functions return the actual result of the query: they do not
* `revert` if an interface is not supported. It is up to the caller to decide
* what to do in these cases.
*/libraryERC165Checker{
// As per the EIP-165 spec, no interface should ever match 0xffffffffbytes4privateconstant _INTERFACE_ID_INVALID =0xffffffff;
/**
* @dev Returns true if `account` supports the {IERC165} interface.
*/functionsupportsERC165(address account) internalviewreturns (bool) {
// Any contract that implements ERC165 must explicitly indicate support of// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalidreturn
supportsERC165InterfaceUnchecked(account, type(IERC165).interfaceId) &&!supportsERC165InterfaceUnchecked(account, _INTERFACE_ID_INVALID);
}
/**
* @dev Returns true if `account` supports the interface defined by
* `interfaceId`. Support for {IERC165} itself is queried automatically.
*
* See {IERC165-supportsInterface}.
*/functionsupportsInterface(address account, bytes4 interfaceId) internalviewreturns (bool) {
// query support of both ERC165 as per the spec and support of _interfaceIdreturn supportsERC165(account) && supportsERC165InterfaceUnchecked(account, interfaceId);
}
/**
* @dev Returns a boolean array where each value corresponds to the
* interfaces passed in and whether they're supported or not. This allows
* you to batch check interfaces for a contract where your expectation
* is that some interfaces may not be supported.
*
* See {IERC165-supportsInterface}.
*
* _Available since v3.4._
*/functiongetSupportedInterfaces(address account,
bytes4[] memory interfaceIds
) internalviewreturns (bool[] memory) {
// an array of booleans corresponding to interfaceIds and whether they're supported or notbool[] memory interfaceIdsSupported =newbool[](interfaceIds.length);
// query support of ERC165 itselfif (supportsERC165(account)) {
// query support of each interface in interfaceIdsfor (uint256 i =0; i < interfaceIds.length; i++) {
interfaceIdsSupported[i] = supportsERC165InterfaceUnchecked(account, interfaceIds[i]);
}
}
return interfaceIdsSupported;
}
/**
* @dev Returns true if `account` supports all the interfaces defined in
* `interfaceIds`. Support for {IERC165} itself is queried automatically.
*
* Batch-querying can lead to gas savings by skipping repeated checks for
* {IERC165} support.
*
* See {IERC165-supportsInterface}.
*/functionsupportsAllInterfaces(address account, bytes4[] memory interfaceIds) internalviewreturns (bool) {
// query support of ERC165 itselfif (!supportsERC165(account)) {
returnfalse;
}
// query support of each interface in interfaceIdsfor (uint256 i =0; i < interfaceIds.length; i++) {
if (!supportsERC165InterfaceUnchecked(account, interfaceIds[i])) {
returnfalse;
}
}
// all interfaces supportedreturntrue;
}
/**
* @notice Query if a contract implements an interface, does not check ERC165 support
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return true if the contract at account indicates support of the interface with
* identifier interfaceId, false otherwise
* @dev Assumes that account contains a contract that supports ERC165, otherwise
* the behavior of this method is undefined. This precondition can be checked
* with {supportsERC165}.
*
* Some precompiled contracts will falsely indicate support for a given interface, so caution
* should be exercised when using this function.
*
* Interface identification is specified in ERC-165.
*/functionsupportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internalviewreturns (bool) {
// prepare callbytesmemory encodedParams =abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);
// perform static callbool success;
uint256 returnSize;
uint256 returnValue;
assembly {
success :=staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)
returnSize :=returndatasize()
returnValue :=mload(0x00)
}
return success && returnSize >=0x20&& returnValue >0;
}
}
Contract Source Code
File 13 of 30: EnumerableSet.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.pragmasolidity ^0.8.0;/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/libraryEnumerableSet{
// To implement this library for multiple types with as little code// repetition as possible, we write it in terms of a generic Set type with// bytes32 values.// The Set implementation uses private functions, and user-facing// implementations (such as AddressSet) are just wrappers around the// underlying Set.// This means that we can only create new EnumerableSets for types that fit// in bytes32.structSet {
// Storage of set valuesbytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0// means a value is not in the set.mapping(bytes32=>uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/function_add(Set storage set, bytes32 value) privatereturns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
returntrue;
} else {
returnfalse;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/function_remove(Set storage set, bytes32 value) privatereturns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slotuint256 valueIndex = set._indexes[value];
if (valueIndex !=0) {
// Equivalent to contains(set, value)// To delete an element from the _values array in O(1), we swap the element to delete with the last one in// the array, and then remove the last element (sometimes called as 'swap and pop').// This modifies the order of the array, as noted in {at}.uint256 toDeleteIndex = valueIndex -1;
uint256 lastIndex = set._values.length-1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slotdelete set._indexes[value];
returntrue;
} else {
returnfalse;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/function_contains(Set storage set, bytes32 value) privateviewreturns (bool) {
return set._indexes[value] !=0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/function_length(Set storage set) privateviewreturns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/function_at(Set storage set, uint256 index) privateviewreturns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/function_values(Set storage set) privateviewreturns (bytes32[] memory) {
return set._values;
}
// Bytes32SetstructBytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/functionadd(Bytes32Set storage set, bytes32 value) internalreturns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/functionremove(Bytes32Set storage set, bytes32 value) internalreturns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/functioncontains(Bytes32Set storage set, bytes32 value) internalviewreturns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/functionlength(Bytes32Set storage set) internalviewreturns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/functionat(Bytes32Set storage set, uint256 index) internalviewreturns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/functionvalues(Bytes32Set storage set) internalviewreturns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assemblyassembly {
result := store
}
return result;
}
// AddressSetstructAddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/functionadd(AddressSet storage set, address value) internalreturns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/functionremove(AddressSet storage set, address value) internalreturns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/functioncontains(AddressSet storage set, address value) internalviewreturns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/functionlength(AddressSet storage set) internalviewreturns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/functionat(AddressSet storage set, uint256 index) internalviewreturns (address) {
returnaddress(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/functionvalues(AddressSet storage set) internalviewreturns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assemblyassembly {
result := store
}
return result;
}
// UintSetstructUintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/functionadd(UintSet storage set, uint256 value) internalreturns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/functionremove(UintSet storage set, uint256 value) internalreturns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/functioncontains(UintSet storage set, uint256 value) internalviewreturns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/functionlength(UintSet storage set) internalviewreturns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/functionat(UintSet storage set, uint256 index) internalviewreturns (uint256) {
returnuint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/functionvalues(UintSet storage set) internalviewreturns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assemblyassembly {
result := store
}
return result;
}
}
Contract Source Code
File 14 of 30: IAdminControl.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/// @author: manifold.xyzimport"@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @dev Interface for admin control
*/interfaceIAdminControlisIERC165{
eventAdminApproved(addressindexed account, addressindexed sender);
eventAdminRevoked(addressindexed account, addressindexed sender);
/**
* @dev gets address of all admins
*/functiongetAdmins() externalviewreturns (address[] memory);
/**
* @dev add an admin. Can only be called by contract owner.
*/functionapproveAdmin(address admin) external;
/**
* @dev remove an admin. Can only be called by contract owner.
*/functionrevokeAdmin(address admin) external;
/**
* @dev checks whether or not given address is an admin
* Returns True if they are
*/functionisAdmin(address admin) externalviewreturns (bool);
}
Contract Source Code
File 15 of 30: ICreatorCore.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/// @author: manifold.xyzimport"@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @dev Core creator interface
*/interfaceICreatorCoreisIERC165{
eventExtensionRegistered(addressindexed extension, addressindexed sender);
eventExtensionUnregistered(addressindexed extension, addressindexed sender);
eventExtensionBlacklisted(addressindexed extension, addressindexed sender);
eventMintPermissionsUpdated(addressindexed extension, addressindexed permissions, addressindexed sender);
eventRoyaltiesUpdated(uint256indexed tokenId, addresspayable[] receivers, uint256[] basisPoints);
eventDefaultRoyaltiesUpdated(addresspayable[] receivers, uint256[] basisPoints);
eventApproveTransferUpdated(address extension);
eventExtensionRoyaltiesUpdated(addressindexed extension, addresspayable[] receivers, uint256[] basisPoints);
eventExtensionApproveTransferUpdated(addressindexed extension, bool enabled);
/**
* @dev gets address of all extensions
*/functiongetExtensions() externalviewreturns (address[] memory);
/**
* @dev add an extension. Can only be called by contract owner or admin.
* extension address must point to a contract implementing ICreatorExtension.
* Returns True if newly added, False if already added.
*/functionregisterExtension(address extension, stringcalldata baseURI) external;
/**
* @dev add an extension. Can only be called by contract owner or admin.
* extension address must point to a contract implementing ICreatorExtension.
* Returns True if newly added, False if already added.
*/functionregisterExtension(address extension, stringcalldata baseURI, bool baseURIIdentical) external;
/**
* @dev add an extension. Can only be called by contract owner or admin.
* Returns True if removed, False if already removed.
*/functionunregisterExtension(address extension) external;
/**
* @dev blacklist an extension. Can only be called by contract owner or admin.
* This function will destroy all ability to reference the metadata of any tokens created
* by the specified extension. It will also unregister the extension if needed.
* Returns True if removed, False if already removed.
*/functionblacklistExtension(address extension) external;
/**
* @dev set the baseTokenURI of an extension. Can only be called by extension.
*/functionsetBaseTokenURIExtension(stringcalldata uri) external;
/**
* @dev set the baseTokenURI of an extension. Can only be called by extension.
* For tokens with no uri configured, tokenURI will return "uri+tokenId"
*/functionsetBaseTokenURIExtension(stringcalldata uri, bool identical) external;
/**
* @dev set the common prefix of an extension. Can only be called by extension.
* If configured, and a token has a uri set, tokenURI will return "prefixURI+tokenURI"
* Useful if you want to use ipfs/arweave
*/functionsetTokenURIPrefixExtension(stringcalldata prefix) external;
/**
* @dev set the tokenURI of a token extension. Can only be called by extension that minted token.
*/functionsetTokenURIExtension(uint256 tokenId, stringcalldata uri) external;
/**
* @dev set the tokenURI of a token extension for multiple tokens. Can only be called by extension that minted token.
*/functionsetTokenURIExtension(uint256[] memory tokenId, string[] calldata uri) external;
/**
* @dev set the baseTokenURI for tokens with no extension. Can only be called by owner/admin.
* For tokens with no uri configured, tokenURI will return "uri+tokenId"
*/functionsetBaseTokenURI(stringcalldata uri) external;
/**
* @dev set the common prefix for tokens with no extension. Can only be called by owner/admin.
* If configured, and a token has a uri set, tokenURI will return "prefixURI+tokenURI"
* Useful if you want to use ipfs/arweave
*/functionsetTokenURIPrefix(stringcalldata prefix) external;
/**
* @dev set the tokenURI of a token with no extension. Can only be called by owner/admin.
*/functionsetTokenURI(uint256 tokenId, stringcalldata uri) external;
/**
* @dev set the tokenURI of multiple tokens with no extension. Can only be called by owner/admin.
*/functionsetTokenURI(uint256[] memory tokenIds, string[] calldata uris) external;
/**
* @dev set a permissions contract for an extension. Used to control minting.
*/functionsetMintPermissions(address extension, address permissions) external;
/**
* @dev Configure so transfers of tokens created by the caller (must be extension) gets approval
* from the extension before transferring
*/functionsetApproveTransferExtension(bool enabled) external;
/**
* @dev get the extension of a given token
*/functiontokenExtension(uint256 tokenId) externalviewreturns (address);
/**
* @dev Set default royalties
*/functionsetRoyalties(addresspayable[] calldata receivers, uint256[] calldata basisPoints) external;
/**
* @dev Set royalties of a token
*/functionsetRoyalties(uint256 tokenId, addresspayable[] calldata receivers, uint256[] calldata basisPoints) external;
/**
* @dev Set royalties of an extension
*/functionsetRoyaltiesExtension(address extension, addresspayable[] calldata receivers, uint256[] calldata basisPoints) external;
/**
* @dev Get royalites of a token. Returns list of receivers and basisPoints
*/functiongetRoyalties(uint256 tokenId) externalviewreturns (addresspayable[] memory, uint256[] memory);
// Royalty support for various other standardsfunctiongetFeeRecipients(uint256 tokenId) externalviewreturns (addresspayable[] memory);
functiongetFeeBps(uint256 tokenId) externalviewreturns (uint[] memory);
functiongetFees(uint256 tokenId) externalviewreturns (addresspayable[] memory, uint256[] memory);
functionroyaltyInfo(uint256 tokenId, uint256 value) externalviewreturns (address, uint256);
/**
* @dev Set the default approve transfer contract location.
*/functionsetApproveTransfer(address extension) external;
/**
* @dev Get the default approve transfer contract location.
*/functiongetApproveTransfer() externalviewreturns (address);
}
Contract Source Code
File 16 of 30: ICreatorExtensionRoyalties.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/// @author: manifold.xyzimport"@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @dev Implement this if you want your extension to have overloadable royalties
*/interfaceICreatorExtensionRoyaltiesisIERC165{
/**
* Get the royalties for a given creator/tokenId
*/functiongetRoyalties(address creator, uint256 tokenId) externalviewreturns (addresspayable[] memory, uint256[] memory);
}
Contract Source Code
File 17 of 30: ICreatorExtensionTokenURI.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/// @author: manifold.xyzimport"@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @dev Implement this if you want your extension to have overloadable URI's
*/interfaceICreatorExtensionTokenURIisIERC165{
/**
* Get the uri for a given creator/tokenId
*/functiontokenURI(address creator, uint256 tokenId) externalviewreturns (stringmemory);
}
Contract Source Code
File 18 of 30: IERC1155.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/IERC1155.sol)pragmasolidity ^0.8.0;import"../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/interfaceIERC1155isIERC165{
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/eventTransferSingle(addressindexed operator, addressindexedfrom, addressindexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/eventTransferBatch(addressindexed operator,
addressindexedfrom,
addressindexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/eventApprovalForAll(addressindexed account, addressindexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/eventURI(string value, uint256indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/functionbalanceOf(address account, uint256 id) externalviewreturns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/functionbalanceOfBatch(address[] calldata accounts,
uint256[] calldata ids
) externalviewreturns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/functionsetApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/functionisApprovedForAll(address account, address operator) externalviewreturns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/functionsafeTransferFrom(addressfrom, address to, uint256 id, uint256 amount, bytescalldata data) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/functionsafeBatchTransferFrom(addressfrom,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytescalldata data
) external;
}
Contract Source Code
File 19 of 30: IERC1155CreatorCore.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/// @author: manifold.xyzimport"./CreatorCore.sol";
/**
* @dev Core ERC1155 creator interface
*/interfaceIERC1155CreatorCoreisICreatorCore{
/**
* @dev mint a token with no extension. Can only be called by an admin.
*
* @param to - Can be a single element array (all tokens go to same address) or multi-element array (single token to many recipients)
* @param amounts - Can be a single element array (all recipients get the same amount) or a multi-element array
* @param uris - If no elements, all tokens use the default uri.
* If any element is an empty string, the corresponding token uses the default uri.
*
*
* Requirements: If to is a multi-element array, then uris must be empty or single element array
* If to is a multi-element array, then amounts must be a single element array or a multi-element array of the same size
* If to is a single element array, uris must be empty or the same length as amounts
*
* Examples:
* mintBaseNew(['0x....1', '0x....2'], [1], [])
* Mints a single new token, and gives 1 each to '0x....1' and '0x....2'. Token uses default uri.
*
* mintBaseNew(['0x....1', '0x....2'], [1, 2], [])
* Mints a single new token, and gives 1 to '0x....1' and 2 to '0x....2'. Token uses default uri.
*
* mintBaseNew(['0x....1'], [1, 2], ["", "http://token2.com"])
* Mints two new tokens to '0x....1'. 1 of the first token, 2 of the second. 1st token uses default uri, second uses "http://token2.com".
*
* @return Returns list of tokenIds minted
*/functionmintBaseNew(address[] calldata to, uint256[] calldata amounts, string[] calldata uris) externalreturns (uint256[] memory);
/**
* @dev batch mint existing token with no extension. Can only be called by an admin.
*
* @param to - Can be a single element array (all tokens go to same address) or multi-element array (single token to many recipients)
* @param tokenIds - Can be a single element array (all recipients get the same token) or a multi-element array
* @param amounts - Can be a single element array (all recipients get the same amount) or a multi-element array
*
* Requirements: If any of the parameters are multi-element arrays, they need to be the same length as other multi-element arrays
*
* Examples:
* mintBaseExisting(['0x....1', '0x....2'], [1], [10])
* Mints 10 of tokenId 1 to each of '0x....1' and '0x....2'.
*
* mintBaseExisting(['0x....1', '0x....2'], [1, 2], [10, 20])
* Mints 10 of tokenId 1 to '0x....1' and 20 of tokenId 2 to '0x....2'.
*
* mintBaseExisting(['0x....1'], [1, 2], [10, 20])
* Mints 10 of tokenId 1 and 20 of tokenId 2 to '0x....1'.
*
* mintBaseExisting(['0x....1', '0x....2'], [1], [10, 20])
* Mints 10 of tokenId 1 to '0x....1' and 20 of tokenId 1 to '0x....2'.
*
*/functionmintBaseExisting(address[] calldata to, uint256[] calldata tokenIds, uint256[] calldata amounts) external;
/**
* @dev mint a token from an extension. Can only be called by a registered extension.
*
* @param to - Can be a single element array (all tokens go to same address) or multi-element array (single token to many recipients)
* @param amounts - Can be a single element array (all recipients get the same amount) or a multi-element array
* @param uris - If no elements, all tokens use the default uri.
* If any element is an empty string, the corresponding token uses the default uri.
*
*
* Requirements: If to is a multi-element array, then uris must be empty or single element array
* If to is a multi-element array, then amounts must be a single element array or a multi-element array of the same size
* If to is a single element array, uris must be empty or the same length as amounts
*
* Examples:
* mintExtensionNew(['0x....1', '0x....2'], [1], [])
* Mints a single new token, and gives 1 each to '0x....1' and '0x....2'. Token uses default uri.
*
* mintExtensionNew(['0x....1', '0x....2'], [1, 2], [])
* Mints a single new token, and gives 1 to '0x....1' and 2 to '0x....2'. Token uses default uri.
*
* mintExtensionNew(['0x....1'], [1, 2], ["", "http://token2.com"])
* Mints two new tokens to '0x....1'. 1 of the first token, 2 of the second. 1st token uses default uri, second uses "http://token2.com".
*
* @return Returns list of tokenIds minted
*/functionmintExtensionNew(address[] calldata to, uint256[] calldata amounts, string[] calldata uris) externalreturns (uint256[] memory);
/**
* @dev batch mint existing token from extension. Can only be called by a registered extension.
*
* @param to - Can be a single element array (all tokens go to same address) or multi-element array (single token to many recipients)
* @param tokenIds - Can be a single element array (all recipients get the same token) or a multi-element array
* @param amounts - Can be a single element array (all recipients get the same amount) or a multi-element array
*
* Requirements: If any of the parameters are multi-element arrays, they need to be the same length as other multi-element arrays
*
* Examples:
* mintExtensionExisting(['0x....1', '0x....2'], [1], [10])
* Mints 10 of tokenId 1 to each of '0x....1' and '0x....2'.
*
* mintExtensionExisting(['0x....1', '0x....2'], [1, 2], [10, 20])
* Mints 10 of tokenId 1 to '0x....1' and 20 of tokenId 2 to '0x....2'.
*
* mintExtensionExisting(['0x....1'], [1, 2], [10, 20])
* Mints 10 of tokenId 1 and 20 of tokenId 2 to '0x....1'.
*
* mintExtensionExisting(['0x....1', '0x....2'], [1], [10, 20])
* Mints 10 of tokenId 1 to '0x....1' and 20 of tokenId 1 to '0x....2'.
*
*/functionmintExtensionExisting(address[] calldata to, uint256[] calldata tokenIds, uint256[] calldata amounts) external;
/**
* @dev burn tokens. Can only be called by token owner or approved address.
* On burn, calls back to the registered extension's onBurn method
*/functionburn(address account, uint256[] calldata tokenIds, uint256[] calldata amounts) external;
/**
* @dev Total amount of tokens in with a given tokenId.
*/functiontotalSupply(uint256 tokenId) externalviewreturns (uint256);
}
Contract Source Code
File 20 of 30: IERC1155CreatorExtensionApproveTransfer.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/// @author: manifold.xyzimport"@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* Implement this if you want your extension to approve a transfer
*/interfaceIERC1155CreatorExtensionApproveTransferisIERC165{
/**
* @dev Set whether or not the creator contract will check the extension for approval of token transfer
*/functionsetApproveTransfer(address creator, bool enabled) external;
/**
* @dev Called by creator contract to approve a transfer
*/functionapproveTransfer(address operator, addressfrom, address to, uint256[] calldata tokenIds, uint256[] calldata amounts) externalreturns (bool);
}
Contract Source Code
File 21 of 30: IERC1155CreatorExtensionBurnable.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/// @author: manifold.xyzimport"@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @dev Your extension is required to implement this interface if it wishes
* to receive the onBurn callback whenever a token the extension created is
* burned
*/interfaceIERC1155CreatorExtensionBurnableisIERC165{
/**
* @dev callback handler for burn events
*/functiononBurn(address owner, uint256[] calldata tokenIds, uint256[] calldata amounts) external;
}
Contract Source Code
File 22 of 30: IERC1155CreatorMintPermissions.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/// @author: manifold.xyzimport"@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155Creator compliant extension contracts.
*/interfaceIERC1155CreatorMintPermissionsisIERC165{
/**
* @dev get approval to mint
*/functionapproveMint(address extension, address[] calldata to, uint256[] calldata tokenIds, uint256[] calldata amounts) external;
}
Contract Source Code
File 23 of 30: IERC1155MetadataURI.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)pragmasolidity ^0.8.0;import"../IERC1155.sol";
/**
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
*
* _Available since v3.1._
*/interfaceIERC1155MetadataURIisIERC1155{
/**
* @dev Returns the URI for token type `id`.
*
* If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/functionuri(uint256 id) externalviewreturns (stringmemory);
}
Contract Source Code
File 24 of 30: IERC1155Receiver.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)pragmasolidity ^0.8.0;import"../../utils/introspection/IERC165.sol";
/**
* @dev _Available since v3.1._
*/interfaceIERC1155ReceiverisIERC165{
/**
* @dev Handles the receipt of a single ERC1155 token type. This function is
* called at the end of a `safeTransferFrom` after the balance has been updated.
*
* NOTE: To accept the transfer, this must return
* `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
* (i.e. 0xf23a6e61, or its own function selector).
*
* @param operator The address which initiated the transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param id The ID of the token being transferred
* @param value The amount of tokens being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/functiononERC1155Received(address operator,
addressfrom,
uint256 id,
uint256 value,
bytescalldata data
) externalreturns (bytes4);
/**
* @dev Handles the receipt of a multiple ERC1155 token types. This function
* is called at the end of a `safeBatchTransferFrom` after the balances have
* been updated.
*
* NOTE: To accept the transfer(s), this must return
* `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
* (i.e. 0xbc197c81, or its own function selector).
*
* @param operator The address which initiated the batch transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param ids An array containing ids of each token being transferred (order and length must match values array)
* @param values An array containing amounts of each token being transferred (order and length must match ids array)
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/functiononERC1155BatchReceived(address operator,
addressfrom,
uint256[] calldata ids,
uint256[] calldata values,
bytescalldata data
) externalreturns (bytes4);
}
Contract Source Code
File 25 of 30: IERC165.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)pragmasolidity ^0.8.0;/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/interfaceIERC165{
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/functionsupportsInterface(bytes4 interfaceId) externalviewreturns (bool);
}
Contract Source Code
File 26 of 30: Math.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)pragmasolidity ^0.8.0;/**
* @dev Standard math utilities missing in the Solidity language.
*/libraryMath{
enumRounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/functionmax(uint256 a, uint256 b) internalpurereturns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/functionmin(uint256 a, uint256 b) internalpurereturns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/functionaverage(uint256 a, uint256 b) internalpurereturns (uint256) {
// (a + b) / 2 can overflow.return (a & b) + (a ^ b) /2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/functionceilDiv(uint256 a, uint256 b) internalpurereturns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.return a ==0 ? 0 : (a -1) / b +1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/functionmulDiv(uint256 x, uint256 y, uint256 denominator) internalpurereturns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256// variables such that product = prod1 * 2^256 + prod0.uint256 prod0; // Least significant 256 bits of the productuint256 prod1; // Most significant 256 bits of the productassembly {
let mm :=mulmod(x, y, not(0))
prod0 :=mul(x, y)
prod1 :=sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.if (prod1 ==0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.// The surrounding unchecked block does not change this fact.// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////// 512 by 256 division.///////////////////////////////////////////////// Make division exact by subtracting the remainder from [prod1 prod0].uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder :=mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 :=sub(prod1, gt(remainder, prod0))
prod0 :=sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.// See https://cs.stackexchange.com/q/138556/92363.// Does not overflow because the denominator cannot be zero at this stage in the function.uint256 twos = denominator & (~denominator +1);
assembly {
// Divide denominator by twos.
denominator :=div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 :=div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos :=add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for// four bits. That is, denominator * inv = 1 mod 2^4.uint256 inverse = (3* denominator) ^2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works// in modular arithmetic, doubling the correct bits in each step.
inverse *=2- denominator * inverse; // inverse mod 2^8
inverse *=2- denominator * inverse; // inverse mod 2^16
inverse *=2- denominator * inverse; // inverse mod 2^32
inverse *=2- denominator * inverse; // inverse mod 2^64
inverse *=2- denominator * inverse; // inverse mod 2^128
inverse *=2- denominator * inverse; // inverse mod 2^256// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/functionmulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internalpurereturns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up &&mulmod(x, y, denominator) >0) {
result +=1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/functionsqrt(uint256 a) internalpurereturns (uint256) {
if (a ==0) {
return0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.//// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.//// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`//// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.uint256 result =1<< (log2(a) >>1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision// into the expected uint128 result.unchecked {
result = (result + a / result) >>1;
result = (result + a / result) >>1;
result = (result + a / result) >>1;
result = (result + a / result) >>1;
result = (result + a / result) >>1;
result = (result + a / result) >>1;
result = (result + a / result) >>1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/functionsqrt(uint256 a, Rounding rounding) internalpurereturns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/functionlog2(uint256 value) internalpurereturns (uint256) {
uint256 result =0;
unchecked {
if (value >>128>0) {
value >>=128;
result +=128;
}
if (value >>64>0) {
value >>=64;
result +=64;
}
if (value >>32>0) {
value >>=32;
result +=32;
}
if (value >>16>0) {
value >>=16;
result +=16;
}
if (value >>8>0) {
value >>=8;
result +=8;
}
if (value >>4>0) {
value >>=4;
result +=4;
}
if (value >>2>0) {
value >>=2;
result +=2;
}
if (value >>1>0) {
result +=1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/functionlog2(uint256 value, Rounding rounding) internalpurereturns (uint256) {
unchecked {
uint256 result =log2(value);
return result + (rounding == Rounding.Up &&1<< result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/functionlog10(uint256 value) internalpurereturns (uint256) {
uint256 result =0;
unchecked {
if (value >=10**64) {
value /=10**64;
result +=64;
}
if (value >=10**32) {
value /=10**32;
result +=32;
}
if (value >=10**16) {
value /=10**16;
result +=16;
}
if (value >=10**8) {
value /=10**8;
result +=8;
}
if (value >=10**4) {
value /=10**4;
result +=4;
}
if (value >=10**2) {
value /=10**2;
result +=2;
}
if (value >=10**1) {
result +=1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/functionlog10(uint256 value, Rounding rounding) internalpurereturns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up &&10** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/functionlog256(uint256 value) internalpurereturns (uint256) {
uint256 result =0;
unchecked {
if (value >>128>0) {
value >>=128;
result +=16;
}
if (value >>64>0) {
value >>=64;
result +=8;
}
if (value >>32>0) {
value >>=32;
result +=4;
}
if (value >>16>0) {
value >>=16;
result +=2;
}
if (value >>8>0) {
result +=1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/functionlog256(uint256 value, Rounding rounding) internalpurereturns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up &&1<< (result <<3) < value ? 1 : 0);
}
}
}
Contract Source Code
File 27 of 30: Ownable.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)pragmasolidity ^0.8.0;import"../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/abstractcontractOwnableisContext{
addressprivate _owner;
eventOwnershipTransferred(addressindexed previousOwner, addressindexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/modifieronlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/functionowner() publicviewvirtualreturns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/function_checkOwner() internalviewvirtual{
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/functionrenounceOwnership() publicvirtualonlyOwner{
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/functiontransferOwnership(address newOwner) publicvirtualonlyOwner{
require(newOwner !=address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/function_transferOwnership(address newOwner) internalvirtual{
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Contract Source Code
File 28 of 30: ReentrancyGuard.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)pragmasolidity ^0.8.0;/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/abstractcontractReentrancyGuard{
// Booleans are more expensive than uint256 or any type that takes up a full// word because each write operation emits an extra SLOAD to first read the// slot's contents, replace the bits taken up by the boolean, and then write// back. This is the compiler's defense against contract upgrades and// pointer aliasing, and it cannot be disabled.// The values being non-zero value makes deployment a bit more expensive,// but in exchange the refund on every call to nonReentrant will be lower in// amount. Since refunds are capped to a percentage of the total// transaction's gas, it is best to keep them low in cases like this one, to// increase the likelihood of the full refund coming into effect.uint256privateconstant _NOT_ENTERED =1;
uint256privateconstant _ENTERED =2;
uint256private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/modifiernonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function_nonReentrantBefore() private{
// On the first call to nonReentrant, _status will be _NOT_ENTEREDrequire(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function_nonReentrantAfter() private{
// By storing the original value once again, a refund is triggered (see// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/function_reentrancyGuardEntered() internalviewreturns (bool) {
return _status == _ENTERED;
}
}
Contract Source Code
File 29 of 30: SignedMath.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)pragmasolidity ^0.8.0;/**
* @dev Standard signed math utilities missing in the Solidity language.
*/librarySignedMath{
/**
* @dev Returns the largest of two signed numbers.
*/functionmax(int256 a, int256 b) internalpurereturns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/functionmin(int256 a, int256 b) internalpurereturns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/functionaverage(int256 a, int256 b) internalpurereturns (int256) {
// Formula from the book "Hacker's Delight"int256 x = (a & b) + ((a ^ b) >>1);
return x + (int256(uint256(x) >>255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/functionabs(int256 n) internalpurereturns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`returnuint256(n >=0 ? n : -n);
}
}
}
Contract Source Code
File 30 of 30: Strings.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)pragmasolidity ^0.8.0;import"./math/Math.sol";
import"./math/SignedMath.sol";
/**
* @dev String operations.
*/libraryStrings{
bytes16privateconstant _SYMBOLS ="0123456789abcdef";
uint8privateconstant _ADDRESS_LENGTH =20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/functiontoString(uint256 value) internalpurereturns (stringmemory) {
unchecked {
uint256 length = Math.log10(value) +1;
stringmemory buffer =newstring(length);
uint256 ptr;
/// @solidity memory-safe-assemblyassembly {
ptr :=add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assemblyassembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /=10;
if (value ==0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/functiontoString(int256 value) internalpurereturns (stringmemory) {
returnstring(abi.encodePacked(value <0 ? "-" : "", toString(SignedMath.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/functiontoHexString(uint256 value) internalpurereturns (stringmemory) {
unchecked {
return toHexString(value, Math.log256(value) +1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/functiontoHexString(uint256 value, uint256 length) internalpurereturns (stringmemory) {
bytesmemory buffer =newbytes(2* length +2);
buffer[0] ="0";
buffer[1] ="x";
for (uint256 i =2* length +1; i >1; --i) {
buffer[i] = _SYMBOLS[value &0xf];
value >>=4;
}
require(value ==0, "Strings: hex length insufficient");
returnstring(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/functiontoHexString(address addr) internalpurereturns (stringmemory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/functionequal(stringmemory a, stringmemory b) internalpurereturns (bool) {
returnkeccak256(bytes(a)) ==keccak256(bytes(b));
}
}