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): trailblazers badges s2 #18040

Merged
merged 96 commits into from
Dec 2, 2024
Merged
Changes from 1 commit
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
14e5501
scaffolding for s2 tbz contracts
bearni95 Aug 27, 2024
1b722cd
simplified and unified contracts
bearni95 Aug 28, 2024
d926dae
added clarification method on BadgeMigration
bearni95 Aug 28, 2024
0c74f75
partial tests and proper, full implementation
bearni95 Sep 2, 2024
70ac2c0
flow for start, tamper and end migrations
bearni95 Sep 2, 2024
fafcffa
enabling of badgeIds and revert case tests
bearni95 Sep 2, 2024
fc5a771
feature-complete tests
bearni95 Sep 2, 2024
55379a7
natspec docs for s2 badges contract
bearni95 Sep 2, 2024
82d4fa0
hekla deployment script and typo fix
bearni95 Sep 2, 2024
b6a1e2b
minor cleanup
bearni95 Sep 2, 2024
8bc8fbf
hekla testing
bearni95 Sep 3, 2024
d898be4
frontend changes
bearni95 Sep 4, 2024
f64468c
ideal 8-participant structure, tests
bearni95 Sep 5, 2024
de82834
latest hekla deployment
bearni95 Sep 5, 2024
3db7acf
Merge branch 'tbz-s2-setup' into nfts-tbz-s2-champion-game-draft
bearni95 Sep 5, 2024
af66ab9
pnpm scripts cleanup
bearni95 Sep 5, 2024
4ad9fbe
game implementation with leagues
bearni95 Sep 5, 2024
64fcd42
contract simplification: pending event-driven tests
bearni95 Sep 5, 2024
506492f
runcommand added
bearni95 Sep 6, 2024
8979d9d
badge champions update
bearni95 Sep 7, 2024
dce2579
Merge branch 'main' into nfts-tbz-s2-champion-game-draft
bearni95 Sep 11, 2024
46cdf8b
forge fmt & update contract layout table
bearni95 Sep 11, 2024
284112f
s2 deployments hekla updates
bearni95 Sep 11, 2024
6920914
Merge branch 'nfts-tbz-s2-champion-game-draft' of ssh://github.com/ta…
bearni95 Sep 11, 2024
c53cb86
swapping branches
bearni95 Sep 12, 2024
934104e
s2 badges rework
bearni95 Sep 18, 2024
b6211bf
added pfps mainnet deployment
bearni95 Sep 18, 2024
161dbc0
Merge branch 'main' into nfts-tbz-s2-champion-game-draft
bearni95 Sep 19, 2024
e6a0f9a
updated hash method
bearni95 Oct 1, 2024
0d66eb2
badge champions comment corrections
bearni95 Oct 1, 2024
03301d2
badge champions comment corrections
bearni95 Oct 1, 2024
87e1e7b
cleanup
bearni95 Oct 2, 2024
fef0cb6
Merge branch 'main' into nfts-tbz-s2-champion-game-draft
bearni95 Oct 2, 2024
89bfd87
Merge branch 'main' into nfts-tbz-s2-champion-game-draft
bearni95 Oct 3, 2024
521b7de
refactored s2 contracts onto their own locations
bearni95 Oct 3, 2024
44ac3ac
fmt, lint
bearni95 Oct 3, 2024
7e81f01
Merge branch 'main' into nfts-tbz-s2-champion-game-draft
bearni95 Oct 4, 2024
edf7704
latest hekla deployment
bearni95 Oct 4, 2024
1a28ce7
safekeeping
bearni95 Oct 9, 2024
6178142
tbz updated blacklist
bearni95 Oct 10, 2024
439b237
Merge branch 'main' of ssh://github.com/taikoxyz/taiko-mono
bearni95 Oct 11, 2024
f50eeb6
Merge branch 'main' of ssh://github.com/taikoxyz/taiko-mono
bearni95 Oct 16, 2024
ec62b64
approvals, start, tampers fully tested on front
bearni95 Oct 16, 2024
df62c0e
working code; needs cleanup
bearni95 Oct 17, 2024
7d53685
safekeep commit before refactors
bearni95 Oct 17, 2024
18b71c2
refactored erc1155 aside
bearni95 Oct 17, 2024
3f37702
extended erc1155 tests
bearni95 Oct 17, 2024
e338efd
refactored out migrations; passing tests; needs cleanup
bearni95 Oct 17, 2024
f09204a
refactored migration using structs
bearni95 Oct 17, 2024
60ec90a
refactored config
bearni95 Oct 17, 2024
257e12d
tests for config refactor
bearni95 Oct 17, 2024
84ceaee
post-mint reading states simplified
bearni95 Oct 17, 2024
c752fb4
cycle tests
bearni95 Oct 17, 2024
eceb798
refactored events for simplicity
bearni95 Oct 17, 2024
5f55660
refactored max tampers to be exp-bound
bearni95 Oct 17, 2024
98c374b
natspec comment, cleanup
bearni95 Oct 17, 2024
7473c5b
hekla deployment script
bearni95 Oct 17, 2024
f86e632
pre-merge commit
bearni95 Oct 17, 2024
cb0e4a8
Merge branch 'main' of ssh://github.com/taikoxyz/taiko-mono
bearni95 Oct 17, 2024
7604c55
Merge branch 'main' into nfts-tbz-s2-champion-game-draft
bearni95 Oct 17, 2024
65e8127
reverted unwanted changes
bearni95 Oct 17, 2024
dcd0d06
refactored s1 badges being frozen for a year, rather than burnt
bearni95 Oct 21, 2024
b2d7258
added dev as s2 badge
bearni95 Oct 22, 2024
1ab2afd
added exp-driven badge claims
bearni95 Oct 22, 2024
f5799da
Merge branch 'main' into nfts-tbz-s2-champion-game-draft
bearni95 Oct 22, 2024
13e7401
restored unwanted changes
bearni95 Oct 22, 2024
74b4a54
typo fix
bearni95 Oct 22, 2024
2094baf
updated endMigration function; emit migrationComplete event
bearni95 Oct 22, 2024
17b1220
updated deployment
bearni95 Oct 22, 2024
4737123
updated migration
bearni95 Oct 22, 2024
01dcb14
qa deployment
bearni95 Oct 23, 2024
db244bc
updated hekla deployment
bearni95 Oct 23, 2024
dd231aa
addressed review comments
bearni95 Oct 25, 2024
ffdc316
Merge branch 'main' into nfts-tbz-s2-champion-game-draft
bearni95 Oct 25, 2024
4615fec
hekla deployment and taikoons contract replacement
bearni95 Oct 25, 2024
8c781aa
Merge branch 'main' into nfts-tbz-s2-champion-game-draft
bearni95 Oct 28, 2024
c1b6c7f
removal of dev s2 badges
bearni95 Oct 31, 2024
deffd9b
cleanup
bearni95 Oct 31, 2024
f42edee
refactored naming
bearni95 Nov 4, 2024
a61e28c
Merge branch 'nfts-tbz-s2-champion-game-draft' of ssh://github.com/ta…
bearni95 Nov 4, 2024
bb1f34a
cleanup
bearni95 Nov 4, 2024
d383eea
hekla deployment
bearni95 Nov 4, 2024
f889c2a
recruitment type and hash split
bearni95 Nov 6, 2024
88c6d59
updated hekla deployment
bearni95 Nov 14, 2024
dc9a65b
qa deployment
bearni95 Nov 14, 2024
099aa8b
predeployment commit
bearni95 Nov 28, 2024
8213699
production deployment
bearni95 Nov 28, 2024
999f49e
Merge branch 'main' of ssh://github.com/taikoxyz/taiko-mono
bearni95 Dec 2, 2024
093fbcc
Merge branch 'main' into nfts-tbz-s2-champion-game-draft
bearni95 Dec 2, 2024
548217b
reverted unwanted changes on external packages
bearni95 Dec 2, 2024
f4e5bea
restored workflow
bearni95 Dec 2, 2024
83e2d4a
restored gha
bearni95 Dec 2, 2024
5dd4fab
restored docs-site
bearni95 Dec 2, 2024
56765ab
restored protocol
bearni95 Dec 2, 2024
637d193
solved gh errors
bearni95 Dec 2, 2024
258333d
refactored folders
bearni95 Dec 2, 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
Prev Previous commit
Next Next commit
enabling of badgeIds and revert case tests
bearni95 committed Sep 2, 2024
commit fafcffa9f0e6a8c8e9dab5444f089acc7836ef32
Original file line number Diff line number Diff line change
@@ -67,6 +67,10 @@ contract TrailblazersBadgesS2 is
error CONTRACT_PAUSED();
error MIGRATION_NOT_READY();
error TOKEN_NOT_MINTED();
error MIGRATION_NOT_ENABLED();


