// 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 2 of 15: 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 3 of 15: 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 4 of 15: ERC721LazyClaim.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;import"@manifoldxyz/creator-core-solidity/contracts/core/IERC721CreatorCore.sol";
import"@manifoldxyz/libraries-solidity/contracts/access/AdminControl.sol";
import"@manifoldxyz/creator-core-solidity/contracts/extensions/ICreatorExtensionTokenURI.sol";
import"@openzeppelin/contracts/security/ReentrancyGuard.sol";
import"@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import"@openzeppelin/contracts/interfaces/IERC165.sol";
import"@openzeppelin/contracts/utils/Strings.sol";
import"./IERC721LazyClaim.sol";
/**
* @title Lazy Claim
* @author manifold.xyz
* @notice Lazy claim with optional whitelist ERC721 tokens
*/contractERC721LazyClaimisIERC165, IERC721LazyClaim, ICreatorExtensionTokenURI, ReentrancyGuard{
usingStringsforuint256;
stringprivateconstant ARWEAVE_PREFIX ="https://arweave.net/";
stringprivateconstant IPFS_PREFIX ="ipfs://";
uint256privateconstant MINT_INDEX_BITMASK =0xFF;
// stores the number of claim instances made by a given creator contract// used to determine the next claimIndex for a creator contract// { contractAddress => claimCount }mapping(address=>uint224) private _claimCounts;
// stores mapping from tokenId to the claim it represents// { contractAddress => { tokenId => Claim } }mapping(address=>mapping(uint256=> Claim)) private _claims;
// ONLY USED FOR NON-MERKLE MINTS: stores the number of tokens minted per wallet per claim, in order to limit maximum// { contractAddress => { claimIndex => { walletAddress => walletMints } } }mapping(address=>mapping(uint256=>mapping(address=>uint256))) private _mintsPerWallet;
// ONLY USED FOR MERKLE MINTS: stores mapping from claim to indices minted// { contractAddress => {claimIndex => { claimIndexOffset => index } } }mapping(address=>mapping(uint256=>mapping(uint256=>uint256))) private _claimMintIndices;
structTokenClaim {
uint224 claimIndex;
uint32 mintOrder;
}
// stores which tokenId corresponds to which claimIndex, used to generate token uris// { contractAddress => { tokenId => TokenClaim } }mapping(address=>mapping(uint256=> TokenClaim)) private _tokenClaims;
functionsupportsInterface(bytes4 interfaceId) publicviewvirtualoverride(IERC165) returns (bool) {
return interfaceId ==type(IERC721LazyClaim).interfaceId||
interfaceId ==type(ICreatorExtensionTokenURI).interfaceId||
interfaceId ==type(IERC165).interfaceId;
}
/**
* @notice This extension is shared, not single-creator. So we must ensure
* that a claim's initializer is an admin on the creator contract
* @param creatorContractAddress the address of the creator contract to check the admin against
*/modifiercreatorAdminRequired(address creatorContractAddress) {
AdminControl creatorCoreContract = AdminControl(creatorContractAddress);
require(creatorCoreContract.isAdmin(msg.sender), "Wallet is not an administrator for contract");
_;
}
/**
* See {IERC721LazyClaim-initializeClaim}.
*/functioninitializeClaim(address creatorContractAddress,
ClaimParameters calldata claimParameters
) externaloverridecreatorAdminRequired(creatorContractAddress) returns (uint256) {
// Sanity checksrequire(claimParameters.storageProtocol != StorageProtocol.INVALID, "Cannot initialize with invalid storage protocol");
require(claimParameters.endDate ==0|| claimParameters.startDate < claimParameters.endDate, "Cannot have startDate greater than or equal to endDate");
require(claimParameters.merkleRoot ==""|| claimParameters.walletMax ==0, "Cannot provide both mintsPerWallet and merkleRoot");
// Get the index for the new claim
_claimCounts[creatorContractAddress]++;
uint224 newIndex = _claimCounts[creatorContractAddress];
// Create the claim
_claims[creatorContractAddress][newIndex] = Claim({
total: 0,
totalMax: claimParameters.totalMax,
walletMax: claimParameters.walletMax,
startDate: claimParameters.startDate,
endDate: claimParameters.endDate,
storageProtocol: claimParameters.storageProtocol,
identical: claimParameters.identical,
merkleRoot: claimParameters.merkleRoot,
location: claimParameters.location
});
emit ClaimInitialized(creatorContractAddress, newIndex, msg.sender);
return newIndex;
}
/**
* See {IERC721LazyClaim-udpateClaim}.
*/functionupdateClaim(address creatorContractAddress,
uint256 claimIndex,
ClaimParameters calldata claimParameters
) externaloverridecreatorAdminRequired(creatorContractAddress) {
// Sanity checksrequire(_claims[creatorContractAddress][claimIndex].storageProtocol != StorageProtocol.INVALID, "Claim not initialized");
require(claimParameters.storageProtocol != StorageProtocol.INVALID, "Cannot set invalid storage protocol");
require(_claims[creatorContractAddress][claimIndex].totalMax ==0|| _claims[creatorContractAddress][claimIndex].totalMax <= claimParameters.totalMax, "Cannot decrease totalMax");
require(_claims[creatorContractAddress][claimIndex].walletMax ==0|| _claims[creatorContractAddress][claimIndex].walletMax <= claimParameters.walletMax, "Cannot decrease walletMax");
require(claimParameters.endDate ==0|| claimParameters.startDate < claimParameters.endDate, "Cannot have startDate greater than or equal to endDate");
// Overwrite the existing claim
_claims[creatorContractAddress][claimIndex] = Claim({
total: _claims[creatorContractAddress][claimIndex].total,
totalMax: claimParameters.totalMax,
walletMax: claimParameters.walletMax,
startDate: claimParameters.startDate,
endDate: claimParameters.endDate,
storageProtocol: claimParameters.storageProtocol,
identical: claimParameters.identical,
merkleRoot: claimParameters.merkleRoot,
location: claimParameters.location
});
}
/**
* See {IERC721LazyClaim-getClaimCount}.
*/functiongetClaimCount(address creatorContractAddress) externaloverrideviewreturns(uint256) {
return _claimCounts[creatorContractAddress];
}
/**
* See {IERC721LazyClaim-getClaim}.
*/functiongetClaim(address creatorContractAddress, uint256 claimIndex) externaloverrideviewreturns(Claim memory) {
require(_claims[creatorContractAddress][claimIndex].storageProtocol != StorageProtocol.INVALID, "Claim not initialized");
return _claims[creatorContractAddress][claimIndex];
}
/**
* See {IERC721LazyClaim-checkMintIndex}.
*/functioncheckMintIndex(address creatorContractAddress, uint256 claimIndex, uint32 mintIndex) publicoverrideviewreturns(bool) {
Claim storage claim = _claims[creatorContractAddress][claimIndex];
require(claim.storageProtocol != StorageProtocol.INVALID, "Claim not initialized");
require(claim.merkleRoot !="", "Can only check merkle claims");
uint256 claimMintIndex = mintIndex >>8;
uint256 claimMintTracking = _claimMintIndices[creatorContractAddress][claimIndex][claimMintIndex];
uint256 mintBitmask =1<< (mintIndex & MINT_INDEX_BITMASK);
return mintBitmask & claimMintTracking !=0;
}
/**
* See {IERC721LazyClaim-checkMintIndices}.
*/functioncheckMintIndices(address creatorContractAddress, uint256 claimIndex, uint32[] calldata mintIndices) externaloverrideviewreturns(bool[] memory minted) {
minted =newbool[](mintIndices.length);
for (uint i =0; i < mintIndices.length; i++) {
minted[i] = checkMintIndex(creatorContractAddress, claimIndex, mintIndices[i]);
}
}
/**
* See {IERC721LazyClaim-getTotalMints}.
*/functiongetTotalMints(address minter, address creatorContractAddress, uint256 claimIndex) externaloverrideviewreturns(uint32) {
Claim storage claim = _claims[creatorContractAddress][claimIndex];
require(claim.storageProtocol != StorageProtocol.INVALID, "Claim not initialized");
require(claim.walletMax !=0, "Can only retrieve for non-merkle claims with walletMax");
returnuint32(_mintsPerWallet[creatorContractAddress][claimIndex][minter]);
}
/**
* See {IERC721LazyClaim-mint}.
*/functionmint(address creatorContractAddress, uint256 claimIndex, uint32 mintIndex, bytes32[] calldata merkleProof) externaloverride{
Claim storage claim = _claims[creatorContractAddress][claimIndex];
// Safely retrieve the claimrequire(claim.storageProtocol != StorageProtocol.INVALID, "Claim not initialized");
// Check timestampsrequire(claim.startDate ==0|| claim.startDate <block.timestamp, "Transaction before start date");
require(claim.endDate ==0|| claim.endDate >=block.timestamp, "Transaction after end date");
// Check totalMaxrequire(claim.totalMax ==0|| claim.total < claim.totalMax, "Maximum tokens already minted for this claim");
if (claim.merkleRoot !="") {
// Merkle mint
_checkMerkleAndUpdate(claim, creatorContractAddress, claimIndex, mintIndex, merkleProof);
} else {
// Non-merkle mintif (claim.walletMax !=0) {
require(_mintsPerWallet[creatorContractAddress][claimIndex][msg.sender] < claim.walletMax, "Maximum tokens already minted for this wallet");
unchecked{ _mintsPerWallet[creatorContractAddress][claimIndex][msg.sender]++; }
}
}
unchecked{ claim.total++; }
// Do mintuint256 newTokenId = IERC721CreatorCore(creatorContractAddress).mintExtension(msg.sender);
// Insert the new tokenId into _tokenClaims for the current claim address & index
_tokenClaims[creatorContractAddress][newTokenId] = TokenClaim(uint224(claimIndex), claim.total);
emit ClaimMint(creatorContractAddress, claimIndex);
}
/**
* See {IERC721LazyClaim-mintBatch}.
*/functionmintBatch(address creatorContractAddress, uint256 claimIndex, uint16 mintCount, uint32[] calldata mintIndices, bytes32[][] calldata merkleProofs) externaloverride{
Claim storage claim = _claims[creatorContractAddress][claimIndex];
// Safely retrieve the claimrequire(claim.storageProtocol != StorageProtocol.INVALID, "Claim not initialized");
// Check timestampsrequire(claim.startDate ==0|| claim.startDate <block.timestamp, "Transaction before start date");
require(claim.endDate ==0|| claim.endDate >=block.timestamp, "Transaction after end date");
// Check totalMaxrequire(claim.totalMax ==0|| claim.total+mintCount <= claim.totalMax, "Too many requested for this claim");
uint256 newMintIndex = claim.total+1;
unchecked{ claim.total += mintCount; }
if (claim.merkleRoot !="") {
require(mintCount == mintIndices.length&& mintCount == merkleProofs.length, "Invalid input");
// Merkle mintfor (uint i =0; i < mintCount; ) {
uint32 mintIndex = mintIndices[i];
bytes32[] memory merkleProof = merkleProofs[i];
_checkMerkleAndUpdate(claim, creatorContractAddress, claimIndex, mintIndex, merkleProof);
unchecked { i++; }
}
} else {
// Non-merkle mintif (claim.walletMax !=0) {
require(_mintsPerWallet[creatorContractAddress][claimIndex][msg.sender]+mintCount <= claim.walletMax, "Too many requested for this wallet");
unchecked{ _mintsPerWallet[creatorContractAddress][claimIndex][msg.sender] += mintCount; }
}
}
uint256[] memory newTokenIds = IERC721CreatorCore(creatorContractAddress).mintExtensionBatch(msg.sender, mintCount);
for (uint i =0; i < mintCount; ) {
_tokenClaims[creatorContractAddress][newTokenIds[i]] = TokenClaim(uint224(claimIndex), uint32(newMintIndex+i));
unchecked { i++; }
}
emit ClaimMintBatch(creatorContractAddress, claimIndex, mintCount);
}
/**
* Helper to check merkle proof and whether or not the mintIndex was consumed. Also updates the consumed counts
*/function_checkMerkleAndUpdate(Claim storage claim, address creatorContractAddress, uint256 claimIndex, uint32 mintIndex, bytes32[] memory merkleProof) private{
// Merkle mintbytes32 leaf =keccak256(abi.encodePacked(msg.sender, mintIndex));
require(MerkleProof.verify(merkleProof, claim.merkleRoot, leaf), "Could not verify merkle proof");
// Check if mintIndex has been minteduint256 claimMintIndex = mintIndex >>8;
uint256 claimMintTracking = _claimMintIndices[creatorContractAddress][claimIndex][claimMintIndex];
uint256 mintBitmask =1<< (mintIndex & MINT_INDEX_BITMASK);
require(mintBitmask & claimMintTracking ==0, "Already minted");
_claimMintIndices[creatorContractAddress][claimIndex][claimMintIndex] = claimMintTracking | mintBitmask;
}
/**
* See {ICreatorExtensionTokenURI-tokenURI}.
*/functiontokenURI(address creatorContractAddress, uint256 tokenId) externaloverrideviewreturns(stringmemory uri) {
TokenClaim memory tokenClaim = _tokenClaims[creatorContractAddress][tokenId];
require(tokenClaim.claimIndex >0, "Token does not exist");
Claim memory claim = _claims[creatorContractAddress][tokenClaim.claimIndex];
stringmemory prefix ="";
if (claim.storageProtocol == StorageProtocol.ARWEAVE) {
prefix = ARWEAVE_PREFIX;
} elseif (claim.storageProtocol == StorageProtocol.IPFS) {
prefix = IPFS_PREFIX;
}
uri =string(abi.encodePacked(prefix, claim.location));
// Depending on params, we may want to append a suffix to locationif (!claim.identical) {
uri =string(abi.encodePacked(uri, "/", uint256(tokenClaim.mintOrder).toString()));
}
}
}
Contract Source Code
File 5 of 15: EnumerableSet.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)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.
*
* ```
* 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.
*/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) {
return _values(set._inner);
}
// 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;
assembly {
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 on 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;
assembly {
result := store
}
return result;
}
}
Contract Source Code
File 6 of 15: 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 7 of 15: 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);
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);
}
Contract Source Code
File 8 of 15: 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 9 of 15: 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 10 of 15: IERC721CreatorCore.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/// @author: manifold.xyzimport"./ICreatorCore.sol";
/**
* @dev Core ERC721 creator interface
*/interfaceIERC721CreatorCoreisICreatorCore{
/**
* @dev mint a token with no extension. Can only be called by an admin.
* Returns tokenId minted
*/functionmintBase(address to) externalreturns (uint256);
/**
* @dev mint a token with no extension. Can only be called by an admin.
* Returns tokenId minted
*/functionmintBase(address to, stringcalldata uri) externalreturns (uint256);
/**
* @dev batch mint a token with no extension. Can only be called by an admin.
* Returns tokenId minted
*/functionmintBaseBatch(address to, uint16 count) externalreturns (uint256[] memory);
/**
* @dev batch mint a token with no extension. Can only be called by an admin.
* Returns tokenId minted
*/functionmintBaseBatch(address to, string[] calldata uris) externalreturns (uint256[] memory);
/**
* @dev mint a token. Can only be called by a registered extension.
* Returns tokenId minted
*/functionmintExtension(address to) externalreturns (uint256);
/**
* @dev mint a token. Can only be called by a registered extension.
* Returns tokenId minted
*/functionmintExtension(address to, stringcalldata uri) externalreturns (uint256);
/**
* @dev batch mint a token. Can only be called by a registered extension.
* Returns tokenIds minted
*/functionmintExtensionBatch(address to, uint16 count) externalreturns (uint256[] memory);
/**
* @dev batch mint a token. Can only be called by a registered extension.
* Returns tokenId minted
*/functionmintExtensionBatch(address to, string[] calldata uris) externalreturns (uint256[] memory);
/**
* @dev burn a token. Can only be called by token owner or approved address.
* On burn, calls back to the registered extension's onBurn method
*/functionburn(uint256 tokenId) external;
}
Contract Source Code
File 11 of 15: IERC721LazyClaim.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/// @author: manifold.xyz/**
* Lazy Claim interface
*/interfaceIERC721LazyClaim{
enumStorageProtocol { INVALID, NONE, ARWEAVE, IPFS }
structClaimParameters {
uint32 totalMax;
uint32 walletMax;
uint48 startDate;
uint48 endDate;
StorageProtocol storageProtocol;
bool identical;
bytes32 merkleRoot;
string location;
}
structClaim {
uint32 total;
uint32 totalMax;
uint32 walletMax;
uint48 startDate;
uint48 endDate;
StorageProtocol storageProtocol;
bool identical;
bytes32 merkleRoot;
string location;
}
eventClaimInitialized(addressindexed creatorContract, uint224indexed claimIndex, address initializer);
eventClaimMint(addressindexed creatorContract, uint256indexed claimIndex);
eventClaimMintBatch(addressindexed creatorContract, uint256indexed claimIndex, uint16 mintCount);
/**
* @notice initialize a new claim, emit initialize event, and return the newly created index
* @param creatorContractAddress the creator contract the claim will mint tokens for
* @param claimParameters the parameters which will affect the minting behavior of the claim
* @return the index of the newly created claim
*/functioninitializeClaim(address creatorContractAddress, ClaimParameters calldata claimParameters) externalreturns(uint256);
/**
* @notice update an existing claim at claimIndex
* @param creatorContractAddress the creator contract corresponding to the claim
* @param claimIndex the index of the claim in the list of creatorContractAddress' _claims
* @param claimParameters the parameters which will affect the minting behavior of the claim
*/functionupdateClaim(address creatorContractAddress, uint256 claimIndex, ClaimParameters calldata claimParameters) external;
/**
* @notice get the number of _claims initialized for a given creator contract
* @param creatorContractAddress the address of the creator contract
* @return the number of _claims initialized for this creator contract
*/functiongetClaimCount(address creatorContractAddress) externalviewreturns(uint256);
/**
* @notice get a claim corresponding to a creator contract and index
* @param creatorContractAddress the address of the creator contract
* @param claimIndex the index of the claim
* @return the claim object
*/functiongetClaim(address creatorContractAddress, uint256 claimIndex) externalviewreturns(Claim memory);
/**
* @notice check if a mint index has been consumed or not (only for merkle claims)
*
* @param creatorContractAddress the address of the creator contract for the claim
* @param claimIndex the index of the claim
* @param mintIndex the mint index of the claim
* @return whether or not the mint index was consumed
*/functioncheckMintIndex(address creatorContractAddress, uint256 claimIndex, uint32 mintIndex) externalviewreturns(bool);
/**
* @notice check if multiple mint indices has been consumed or not (only for merkle claims)
*
* @param creatorContractAddress the address of the creator contract for the claim
* @param claimIndex the index of the claim
* @param mintIndices the mint index of the claim
* @return whether or not the mint index was consumed
*/functioncheckMintIndices(address creatorContractAddress, uint256 claimIndex, uint32[] calldata mintIndices) externalviewreturns(bool[] memory);
/**
* @notice get mints made for a wallet (only for non-merkle claims with walletMax)
*
* @param minter the address of the minting address
* @param creatorContractAddress the address of the creator contract for the claim
* @param claimIndex the index of the claim
* @return how many mints the minter has made
*/functiongetTotalMints(address minter, address creatorContractAddress, uint256 claimIndex) externalviewreturns(uint32);
/**
* @notice allow a wallet to lazily claim a token according to parameters
* @param creatorContractAddress the creator contract address
* @param claimIndex the index of the claim for which we will mint
* @param mintIndex the mint index (only needed for merkle claims)
* @param merkleProof if the claim has a merkleRoot, verifying merkleProof ensures that address + minterValue was used to construct it (only needed for merkle claims)
*/functionmint(address creatorContractAddress, uint256 claimIndex, uint32 mintIndex, bytes32[] calldata merkleProof) external;
/**
* @notice allow a wallet to lazily claim a token according to parameters
* @param creatorContractAddress the creator contract address
* @param claimIndex the index of the claim for which we will mint
* @param mintCount the number of claims to mint
* @param mintIndices the mint index (only needed for merkle claims)
* @param merkleProofs if the claim has a merkleRoot, verifying merkleProof ensures that address + minterValue was used to construct it (only needed for merkle claims)
*/functionmintBatch(address creatorContractAddress, uint256 claimIndex, uint16 mintCount, uint32[] calldata mintIndices, bytes32[][] calldata merkleProofs) external;
}
Contract Source Code
File 12 of 15: MerkleProof.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol)pragmasolidity ^0.8.0;/**
* @dev These functions deal with verification of Merkle Trees proofs.
*
* The proofs can be generated using the JavaScript library
* https://github.com/miguelmota/merkletreejs[merkletreejs].
* Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
*
* See `test/utils/cryptography/MerkleProof.test.js` for some examples.
*/libraryMerkleProof{
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/functionverify(bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internalpurereturns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merklee tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/functionprocessProof(bytes32[] memory proof, bytes32 leaf) internalpurereturns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i =0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash =keccak256(abi.encodePacked(computedHash, proofElement));
} else {
// Hash(current element of the proof + current computed hash)
computedHash =keccak256(abi.encodePacked(proofElement, computedHash));
}
}
return computedHash;
}
}
Contract Source Code
File 13 of 15: Ownable.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.1 (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 Returns the address of the current owner.
*/functionowner() publicviewvirtualreturns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/modifieronlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing 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 14 of 15: ReentrancyGuard.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.1 (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() {
// On the first call to nonReentrant, _notEntered will be truerequire(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
Contract Source Code
File 15 of 15: Strings.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)pragmasolidity ^0.8.0;/**
* @dev String operations.
*/libraryStrings{
bytes16privateconstant _HEX_SYMBOLS ="0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/functiontoString(uint256 value) internalpurereturns (stringmemory) {
// Inspired by OraclizeAPI's implementation - MIT licence// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.solif (value ==0) {
return"0";
}
uint256 temp = value;
uint256 digits;
while (temp !=0) {
digits++;
temp /=10;
}
bytesmemory buffer =newbytes(digits);
while (value !=0) {
digits -=1;
buffer[digits] =bytes1(uint8(48+uint256(value %10)));
value /=10;
}
returnstring(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/functiontoHexString(uint256 value) internalpurereturns (stringmemory) {
if (value ==0) {
return"0x00";
}
uint256 temp = value;
uint256 length =0;
while (temp !=0) {
length++;
temp >>=8;
}
return toHexString(value, length);
}
/**
* @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] = _HEX_SYMBOLS[value &0xf];
value >>=4;
}
require(value ==0, "Strings: hex length insufficient");
returnstring(buffer);
}
}