-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
617 additions
and
10 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
98 changes: 98 additions & 0 deletions
98
packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV6.sol
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,98 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import "./TrailblazersS1BadgesV5.sol"; | ||
import "./BadgeRecruitment.sol"; | ||
import "./BadgeRecruitmentV2.sol"; | ||
|
||
contract TrailblazersBadgesV6 is TrailblazersBadgesV5 { | ||
/// @notice Updated version function | ||
/// @return Version string | ||
function version() external pure virtual override returns (string memory) { | ||
return "V6"; | ||
} | ||
/// @notice Errors | ||
|
||
error BADGE_LOCKED_SEASON_2(); | ||
|
||
/// @notice Season end timestamps | ||
uint256 public season2EndTimestamp; // 1734350400 | ||
uint256 public season3EndTimestamp; // 1742212800 | ||
|
||
/// @notice Setter for season 2 end timestamps | ||
/// @param _ts Timestamp | ||
/// @dev Only owner can set the timestamp | ||
function setSeason2EndTimestamp(uint256 _ts) public virtual onlyOwner { | ||
season2EndTimestamp = _ts; | ||
} | ||
|
||
/// @notice Setter for season 3 end timestamps | ||
/// @param _ts Timestamp | ||
/// @dev Only owner can set the timestamp | ||
function setSeason3EndTimestamp(uint256 _ts) public virtual onlyOwner { | ||
season3EndTimestamp = _ts; | ||
} | ||
|
||
/// @notice Modifier to ensure a badge isn't locked on a recruitment for that season | ||
/// @param tokenId Badge token id | ||
modifier isNotLocked(uint256 tokenId) virtual { | ||
if (unlockTimestamps[tokenId] > 0 && block.timestamp < season2EndTimestamp) { | ||
// s2 | ||
revert BADGE_LOCKED(); | ||
} else if ( | ||
unlockTimestamps[tokenId] == season3EndTimestamp | ||
&& block.timestamp > season2EndTimestamp && block.timestamp < season3EndTimestamp | ||
) { | ||
// s3 | ||
revert BADGE_LOCKED_SEASON_2(); | ||
} | ||
_; | ||
} | ||
|
||
/// @notice Overwritten update function that prevents locked badges from being transferred | ||
/// @param to Address to transfer badge to | ||
/// @param tokenId Badge token id | ||
/// @param auth Address to authorize transfer | ||
/// @return Address of the recipient | ||
function _update( | ||
address to, | ||
uint256 tokenId, | ||
address auth | ||
) | ||
internal | ||
virtual | ||
override | ||
isNotLocked(tokenId) | ||
returns (address) | ||
{ | ||
return super._update(to, tokenId, auth); | ||
} | ||
|
||
/// @notice Start recruitment for a badge | ||
/// @param _badgeId Badge ID | ||
/// @param _tokenId Token ID | ||
function startRecruitment( | ||
uint256 _badgeId, | ||
uint256 _tokenId | ||
) | ||
public | ||
virtual | ||
override | ||
isNotLocked(_tokenId) | ||
{ | ||
if (recruitmentLockDuration == 0) { | ||
revert RECRUITMENT_LOCK_DURATION_NOT_SET(); | ||
} | ||
if (ownerOf(_tokenId) != _msgSender()) { | ||
revert NOT_OWNER(); | ||
} | ||
|
||
if (block.timestamp < season2EndTimestamp) { | ||
unlockTimestamps[_tokenId] = season2EndTimestamp; | ||
} else { | ||
unlockTimestamps[_tokenId] = season3EndTimestamp; | ||
} | ||
|
||
recruitmentContractV2.startRecruitment(_msgSender(), _badgeId, _tokenId); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV7.sol
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,77 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import "./TrailblazersS1BadgesV6.sol"; | ||
import "./BadgeRecruitment.sol"; | ||
import "./BadgeRecruitmentV2.sol"; | ||
|
||
contract TrailblazersBadgesV7 is TrailblazersBadgesV6 { | ||
/// @notice Updated version function | ||
/// @return Version string | ||
function version() external pure virtual override returns (string memory) { | ||
return "V7"; | ||
} | ||
|
||
/// @notice Modifier to ensure a badge isn't locked on a recruitment for that season | ||
/// @param tokenId Badge token id | ||
modifier isNotLockedV7(uint256 tokenId) virtual { | ||
if (unlockTimestamps[tokenId] > 0 && block.timestamp < season2EndTimestamp) { | ||
// s2 | ||
revert BADGE_LOCKED(); | ||
} else if ( | ||
unlockTimestamps[tokenId] == season3EndTimestamp | ||
&& block.timestamp > season2EndTimestamp && block.timestamp < season3EndTimestamp | ||
) { | ||
// s3 | ||
revert BADGE_LOCKED_SEASON_2(); | ||
} | ||
_; | ||
} | ||
|
||
/// @notice Overwritten update function that prevents locked badges from being transferred | ||
/// @param to Address to transfer badge to | ||
/// @param tokenId Badge token id | ||
/// @param auth Address to authorize transfer | ||
/// @return Address of the recipient | ||
function _update( | ||
address to, | ||
uint256 tokenId, | ||
address auth | ||
) | ||
internal | ||
virtual | ||
override | ||
isNotLockedV7(tokenId) | ||
returns (address) | ||
{ | ||
return super._update(to, tokenId, auth); | ||
} | ||
|
||
/// @notice Start recruitment for a badge | ||
/// @param _badgeId Badge ID | ||
/// @param _tokenId Token ID | ||
function startRecruitment( | ||
uint256 _badgeId, | ||
uint256 _tokenId | ||
) | ||
public | ||
virtual | ||
override | ||
isNotLockedV7(_tokenId) | ||
{ | ||
if (recruitmentLockDuration == 0) { | ||
revert RECRUITMENT_LOCK_DURATION_NOT_SET(); | ||
} | ||
if (ownerOf(_tokenId) != _msgSender()) { | ||
revert NOT_OWNER(); | ||
} | ||
|
||
if (block.timestamp < season2EndTimestamp) { | ||
unlockTimestamps[_tokenId] = season2EndTimestamp; | ||
} else { | ||
unlockTimestamps[_tokenId] = season3EndTimestamp; | ||
} | ||
|
||
recruitmentContractV2.startRecruitment(_msgSender(), _badgeId, _tokenId); | ||
} | ||
} |
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,4 @@ | ||
{ | ||
"Owner": "0xB73b0FC4C0Cfc73cF6e034Af6f6b42Ebe6c8b49D", | ||
"SnaefellToken": "0xD57b9EE8f597801e82018ed44e07E9065645B0c1" | ||
} |
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
53 changes: 53 additions & 0 deletions
53
packages/nfts/script/trailblazers-season-2/UpgradeS1BadgesV6.s.sol
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,53 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import { UtilsScript } from "./Utils.s.sol"; | ||
import { Script, console } from "forge-std/src/Script.sol"; | ||
import { Merkle } from "murky/Merkle.sol"; | ||
import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
import { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; | ||
import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; | ||
|
||
import "../../contracts/trailblazers-season-2/TrailblazersS1BadgesV5.sol"; | ||
import "../../contracts/trailblazers-season-2/TrailblazersS1BadgesV6.sol"; | ||
|
||
contract UpgradeS1BadgesV6 is Script { | ||
UtilsScript public utils; | ||
string public jsonLocation; | ||
uint256 public deployerPrivateKey; | ||
address public deployerAddress; | ||
|
||
address public s1TokenAddress = 0xa20a8856e00F5ad024a55A663F06DCc419FFc4d5; | ||
TrailblazersBadgesV6 public token; | ||
|
||
uint256 public SEASON_2_END_TS = 1_734_350_400; | ||
uint256 public SEASON_3_END_TS = 1_742_212_800; | ||
//1_734_387_911 | ||
|
||
function setUp() public { | ||
utils = new UtilsScript(); | ||
utils.setUp(); | ||
|
||
jsonLocation = utils.getContractJsonLocation(); | ||
deployerPrivateKey = utils.getPrivateKey(); | ||
deployerAddress = utils.getAddress(); | ||
} | ||
|
||
function run() public { | ||
vm.startBroadcast(deployerPrivateKey); | ||
TrailblazersBadgesV5 tokenV5 = TrailblazersBadgesV5(s1TokenAddress); | ||
|
||
tokenV5.upgradeToAndCall( | ||
address(new TrailblazersBadgesV6()), abi.encodeCall(TrailblazersBadgesV6.version, ()) | ||
); | ||
|
||
token = TrailblazersBadgesV6(address(tokenV5)); | ||
|
||
console.log("Upgraded TrailblazersBadgesV6 on:", address(token)); | ||
|
||
token.setSeason2EndTimestamp(SEASON_2_END_TS); | ||
console.log("Updated s2 end timestamp to:", SEASON_2_END_TS); | ||
token.setSeason3EndTimestamp(SEASON_3_END_TS); | ||
console.log("Updated s3 end timestamp to:", SEASON_3_END_TS); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
packages/nfts/script/trailblazers-season-2/UpgradeS1BadgesV7.s.sol
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,47 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.24; | ||
|
||
import { UtilsScript } from "./Utils.s.sol"; | ||
import { Script, console } from "forge-std/src/Script.sol"; | ||
import { Merkle } from "murky/Merkle.sol"; | ||
import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
import { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; | ||
import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; | ||
|
||
import "../../contracts/trailblazers-season-2/TrailblazersS1BadgesV6.sol"; | ||
import "../../contracts/trailblazers-season-2/TrailblazersS1BadgesV7.sol"; | ||
|
||
contract UpgradeS1BadgesV7 is Script { | ||
UtilsScript public utils; | ||
string public jsonLocation; | ||
uint256 public deployerPrivateKey; | ||
address public deployerAddress; | ||
|
||
address public s1TokenAddress = 0xa20a8856e00F5ad024a55A663F06DCc419FFc4d5; | ||
TrailblazersBadgesV7 public token; | ||
|
||
uint256 public SEASON_2_END_TS = 1_734_350_400; | ||
uint256 public SEASON_3_END_TS = 1_742_212_800; | ||
|
||
function setUp() public { | ||
utils = new UtilsScript(); | ||
utils.setUp(); | ||
|
||
jsonLocation = utils.getContractJsonLocation(); | ||
deployerPrivateKey = utils.getPrivateKey(); | ||
deployerAddress = utils.getAddress(); | ||
} | ||
|
||
function run() public { | ||
vm.startBroadcast(deployerPrivateKey); | ||
TrailblazersBadgesV6 tokenV6 = TrailblazersBadgesV6(s1TokenAddress); | ||
|
||
tokenV6.upgradeToAndCall( | ||
address(new TrailblazersBadgesV7()), abi.encodeCall(TrailblazersBadgesV7.version, ()) | ||
); | ||
|
||
token = TrailblazersBadgesV7(address(tokenV6)); | ||
|
||
console.log("Upgraded TrailblazersBadgesV7 on:", address(token)); | ||
} | ||
} |
Oops, something went wrong.