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): korea blockchain week contract deployment #17916

Merged
merged 38 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
70c03b3
contract and basic tests
bearni95 Jul 17, 2024
06b0607
fixed comment typo
bearni95 Jul 17, 2024
287c4f1
linted and formatted
bearni95 Jul 30, 2024
6d6a6b7
deployment scripts
bearni95 Jul 30, 2024
e1aa36d
cleanup
bearni95 Jul 30, 2024
68fedc1
reverted changes to taikoon data
bearni95 Jul 30, 2024
fed511c
change revert cleanup
bearni95 Jul 30, 2024
cbfe8ee
Merge branch 'main' into kbw-contracts-setup
bearni95 Jul 30, 2024
1e101bb
Update packages/nfts/contracts/party-ticket/TaikoPartyTicket.sol
bearni95 Jul 30, 2024
5d92631
removal of tokenId from tokenURI logic, beyond determining the winner
bearni95 Jul 30, 2024
ba7845a
Merge branch 'main' into kbw-contracts-setup
bearni95 Jul 30, 2024
61f729e
added mintWinner method
bearni95 Jul 30, 2024
96d7309
Merge branch 'main' into kbw-contracts-setup
bearni95 Jul 31, 2024
3e4f009
Deployment updates for taiko-party-ticket
bearni95 Aug 7, 2024
5dc4952
Merge branch 'kbw-contracts-setup' of ssh://github.com/taikoxyz/taiko…
bearni95 Aug 7, 2024
bfaa57f
modifications for single-dir ipfs data root
bearni95 Aug 7, 2024
00d48a2
proper values for ipfs hekla testing
bearni95 Aug 7, 2024
4e78bc4
dev push
bearni95 Aug 7, 2024
7f47c85
uncommented dev lines
bearni95 Aug 7, 2024
a3aef0e
proper hekla deployment
bearni95 Aug 7, 2024
7d057a9
reverted error changes
bearni95 Aug 7, 2024
6f6f51d
patched up tests
bearni95 Aug 7, 2024
d7049cf
gap allocation fix; blacklist modifier
bearni95 Aug 8, 2024
3dcf0e2
added revokeWinners method
bearni95 Aug 8, 2024
5f7f4c1
modified code and added tests for upgradeability
bearni95 Aug 8, 2024
7d405f2
Merge branch 'main' into kbw-contracts-setup
bearni95 Aug 8, 2024
1ee33de
upgrade test confirmations
bearni95 Aug 8, 2024
997174e
Merge branch 'kbw-contracts-setup' of ssh://github.com/taikoxyz/taiko…
bearni95 Aug 8, 2024
c535e82
a typo...
bearni95 Aug 8, 2024
1ceacc3
uncommented blacklist modifier
bearni95 Aug 8, 2024
c660131
updated ipfs data with winner image
bearni95 Aug 8, 2024
e6b495b
deployment values
bearni95 Aug 14, 2024
b1ab805
removed unused owner role
bearni95 Aug 14, 2024
804f9a6
updated 'withdraw' to 'payout', as it's executed by the admin
bearni95 Aug 14, 2024
452d902
reverted protocol changes
bearni95 Aug 14, 2024
b6efa46
reverted protocol changes
bearni95 Aug 14, 2024
0751962
updated deployment price point
bearni95 Aug 14, 2024
388fd54
final adjustments for prod values
bearni95 Aug 14, 2024
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
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