event MigrationEnabled(uint256 _s1BadgeId, bool _enabled);

mapping(uint256 _s1BadgeId => bool _enabled) public enabledBadgeIds;

@@ -103,11 +107,19 @@ contract TrailblazersBadgesS2 is
_;
}

modifier migrationOpen(uint256 _s1BadgeId) {
if (!enabledBadgeIds[_s1BadgeId]){
revert MIGRATION_NOT_ENABLED();
}
_;
}

function initialize(address _badges) external initializer {
__ERC1155_init("");
__ERC1155Supply_init();
_transferOwnership(_msgSender());
__Context_init();
_grantRole(DEFAULT_ADMIN_ROLE, _msgSender());

badges = TrailblazersBadges(_badges);
}
@@ -117,7 +129,7 @@ contract TrailblazersBadgesS2 is
/// @dev Not all badges are eligible for migration at the same time
/// @dev Defines a cooldown for the migration to be complete
/// @dev the cooldown is lesser the higher the Pass Tier
function startMigration(uint256 _s1BadgeId) external {
function startMigration(uint256 _s1BadgeId) external migrationOpen(_s1BadgeId) isNotMigrating {
uint256 s1TokenId = badges.getTokenId(_msgSender(), _s1BadgeId);
if (badges.ownerOf(s1TokenId) != _msgSender()) {
revert TOKEN_NOT_MINTED();
@@ -183,31 +195,26 @@ contract TrailblazersBadgesS2 is
userBadges[_msgSender()][s2BadgeId] = s2TokenId;
}

/// @notice Get the max tamper amount for the calling user and their Trail tier
/// @return The maximum tamper amount
function getMaximumTampers() external view returns (uint256) { }

/// @notice supportsInterface implementation
/// @param interfaceId The interface ID
/// @return Whether the interface is supported
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC1155Upgradeable, AccessControlUpgradeable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}

/// @notice Internal method to authorize an upgrade
function _authorizeUpgrade(address) internal virtual override onlyOwner { }

function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) {
for (uint256 i = 0; i < 8; i++) {
if (enabledBadgeIds[i]) {
emit MigrationEnabled(i, false);
}

enabledBadgeIds[i] = false;
}
}

