Skip to content

Commit

Permalink
feat(nfts): korea blockchain week contract deployment (#17916)
Browse files Browse the repository at this point in the history
Co-authored-by: Kenk <[email protected]>
  • Loading branch information
bearni95 and 2manslkh authored Aug 16, 2024
1 parent dd40a4e commit 74a00b9
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 28 deletions.
34 changes: 19 additions & 15 deletions packages/nfts/contracts/party-ticket/TaikoPartyTicket.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ contract TaikoPartyTicket is
{
event BlacklistUpdated(address _blacklist);

/// @notice Owner role
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE");
/// @notice Mint fee
uint256 public mintFee;
/// @notice Mint active flag
Expand Down Expand Up @@ -79,7 +77,6 @@ contract TaikoPartyTicket is
blacklist = _blacklistAddress;

_grantRole(DEFAULT_ADMIN_ROLE, _msgSender());
_grantRole(OWNER_ROLE, _payoutAddress);

_transferOwnership(_msgSender());
}
Expand All @@ -102,12 +99,13 @@ contract TaikoPartyTicket is
/// @param tokenId The token ID
/// @return The token URI
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (winners[tokenId]) {
if (winnerIds.length == 0) {
return string(abi.encodePacked(baseURI, "/raffle.json"));
} else if (winners[tokenId]) {
return string(abi.encodePacked(baseURI, "/winner.json"));
} else if (paused()) {
} else {
return string(abi.encodePacked(baseURI, "/loser.json"));
}
return string(abi.encodePacked(baseURI, "/raffle.json"));
}

/// @notice Checks if a tokenId is a winner
Expand All @@ -133,14 +131,13 @@ contract TaikoPartyTicket is
/// @param _winners The list of winning token ids
function setWinners(uint256[] calldata _winners)
external
whenNotPaused
whenPaused
onlyRole(DEFAULT_ADMIN_ROLE)
{
for (uint256 i = 0; i < _winners.length; i++) {
winners[_winners[i]] = true;
winnerIds.push(_winners[i]);
}
pause();
}

/// @notice Set the base URI
Expand Down Expand Up @@ -215,11 +212,7 @@ contract TaikoPartyTicket is

/// @notice Revoke a winner's status
/// @param tokenIds The IDs of the winner to revoke
function revokeWinners(uint256[] calldata tokenIds)
external
whenPaused
onlyRole(DEFAULT_ADMIN_ROLE)
{
function revokeWinners(uint256[] calldata tokenIds) external onlyRole(DEFAULT_ADMIN_ROLE) {
for (uint256 i = 0; i < tokenIds.length; i++) {
revokeWinner(tokenIds[i]);
}
Expand All @@ -233,7 +226,6 @@ contract TaikoPartyTicket is
uint256 newWinnerId
)
external
whenPaused
onlyRole(DEFAULT_ADMIN_ROLE)
{
if (!winners[revokeId]) revert CANNOT_REVOKE_NON_WINNER();
Expand All @@ -254,10 +246,16 @@ contract TaikoPartyTicket is
_unpause();
}

/// @notice Update the payout address
/// @param _payoutAddress The new payout address
function updatePayoutAddress(address _payoutAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
payoutAddress = _payoutAddress;
}

/// @notice Withdraw the contract balance
/// @dev Can only be called by the admin
/// @dev Requires the contract to be paused
function withdraw() external whenPaused onlyRole(DEFAULT_ADMIN_ROLE) {
function payout() external whenPaused onlyRole(DEFAULT_ADMIN_ROLE) {
payable(payoutAddress).transfer(address(this).balance);
}

Expand All @@ -277,6 +275,12 @@ contract TaikoPartyTicket is
return _winners;
}

/// @notice Get the winner addresses
/// @return bool if the winners have been set
function areWinnersSet() public view returns (bool) {
return winnerIds.length > 0;
}

/// @notice supportsInterface implementation
/// @param interfaceId The interface ID
/// @return Whether the interface is supported
Expand Down
2 changes: 1 addition & 1 deletion packages/nfts/data/party-token/metadata/loser.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "[L] KBW Party Raffle Ticket",
"description": "A raffle ticket for the KBW Party. This ticket won nothing at the raffle.",
"image": "https://taikonfts.4everland.link/ipfs/bafybeibmuovja47ghveaiosvz442lkjb5oduiebydsgwob7r2xzm7d3yne/loser.png"
"image": "https://taikonfts.4everland.link/ipfs/bafybeialwrhlnfb46o3mdd2gcrrc3ksf5exuji5lmwwcljynae4kdq4pae/loser.png"
}
2 changes: 1 addition & 1 deletion packages/nfts/data/party-token/metadata/raffle.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "KBW Party Raffle Ticket",
"description": "A raffle ticket for the KBW Party. This ticket gives you a chance to win a special prize.",
"image": "https://taikonfts.4everland.link/ipfs/bafybeibmuovja47ghveaiosvz442lkjb5oduiebydsgwob7r2xzm7d3yne/raffle.png"
"image": "https://taikonfts.4everland.link/ipfs/bafybeialwrhlnfb46o3mdd2gcrrc3ksf5exuji5lmwwcljynae4kdq4pae/raffle.png"
}
4 changes: 2 additions & 2 deletions packages/nfts/data/party-token/metadata/winner.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "[W] KBW Party Raffle Ticket",
"description": "A raffle ticket for the KBW Party. This ticket won a special prize at the raffle.",
"image": "https://taikonfts.4everland.link/ipfs/bafybeibmuovja47ghveaiosvz442lkjb5oduiebydsgwob7r2xzm7d3yne/winner.gif",
"animation_url": "https://taikonfts.4everland.link/ipfs/bafybeibmuovja47ghveaiosvz442lkjb5oduiebydsgwob7r2xzm7d3yne/winner.gif"
"image": "https://taikonfts.4everland.link/ipfs/bafybeialwrhlnfb46o3mdd2gcrrc3ksf5exuji5lmwwcljynae4kdq4pae/winner.gif",
"animation_url": "https://taikonfts.4everland.link/ipfs/bafybeialwrhlnfb46o3mdd2gcrrc3ksf5exuji5lmwwcljynae4kdq4pae/winner.gif"
}
Binary file modified packages/nfts/data/party-token/static/winner.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/nfts/deployments/party-ticket/hekla.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"TaikoPartyTicket": "0x166fbdF89A3bFE470cA2BA5Bd4a7058Bb93b3595"
"TaikoPartyTicket": "0x1fE073fb9C749Ba99aab01aEc4E9d08875ea55a9"
}
9 changes: 4 additions & 5 deletions packages/nfts/script/party-ticket/sol/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ contract DeployScript is Script {
uint256 public deployerPrivateKey;
address public deployerAddress;

// Hardhat Testnet Values
string baseURI =
"https://taikonfts.4everland.link/ipfs/bafybeighqzbsghqsnlo2ksf2afvbhyym6xde7cdoz2nri2xcoctuy7rya4";
IMinimalBlacklist blacklist = IMinimalBlacklist(0xe61E9034b5633977eC98E302b33e321e8140F105);
"https://taikonfts.4everland.link/ipfs/bafybeia5mmkauevbhs4fm6wfib5wfifefrwfremlc67whrrgsgzj46kfsm";
IMinimalBlacklist blacklist = IMinimalBlacklist(0xfA5EA6f9A13532cd64e805996a941F101CCaAc9a);

uint256 mintFee = 0.03 ether;
address payoutWallet = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266;
uint256 mintFee = 0.002 ether;
address payoutWallet = 0x2e44474B7F5726908ef509B6C8d561fA40a52f90;

function setUp() public {
utils = new UtilsScript();
Expand Down
9 changes: 6 additions & 3 deletions packages/nfts/test/party-ticket/TaikoPartyTicket.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,13 @@ contract TaikoPartyTicketTest is Test {
uint256 winnerTokenId = 0;

// set minters[0] as winner
vm.prank(admin);
vm.startPrank(admin);
uint256[] memory winners = new uint256[](1);
winners[0] = winnerTokenId;
// ability to pause the minting and set the winners later
token.pause();
token.setWinners(winners);
vm.stopPrank();
// check winner with both tokenId and address
assertTrue(token.isWinner(winnerTokenId));
assertTrue(token.isWinner(minters[0]));
Expand All @@ -101,11 +104,11 @@ contract TaikoPartyTicketTest is Test {
assertEq(address(token).balance, MINT_FEE * minters.length);
}

function test_withdraw() public {
function test_payout() public {
test_winnerFlow();
uint256 collectedEth = address(token).balance;
vm.prank(admin);
token.withdraw();
token.payout();
assertEq(payoutWallet.balance, collectedEth);
assertEq(address(token).balance, 0);
}
Expand Down

0 comments on commit 74a00b9

Please sign in to comment.