Skip to content

Commit

Permalink
s1 badge upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
bearni95 committed Dec 19, 2024
1 parent 7486688 commit 8a18f7d
Show file tree
Hide file tree
Showing 9 changed files with 617 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract TrailblazersBadgesV5 is TrailblazersBadgesV4 {
/// @notice Start recruitment for a badge
/// @param _badgeId Badge ID
/// @param _tokenId Token ID
function startRecruitment(uint256 _badgeId, uint256 _tokenId) public {
function startRecruitment(uint256 _badgeId, uint256 _tokenId) public virtual {
if (recruitmentLockDuration == 0) {
revert RECRUITMENT_LOCK_DURATION_NOT_SET();
}
Expand Down
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);
}
}
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);
}
}
4 changes: 4 additions & 0 deletions packages/nfts/deployments/snaefell/hekla.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Owner": "0xB73b0FC4C0Cfc73cF6e034Af6f6b42Ebe6c8b49D",
"SnaefellToken": "0xD57b9EE8f597801e82018ed44e07E9065645B0c1"
}
4 changes: 3 additions & 1 deletion packages/nfts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
"tbz:upgradeV4:mainnet": "forge clean && pnpm compile && forge script script/trailblazers-badges/UpgradeV4.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --gas-estimate-multiplier 100",
"tbz-s2:upgradeV2:mainnet": "forge clean && pnpm compile && forge script script/trailblazers-season-2/UpgradeV2.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --gas-estimate-multiplier 100",
"tbz-s2:upgradeRecruitmentV2:hekla": "forge clean && pnpm compile && forge script script/trailblazers-season-2/RecruitmentUpgradeV2.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200",
"tbz-s2:upgradeRecruitmentV2:mainnet": "forge clean && pnpm compile && forge script script/trailblazers-season-2/RecruitmentUpgradeV2.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --gas-estimate-multiplier 100"
"tbz-s2:upgradeRecruitmentV2:mainnet": "forge clean && pnpm compile && forge script script/trailblazers-season-2/RecruitmentUpgradeV2.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --gas-estimate-multiplier 100",
"tbz:upgradeV6:mainnet": "forge clean && pnpm compile && forge script script/trailblazers-season-2/UpgradeS1BadgesV6.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --gas-estimate-multiplier 100",
"tbz:upgradeV7:mainnet": "forge clean && pnpm compile && forge script script/trailblazers-season-2/UpgradeS1BadgesV7.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --gas-estimate-multiplier 100"
},
"devDependencies": {
"@types/node": "^20.11.30",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,25 @@ contract UpgradeV2 is Script {
// mainnet config
address public s1TokenAddress = 0xa20a8856e00F5ad024a55A663F06DCc419FFc4d5;
address public badgeRecruitmentAddress = 0xa9Ceb04F3aF71fF123409d426A92BABb5124970C;
/*
/*
// hekla config
string baseURI =
"https://taikonfts.4everland.link/ipfs/bafybeiatuzeeeznd3hi5qiulslxcjd22ebu45t4fra2jvi3smhocr2c66a";
"https://taikonfts.4everland.link/ipfs/bafybeiatuzeeeznd3hi5qiulslxcjd22ebu45t4fra2jvi3smhocr2c66a";
IMinimalBlacklist blacklist = IMinimalBlacklist(0xe61E9034b5633977eC98E302b33e321e8140F105);
address claimMintSigner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266;
address recruitmentSigner = 0x3cda4F2EaC3fc2FdE78B3DFFe1A1A1Eff88c68c5;
uint256 public MAX_INFLUENCES = 5;
uint256 public MAX_INFLUENCES = 5;
uint256 public COOLDOWN_RECRUITMENT = 10 minutes;
uint256 public COOLDOWN_INFLUENCE = 5 minutes;
uint256 public INFLUENCE_WEIGHT_PERCENT = 9;
uint256 public MAX_INFLUENCES_DIVIDER = 100;
uint256 public DEFAULT_CYCLE_DURATION = 7 days;
uint256 public s1EndDate = 1_734_350_400; // Dec 16th 2024, noon UTC
uint256 public S1_LOCK_DURATION = (s1EndDate - block.timestamp);
*/
*/

function setUp() public {
utils = new UtilsScript();
utils.setUp();
Expand All @@ -56,10 +57,10 @@ contract UpgradeV2 is Script {
function run() public {
vm.startBroadcast(deployerPrivateKey);

// address impl;
// address proxy;
// address impl;
// address proxy;
TrailblazersBadgesV4 s1Token;
// TrailblazersBadgesS2 s2Token;
// TrailblazersBadgesS2 s2Token;
BadgeRecruitment badgeRecruitment;

if (block.chainid == 167_000) {
Expand Down Expand Up @@ -98,7 +99,7 @@ contract UpgradeV2 is Script {
proxy = address(
new ERC1967Proxy(
impl,
abi.encodeCall(TrailblazersBadgesS2.initialize, (deployerAddress, baseURI))
abi.encodeCall(TrailblazersBadgesS2.initialize, (deployerAddress, baseURI))
)
);
Expand Down
53 changes: 53 additions & 0 deletions packages/nfts/script/trailblazers-season-2/UpgradeS1BadgesV6.s.sol
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 packages/nfts/script/trailblazers-season-2/UpgradeS1BadgesV7.s.sol
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));
}
}
Loading

0 comments on commit 8a18f7d

Please sign in to comment.