function enableMigrations(
uint256[] calldata _s1BadgeIds
) external onlyRole(DEFAULT_ADMIN_ROLE) {
for (uint256 i = 0; i < _s1BadgeIds.length; i++) {
enabledBadgeIds[_s1BadgeIds[i]] = true;
emit MigrationEnabled(_s1BadgeIds[i], true);
}
}

function paused(uint256 _s1Badge) public view returns (bool) {
for (uint256 i = 0; i < 8; i++) {
if (enabledBadgeIds[i] && i == _s1Badge) {
@@ -274,4 +281,21 @@ contract TrailblazersBadgesS2 is

return _balance;
}


/// @notice supportsInterface implementation
/// @param interfaceId The interface ID
/// @return Whether the interface is supported
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC1155Upgradeable, AccessControlUpgradeable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}

/// @notice Internal method to authorize an upgrade
function _authorizeUpgrade(address) internal virtual override onlyOwner { }

}
25 changes: 25 additions & 0 deletions packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol
Original file line number Diff line number Diff line change
@@ -70,6 +70,13 @@ contract TrailblazersBadgesTest is Test {
MAX_TAMPERS = s2Badges.MAX_TAMPERS();

s1Badges.setSeason2BadgeContract(address(s2Badges));

// enable migration for BADGE_ID
uint256[] memory enabledBadgeIds = new uint256[](1);
enabledBadgeIds[0] = BADGE_ID;
s2Badges.enableMigrations(enabledBadgeIds);


vm.stopBroadcast();
}

@@ -319,6 +326,24 @@ contract TrailblazersBadgesTest is Test {
vm.stopPrank();
}

function test_revert_migrateDisabled() public {
uint256 badgeId = s1Badges.BADGE_ROBOTS();
mint_s1(minters[0], badgeId);

uint256 tokenId = s1Badges.tokenOfOwnerByIndex(minters[0], 0);

vm.startPrank(minters[0]);
s1Badges.approve(address(s2Badges), tokenId);
vm.expectRevert();
s2Badges.startMigration(badgeId);
vm.stopPrank();
// ensure no values got changed/updated
assertEq(s1Badges.balanceOf(minters[0]), 1);
assertEq(s1Badges.balanceOf(address(s2Badges)), 0);
assertEq(s1Badges.ownerOf(tokenId), minters[0]);
assertEq(s2Badges.isMigrationActive(minters[0]), false);
}

/*
function test_simulateS1() public {
vm.prank(minters[0]);
Loading
Oops, something went wrong.