Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nfts): blacklist integration #17217

Merged
merged 13 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/nfts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ lcov.info
broadcast
.states
coverage
data/original
data/images
data/metadata
data/taikoon/original
data/taikoon/images
data/taikoon/metadata
lcov.info
lib
data/whitelist/hardhat.csv
data/whitelist/holesky.csv
data/whitelist/mainnet.csv
data/whitelist/*.json
data/taikoon/whitelist/hardhat.csv
data/taikoon/whitelist/holesky.csv
data/taikoon/whitelist/mainnet.csv
data/taikoon/whitelist/*.json
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
}

Expand Down
14 changes: 0 additions & 14 deletions packages/nfts/data/taikoons-32.json

This file was deleted.

5 changes: 5 additions & 0 deletions packages/nfts/deployments/taikoon/devnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"MerkleRoot": "0x1c71ed62062e13d65812291988bfef0460682d875100761c58592d17c18555a9",
"Owner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"TaikoonToken": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"
}
5 changes: 5 additions & 0 deletions packages/nfts/deployments/taikoon/holesky.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"MerkleRoot": "0x3e2da39414868a8a49c4ee78da50cc4430d88df27060300e553810ab2d23b5bd",
"Owner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"TaikoonToken": "0xfDbaA6d6c382A2555856bFaB315D5E6F3CDA1393"
}
5 changes: 5 additions & 0 deletions packages/nfts/deployments/taikoon/localhost.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"MerkleRoot": "0x1c3b504b4d5640d26ad1aa3b57a9df9ec034f19239768e734b849c306d10b110",
"Owner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"TaikoonToken": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0"
}
1 change: 1 addition & 0 deletions packages/nfts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ remappings = [
"p256-verifier/=node_modules/p256-verifier/",
"murky/=node_modules/murky/src/",
"solidity-stringutils/=node_modules/solidity-stringutils/",
"@taiko/blacklist/=node_modules/@taiko/supplementary-contracts/contracts/blacklist/",
]

# Do not change the block_gas_limit value, TaikoL2.t.sol depends on it.
Expand Down
15 changes: 9 additions & 6 deletions packages/nfts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
"lint:sol": "forge fmt && pnpm solhint 'contracts/**/*.sol'",
"test": "pnpm clean && pnpm compile && forge test --match-path 'test/*.t.sol' -vvv",
"node": "anvil",
"merkle": "node script/js/generate-merkle-tree.js",
"deploy:localhost": "forge clean && pnpm compile && forge script script/sol/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast",
"deploy:holesky": "forge clean && pnpm compile && forge script script/sol/Deploy.s.sol --rpc-url https://l1rpc.hekla.taiko.xyz/ --broadcast --gas-estimate-multiplier 200",
"deploy:ipfs": "rm -rf data/metadata/* && node script/js/resize-images.js && node script/js/4everland.js",
"deploy:devnet": "forge clean && pnpm compile && forge script script/sol/Deploy.s.sol --rpc-url https://rpc.internal.taiko.xyz --broadcast --gas-estimate-multiplier 200"
"taikoon:merkle": "node script/taikoon/js/generate-merkle-tree.js",
"taikoon:deploy:localhost": "forge clean && pnpm compile && forge script script/taikoon/sol/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast",
"taikoon:deploy:holesky": "forge clean && pnpm compile && forge script script/taikoon/sol/Deploy.s.sol --rpc-url https://l1rpc.hekla.taiko.xyz/ --broadcast --gas-estimate-multiplier 200",
"taikoon:deploy:ipfs": "rm -rf data/metadata/* && node script/taikoon/js/4everland.js",
"taikoon:deploy:devnet": "forge clean && pnpm compile && forge script script/taikoon/sol/Deploy.s.sol --rpc-url https://rpc.internal.taiko.xyz --broadcast --gas-estimate-multiplier 200",
"merkle": "pnpm taikoon:merkle",
"deploy:ipfs": "pnpm taikoon:deploy:ipfs"
},
"devDependencies": {
"@types/node": "^20.11.30",
Expand Down Expand Up @@ -49,6 +51,7 @@
"p256-verifier": "github:taikoxyz/p256-verifier#v0.1.0",
"sharp": "^0.33.3",
"solady": "github:Vectorized/solady#v0.0.167",
"solidity-stringutils": "github:Arachnid/solidity-stringutils"
"solidity-stringutils": "github:Arachnid/solidity-stringutils",
"@taiko/supplementary-contracts": "workspace:*"
}
}
120 changes: 0 additions & 120 deletions packages/nfts/script/js/add-images-ipfs.js

This file was deleted.

56 changes: 0 additions & 56 deletions packages/nfts/script/js/resize-images.js

This file was deleted.

Loading
Loading