-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
draft limited edition contract (ex-ERC721AB)
- Loading branch information
Showing
1 changed file
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
// ██████████████████████████████████ | ||
// ██████████████████████████████████ | ||
// ██████████████████████████████████ | ||
// ██████████████████████████████████ | ||
// ██████████████████████████████████ | ||
// ██████████████████████████████████ | ||
// ██████████████████████████████████ | ||
// ██████████████████████████████████ | ||
// ██████████████████████████████████ | ||
// ████████████████████████ ██████████ | ||
// ████████████████████████ ██████████ | ||
// ████████████████████████ ██████████ | ||
// ████████████████████████ ██████████ | ||
// ████████████████████ | ||
// ████████████████████ | ||
// ████████████████████ | ||
// ████████████████████ | ||
// | ||
// | ||
// █████╗ ███╗ ██╗ ██████╗ ████████╗██╗ ██╗███████╗██████╗ ██████╗ ██╗ ██████╗ ██████╗██╗ ██╗ | ||
// ██╔══██╗████╗ ██║██╔═══██╗╚══██╔══╝██║ ██║██╔════╝██╔══██╗██╔══██╗██║ ██╔═══██╗██╔════╝██║ ██╔╝ | ||
// ███████║██╔██╗ ██║██║ ██║ ██║ ███████║█████╗ ██████╔╝██████╔╝██║ ██║ ██║██║ █████╔╝ | ||
// ██╔══██║██║╚██╗██║██║ ██║ ██║ ██╔══██║██╔══╝ ██╔══██╗██╔══██╗██║ ██║ ██║██║ ██╔═██╗ | ||
// ██║ ██║██║ ╚████║╚██████╔╝ ██║ ██║ ██║███████╗██║ ██║██████╔╝███████╗╚██████╔╝╚██████╗██║ ██╗ | ||
// ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚══════╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝ | ||
// | ||
|
||
/** | ||
* @title ERC721ABLE | ||
* @author anotherblock Technical Team | ||
* @notice anotherblock ERC721 contract used for regular mint mechanism & limited edition | ||
* | ||
*/ | ||
|
||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.18; | ||
|
||
/* Openzeppelin Contract */ | ||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; | ||
|
||
/* anotherblock Contract */ | ||
import {ERC721AB} from "src/token/ERC721/ERC721AB.sol"; | ||
|
||
/* anotherblock Libraries */ | ||
import {ABDataTypes} from "src/libraries/ABDataTypes.sol"; | ||
import {ABErrors} from "src/libraries/ABErrors.sol"; | ||
import {ABEvents} from "src/libraries/ABEvents.sol"; | ||
|
||
/* anotherblock Interfaces */ | ||
import {IABVerifier} from "src/utils/IABVerifier.sol"; | ||
import {IABDataRegistry} from "src/utils/IABDataRegistry.sol"; | ||
|
||
contract ERC721ABLE is ERC721AB { | ||
// _____ __ __ | ||
// / ___// /_____ _/ /____ _____ | ||
// \__ \/ __/ __ `/ __/ _ \/ ___/ | ||
// ___/ / /_/ /_/ / /_/ __(__ ) | ||
// /____/\__/\__,_/\__/\___/____/ | ||
|
||
/// @dev Supply cap for this collection | ||
uint256 public maxSupply; | ||
|
||
/// @dev ERC721AB implementation version | ||
uint8 public constant IMPLEMENTATION_VERSION = 1; | ||
|
||
// ______ __ __ | ||
// / ____/___ ____ _____/ /________ _______/ /_____ _____ | ||
// / / / __ \/ __ \/ ___/ __/ ___/ / / / ___/ __/ __ \/ ___/ | ||
// / /___/ /_/ / / / (__ ) /_/ / / /_/ / /__/ /_/ /_/ / / | ||
// \____/\____/_/ /_/____/\__/_/ \__,_/\___/\__/\____/_/ | ||
|
||
/** | ||
* @notice | ||
* Contract Constructor | ||
*/ | ||
/// @custom:oz-upgrades-unsafe-allow constructor | ||
constructor() { | ||
_disableInitializers(); | ||
} | ||
|
||
// ______ __ __ ______ __ _ | ||
// / ____/ __/ /____ _________ ____ _/ / / ____/_ ______ _____/ /_(_)___ ____ _____ | ||
// / __/ | |/_/ __/ _ \/ ___/ __ \/ __ `/ / / /_ / / / / __ \/ ___/ __/ / __ \/ __ \/ ___/ | ||
// / /____> </ /_/ __/ / / / / / /_/ / / / __/ / /_/ / / / / /__/ /_/ / /_/ / / / (__ ) | ||
// /_____/_/|_|\__/\___/_/ /_/ /_/\__,_/_/ /_/ \__,_/_/ /_/\___/\__/_/\____/_/ /_/____/ | ||
|
||
/** | ||
* @notice | ||
* Mint `_quantity` tokens to `_to` address based on the current `_phaseId` if `_signature` is valid | ||
* | ||
* @param _to token recipient address (must be whitelisted) | ||
* @param _phaseId current minting phase (must be started) | ||
* @param _quantity quantity of tokens requested (must be less than max mint per phase) | ||
* @param _signature signature to verify allowlist status | ||
*/ | ||
function mint(address _to, uint256 _phaseId, uint256 _quantity, bytes calldata _signature) | ||
external | ||
payable | ||
override | ||
{ | ||
// Check that the requested minting phase has started | ||
if (!_isPhaseActive(_phaseId)) revert ABErrors.PHASE_NOT_ACTIVE(); | ||
|
||
// Get requested phase details | ||
ABDataTypes.Phase memory phase = phases[_phaseId]; | ||
|
||
// Check that there are enough tokens available for sale | ||
if (_totalMinted() + _quantity > maxSupply) { | ||
revert ABErrors.NOT_ENOUGH_TOKEN_AVAILABLE(); | ||
} | ||
|
||
// Check if the current phase is private | ||
if (!phase.isPublic) { | ||
// Check that the user is included in the allowlist | ||
if (!abVerifier.verifySignature721(_to, address(this), _phaseId, _signature)) { | ||
revert ABErrors.NOT_ELIGIBLE(); | ||
} | ||
} | ||
|
||
// Check that user did not mint / is not asking to mint more than the max mint per address for the current phase | ||
if (mintedPerPhase[_to][_phaseId] + _quantity > phase.maxMint) revert ABErrors.MAX_MINT_PER_ADDRESS(); | ||
|
||
// Check that user is sending the correct amount of ETH (will revert if user send too much or not enough) | ||
if (msg.value != phase.price * _quantity) revert ABErrors.INCORRECT_ETH_SENT(); | ||
|
||
// Set quantity minted for `_to` during the current phase | ||
mintedPerPhase[_to][_phaseId] += _quantity; | ||
|
||
// Mint `_quantity` amount to `_to` address | ||
_mint(_to, _quantity); | ||
} | ||
|
||
// ____ __ ___ __ _ | ||
// / __ \____ / /_ __ / | ____/ /___ ___ (_)___ | ||
// / / / / __ \/ / / / / / /| |/ __ / __ `__ \/ / __ \ | ||
// / /_/ / / / / / /_/ / / ___ / /_/ / / / / / / / / / / | ||
// \____/_/ /_/_/\__, / /_/ |_\__,_/_/ /_/ /_/_/_/ /_/ | ||
// /____/ | ||
|
||
/** | ||
* @notice | ||
* Initialize the Drop parameters | ||
* Only the contract owner can perform this operation | ||
* | ||
* @param _maxSupply supply cap for this drop | ||
* @param _sharePerToken percentage ownership of the full master right for one token (to be divided by 1e6) | ||
* @param _mintGenesis amount of genesis tokens to be minted | ||
* @param _genesisRecipient recipient address of genesis tokens | ||
* @param _royaltyCurrency royalty currency contract address | ||
* @param _baseUri base URI for this drop | ||
*/ | ||
function initDrop( | ||
uint256 _maxSupply, | ||
uint256 _sharePerToken, | ||
uint256 _mintGenesis, | ||
address _genesisRecipient, | ||
address _royaltyCurrency, | ||
string calldata _baseUri | ||
) external override onlyOwner { | ||
// Check that the drop hasn't been already initialized | ||
if (dropId != 0) revert ABErrors.DROP_ALREADY_INITIALIZED(); | ||
|
||
// Check that share per token & royalty currency are consistent | ||
if ( | ||
(_sharePerToken == 0 && _royaltyCurrency != address(0)) | ||
|| (_royaltyCurrency == address(0) && _sharePerToken != 0) | ||
) revert ABErrors.INVALID_PARAMETER(); | ||
|
||
// Register Drop within ABDropRegistry | ||
dropId = abDataRegistry.registerDrop(publisher, _royaltyCurrency, 0); | ||
|
||
// Set supply cap | ||
maxSupply = _maxSupply; | ||
|
||
// Set the royalty share | ||
sharePerToken = _sharePerToken; | ||
|
||
// Set base URI | ||
baseTokenURI = _baseUri; | ||
|
||
// Mint Genesis tokens to `_genesisRecipient` address | ||
if (_mintGenesis > 0) { | ||
if (_mintGenesis > _maxSupply) revert ABErrors.INVALID_PARAMETER(); | ||
_mint(_genesisRecipient, _mintGenesis); | ||
} | ||
} | ||
|
||
/** | ||
* @notice | ||
* Set the maximum supply | ||
* Only the contract owner can perform this operation | ||
* | ||
* @param _maxSupply new maximum supply to be set | ||
*/ | ||
function setMaxSupply(uint256 _maxSupply) external onlyOwner { | ||
if (_maxSupply < _totalMinted()) revert ABErrors.INVALID_PARAMETER(); | ||
maxSupply = _maxSupply; | ||
} | ||
} |