forked from taikoxyz/taiko-mono
-
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.
feat(nfts): blacklist integration (taikoxyz#17217)
- Loading branch information
Showing
25 changed files
with
12,214 additions
and
10,020 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
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 |
---|---|---|
|
@@ -8,41 +8,61 @@ import { Ownable2StepUpgradeable } from | |
import { MerkleProof } from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; | ||
import { ContextUpgradeable } from | ||
"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; | ||
import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; | ||
|
||
/// @title MerkleWhitelist | ||
/// @dev Merkle Tree Whitelist | ||
/// @custom:security-contact [email protected] | ||
contract MerkleWhitelist is ContextUpgradeable, UUPSUpgradeable, Ownable2StepUpgradeable { | ||
event RootUpdated(bytes32 _root); | ||
event MintConsumed(address _minter, uint256 _mintAmount); | ||
event BlacklistUpdated(address _blacklist); | ||
|
||
error MINTS_EXCEEDED(); | ||
error INVALID_PROOF(); | ||
error INVALID_TOKEN_AMOUNT(); | ||
error ADDRESS_BLACKLISTED(); | ||
|
||
/// @notice Merkle Tree Root | ||
bytes32 public root; | ||
/// @notice Tracker for minted leaves | ||
mapping(bytes32 leaf => bool hasMinted) public minted; | ||
|
||
uint256[48] private __gap; | ||
/// @notice Blackist address | ||
IMinimalBlacklist public blacklist; | ||
/// @notice Gap for upgrade safety | ||
uint256[47] private __gap; | ||
|
||
/// @custom:oz-upgrades-unsafe-allow constructor | ||
constructor() { | ||
_disableInitializers(); | ||
} | ||
|
||
/// @notice Update the blacklist address | ||
/// @param _blacklist The new blacklist address | ||
function updateBlacklist(IMinimalBlacklist _blacklist) external onlyOwner { | ||
blacklist = _blacklist; | ||
emit BlacklistUpdated(address(_blacklist)); | ||
} | ||
|
||
/// @notice Contract initializer | ||
/// @param _root Merkle Tree root | ||
function initialize(address _owner, bytes32 _root) external initializer { | ||
__MerkleWhitelist_init(_owner, _root); | ||
function initialize( | ||
address _owner, | ||
bytes32 _root, | ||
IMinimalBlacklist _blacklist | ||
) | ||
external | ||
initializer | ||
{ | ||
__MerkleWhitelist_init(_owner, _root, _blacklist); | ||
} | ||
|
||
/// @notice Check if a wallet can free mint | ||
/// @param _minter Address of the minter | ||
/// @param _maxMints Max amount of free mints | ||
/// @return Whether the wallet can mint | ||
function canMint(address _minter, uint256 _maxMints) public view returns (bool) { | ||
if (blacklist.isBlacklisted(_minter)) revert ADDRESS_BLACKLISTED(); | ||
bytes32 _leaf = leaf(_minter, _maxMints); | ||
return !minted[_leaf]; | ||
} | ||
|
@@ -57,10 +77,18 @@ contract MerkleWhitelist is ContextUpgradeable, UUPSUpgradeable, Ownable2StepUpg | |
|
||
/// @notice Internal initializer | ||
/// @param _root Merkle Tree root | ||
function __MerkleWhitelist_init(address _owner, bytes32 _root) internal initializer { | ||
function __MerkleWhitelist_init( | ||
address _owner, | ||
bytes32 _root, | ||
IMinimalBlacklist _blacklist | ||
) | ||
internal | ||
initializer | ||
{ | ||
_transferOwnership(_owner == address(0) ? msg.sender : _owner); | ||
__Context_init(); | ||
root = _root; | ||
blacklist = _blacklist; | ||
} | ||
|
||
/// @notice Update the merkle tree's root | ||
|
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 |
---|---|---|
|
@@ -7,17 +7,18 @@ import { ERC721EnumerableUpgradeable } from | |
"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; | ||
|
||
import { MerkleWhitelist } from "./MerkleWhitelist.sol"; | ||
import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; | ||
|
||
/// @title TaikoonToken | ||
/// @dev The Taikoons ERC-721 token | ||
/// @custom:security-contact [email protected] | ||
contract TaikoonToken is ERC721EnumerableUpgradeable, MerkleWhitelist { | ||
/// @notice The current supply | ||
uint256 private _totalSupply; | ||
// Base URI required to interact with IPFS | ||
/// @notice Base URI required to interact with IPFS | ||
string private _baseURIExtended; | ||
|
||
uint256[48] private __gap; | ||
/// @notice Gap for upgrade safety | ||
uint256[47] private __gap; | ||
|
||
error MAX_MINTS_EXCEEDED(); | ||
error MAX_SUPPLY_REACHED(); | ||
|
@@ -30,13 +31,14 @@ contract TaikoonToken is ERC721EnumerableUpgradeable, MerkleWhitelist { | |
function initialize( | ||
address _owner, | ||
string memory _rootURI, | ||
bytes32 _merkleRoot | ||
bytes32 _merkleRoot, | ||
IMinimalBlacklist _blacklistAddress | ||
) | ||
external | ||
initializer | ||
{ | ||
__ERC721_init("Taikoon", "TKOON"); | ||
__MerkleWhitelist_init(_owner, _merkleRoot); | ||
__MerkleWhitelist_init(_owner, _merkleRoot, _blacklistAddress); | ||
_baseURIExtended = _rootURI; | ||
} | ||
|
||
|
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
{ | ||
"MerkleRoot": "0x1c71ed62062e13d65812291988bfef0460682d875100761c58592d17c18555a9", | ||
"Owner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", | ||
"TaikoonToken": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" | ||
} |
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,5 @@ | ||
{ | ||
"MerkleRoot": "0x3e2da39414868a8a49c4ee78da50cc4430d88df27060300e553810ab2d23b5bd", | ||
"Owner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", | ||
"TaikoonToken": "0xfDbaA6d6c382A2555856bFaB315D5E6F3CDA1393" | ||
} |
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,5 @@ | ||
{ | ||
"MerkleRoot": "0x1c3b504b4d5640d26ad1aa3b57a9df9ec034f19239768e734b849c306d10b110", | ||
"Owner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", | ||
"TaikoonToken": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0" | ||
} |
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.