From 14e55017708769f830e08f9b8df41e7a853772cc Mon Sep 17 00:00:00 2001 From: bearni95 Date: Tue, 27 Aug 2024 22:10:55 +0200 Subject: [PATCH 01/79] scaffolding for s2 tbz contracts --- .../trailblazers-badges/TrailPass.sol | 224 +++++++++++++++++ .../trailblazers-badges/TrailRaffle.sol | 176 +++++++++++++ .../TrailblazersSigils.sol | 233 ++++++++++++++++++ 3 files changed, 633 insertions(+) create mode 100644 packages/nfts/contracts/trailblazers-badges/TrailPass.sol create mode 100644 packages/nfts/contracts/trailblazers-badges/TrailRaffle.sol create mode 100644 packages/nfts/contracts/trailblazers-badges/TrailblazersSigils.sol diff --git a/packages/nfts/contracts/trailblazers-badges/TrailPass.sol b/packages/nfts/contracts/trailblazers-badges/TrailPass.sol new file mode 100644 index 00000000000..d392e308325 --- /dev/null +++ b/packages/nfts/contracts/trailblazers-badges/TrailPass.sol @@ -0,0 +1,224 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol"; +import "./ECDSAWhitelist.sol"; +import "@taiko/blacklist/IMinimalBlacklist.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; +import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; +import "@taiko/blacklist/IMinimalBlacklist.sol"; +import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; +import "@openzeppelin/contracts/access/AccessControl.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; +import "@taiko/blacklist/IMinimalBlacklist.sol"; +import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; + +contract TrailPass is + PausableUpgradeable, + UUPSUpgradeable, + Ownable2StepUpgradeable, + AccessControlUpgradeable, + ERC1155SupplyUpgradeable +{ + // important wallets + address public levelUpSigner; + + // token ids + uint256 public constant PASS_TIER_A_PINK = 0; + uint256 public constant PASS_TIER_A_PURPLE = 1; + uint256 public constant PASS_TIER_B_PINK = 2; + uint256 public constant PASS_TIER_B_PURPLE = 3; + uint256 public constant PASS_TIER_C_PINK = 4; + uint256 public constant PASS_TIER_C_PURPLE = 5; + + mapping(address _user => uint256 _exp) public userExp; + + uint256[] public TOKEN_IDS = [ + PASS_TIER_A_PINK, + PASS_TIER_A_PURPLE, + PASS_TIER_B_PINK, + PASS_TIER_B_PURPLE, + PASS_TIER_C_PINK, + PASS_TIER_C_PURPLE + ]; + + // tier prices + uint256 public constant TIER_A_PRICE = 10 ether; + uint256 public constant TIER_B_PRICE = 5 ether; + uint256 public constant TIER_C_PRICE = 3 ether; + + uint256[42] private __gap; + + error TOKEN_CANNOT_BE_TRANSFERRED(); + error BATTLE_PASS_ALREADY_OWNED(); + error BATTLE_PASS_NOT_OWNED(); + error INVALID_TIER(); + error INVALID_LEVEL_UP_SIGNATURE(); + error INVALID_EXP_AMOUNT(); + + function initialize(address _levelUpSigner) external initializer { + __ERC1155_init(""); + __ERC1155Supply_init(); + _transferOwnership(_msgSender()); + __Context_init(); + + levelUpSigner = _levelUpSigner; + } + + modifier onlyNewUser() { + if (hasPass(_msgSender())) { + revert BATTLE_PASS_ALREADY_OWNED(); + } + _; + } + + modifier requireBattlePass(uint256 _tier) { + if (!hasPass(_msgSender(), _tier)) { + revert BATTLE_PASS_NOT_OWNED(); + } + _; + } + + modifier requireAnyBattlePass() { + if (!hasPass(_msgSender())) { + revert BATTLE_PASS_NOT_OWNED(); + } + _; + } + + function getTierPrice(uint256 _tokenId) public view returns (uint256) { + if (_tokenId == PASS_TIER_A_PINK || _tokenId == PASS_TIER_A_PURPLE) { + return TIER_A_PRICE; + } else if (_tokenId == PASS_TIER_B_PINK || _tokenId == PASS_TIER_B_PURPLE) { + return TIER_B_PRICE; + } else if (_tokenId == PASS_TIER_C_PINK || _tokenId == PASS_TIER_C_PURPLE) { + return TIER_C_PRICE; + } + revert INVALID_TIER(); + } + + function mint(uint256 _tier) public payable onlyNewUser { + uint256 price = getTierPrice(_tier); + if (msg.value < price) { + revert("Insufficient funds"); + } + + _mint(_msgSender(), _tier, 1, ""); + } + + function withdrawStake() public requireAnyBattlePass { + uint256 tier = getUserTier(_msgSender()); + uint256 price = getTierPrice(tier); + _burn(_msgSender(), tier, 1); + payable(_msgSender()).transfer(price); + } + + function hasPass(address _user, uint256 _tier) public view returns (bool) { + return balanceOf(_user, _tier) > 0; + } + + function hasPass(address _user) public view returns (bool) { + for (uint256 i = 0; i < TOKEN_IDS.length; i++) { + if (hasPass(_user, TOKEN_IDS[i])) { + return true; + } + } + return false; + } + + function getUserTier(address _user) public view returns (uint256 tier) { + for (uint256 i = 0; i < TOKEN_IDS.length; i++) { + if (hasPass(_user, TOKEN_IDS[i])) { + return TOKEN_IDS[i]; + } + } + revert BATTLE_PASS_NOT_OWNED(); + } + + // makes the season pass non-transferable + function _update( + address from, + address to, + uint256[] memory ids, + uint256[] memory values + ) + internal + override + { + if (from != address(0)) { + revert TOKEN_CANNOT_BE_TRANSFERRED(); + } + super._update(from, to, ids, values); + } + + /// @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 { } + + // todo: methods to register points from the backend + /// @notice Generate a standardized hash for externally signing + /// @param _minter Address of the minter + /// @param _tokenId ID for the token to mint + function getHash(address _minter, uint256 _tokenId) public pure returns (bytes32) { + return keccak256(bytes.concat(keccak256(abi.encode(_minter, _tokenId)))); + } + + function _isSignatureValid( + bytes memory _signature, + address _minter, + uint256 _exp + ) + internal + view + returns (bool) + { + bytes32 _hash = getHash(_minter, _exp); + (address _recovered,,) = ECDSA.tryRecover(_hash, _signature); + + return _recovered == levelUpSigner; + } + + function getExp(address _user) public view returns (uint256) { + if (!hasPass(_user)) { + revert BATTLE_PASS_NOT_OWNED(); + } + return userExp[_user]; + } + + function getLevel(address _user) public view returns (uint256) { + if (!hasPass(_user)) { + revert BATTLE_PASS_NOT_OWNED(); + } + return userExp[_user] / 100; + } + + function levelUp(uint256 _exp, bytes memory _signature) public requireAnyBattlePass { + if (!_isSignatureValid(_signature, _msgSender(), _exp)) { + revert INVALID_LEVEL_UP_SIGNATURE(); + } + if (_exp < getExp(_msgSender())) { + revert INVALID_EXP_AMOUNT(); + } + userExp[_msgSender()] = _exp; + } +} diff --git a/packages/nfts/contracts/trailblazers-badges/TrailRaffle.sol b/packages/nfts/contracts/trailblazers-badges/TrailRaffle.sol new file mode 100644 index 00000000000..b0f73495f38 --- /dev/null +++ b/packages/nfts/contracts/trailblazers-badges/TrailRaffle.sol @@ -0,0 +1,176 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; +import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; +import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; +import "@openzeppelin/contracts/access/Ownable.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; +import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; +import "./TrailPass.sol"; + +// todo: integrate with trailPass + +contract RaffleERC1155 is + PausableUpgradeable, + UUPSUpgradeable, + Ownable2StepUpgradeable, + AccessControlUpgradeable, + ERC1155SupplyUpgradeable +{ + struct Prize { + address tokenAddress; + uint256 tokenId; // For ERC721 and ERC1155 + uint256 amount; // For ERC20 and ERC1155 + } + + struct Raffle { + uint256 trailPassTier; + uint256 startTime; + uint256 endTime; + uint256 ticketPrice; // Price in ETH + address[] prizeTokens; + mapping(address => Prize[]) prizes; + mapping(address => uint256) ticketsPurchased; // Track tickets purchased per participant + } + + // Mapping from raffle ID to Raffle details + mapping(uint256 => Raffle) public raffles; + uint256 public raffleCount; + + event RaffleCreated(uint256 raffleId, uint256 startTime, uint256 endTime, uint256 ticketPrice, address[] prizeTokens); + event PrizeAdded(uint256 raffleId, address tokenAddress, uint256 tokenId, uint256 amount); + event RaffleEntered(uint256 raffleId, address participant, uint256 numberOfTickets); + event TicketPriceUpdated(uint256 raffleId, uint256 newPrice); + + + TrailPass public trailPass; + function initialize( address _trailPass) external initializer { + __ERC1155_init(""); + __ERC1155Supply_init(); + _transferOwnership(_msgSender()); + __Context_init(); + trailPass = TrailPass(_trailPass); + } + + function createRaffle( + uint256 _tier, + uint256 _startTime, + uint256 _endTime, + uint256 _ticketPrice, + address[] memory _prizeTokens + ) external onlyOwner { + if (_startTime >= _endTime) revert StartTimeMustBeBeforeEndTime(); + if (_ticketPrice == 0) revert TicketPriceMustBeGreaterThanZero(); + + raffleCount++; + Raffle storage newRaffle = raffles[raffleCount]; + + newRaffle.trailPassTier = _tier; + newRaffle.startTime = _startTime; + newRaffle.endTime = _endTime; + newRaffle.ticketPrice = _ticketPrice; + newRaffle.prizeTokens = _prizeTokens; + + emit RaffleCreated(raffleCount, _startTime, _endTime, _ticketPrice, _prizeTokens); + } + + function addPrize( + uint256 raffleId, + address tokenAddress, + uint256 tokenId, + uint256 amount + ) external onlyOwner { + if (raffleId == 0 || raffleId > raffleCount) revert InvalidRaffleId(); + if (amount == 0) revert AmountMustBeGreaterThanZero(); + + Raffle storage raffle = raffles[raffleId]; + + raffle.prizes[tokenAddress].push(Prize({ + tokenAddress: tokenAddress, + tokenId: tokenId, + amount: amount + })); + + emit PrizeAdded(raffleId, tokenAddress, tokenId, amount); + } + + function updateTicketPrice(uint256 raffleId, uint256 newPrice) external onlyOwner { + if (raffleId == 0 || raffleId > raffleCount) revert InvalidRaffleId(); + if (newPrice == 0) revert TicketPriceMustBeGreaterThanZero(); + + Raffle storage raffle = raffles[raffleId]; + raffle.ticketPrice = newPrice; + + emit TicketPriceUpdated(raffleId, newPrice); + } + + function enterRaffle(uint256 raffleId, uint256 numberOfTickets) external payable { + if (raffleId == 0 || raffleId > raffleCount) revert InvalidRaffleId(); + if (numberOfTickets == 0) revert NumberOfTicketsMustBeGreaterThanZero(); + if (msg.value != raffles[raffleId].ticketPrice * numberOfTickets) revert IncorrectETHAmount(); + + Raffle storage raffle = raffles[raffleId]; + if (block.timestamp < raffle.startTime) revert RaffleNotStartedYet(); + if (block.timestamp > raffle.endTime) revert RaffleEnded(); + + raffle.ticketsPurchased[msg.sender] += numberOfTickets; + + emit RaffleEntered(raffleId, msg.sender, numberOfTickets); + } + + function distributePrizes(uint256 raffleId, address winner) external onlyOwner { + if (raffleId == 0 || raffleId > raffleCount) revert InvalidRaffleId(); + if (block.timestamp <= raffles[raffleId].endTime) revert RaffleNotEnded(); + + Raffle storage raffle = raffles[raffleId]; + for (uint i = 0; i < raffle.prizeTokens.length; i++) { + address tokenAddress = raffle.prizeTokens[i]; + Prize[] storage prizes = raffle.prizes[tokenAddress]; + + for (uint j = 0; j < prizes.length; j++) { + Prize storage prize = prizes[j]; + if (prize.amount > 0) { + if (prize.tokenAddress == address(0)) { + // Handle ERC20 transfer + IERC20(tokenAddress).transfer(winner, prize.amount); + } else if (IERC721(tokenAddress).ownerOf(prize.tokenId) == address(this)) { + // Handle ERC721 transfer + IERC721(tokenAddress).safeTransferFrom(address(this), winner, prize.tokenId); + } else if (IERC1155(tokenAddress).balanceOf(address(this), prize.tokenId) > 0) { + // Handle ERC1155 transfer + IERC1155(tokenAddress).safeTransferFrom(address(this), winner, prize.tokenId, prize.amount, ""); + } + } + } + } + } + + function _authorizeUpgrade(address) internal virtual override onlyOwner {} + + function supportsInterface(bytes4 interfaceId) + public + view + override(ERC1155Upgradeable, AccessControlUpgradeable) + returns (bool) + { + return super.supportsInterface(interfaceId); + } + + // Custom error definitions + error StartTimeMustBeBeforeEndTime(); + error TicketPriceMustBeGreaterThanZero(); + error InvalidRaffleId(); + error AmountMustBeGreaterThanZero(); + error NumberOfTicketsMustBeGreaterThanZero(); + error IncorrectETHAmount(); + error RaffleNotStartedYet(); + error RaffleEnded(); + error RaffleNotEnded(); +} diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersSigils.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersSigils.sol new file mode 100644 index 00000000000..c6cdf4a1375 --- /dev/null +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersSigils.sol @@ -0,0 +1,233 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol"; +import "./ECDSAWhitelist.sol"; +import "@taiko/blacklist/IMinimalBlacklist.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; +import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; +import "@taiko/blacklist/IMinimalBlacklist.sol"; +import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; +import "@openzeppelin/contracts/access/AccessControl.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; +import "@taiko/blacklist/IMinimalBlacklist.sol"; +import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; +import "./TrailPass.sol"; +import "./TrailblazersBadges.sol"; + +contract TrailblazersSigils is + PausableUpgradeable, + UUPSUpgradeable, + Ownable2StepUpgradeable, + AccessControlUpgradeable, + ERC1155SupplyUpgradeable +{ + TrailPass public trailPass; + TrailblazersBadges public badges; + // token ids + + uint256 public constant RAVER_PINK_ID = 0; + uint256 public constant RAVER_PURPLE_ID = 1; + uint256 public constant ROBOT_PINK_ID = 2; + uint256 public constant ROBOT_PURPLE_ID = 3; + uint256 public constant BOUNCER_PINK_ID = 4; + uint256 public constant BOUNCER_PURPLE_ID = 5; + uint256 public constant MASTER_PINK_ID = 6; + uint256 public constant MASTER_PURPLE_ID = 7; + uint256 public constant DRUMMER_PINK_ID = 8; + uint256 public constant DRUMMER_PURPLE_ID = 9; + uint256 public constant ANDROID_PINK_ID = 10; + uint256 public constant ANDROID_PURPLE_ID = 11; + uint256 public constant MONK_PINK_ID = 12; + uint256 public constant MONK_PURPLE_ID = 13; + uint256 public constant SHINTO_PINK_ID = 14; + uint256 public constant SHINTO_PURPLE_ID = 15; + + uint256[] public TOKEN_IDS = [ + RAVER_PINK_ID, + RAVER_PURPLE_ID, + ROBOT_PINK_ID, + ROBOT_PURPLE_ID, + BOUNCER_PINK_ID, + BOUNCER_PURPLE_ID, + MASTER_PINK_ID, + MASTER_PURPLE_ID, + DRUMMER_PINK_ID, + DRUMMER_PURPLE_ID, + ANDROID_PINK_ID, + ANDROID_PURPLE_ID, + MONK_PINK_ID, + MONK_PURPLE_ID, + SHINTO_PINK_ID, + SHINTO_PURPLE_ID + ]; + + uint256[] public pausedBadgeIds; + + mapping(address _user => uint256 _cooldown) public claimCooldowns; + mapping(address _user => uint256 _cooldown) public tamperCooldowns; + + mapping(address _user => mapping(bool pinkOrPurple => uint256 _tampers)) public migrationTampers; + + mapping(address _user => uint256 _badgeId) public migrationBadgeIds; + + error MAX_TAMPERS_REACHED(); + + error MIGRATION_NOT_STARTED(); + error MIGRATION_ALREADY_STARTED(); + error TAMPER_IN_PROGRESS(); + error CONTRACT_PAUSED(); + + mapping(uint256 => bool) public enabledBadgeIds; + + function initialize(address _badges, address _trailPass) external initializer { + __ERC1155_init(""); + __ERC1155Supply_init(); + _transferOwnership(_msgSender()); + __Context_init(); + + badges = TrailblazersBadges(_badges); + trailPass = TrailPass(_trailPass); + } + + modifier whenUnpaused(uint256 _badgeId) { + if (paused(_badgeId)) { + revert CONTRACT_PAUSED(); + } + _; + } + + modifier isMigrating() { + if (claimCooldowns[_msgSender()] == 0 || block.timestamp < claimCooldowns[_msgSender()]) { + revert MIGRATION_NOT_STARTED(); + } + _; + } + + modifier isNotMigrating() { + if (claimCooldowns[_msgSender()] != 0) { + revert MIGRATION_ALREADY_STARTED(); + } + _; + } + + modifier isNotTampering() { + // revert if the user is tampering; ie, their cooldown + // has not expired + + if (tamperCooldowns[_msgSender()] < block.timestamp) { + revert TAMPER_IN_PROGRESS(); + } + _; + } + + /// @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 { } + + // forge methods + + function startMigration(uint256 _badgeTokenId) public whenUnpaused(_badgeTokenId) { + // transfer the badge tokens to the migration contract + badges.transferFrom(_msgSender(), address(this), _badgeTokenId); + // set off the claim cooldown + uint256 level = trailPass.getLevel(_msgSender()); + claimCooldowns[_msgSender()] = block.timestamp + ((12 - level) * 1 hours); + migrationTampers[_msgSender()][true] = 0; + migrationTampers[_msgSender()][false] = 0; + migrationBadgeIds[_msgSender()] = _badgeTokenId; + } + + function tamperMigration(bool _pinkOrPurple) public isMigrating isNotTampering { + uint256 maxTampers = trailPass.getLevel(_msgSender()); + + if (migrationTampers[_msgSender()][_pinkOrPurple] >= maxTampers) { + revert MAX_TAMPERS_REACHED(); + } + migrationTampers[_msgSender()][_pinkOrPurple] += 1; + tamperCooldowns[_msgSender()] = block.timestamp + 1 hours; + } + + function endMigration() public isMigrating { + // assign final color with 50/50 chances + bool finalColor = block.number % 2 == 0; + + // have pink and purple influence the final color + // at most, each can add 50% to the final color choice + // + uint256 pink = migrationTampers[_msgSender()][true]; + uint256 purple = migrationTampers[_msgSender()][false]; + + if (pink > 0 || purple > 0) { + uint256 maxTampers = trailPass.getLevel(_msgSender()); + // make the contribution proportioanl to the maxTamper + uint256 pinkContribution = pink * 100 / (maxTampers - 1); + uint256 purpleContribution = purple * 100 / (maxTampers - 1); + + // make the final color choice + if (pinkContribution > purpleContribution) { + finalColor = true; + } else if (purpleContribution > pinkContribution) { + finalColor = false; + } + } + uint256 badgeTokenId = migrationBadgeIds[_msgSender()]; + // mint the sigil + uint256 sigilId = finalColor ? TOKEN_IDS[badgeTokenId * 2] : TOKEN_IDS[badgeTokenId * 2 + 1]; + _mint(_msgSender(), sigilId, 1, ""); + // reset the cooldown + claimCooldowns[_msgSender()] = 0; + migrationTampers[_msgSender()][true] = 0; + migrationTampers[_msgSender()][false] = 0; + migrationBadgeIds[_msgSender()] = 0; + } + + function paused(uint256 _sigilId) public view returns (bool) { + return super.paused(); + } + + function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) { + for (uint256 i = 0; i < 8; i++) { + enabledBadgeIds[i] = false; + } + } + + function pause() public onlyRole(DEFAULT_ADMIN_ROLE) { + _disableMigrations(); + _pause(); + } + + function unpause(uint256[] calldata _badgeIds) public onlyRole(DEFAULT_ADMIN_ROLE) { + _disableMigrations(); + + for (uint256 i = 0; i < _badgeIds.length; i++) { + enabledBadgeIds[_badgeIds[i]] = true; + } + _unpause(); + } + + function mint(address _to, uint256 _id, uint256 _amount, bytes memory _data) public { + require(trailPass.hasPass(_to), "TrailblazersSigils: user does not have a pass"); + _mint(_to, _id, _amount, _data); + } +} From 1b722cd8ed8ee2ee3639e49c5b99536d7f8a32b7 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Wed, 28 Aug 2024 13:43:39 +0200 Subject: [PATCH 02/79] simplified and unified contracts --- .../trailblazers-badges/TrailPass.sol | 224 ----------------- .../trailblazers-badges/TrailRaffle.sol | 176 ------------- .../TrailblazersSeason2.sol | 110 +++++++++ .../TrailblazersSigils.sol | 233 ------------------ 4 files changed, 110 insertions(+), 633 deletions(-) delete mode 100644 packages/nfts/contracts/trailblazers-badges/TrailPass.sol delete mode 100644 packages/nfts/contracts/trailblazers-badges/TrailRaffle.sol create mode 100644 packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol delete mode 100644 packages/nfts/contracts/trailblazers-badges/TrailblazersSigils.sol diff --git a/packages/nfts/contracts/trailblazers-badges/TrailPass.sol b/packages/nfts/contracts/trailblazers-badges/TrailPass.sol deleted file mode 100644 index d392e308325..00000000000 --- a/packages/nfts/contracts/trailblazers-badges/TrailPass.sol +++ /dev/null @@ -1,224 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.24; - -import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol"; -import "./ECDSAWhitelist.sol"; -import "@taiko/blacklist/IMinimalBlacklist.sol"; -import "@openzeppelin/contracts/utils/Strings.sol"; -import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; -import "@taiko/blacklist/IMinimalBlacklist.sol"; -import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; -import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; -import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; -import "@openzeppelin/contracts/access/AccessControl.sol"; -import "@openzeppelin/contracts/utils/Strings.sol"; -import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; -import "@taiko/blacklist/IMinimalBlacklist.sol"; -import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; - -contract TrailPass is - PausableUpgradeable, - UUPSUpgradeable, - Ownable2StepUpgradeable, - AccessControlUpgradeable, - ERC1155SupplyUpgradeable -{ - // important wallets - address public levelUpSigner; - - // token ids - uint256 public constant PASS_TIER_A_PINK = 0; - uint256 public constant PASS_TIER_A_PURPLE = 1; - uint256 public constant PASS_TIER_B_PINK = 2; - uint256 public constant PASS_TIER_B_PURPLE = 3; - uint256 public constant PASS_TIER_C_PINK = 4; - uint256 public constant PASS_TIER_C_PURPLE = 5; - - mapping(address _user => uint256 _exp) public userExp; - - uint256[] public TOKEN_IDS = [ - PASS_TIER_A_PINK, - PASS_TIER_A_PURPLE, - PASS_TIER_B_PINK, - PASS_TIER_B_PURPLE, - PASS_TIER_C_PINK, - PASS_TIER_C_PURPLE - ]; - - // tier prices - uint256 public constant TIER_A_PRICE = 10 ether; - uint256 public constant TIER_B_PRICE = 5 ether; - uint256 public constant TIER_C_PRICE = 3 ether; - - uint256[42] private __gap; - - error TOKEN_CANNOT_BE_TRANSFERRED(); - error BATTLE_PASS_ALREADY_OWNED(); - error BATTLE_PASS_NOT_OWNED(); - error INVALID_TIER(); - error INVALID_LEVEL_UP_SIGNATURE(); - error INVALID_EXP_AMOUNT(); - - function initialize(address _levelUpSigner) external initializer { - __ERC1155_init(""); - __ERC1155Supply_init(); - _transferOwnership(_msgSender()); - __Context_init(); - - levelUpSigner = _levelUpSigner; - } - - modifier onlyNewUser() { - if (hasPass(_msgSender())) { - revert BATTLE_PASS_ALREADY_OWNED(); - } - _; - } - - modifier requireBattlePass(uint256 _tier) { - if (!hasPass(_msgSender(), _tier)) { - revert BATTLE_PASS_NOT_OWNED(); - } - _; - } - - modifier requireAnyBattlePass() { - if (!hasPass(_msgSender())) { - revert BATTLE_PASS_NOT_OWNED(); - } - _; - } - - function getTierPrice(uint256 _tokenId) public view returns (uint256) { - if (_tokenId == PASS_TIER_A_PINK || _tokenId == PASS_TIER_A_PURPLE) { - return TIER_A_PRICE; - } else if (_tokenId == PASS_TIER_B_PINK || _tokenId == PASS_TIER_B_PURPLE) { - return TIER_B_PRICE; - } else if (_tokenId == PASS_TIER_C_PINK || _tokenId == PASS_TIER_C_PURPLE) { - return TIER_C_PRICE; - } - revert INVALID_TIER(); - } - - function mint(uint256 _tier) public payable onlyNewUser { - uint256 price = getTierPrice(_tier); - if (msg.value < price) { - revert("Insufficient funds"); - } - - _mint(_msgSender(), _tier, 1, ""); - } - - function withdrawStake() public requireAnyBattlePass { - uint256 tier = getUserTier(_msgSender()); - uint256 price = getTierPrice(tier); - _burn(_msgSender(), tier, 1); - payable(_msgSender()).transfer(price); - } - - function hasPass(address _user, uint256 _tier) public view returns (bool) { - return balanceOf(_user, _tier) > 0; - } - - function hasPass(address _user) public view returns (bool) { - for (uint256 i = 0; i < TOKEN_IDS.length; i++) { - if (hasPass(_user, TOKEN_IDS[i])) { - return true; - } - } - return false; - } - - function getUserTier(address _user) public view returns (uint256 tier) { - for (uint256 i = 0; i < TOKEN_IDS.length; i++) { - if (hasPass(_user, TOKEN_IDS[i])) { - return TOKEN_IDS[i]; - } - } - revert BATTLE_PASS_NOT_OWNED(); - } - - // makes the season pass non-transferable - function _update( - address from, - address to, - uint256[] memory ids, - uint256[] memory values - ) - internal - override - { - if (from != address(0)) { - revert TOKEN_CANNOT_BE_TRANSFERRED(); - } - super._update(from, to, ids, values); - } - - /// @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 { } - - // todo: methods to register points from the backend - /// @notice Generate a standardized hash for externally signing - /// @param _minter Address of the minter - /// @param _tokenId ID for the token to mint - function getHash(address _minter, uint256 _tokenId) public pure returns (bytes32) { - return keccak256(bytes.concat(keccak256(abi.encode(_minter, _tokenId)))); - } - - function _isSignatureValid( - bytes memory _signature, - address _minter, - uint256 _exp - ) - internal - view - returns (bool) - { - bytes32 _hash = getHash(_minter, _exp); - (address _recovered,,) = ECDSA.tryRecover(_hash, _signature); - - return _recovered == levelUpSigner; - } - - function getExp(address _user) public view returns (uint256) { - if (!hasPass(_user)) { - revert BATTLE_PASS_NOT_OWNED(); - } - return userExp[_user]; - } - - function getLevel(address _user) public view returns (uint256) { - if (!hasPass(_user)) { - revert BATTLE_PASS_NOT_OWNED(); - } - return userExp[_user] / 100; - } - - function levelUp(uint256 _exp, bytes memory _signature) public requireAnyBattlePass { - if (!_isSignatureValid(_signature, _msgSender(), _exp)) { - revert INVALID_LEVEL_UP_SIGNATURE(); - } - if (_exp < getExp(_msgSender())) { - revert INVALID_EXP_AMOUNT(); - } - userExp[_msgSender()] = _exp; - } -} diff --git a/packages/nfts/contracts/trailblazers-badges/TrailRaffle.sol b/packages/nfts/contracts/trailblazers-badges/TrailRaffle.sol deleted file mode 100644 index b0f73495f38..00000000000 --- a/packages/nfts/contracts/trailblazers-badges/TrailRaffle.sol +++ /dev/null @@ -1,176 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.24; - -import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; -import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; -import "@openzeppelin/contracts/access/Ownable.sol"; -import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; -import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -import "@openzeppelin/contracts/utils/Strings.sol"; -import "./TrailPass.sol"; - -// todo: integrate with trailPass - -contract RaffleERC1155 is - PausableUpgradeable, - UUPSUpgradeable, - Ownable2StepUpgradeable, - AccessControlUpgradeable, - ERC1155SupplyUpgradeable -{ - struct Prize { - address tokenAddress; - uint256 tokenId; // For ERC721 and ERC1155 - uint256 amount; // For ERC20 and ERC1155 - } - - struct Raffle { - uint256 trailPassTier; - uint256 startTime; - uint256 endTime; - uint256 ticketPrice; // Price in ETH - address[] prizeTokens; - mapping(address => Prize[]) prizes; - mapping(address => uint256) ticketsPurchased; // Track tickets purchased per participant - } - - // Mapping from raffle ID to Raffle details - mapping(uint256 => Raffle) public raffles; - uint256 public raffleCount; - - event RaffleCreated(uint256 raffleId, uint256 startTime, uint256 endTime, uint256 ticketPrice, address[] prizeTokens); - event PrizeAdded(uint256 raffleId, address tokenAddress, uint256 tokenId, uint256 amount); - event RaffleEntered(uint256 raffleId, address participant, uint256 numberOfTickets); - event TicketPriceUpdated(uint256 raffleId, uint256 newPrice); - - - TrailPass public trailPass; - function initialize( address _trailPass) external initializer { - __ERC1155_init(""); - __ERC1155Supply_init(); - _transferOwnership(_msgSender()); - __Context_init(); - trailPass = TrailPass(_trailPass); - } - - function createRaffle( - uint256 _tier, - uint256 _startTime, - uint256 _endTime, - uint256 _ticketPrice, - address[] memory _prizeTokens - ) external onlyOwner { - if (_startTime >= _endTime) revert StartTimeMustBeBeforeEndTime(); - if (_ticketPrice == 0) revert TicketPriceMustBeGreaterThanZero(); - - raffleCount++; - Raffle storage newRaffle = raffles[raffleCount]; - - newRaffle.trailPassTier = _tier; - newRaffle.startTime = _startTime; - newRaffle.endTime = _endTime; - newRaffle.ticketPrice = _ticketPrice; - newRaffle.prizeTokens = _prizeTokens; - - emit RaffleCreated(raffleCount, _startTime, _endTime, _ticketPrice, _prizeTokens); - } - - function addPrize( - uint256 raffleId, - address tokenAddress, - uint256 tokenId, - uint256 amount - ) external onlyOwner { - if (raffleId == 0 || raffleId > raffleCount) revert InvalidRaffleId(); - if (amount == 0) revert AmountMustBeGreaterThanZero(); - - Raffle storage raffle = raffles[raffleId]; - - raffle.prizes[tokenAddress].push(Prize({ - tokenAddress: tokenAddress, - tokenId: tokenId, - amount: amount - })); - - emit PrizeAdded(raffleId, tokenAddress, tokenId, amount); - } - - function updateTicketPrice(uint256 raffleId, uint256 newPrice) external onlyOwner { - if (raffleId == 0 || raffleId > raffleCount) revert InvalidRaffleId(); - if (newPrice == 0) revert TicketPriceMustBeGreaterThanZero(); - - Raffle storage raffle = raffles[raffleId]; - raffle.ticketPrice = newPrice; - - emit TicketPriceUpdated(raffleId, newPrice); - } - - function enterRaffle(uint256 raffleId, uint256 numberOfTickets) external payable { - if (raffleId == 0 || raffleId > raffleCount) revert InvalidRaffleId(); - if (numberOfTickets == 0) revert NumberOfTicketsMustBeGreaterThanZero(); - if (msg.value != raffles[raffleId].ticketPrice * numberOfTickets) revert IncorrectETHAmount(); - - Raffle storage raffle = raffles[raffleId]; - if (block.timestamp < raffle.startTime) revert RaffleNotStartedYet(); - if (block.timestamp > raffle.endTime) revert RaffleEnded(); - - raffle.ticketsPurchased[msg.sender] += numberOfTickets; - - emit RaffleEntered(raffleId, msg.sender, numberOfTickets); - } - - function distributePrizes(uint256 raffleId, address winner) external onlyOwner { - if (raffleId == 0 || raffleId > raffleCount) revert InvalidRaffleId(); - if (block.timestamp <= raffles[raffleId].endTime) revert RaffleNotEnded(); - - Raffle storage raffle = raffles[raffleId]; - for (uint i = 0; i < raffle.prizeTokens.length; i++) { - address tokenAddress = raffle.prizeTokens[i]; - Prize[] storage prizes = raffle.prizes[tokenAddress]; - - for (uint j = 0; j < prizes.length; j++) { - Prize storage prize = prizes[j]; - if (prize.amount > 0) { - if (prize.tokenAddress == address(0)) { - // Handle ERC20 transfer - IERC20(tokenAddress).transfer(winner, prize.amount); - } else if (IERC721(tokenAddress).ownerOf(prize.tokenId) == address(this)) { - // Handle ERC721 transfer - IERC721(tokenAddress).safeTransferFrom(address(this), winner, prize.tokenId); - } else if (IERC1155(tokenAddress).balanceOf(address(this), prize.tokenId) > 0) { - // Handle ERC1155 transfer - IERC1155(tokenAddress).safeTransferFrom(address(this), winner, prize.tokenId, prize.amount, ""); - } - } - } - } - } - - function _authorizeUpgrade(address) internal virtual override onlyOwner {} - - function supportsInterface(bytes4 interfaceId) - public - view - override(ERC1155Upgradeable, AccessControlUpgradeable) - returns (bool) - { - return super.supportsInterface(interfaceId); - } - - // Custom error definitions - error StartTimeMustBeBeforeEndTime(); - error TicketPriceMustBeGreaterThanZero(); - error InvalidRaffleId(); - error AmountMustBeGreaterThanZero(); - error NumberOfTicketsMustBeGreaterThanZero(); - error IncorrectETHAmount(); - error RaffleNotStartedYet(); - error RaffleEnded(); - error RaffleNotEnded(); -} diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol new file mode 100644 index 00000000000..06f67fa956c --- /dev/null +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +interface BadgeMigration { + /// @notice Start a migration for a badge + /// @param _badgeTokenId The badge token ID (s1) + /// @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 _badgeTokenId) external; + + /// @notice Tamper (alter) the chances during a migration + /// @param _pinkOrPurple true for pink, false for purple + /// @dev Can be called only during an active migration + /// @dev Implements a cooldown before allowing to re-tamper + /// @dev The max tamper amount is determined by Pass Tier + function tamperMigration(bool _pinkOrPurple) external; + + /// @notice End a migration + /// @dev Can be called only during an active migration, after the cooldown is over + /// @dev The final color is determined randomly, and affected by the tamper amounts + function endMigration() external; +} + +interface TrailRaffle { + /// @notice Create a new raffle + /// @param _startTime The start time of the raffle + /// @param _endTime The end time of the raffle + /// @param _participatingEmblemIds emblem ids that will act as tickets + /// @param _erc20TokenRewards array of erc20 addresses for rewards + /// @param _erc20TokenAmounts array of erc20 amounts for rewards + /// @param _erc721TokenRewards array of erc721 addresses for rewards + /// @param _erc721TokenIds array of erc721 token ids for rewards + /// @param _erc1155TokenRewards array of erc1155 addresses for rewards + /// @param _erc1155TokenIds array of erc1155 token ids for rewards + /// @param _erc1155TokenAmounts array of erc1155 token amounts for rewards + /// @dev The raffle will be settled after the end time + /// @dev Each Pass Tier multiplies the raffle chances + function createRaffle( + uint256 _startTime, + uint256 _endTime, + uint256[] calldata _participatingEmblemIds, + address[] calldata _erc20TokenRewards, + uint256[] calldata _erc20TokenAmounts, + address[] calldata _erc721TokenRewards, + uint256[] calldata _erc721TokenIds, + address[] calldata _erc1155TokenRewards, + uint256[] calldata _erc1155TokenIds, + uint256[] calldata _erc1155TokenAmounts + ) + external + returns (uint256 _raffleId); + + /// @notice Check if a raffle is settled + /// @param _raffleId The raffle ID + /// @return Whether the raffle is settled + function isRaffleSettled(uint256 _raffleId) external view returns (bool); + + /// @notice Settle a raffle + /// @param _raffleId The raffle ID + /// @dev Can be called only after the end time of the raffle + function settleRaffle(uint256 _raffleId) external; + + /// @notice Check if an account is a winner in a raffle + /// @param _account The account to check + /// @param _raffleId The raffle ID + /// @return Whether the account is a winner + function isWinner(address _account, uint256 _raffleId) external view returns (bool); + + /// @notice Claim the rewards of a raffle + /// @param _raffleId The raffle ID + /// @dev Can be called once, only after the raffle is settled, and only by the winner + function claimRaffleRewards(uint256 _raffleId) external; +} + +interface TrailPass { + /// @notice Purchase a Trail Pass + /// @param _tier The tier of the Trail Pass + /// @dev The price is determined by the tier + /// @dev The tier is determined by the amount of participations in raffles + /// @dev The tier also increases the max amount of tampering during a migration + function purchaseTrailPass(uint256 _tier) external payable; + + /// @notice Check if an account has a Trail Pass, any + /// @param _account The account to check + function hasTrailPass(address _account) external view returns (bool); + + /// @notice Check if an account has a Trail Pass, specific tier + /// @param _account The account to check + function hasTrailPass(address _account, uint256 _tier) external view returns (bool); + + /// @notice Check if an account has one of the Trail Passes (OR) + /// @param _account The account to check + /// @param _tiers The tiers to check, OR + function hasTrailPass( + address _account, + uint256[] calldata _tiers + ) + external + view + returns (bool); + + /// @notice Get the tier of a Trail Pass + /// @param _account The account to check + function getTrailPass(address _account) external view returns (uint256 _tier); +} + +contract TrailblazersSeason2 is BadgeMigration, TrailRaffle, TrailPass { +// implementation details +} diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersSigils.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersSigils.sol deleted file mode 100644 index c6cdf4a1375..00000000000 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersSigils.sol +++ /dev/null @@ -1,233 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.24; - -import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol"; -import "./ECDSAWhitelist.sol"; -import "@taiko/blacklist/IMinimalBlacklist.sol"; -import "@openzeppelin/contracts/utils/Strings.sol"; -import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; -import "@taiko/blacklist/IMinimalBlacklist.sol"; -import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; -import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; -import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; -import "@openzeppelin/contracts/access/AccessControl.sol"; -import "@openzeppelin/contracts/utils/Strings.sol"; -import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; -import "@taiko/blacklist/IMinimalBlacklist.sol"; -import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; -import "./TrailPass.sol"; -import "./TrailblazersBadges.sol"; - -contract TrailblazersSigils is - PausableUpgradeable, - UUPSUpgradeable, - Ownable2StepUpgradeable, - AccessControlUpgradeable, - ERC1155SupplyUpgradeable -{ - TrailPass public trailPass; - TrailblazersBadges public badges; - // token ids - - uint256 public constant RAVER_PINK_ID = 0; - uint256 public constant RAVER_PURPLE_ID = 1; - uint256 public constant ROBOT_PINK_ID = 2; - uint256 public constant ROBOT_PURPLE_ID = 3; - uint256 public constant BOUNCER_PINK_ID = 4; - uint256 public constant BOUNCER_PURPLE_ID = 5; - uint256 public constant MASTER_PINK_ID = 6; - uint256 public constant MASTER_PURPLE_ID = 7; - uint256 public constant DRUMMER_PINK_ID = 8; - uint256 public constant DRUMMER_PURPLE_ID = 9; - uint256 public constant ANDROID_PINK_ID = 10; - uint256 public constant ANDROID_PURPLE_ID = 11; - uint256 public constant MONK_PINK_ID = 12; - uint256 public constant MONK_PURPLE_ID = 13; - uint256 public constant SHINTO_PINK_ID = 14; - uint256 public constant SHINTO_PURPLE_ID = 15; - - uint256[] public TOKEN_IDS = [ - RAVER_PINK_ID, - RAVER_PURPLE_ID, - ROBOT_PINK_ID, - ROBOT_PURPLE_ID, - BOUNCER_PINK_ID, - BOUNCER_PURPLE_ID, - MASTER_PINK_ID, - MASTER_PURPLE_ID, - DRUMMER_PINK_ID, - DRUMMER_PURPLE_ID, - ANDROID_PINK_ID, - ANDROID_PURPLE_ID, - MONK_PINK_ID, - MONK_PURPLE_ID, - SHINTO_PINK_ID, - SHINTO_PURPLE_ID - ]; - - uint256[] public pausedBadgeIds; - - mapping(address _user => uint256 _cooldown) public claimCooldowns; - mapping(address _user => uint256 _cooldown) public tamperCooldowns; - - mapping(address _user => mapping(bool pinkOrPurple => uint256 _tampers)) public migrationTampers; - - mapping(address _user => uint256 _badgeId) public migrationBadgeIds; - - error MAX_TAMPERS_REACHED(); - - error MIGRATION_NOT_STARTED(); - error MIGRATION_ALREADY_STARTED(); - error TAMPER_IN_PROGRESS(); - error CONTRACT_PAUSED(); - - mapping(uint256 => bool) public enabledBadgeIds; - - function initialize(address _badges, address _trailPass) external initializer { - __ERC1155_init(""); - __ERC1155Supply_init(); - _transferOwnership(_msgSender()); - __Context_init(); - - badges = TrailblazersBadges(_badges); - trailPass = TrailPass(_trailPass); - } - - modifier whenUnpaused(uint256 _badgeId) { - if (paused(_badgeId)) { - revert CONTRACT_PAUSED(); - } - _; - } - - modifier isMigrating() { - if (claimCooldowns[_msgSender()] == 0 || block.timestamp < claimCooldowns[_msgSender()]) { - revert MIGRATION_NOT_STARTED(); - } - _; - } - - modifier isNotMigrating() { - if (claimCooldowns[_msgSender()] != 0) { - revert MIGRATION_ALREADY_STARTED(); - } - _; - } - - modifier isNotTampering() { - // revert if the user is tampering; ie, their cooldown - // has not expired - - if (tamperCooldowns[_msgSender()] < block.timestamp) { - revert TAMPER_IN_PROGRESS(); - } - _; - } - - /// @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 { } - - // forge methods - - function startMigration(uint256 _badgeTokenId) public whenUnpaused(_badgeTokenId) { - // transfer the badge tokens to the migration contract - badges.transferFrom(_msgSender(), address(this), _badgeTokenId); - // set off the claim cooldown - uint256 level = trailPass.getLevel(_msgSender()); - claimCooldowns[_msgSender()] = block.timestamp + ((12 - level) * 1 hours); - migrationTampers[_msgSender()][true] = 0; - migrationTampers[_msgSender()][false] = 0; - migrationBadgeIds[_msgSender()] = _badgeTokenId; - } - - function tamperMigration(bool _pinkOrPurple) public isMigrating isNotTampering { - uint256 maxTampers = trailPass.getLevel(_msgSender()); - - if (migrationTampers[_msgSender()][_pinkOrPurple] >= maxTampers) { - revert MAX_TAMPERS_REACHED(); - } - migrationTampers[_msgSender()][_pinkOrPurple] += 1; - tamperCooldowns[_msgSender()] = block.timestamp + 1 hours; - } - - function endMigration() public isMigrating { - // assign final color with 50/50 chances - bool finalColor = block.number % 2 == 0; - - // have pink and purple influence the final color - // at most, each can add 50% to the final color choice - // - uint256 pink = migrationTampers[_msgSender()][true]; - uint256 purple = migrationTampers[_msgSender()][false]; - - if (pink > 0 || purple > 0) { - uint256 maxTampers = trailPass.getLevel(_msgSender()); - // make the contribution proportioanl to the maxTamper - uint256 pinkContribution = pink * 100 / (maxTampers - 1); - uint256 purpleContribution = purple * 100 / (maxTampers - 1); - - // make the final color choice - if (pinkContribution > purpleContribution) { - finalColor = true; - } else if (purpleContribution > pinkContribution) { - finalColor = false; - } - } - uint256 badgeTokenId = migrationBadgeIds[_msgSender()]; - // mint the sigil - uint256 sigilId = finalColor ? TOKEN_IDS[badgeTokenId * 2] : TOKEN_IDS[badgeTokenId * 2 + 1]; - _mint(_msgSender(), sigilId, 1, ""); - // reset the cooldown - claimCooldowns[_msgSender()] = 0; - migrationTampers[_msgSender()][true] = 0; - migrationTampers[_msgSender()][false] = 0; - migrationBadgeIds[_msgSender()] = 0; - } - - function paused(uint256 _sigilId) public view returns (bool) { - return super.paused(); - } - - function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) { - for (uint256 i = 0; i < 8; i++) { - enabledBadgeIds[i] = false; - } - } - - function pause() public onlyRole(DEFAULT_ADMIN_ROLE) { - _disableMigrations(); - _pause(); - } - - function unpause(uint256[] calldata _badgeIds) public onlyRole(DEFAULT_ADMIN_ROLE) { - _disableMigrations(); - - for (uint256 i = 0; i < _badgeIds.length; i++) { - enabledBadgeIds[_badgeIds[i]] = true; - } - _unpause(); - } - - function mint(address _to, uint256 _id, uint256 _amount, bytes memory _data) public { - require(trailPass.hasPass(_to), "TrailblazersSigils: user does not have a pass"); - _mint(_to, _id, _amount, _data); - } -} From d926dae1661bfececc57f2373e88ad3f5206d15f Mon Sep 17 00:00:00 2001 From: bearni95 Date: Wed, 28 Aug 2024 13:44:40 +0200 Subject: [PATCH 03/79] added clarification method on BadgeMigration --- .../contracts/trailblazers-badges/TrailblazersSeason2.sol | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol index 06f67fa956c..4276569e23e 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol @@ -20,6 +20,10 @@ interface BadgeMigration { /// @dev Can be called only during an active migration, after the cooldown is over /// @dev The final color is determined randomly, and affected by the tamper amounts function endMigration() external; + + /// @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); } interface TrailRaffle { From 0c74f7517a264adf8fc7e3d19e78f51d47eb2467 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 2 Sep 2024 11:09:54 +0200 Subject: [PATCH 04/79] partial tests and proper, full implementation --- .../TrailblazersBadges.sol | 19 ++ .../TrailblazersBadgesS2.sol | 292 ++++++++++++++++ .../TrailblazersSeason2.sol | 41 ++- .../TraiblazersBadgesS2.t.sol | 314 ++++++++++++++++++ 4 files changed, 660 insertions(+), 6 deletions(-) create mode 100644 packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol create mode 100644 packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadges.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadges.sol index 7b55195d412..c0997ac36bd 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadges.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadges.sol @@ -221,4 +221,23 @@ contract TrailblazersBadges is ERC721EnumerableUpgradeable, ECDSAWhitelist { return balances; } + + /// @notice V3 + + address public season2BadgeContract; + + error INVALID_S2_CONTRACT(); + + function setSeason2BadgeContract(address _season2BadgeContract) public onlyOwner { + season2BadgeContract = _season2BadgeContract; + } + + modifier onlySeason2BadgeContract() { + if (msg.sender != season2BadgeContract) revert INVALID_S2_CONTRACT(); + _; + } + + function burn(uint256 _tokenId) public onlySeason2BadgeContract { + _burn(_tokenId); + } } diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol new file mode 100644 index 00000000000..3e609e870a4 --- /dev/null +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol @@ -0,0 +1,292 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol"; +import "./ECDSAWhitelist.sol"; +import "@taiko/blacklist/IMinimalBlacklist.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; +import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; +import "@taiko/blacklist/IMinimalBlacklist.sol"; +import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; +import "@openzeppelin/contracts/access/AccessControl.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; +import "@taiko/blacklist/IMinimalBlacklist.sol"; +import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; +import "./TrailblazersBadges.sol"; + +contract TrailblazersBadgesS2 is + PausableUpgradeable, + UUPSUpgradeable, + Ownable2StepUpgradeable, + AccessControlUpgradeable, + ERC1155SupplyUpgradeable +{ + uint256 public constant MAX_TAMPERS = 3; + + uint256 public constant RAVER_PINK_ID = 0; + uint256 public constant RAVER_PURPLE_ID = 1; + uint256 public constant ROBOT_PINK_ID = 2; + uint256 public constant ROBOT_PURPLE_ID = 3; + uint256 public constant BOUNCER_PINK_ID = 4; + uint256 public constant BOUNCER_PURPLE_ID = 5; + uint256 public constant MASTER_PINK_ID = 6; + uint256 public constant MASTER_PURPLE_ID = 7; + uint256 public constant MONK_PINK_ID = 8; + uint256 public constant MONK_PURPLE_ID = 9; + uint256 public constant DRUMMER_PINK_ID = 10; + uint256 public constant DRUMMER_PURPLE_ID = 11; + uint256 public constant ANDROID_PINK_ID = 12; + uint256 public constant ANDROID_PURPLE_ID = 13; + uint256 public constant SHINTO_PINK_ID = 14; + uint256 public constant SHINTO_PURPLE_ID = 15; + + uint256[16] public BADGE_IDS = [ + RAVER_PINK_ID, + RAVER_PURPLE_ID, + ROBOT_PINK_ID, + ROBOT_PURPLE_ID, + BOUNCER_PINK_ID, + BOUNCER_PURPLE_ID, + MASTER_PINK_ID, + MASTER_PURPLE_ID, + MONK_PINK_ID, + MONK_PURPLE_ID, + DRUMMER_PINK_ID, + DRUMMER_PURPLE_ID, + ANDROID_PINK_ID, + ANDROID_PURPLE_ID, + SHINTO_PINK_ID, + SHINTO_PURPLE_ID + ]; + + mapping(address _user => uint256 _cooldown) public claimCooldowns; + mapping(address _user => uint256 _cooldown) public tamperCooldowns; + mapping(address _user => mapping(bool pinkOrPurple => uint256 _tampers)) public migrationTampers; + + mapping(address _user => uint256 _badgeId) public migrationBadgeIds; + + mapping(address _user => mapping(uint256 _badgeId => uint256 _tokenId)) public userBadges; + + error MAX_TAMPERS_REACHED(); + + error MIGRATION_NOT_STARTED(); + error MIGRATION_ALREADY_STARTED(); + error TAMPER_IN_PROGRESS(); + error CONTRACT_PAUSED(); + error MIGRATION_NOT_READY(); + error TOKEN_NOT_MINTED(); + + mapping(uint256 => bool) public enabledBadgeIds; + + modifier whenUnpaused(uint256 _badgeId) { + if (paused(_badgeId)) { + revert CONTRACT_PAUSED(); + } + _; + } + + TrailblazersBadges public badges; + + modifier isMigrating() { + if (claimCooldowns[_msgSender()] == 0) { + revert MIGRATION_NOT_STARTED(); + } + _; + } + + modifier isNotMigrating() { + if (claimCooldowns[_msgSender()] != 0) { + revert MIGRATION_ALREADY_STARTED(); + } + _; + } + + modifier isNotTampering() { + // revert if the user is tampering; ie, their cooldown + // has not expired + + if (tamperCooldowns[_msgSender()] < block.timestamp) { + revert TAMPER_IN_PROGRESS(); + } + _; + } + + function initialize(address _badges) external initializer { + __ERC1155_init(""); + __ERC1155Supply_init(); + _transferOwnership(_msgSender()); + __Context_init(); + + badges = TrailblazersBadges(_badges); + } + + /// @notice Start a migration for a badge + /// @param _badgeTokenId The badge token ID (s1) + /// @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 _badgeTokenId) external { + // transfer the badge tokens to the migration contract + badges.transferFrom(_msgSender(), address(this), _badgeTokenId); + // set off the claim cooldown + claimCooldowns[_msgSender()] = block.timestamp + 1 hours; + migrationTampers[_msgSender()][true] = 0; + migrationTampers[_msgSender()][false] = 0; + migrationBadgeIds[_msgSender()] = _badgeTokenId; + } + + /// @notice Tamper (alter) the chances during a migration + /// @param _pinkOrPurple true for pink, false for purple + /// @dev Can be called only during an active migration + /// @dev Implements a cooldown before allowing to re-tamper + /// @dev The max tamper amount is determined by Pass Tier + function tamperMigration(bool _pinkOrPurple) external isMigrating { + if (migrationTampers[_msgSender()][_pinkOrPurple] >= MAX_TAMPERS) { + revert MAX_TAMPERS_REACHED(); + } + migrationTampers[_msgSender()][_pinkOrPurple]++; + tamperCooldowns[_msgSender()] = block.timestamp + 1 hours; + } + + /// @notice End a migration + /// @dev Can be called only during an active migration, after the cooldown is over + /// @dev The final color is determined randomly, and affected by the tamper amounts + function endMigration() external isMigrating { + // check if the cooldown is over + if (block.timestamp < claimCooldowns[_msgSender()]) { + revert MIGRATION_NOT_READY(); + } + + // get the tamper amounts + uint256 pinkTampers = migrationTampers[_msgSender()][true]; + uint256 purpleTampers = migrationTampers[_msgSender()][false]; + + // determine the final color, with the tampers adding a max 50% chance if maxxed out + bool isPink = + pinkTampers < 3 && purpleTampers < 3 ? block.timestamp % 2 == 0 : pinkTampers < 3; + + (uint256 pinkBadgeId, uint256 purpleBadgeId) = + getSeason2BadgeIds(migrationBadgeIds[_msgSender()]); + uint256 s2BadgeId = isPink ? pinkBadgeId : purpleBadgeId; + + // burn the s1 badge + uint256 s1TokenId = migrationBadgeIds[_msgSender()]; + badges.burn(s1TokenId); + + uint256 s2TokenId = totalSupply() + 1; + // mint the badge + _mint(_msgSender(), s2TokenId, 1, ""); + + // reset the cooldowns + claimCooldowns[_msgSender()] = 0; + migrationTampers[_msgSender()][true] = 0; + migrationTampers[_msgSender()][false] = 0; + migrationBadgeIds[_msgSender()] = 0; + 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++) { + enabledBadgeIds[i] = false; + } + } + + function paused(uint256 _s1Badge) public view returns (bool) { + for (uint256 i = 0; i < 8; i++) { + if (enabledBadgeIds[i] && i == _s1Badge) { + return true; + } + } + return super.paused(); + } + + function pause() public onlyRole(DEFAULT_ADMIN_ROLE) { + _disableMigrations(); + _pause(); + } + + function getSeason2BadgeIds(uint256 _s1BadgeId) + public + pure + returns (uint256 _pinkBadgeId, uint256 _purpleBadgeId) + { + return (_s1BadgeId * 2, _s1BadgeId * 2 + 1); + } + + function getSeason1BadgeId(uint256 _s2BadgeId) public pure returns (uint256 _s1BadgeId) { + return _s2BadgeId / 2; + } + + function isMigrationActive(address _user) public view returns (bool) { + return claimCooldowns[_user] != 0; + } + + function isTamperActive(address _user) public view returns (bool) { + return tamperCooldowns[_user] > block.timestamp; + } + + function getMigrationTampers(address _user) + public + view + returns (uint256 _pinkTampers, uint256 _purpleTampers) + { + return (migrationTampers[_user][true], migrationTampers[_user][false]); + } + + function getTokenId(address _user, uint256 _s2BadgeId) public view returns (uint256 _tokenId) { + _tokenId = userBadges[_user][_s2BadgeId]; + /* if (_tokenId == 0){ + revert TOKEN_NOT_MINTED(); + }*/ + return _tokenId; + } + + function badgeBalances(address _owner) public view returns (bool[16] memory _balances) { + for (uint256 i = 0; i < BADGE_IDS.length; i++) { + uint256 tokenId = getTokenId(_owner, BADGE_IDS[i]); + _balances[i] = tokenId != 0; + } + + return _balances; + } + + function badgeBalanceOf(address _owner) public view returns (uint256 _balance) { + bool[16] memory balances = badgeBalances(_owner); + + for (uint256 i = 0; i < balances.length; i++) { + if (balances[i]) { + _balance++; + } + } + + return _balance; + } +} diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol index 4276569e23e..85efe5a1a67 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol @@ -26,11 +26,35 @@ interface BadgeMigration { function getMaximumTampers() external view returns (uint256); } +interface TrailRewardVault { + /// @notice Claim rewards + /// @param _experience The experience amount + /// @param _signature The signature to verify + /// @dev The user is the _msgSender() + function claimRewards(uint256 _experience, bytes memory _signature) external; + + /// @notice Internal method to mint s2 badges from claimRewards + /// @param _account The account to mint the badge to + /// @param _tokenId The badge token ID + /// @param _experience The experience amount + /// @param _signature The signature to verify + function _mintBadge( + address _account, + uint256 _tokenId, + uint256 _experience, + bytes memory _signature + ) + external; + + /// @notice Check if an account can claim rewards + /// @param _account The account to check + function canClaim(address _account) external view returns (bool); +} + interface TrailRaffle { /// @notice Create a new raffle /// @param _startTime The start time of the raffle /// @param _endTime The end time of the raffle - /// @param _participatingEmblemIds emblem ids that will act as tickets /// @param _erc20TokenRewards array of erc20 addresses for rewards /// @param _erc20TokenAmounts array of erc20 amounts for rewards /// @param _erc721TokenRewards array of erc721 addresses for rewards @@ -43,7 +67,6 @@ interface TrailRaffle { function createRaffle( uint256 _startTime, uint256 _endTime, - uint256[] calldata _participatingEmblemIds, address[] calldata _erc20TokenRewards, uint256[] calldata _erc20TokenAmounts, address[] calldata _erc721TokenRewards, @@ -75,6 +98,11 @@ interface TrailRaffle { /// @param _raffleId The raffle ID /// @dev Can be called once, only after the raffle is settled, and only by the winner function claimRaffleRewards(uint256 _raffleId) external; + + /// @notice Get the amount of participations in raffles for an account + /// @param _account The account to check + /// @dev Determined by a user's TrailPass Tier + function getRaffleParticipations(address _account) external view returns (uint256); } interface TrailPass { @@ -85,6 +113,11 @@ interface TrailPass { /// @dev The tier also increases the max amount of tampering during a migration function purchaseTrailPass(uint256 _tier) external payable; + /// @notice Upgrade a Trail Pass + /// @param _tier The tier of the Trail Pass + /// @dev The price is determined by the tier, and substracted from the existing trail pass price + function upgradeTrailPass(uint256 _tier) external payable; + /// @notice Check if an account has a Trail Pass, any /// @param _account The account to check function hasTrailPass(address _account) external view returns (bool); @@ -108,7 +141,3 @@ interface TrailPass { /// @param _account The account to check function getTrailPass(address _account) external view returns (uint256 _tier); } - -contract TrailblazersSeason2 is BadgeMigration, TrailRaffle, TrailPass { -// implementation details -} diff --git a/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol new file mode 100644 index 00000000000..b3f434fa80a --- /dev/null +++ b/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol @@ -0,0 +1,314 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import { Test } from "forge-std/src/Test.sol"; + +import { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; +import { Merkle } from "murky/Merkle.sol"; +import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; +import { UtilsScript } from "../../script/taikoon/sol/Utils.s.sol"; +import { MockBlacklist } from "../util/Blacklist.sol"; +import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import { TrailblazersBadgesS2 } from "../../contracts/trailblazers-badges/TrailblazersBadgesS2.sol"; + +contract TrailblazersBadgesTest is Test { + UtilsScript public utils; + + TrailblazersBadges public s1Badges; + TrailblazersBadgesS2 public s2Badges; + + address public owner = vm.addr(0x5); + + address[3] public minters = [vm.addr(0x1), vm.addr(0x2), vm.addr(0x3)]; + + uint256 constant BADGE_ID = 5; + + MockBlacklist public blacklist; + + address mintSigner; + uint256 mintSignerPk; + + bool constant PINK_TAMPER = true; + bool constant PURPLE_TAMPER = false; + + uint256 public MAX_TAMPERS; + + function setUp() public { + utils = new UtilsScript(); + utils.setUp(); + blacklist = new MockBlacklist(); + // create whitelist merkle tree + vm.startBroadcast(owner); + + (mintSigner, mintSignerPk) = makeAddrAndKey("mintSigner"); + + // deploy token with empty root + address impl = address(new TrailblazersBadges()); + address proxy = address( + new ERC1967Proxy( + impl, + abi.encodeCall( + TrailblazersBadges.initialize, (owner, "ipfs://", mintSigner, blacklist) + ) + ) + ); + + s1Badges = TrailblazersBadges(proxy); + + // deploy the s2 contract + + impl = address(new TrailblazersBadgesS2()); + proxy = address( + new ERC1967Proxy( + impl, abi.encodeCall(TrailblazersBadgesS2.initialize, (address(s1Badges))) + ) + ); + + s2Badges = TrailblazersBadgesS2(proxy); + MAX_TAMPERS = s2Badges.MAX_TAMPERS(); + + s1Badges.setSeason2BadgeContract(address(s2Badges)); + vm.stopBroadcast(); + } + + function test_s1_metadata_badges() public view { + assertEq(s1Badges.BADGE_RAVERS(), 0); + assertEq(s1Badges.BADGE_ROBOTS(), 1); + assertEq(s1Badges.BADGE_BOUNCERS(), 2); + assertEq(s1Badges.BADGE_MASTERS(), 3); + assertEq(s1Badges.BADGE_MONKS(), 4); + assertEq(s1Badges.BADGE_DRUMMERS(), 5); + assertEq(s1Badges.BADGE_ANDROIDS(), 6); + assertEq(s1Badges.BADGE_SHINTO(), 7); + } + + function test_s2_metadata_badges() public view { + assertEq(s2Badges.RAVER_PINK_ID(), 0); + assertEq(s2Badges.RAVER_PURPLE_ID(), 1); + assertEq(s2Badges.ROBOT_PINK_ID(), 2); + assertEq(s2Badges.ROBOT_PURPLE_ID(), 3); + assertEq(s2Badges.BOUNCER_PINK_ID(), 4); + assertEq(s2Badges.BOUNCER_PURPLE_ID(), 5); + assertEq(s2Badges.MASTER_PINK_ID(), 6); + assertEq(s2Badges.MASTER_PURPLE_ID(), 7); + assertEq(s2Badges.MONK_PINK_ID(), 8); + assertEq(s2Badges.MONK_PURPLE_ID(), 9); + assertEq(s2Badges.DRUMMER_PINK_ID(), 10); + assertEq(s2Badges.DRUMMER_PURPLE_ID(), 11); + assertEq(s2Badges.ANDROID_PINK_ID(), 12); + assertEq(s2Badges.ANDROID_PURPLE_ID(), 13); + assertEq(s2Badges.SHINTO_PINK_ID(), 14); + assertEq(s2Badges.SHINTO_PURPLE_ID(), 15); + } + + function test_s1_s2_badgeId_conversion() public view { + (uint256 pinkId, uint256 purpleId) = s2Badges.getSeason2BadgeIds(s1Badges.BADGE_RAVERS()); + assertEq(pinkId, s2Badges.RAVER_PINK_ID()); + assertEq(purpleId, s2Badges.RAVER_PURPLE_ID()); + + (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1Badges.BADGE_ROBOTS()); + assertEq(pinkId, s2Badges.ROBOT_PINK_ID()); + assertEq(purpleId, s2Badges.ROBOT_PURPLE_ID()); + + (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1Badges.BADGE_BOUNCERS()); + assertEq(pinkId, s2Badges.BOUNCER_PINK_ID()); + assertEq(purpleId, s2Badges.BOUNCER_PURPLE_ID()); + + (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1Badges.BADGE_MASTERS()); + assertEq(pinkId, s2Badges.MASTER_PINK_ID()); + assertEq(purpleId, s2Badges.MASTER_PURPLE_ID()); + + (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1Badges.BADGE_MONKS()); + assertEq(pinkId, s2Badges.MONK_PINK_ID()); + assertEq(purpleId, s2Badges.MONK_PURPLE_ID()); + + (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1Badges.BADGE_DRUMMERS()); + assertEq(pinkId, s2Badges.DRUMMER_PINK_ID()); + assertEq(purpleId, s2Badges.DRUMMER_PURPLE_ID()); + + (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1Badges.BADGE_ANDROIDS()); + assertEq(pinkId, s2Badges.ANDROID_PINK_ID()); + assertEq(purpleId, s2Badges.ANDROID_PURPLE_ID()); + + (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1Badges.BADGE_SHINTO()); + assertEq(pinkId, s2Badges.SHINTO_PINK_ID()); + assertEq(purpleId, s2Badges.SHINTO_PURPLE_ID()); + } + + function test_s2_s1_badgeId_conversion() public view { + uint256 s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.RAVER_PINK_ID()); + assertEq(s1BadgeId, s1Badges.BADGE_RAVERS()); + s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.RAVER_PURPLE_ID()); + assertEq(s1BadgeId, s1Badges.BADGE_RAVERS()); + + s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.ROBOT_PINK_ID()); + assertEq(s1BadgeId, s1Badges.BADGE_ROBOTS()); + s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.ROBOT_PURPLE_ID()); + assertEq(s1BadgeId, s1Badges.BADGE_ROBOTS()); + + s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.BOUNCER_PINK_ID()); + assertEq(s1BadgeId, s1Badges.BADGE_BOUNCERS()); + s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.BOUNCER_PURPLE_ID()); + assertEq(s1BadgeId, s1Badges.BADGE_BOUNCERS()); + + s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.MASTER_PINK_ID()); + assertEq(s1BadgeId, s1Badges.BADGE_MASTERS()); + s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.MASTER_PURPLE_ID()); + assertEq(s1BadgeId, s1Badges.BADGE_MASTERS()); + + s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.MONK_PINK_ID()); + assertEq(s1BadgeId, s1Badges.BADGE_MONKS()); + s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.MONK_PURPLE_ID()); + assertEq(s1BadgeId, s1Badges.BADGE_MONKS()); + + s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.DRUMMER_PINK_ID()); + assertEq(s1BadgeId, s1Badges.BADGE_DRUMMERS()); + s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.DRUMMER_PURPLE_ID()); + assertEq(s1BadgeId, s1Badges.BADGE_DRUMMERS()); + + s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.ANDROID_PINK_ID()); + assertEq(s1BadgeId, s1Badges.BADGE_ANDROIDS()); + s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.ANDROID_PURPLE_ID()); + assertEq(s1BadgeId, s1Badges.BADGE_ANDROIDS()); + + s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.SHINTO_PINK_ID()); + assertEq(s1BadgeId, s1Badges.BADGE_SHINTO()); + s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.SHINTO_PURPLE_ID()); + assertEq(s1BadgeId, s1Badges.BADGE_SHINTO()); + } + + function mint_s1(address minter, uint256 badgeId) public { + bytes32 _hash = s1Badges.getHash(minter, badgeId); + + (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); + + bool canMint = s1Badges.canMint(abi.encodePacked(r, s, v), minter, badgeId); + assertTrue(canMint); + + vm.startPrank(minter); + s1Badges.mint(abi.encodePacked(r, s, v), badgeId); + vm.stopPrank(); + } + + function test_mint_s1() public { + mint_s1(minters[0], s1Badges.BADGE_RAVERS()); + mint_s1(minters[0], s1Badges.BADGE_ROBOTS()); + assertEq(s1Badges.balanceOf(minters[0]), 2); + + mint_s1(minters[1], s1Badges.BADGE_BOUNCERS()); + mint_s1(minters[1], s1Badges.BADGE_MASTERS()); + assertEq(s1Badges.balanceOf(minters[1]), 2); + + mint_s1(minters[2], s1Badges.BADGE_MONKS()); + mint_s1(minters[2], s1Badges.BADGE_DRUMMERS()); + assertEq(s1Badges.balanceOf(minters[2]), 2); + } + + function test_startMigration() public { + mint_s1(minters[0], BADGE_ID); + + uint256 tokenId = s1Badges.tokenOfOwnerByIndex(minters[0], 0); + + vm.startPrank(minters[0]); + s1Badges.approve(address(s2Badges), tokenId); + s2Badges.startMigration(tokenId); + vm.stopPrank(); + + assertEq(s1Badges.balanceOf(minters[0]), 0); + assertEq(s1Badges.balanceOf(address(s2Badges)), 1); + + assertEq(s1Badges.ownerOf(tokenId), address(s2Badges)); + + assertEq(s2Badges.isMigrationActive(minters[0]), true); + } + + // happy-path, make 3 pink tampers, and 2 purple ones + function test_tamperMigration() public { + test_startMigration(); + + vm.startPrank(minters[0]); + + for (uint256 i = 0; i < MAX_TAMPERS; i++) { + s2Badges.tamperMigration(PINK_TAMPER); + } + + s2Badges.tamperMigration(PURPLE_TAMPER); + s2Badges.tamperMigration(PURPLE_TAMPER); + vm.stopPrank(); + + assertEq(s2Badges.isTamperActive(minters[0]), true); + assertEq(s2Badges.isMigrationActive(minters[0]), true); + + (uint256 pinkTampers, uint256 purpleTampers) = s2Badges.getMigrationTampers(minters[0]); + assertEq(pinkTampers, MAX_TAMPERS); + assertEq(purpleTampers, 2); + } + + // revert when attempting a 4th pink tamper + function test_revert_tooManyTampers() public { + test_tamperMigration(); + vm.startPrank(minters[0]); + vm.expectRevert(); + s2Badges.tamperMigration(PINK_TAMPER); + + vm.stopPrank(); + } + + function test_revert_early_endMigration() public { + test_tamperMigration(); + vm.startPrank(minters[0]); + vm.expectRevert(); + s2Badges.endMigration(); + vm.stopPrank(); + } + + function test_endMigration() public { + test_tamperMigration(); + // roll forward the block number 2 hours + + vm.warp(2 hours); + vm.startPrank(minters[0]); + s2Badges.endMigration(); + vm.stopPrank(); + + assertEq(s1Badges.balanceOf(minters[0]), 0); + assertEq(s1Badges.balanceOf(address(s2Badges)), 0); + + assertEq(s2Badges.isMigrationActive(minters[0]), false); + assertEq(s2Badges.isTamperActive(minters[0]), false); + + uint256 s2TokenId = s2Badges.getTokenId(minters[0], s2Badges.DRUMMER_PINK_ID()); + assertEq(s2TokenId, 0); + assertEq(s2Badges.badgeBalanceOf(minters[0]), 1); + + /* + bool[16] memory badgeBalances = s2Badges.badgeBalances(minters[0]); + + assertFalse(badgeBalances[s2Badges.RAVER_PINK_ID()]); + assertFalse(badgeBalances[s2Badges.RAVER_PURPLE_ID()]); + assertFalse(badgeBalances[s2Badges.ROBOT_PINK_ID()]); + assertFalse(badgeBalances[s2Badges.ROBOT_PURPLE_ID()]); + assertFalse(badgeBalances[s2Badges.BOUNCER_PINK_ID()]); + assertFalse(badgeBalances[s2Badges.BOUNCER_PURPLE_ID()]); + assertFalse(badgeBalances[s2Badges.MASTER_PINK_ID()]); + assertFalse(badgeBalances[s2Badges.MASTER_PURPLE_ID()]); + assertFalse(badgeBalances[s2Badges.MONK_PINK_ID()]); + assertFalse(badgeBalances[s2Badges.MONK_PURPLE_ID()]); + //assertEq() + */ + } + + function test_revert_startMigrationTwice() public { + test_startMigration(); + vm.startPrank(minters[0]); + vm.expectRevert(); + s2Badges.startMigration(0); + vm.stopPrank(); + } + + /* + function test_simulateS1() public { + vm.prank(minters[0]); + s1Badges.mintBadge(minters[0], BADGE_ID, 0, "0x"); + }*/ +} From 70ac2c0671f3e015800cbcf2293ea1f08b777c06 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 2 Sep 2024 11:36:01 +0200 Subject: [PATCH 05/79] flow for start, tamper and end migrations --- .../TrailblazersBadgesS2.sol | 57 +++++++------------ .../TraiblazersBadgesS2.t.sol | 35 ++++++++---- 2 files changed, 45 insertions(+), 47 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol index 3e609e870a4..b180f43294a 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol @@ -49,31 +49,14 @@ contract TrailblazersBadgesS2 is uint256 public constant SHINTO_PINK_ID = 14; uint256 public constant SHINTO_PURPLE_ID = 15; - uint256[16] public BADGE_IDS = [ - RAVER_PINK_ID, - RAVER_PURPLE_ID, - ROBOT_PINK_ID, - ROBOT_PURPLE_ID, - BOUNCER_PINK_ID, - BOUNCER_PURPLE_ID, - MASTER_PINK_ID, - MASTER_PURPLE_ID, - MONK_PINK_ID, - MONK_PURPLE_ID, - DRUMMER_PINK_ID, - DRUMMER_PURPLE_ID, - ANDROID_PINK_ID, - ANDROID_PURPLE_ID, - SHINTO_PINK_ID, - SHINTO_PURPLE_ID - ]; + uint256 public constant BADGE_COUNT = 16; mapping(address _user => uint256 _cooldown) public claimCooldowns; mapping(address _user => uint256 _cooldown) public tamperCooldowns; mapping(address _user => mapping(bool pinkOrPurple => uint256 _tampers)) public migrationTampers; - mapping(address _user => uint256 _badgeId) public migrationBadgeIds; - + mapping(address _user => uint256 _badgeId) public migrationS1BadgeIds; + mapping(address _user => uint256 _tokenId) public migrationS1TokenIds; mapping(address _user => mapping(uint256 _badgeId => uint256 _tokenId)) public userBadges; error MAX_TAMPERS_REACHED(); @@ -85,7 +68,7 @@ contract TrailblazersBadgesS2 is error MIGRATION_NOT_READY(); error TOKEN_NOT_MINTED(); - mapping(uint256 => bool) public enabledBadgeIds; + mapping(uint256 _s1BadgeId => bool _enabled) public enabledBadgeIds; modifier whenUnpaused(uint256 _badgeId) { if (paused(_badgeId)) { @@ -130,18 +113,23 @@ contract TrailblazersBadgesS2 is } /// @notice Start a migration for a badge - /// @param _badgeTokenId The badge token ID (s1) + /// @param _s1BadgeId The badge token ID (s1) /// @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 _badgeTokenId) external { + function startMigration(uint256 _s1BadgeId) external { + uint256 s1TokenId = badges.getTokenId(_msgSender(), _s1BadgeId); + if (badges.ownerOf(s1TokenId) != _msgSender()) { + revert TOKEN_NOT_MINTED(); + } // transfer the badge tokens to the migration contract - badges.transferFrom(_msgSender(), address(this), _badgeTokenId); + badges.transferFrom(_msgSender(), address(this), s1TokenId); // set off the claim cooldown claimCooldowns[_msgSender()] = block.timestamp + 1 hours; migrationTampers[_msgSender()][true] = 0; migrationTampers[_msgSender()][false] = 0; - migrationBadgeIds[_msgSender()] = _badgeTokenId; + migrationS1BadgeIds[_msgSender()] = _s1BadgeId; + migrationS1TokenIds[_msgSender()] = s1TokenId; } /// @notice Tamper (alter) the chances during a migration @@ -175,11 +163,11 @@ contract TrailblazersBadgesS2 is pinkTampers < 3 && purpleTampers < 3 ? block.timestamp % 2 == 0 : pinkTampers < 3; (uint256 pinkBadgeId, uint256 purpleBadgeId) = - getSeason2BadgeIds(migrationBadgeIds[_msgSender()]); + getSeason2BadgeIds(migrationS1BadgeIds[_msgSender()]); uint256 s2BadgeId = isPink ? pinkBadgeId : purpleBadgeId; // burn the s1 badge - uint256 s1TokenId = migrationBadgeIds[_msgSender()]; + uint256 s1TokenId = migrationS1TokenIds[_msgSender()]; badges.burn(s1TokenId); uint256 s2TokenId = totalSupply() + 1; @@ -190,7 +178,8 @@ contract TrailblazersBadgesS2 is claimCooldowns[_msgSender()] = 0; migrationTampers[_msgSender()][true] = 0; migrationTampers[_msgSender()][false] = 0; - migrationBadgeIds[_msgSender()] = 0; + migrationS1BadgeIds[_msgSender()] = 0; + migrationS1TokenIds[_msgSender()] = 0; userBadges[_msgSender()][s2BadgeId] = s2TokenId; } @@ -262,17 +251,13 @@ contract TrailblazersBadgesS2 is } function getTokenId(address _user, uint256 _s2BadgeId) public view returns (uint256 _tokenId) { - _tokenId = userBadges[_user][_s2BadgeId]; - /* if (_tokenId == 0){ - revert TOKEN_NOT_MINTED(); - }*/ - return _tokenId; + return userBadges[_user][_s2BadgeId]; } function badgeBalances(address _owner) public view returns (bool[16] memory _balances) { - for (uint256 i = 0; i < BADGE_IDS.length; i++) { - uint256 tokenId = getTokenId(_owner, BADGE_IDS[i]); - _balances[i] = tokenId != 0; + for (uint256 i = 0; i < BADGE_COUNT; i++) { + uint256 tokenId = getTokenId(_owner, i); + _balances[i] = tokenId > 0; } return _balances; diff --git a/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol index b3f434fa80a..7cc021ebe13 100644 --- a/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol +++ b/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol @@ -21,7 +21,7 @@ contract TrailblazersBadgesTest is Test { address[3] public minters = [vm.addr(0x1), vm.addr(0x2), vm.addr(0x3)]; - uint256 constant BADGE_ID = 5; + uint256 public BADGE_ID; MockBlacklist public blacklist; @@ -55,6 +55,8 @@ contract TrailblazersBadgesTest is Test { s1Badges = TrailblazersBadges(proxy); + BADGE_ID = s1Badges.BADGE_RAVERS(); + // deploy the s2 contract impl = address(new TrailblazersBadgesS2()); @@ -211,7 +213,7 @@ contract TrailblazersBadgesTest is Test { vm.startPrank(minters[0]); s1Badges.approve(address(s2Badges), tokenId); - s2Badges.startMigration(tokenId); + s2Badges.startMigration(BADGE_ID); vm.stopPrank(); assertEq(s1Badges.balanceOf(minters[0]), 0); @@ -271,21 +273,28 @@ contract TrailblazersBadgesTest is Test { s2Badges.endMigration(); vm.stopPrank(); + // check for s1 burn assertEq(s1Badges.balanceOf(minters[0]), 0); assertEq(s1Badges.balanceOf(address(s2Badges)), 0); + // check for s2 state reset assertEq(s2Badges.isMigrationActive(minters[0]), false); assertEq(s2Badges.isTamperActive(minters[0]), false); - uint256 s2TokenId = s2Badges.getTokenId(minters[0], s2Badges.DRUMMER_PINK_ID()); - assertEq(s2TokenId, 0); - assertEq(s2Badges.badgeBalanceOf(minters[0]), 1); + // check for s2 mint + (uint256 pinkBadgeId, uint256 purpleBadgeId) = s2Badges.getSeason2BadgeIds(BADGE_ID); + uint256 s2TokenId = s2Badges.getTokenId(minters[0], pinkBadgeId) > 0 + ? s2Badges.getTokenId(minters[0], pinkBadgeId) + : s2Badges.getTokenId(minters[0], purpleBadgeId); + assertEq(s2Badges.balanceOf(minters[0], s2TokenId), 1); - /* + // check for s2 badge balances bool[16] memory badgeBalances = s2Badges.badgeBalances(minters[0]); - assertFalse(badgeBalances[s2Badges.RAVER_PINK_ID()]); - assertFalse(badgeBalances[s2Badges.RAVER_PURPLE_ID()]); + assertTrue( + badgeBalances[s2Badges.RAVER_PINK_ID()] || badgeBalances[s2Badges.RAVER_PURPLE_ID()] + ); + assertFalse(badgeBalances[s2Badges.ROBOT_PINK_ID()]); assertFalse(badgeBalances[s2Badges.ROBOT_PURPLE_ID()]); assertFalse(badgeBalances[s2Badges.BOUNCER_PINK_ID()]); @@ -294,15 +303,19 @@ contract TrailblazersBadgesTest is Test { assertFalse(badgeBalances[s2Badges.MASTER_PURPLE_ID()]); assertFalse(badgeBalances[s2Badges.MONK_PINK_ID()]); assertFalse(badgeBalances[s2Badges.MONK_PURPLE_ID()]); - //assertEq() - */ + assertFalse(badgeBalances[s2Badges.DRUMMER_PINK_ID()]); + assertFalse(badgeBalances[s2Badges.DRUMMER_PURPLE_ID()]); + assertFalse(badgeBalances[s2Badges.ANDROID_PINK_ID()]); + assertFalse(badgeBalances[s2Badges.ANDROID_PURPLE_ID()]); + assertFalse(badgeBalances[s2Badges.SHINTO_PINK_ID()]); + assertFalse(badgeBalances[s2Badges.SHINTO_PURPLE_ID()]); } function test_revert_startMigrationTwice() public { test_startMigration(); vm.startPrank(minters[0]); vm.expectRevert(); - s2Badges.startMigration(0); + s2Badges.startMigration(BADGE_ID); vm.stopPrank(); } From fafcffa9f0e6a8c8e9dab5444f089acc7836ef32 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 2 Sep 2024 11:49:10 +0200 Subject: [PATCH 06/79] enabling of badgeIds and revert case tests --- .../TrailblazersBadgesS2.sol | 62 +++++++++++++------ .../TraiblazersBadgesS2.t.sol | 25 ++++++++ 2 files changed, 68 insertions(+), 19 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol index b180f43294a..eba24f6dc90 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol @@ -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 { } + } diff --git a/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol index 7cc021ebe13..bcad1e48e41 100644 --- a/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol +++ b/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol @@ -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]); From fc5a77178bd95ab73b10c11bcad90875950445d2 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 2 Sep 2024 11:57:59 +0200 Subject: [PATCH 07/79] feature-complete tests --- .../TrailblazersBadgesS2.sol | 17 +++++------ .../TraiblazersBadgesS2.t.sol | 28 +++++++++++++++---- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol index eba24f6dc90..925a58a715f 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol @@ -69,7 +69,6 @@ contract TrailblazersBadgesS2 is error TOKEN_NOT_MINTED(); error MIGRATION_NOT_ENABLED(); - event MigrationEnabled(uint256 _s1BadgeId, bool _enabled); mapping(uint256 _s1BadgeId => bool _enabled) public enabledBadgeIds; @@ -108,7 +107,7 @@ contract TrailblazersBadgesS2 is } modifier migrationOpen(uint256 _s1BadgeId) { - if (!enabledBadgeIds[_s1BadgeId]){ + if (!enabledBadgeIds[_s1BadgeId]) { revert MIGRATION_NOT_ENABLED(); } _; @@ -195,20 +194,20 @@ contract TrailblazersBadgesS2 is userBadges[_msgSender()][s2BadgeId] = s2TokenId; } - function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) { for (uint256 i = 0; i < 8; i++) { if (enabledBadgeIds[i]) { - emit MigrationEnabled(i, false); + emit MigrationEnabled(i, false); } enabledBadgeIds[i] = false; } } - function enableMigrations( - uint256[] calldata _s1BadgeIds - ) external onlyRole(DEFAULT_ADMIN_ROLE) { + 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); @@ -282,8 +281,7 @@ contract TrailblazersBadgesS2 is return _balance; } - - /// @notice supportsInterface implementation + /// @notice supportsInterface implementation /// @param interfaceId The interface ID /// @return Whether the interface is supported function supportsInterface(bytes4 interfaceId) @@ -297,5 +295,4 @@ contract TrailblazersBadgesS2 is /// @notice Internal method to authorize an upgrade function _authorizeUpgrade(address) internal virtual override onlyOwner { } - } diff --git a/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol index bcad1e48e41..e45e3ca9651 100644 --- a/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol +++ b/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol @@ -76,7 +76,6 @@ contract TrailblazersBadgesTest is Test { enabledBadgeIds[0] = BADGE_ID; s2Badges.enableMigrations(enabledBadgeIds); - vm.stopBroadcast(); } @@ -344,9 +343,26 @@ contract TrailblazersBadgesTest is Test { assertEq(s2Badges.isMigrationActive(minters[0]), false); } - /* - function test_simulateS1() public { - vm.prank(minters[0]); - s1Badges.mintBadge(minters[0], BADGE_ID, 0, "0x"); - }*/ + function test_revert_pausedContract() public { + // have the admin pause the contract + // ensure no badges are mintable afterwards + vm.startPrank(owner); + s2Badges.pause(); + vm.stopPrank(); + + mint_s1(minters[0], BADGE_ID); + + uint256 tokenId = s1Badges.tokenOfOwnerByIndex(minters[0], 0); + + vm.startPrank(minters[0]); + s1Badges.approve(address(s2Badges), tokenId); + vm.expectRevert(); + s2Badges.startMigration(BADGE_ID); + 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); + } } From 55379a7d40aad844de328907804814de8bb1ab2f Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 2 Sep 2024 12:13:09 +0200 Subject: [PATCH 08/79] natspec docs for s2 badges contract --- .../TrailblazersBadgesS2.sol | 102 +++++++++++++----- 1 file changed, 75 insertions(+), 27 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol index 925a58a715f..6d23e1378e4 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol @@ -30,8 +30,9 @@ contract TrailblazersBadgesS2 is AccessControlUpgradeable, ERC1155SupplyUpgradeable { + /// @notice Maximum tamper attempts, per color uint256 public constant MAX_TAMPERS = 3; - + /// @notice S2 Badge IDs uint256 public constant RAVER_PINK_ID = 0; uint256 public constant RAVER_PURPLE_ID = 1; uint256 public constant ROBOT_PINK_ID = 2; @@ -48,19 +49,30 @@ contract TrailblazersBadgesS2 is uint256 public constant ANDROID_PURPLE_ID = 13; uint256 public constant SHINTO_PINK_ID = 14; uint256 public constant SHINTO_PURPLE_ID = 15; - + /// @notice Total badge count uint256 public constant BADGE_COUNT = 16; + /// @notice Cooldown for migration mapping(address _user => uint256 _cooldown) public claimCooldowns; + /// @notice Cooldown for tampering mapping(address _user => uint256 _cooldown) public tamperCooldowns; + /// @notice Tamper count mapping(address _user => mapping(bool pinkOrPurple => uint256 _tampers)) public migrationTampers; - - mapping(address _user => uint256 _badgeId) public migrationS1BadgeIds; - mapping(address _user => uint256 _tokenId) public migrationS1TokenIds; + /// @notice S1 Migration Badge ID mapping + mapping(address _user => uint256 _badgeId) private migrationS1BadgeIds; + /// @notice S1 Migration Token ID mapping + mapping(address _user => uint256 _tokenId) private migrationS1TokenIds; + /// @notice User to badge ID, token ID mapping mapping(address _user => mapping(uint256 _badgeId => uint256 _tokenId)) public userBadges; + /// @notice Migration-enabled badge IDs + mapping(uint256 _s1BadgeId => bool _enabled) public enabledBadgeIds; + /// @notice S1 Badge contract + TrailblazersBadges public badges; + /// @notice Gap for upgrade safety + uint256[43] private __gap; + /// @notice Errors error MAX_TAMPERS_REACHED(); - error MIGRATION_NOT_STARTED(); error MIGRATION_ALREADY_STARTED(); error TAMPER_IN_PROGRESS(); @@ -69,19 +81,17 @@ contract TrailblazersBadgesS2 is error TOKEN_NOT_MINTED(); error MIGRATION_NOT_ENABLED(); + /// @notice Events event MigrationEnabled(uint256 _s1BadgeId, bool _enabled); - mapping(uint256 _s1BadgeId => bool _enabled) public enabledBadgeIds; - + /// @notice Modifiers modifier whenUnpaused(uint256 _badgeId) { - if (paused(_badgeId)) { + if (!canMigrate(_badgeId) || paused()) { revert CONTRACT_PAUSED(); } _; } - TrailblazersBadges public badges; - modifier isMigrating() { if (claimCooldowns[_msgSender()] == 0) { revert MIGRATION_NOT_STARTED(); @@ -97,9 +107,6 @@ contract TrailblazersBadgesS2 is } modifier isNotTampering() { - // revert if the user is tampering; ie, their cooldown - // has not expired - if (tamperCooldowns[_msgSender()] < block.timestamp) { revert TAMPER_IN_PROGRESS(); } @@ -113,13 +120,14 @@ contract TrailblazersBadgesS2 is _; } + /// @notice Contract initializer + /// @param _badges The address of the S1 badges contract function initialize(address _badges) external initializer { __ERC1155_init(""); __ERC1155Supply_init(); _transferOwnership(_msgSender()); __Context_init(); _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); - badges = TrailblazersBadges(_badges); } @@ -194,16 +202,9 @@ contract TrailblazersBadgesS2 is userBadges[_msgSender()][s2BadgeId] = s2TokenId; } - function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) { - for (uint256 i = 0; i < 8; i++) { - if (enabledBadgeIds[i]) { - emit MigrationEnabled(i, false); - } - - enabledBadgeIds[i] = false; - } - } - + /// @notice Enable migrations for a set of badges + /// @param _s1BadgeIds The badge IDs to enable + /// @dev Can be called only by the contract owner/admin function enableMigrations(uint256[] calldata _s1BadgeIds) external onlyRole(DEFAULT_ADMIN_ROLE) @@ -214,20 +215,29 @@ contract TrailblazersBadgesS2 is } } - function paused(uint256 _s1Badge) public view returns (bool) { + /// @notice Check if the migrations for a badge are enabled + /// @param _s1Badge The badge ID to check + /// @return Whether the badge is enabled for migration + function canMigrate(uint256 _s1Badge) public view returns (bool) { for (uint256 i = 0; i < 8; i++) { if (enabledBadgeIds[i] && i == _s1Badge) { return true; } } - return super.paused(); + return false; } + /// @notice Pause the contract + /// @dev Can be called only by the contract owner/admin function pause() public onlyRole(DEFAULT_ADMIN_ROLE) { _disableMigrations(); _pause(); } + /// @notice S1 --> S2 badge ID mapping + /// @param _s1BadgeId The S1 badge ID + /// @return _pinkBadgeId The S2 pink badge ID + /// @return _purpleBadgeId The S2 purple badge ID function getSeason2BadgeIds(uint256 _s1BadgeId) public pure @@ -236,30 +246,53 @@ contract TrailblazersBadgesS2 is return (_s1BadgeId * 2, _s1BadgeId * 2 + 1); } + /// @notice S2 --> S1 badge ID mapping + /// @param _s2BadgeId The S2 badge ID + /// @return _s1BadgeId The S1 badge ID function getSeason1BadgeId(uint256 _s2BadgeId) public pure returns (uint256 _s1BadgeId) { return _s2BadgeId / 2; } + /// @notice Check if a migration is active for a user + /// @param _user The user address + /// @return Whether the user has an active migration function isMigrationActive(address _user) public view returns (bool) { return claimCooldowns[_user] != 0; } + /// @notice Check if a tamper is active for a user + /// @param _user The user address + /// @return Whether the user has an active tamper function isTamperActive(address _user) public view returns (bool) { return tamperCooldowns[_user] > block.timestamp; } + /// @notice Get the migration tamper counts for a user + /// @param _user The user address + /// @return _pinkTampers The pink tamper count + /// @return _purpleTampers The purple tamper count function getMigrationTampers(address _user) public view returns (uint256 _pinkTampers, uint256 _purpleTampers) { + if (!isMigrationActive(_user)) { + revert MIGRATION_NOT_STARTED(); + } return (migrationTampers[_user][true], migrationTampers[_user][false]); } + /// @notice Retrieve a token ID given their owner and S2 Badge ID + /// @param _user The address of the badge owner + /// @param _s2BadgeId The S2 badge ID + /// @return _tokenId The token ID function getTokenId(address _user, uint256 _s2BadgeId) public view returns (uint256 _tokenId) { return userBadges[_user][_s2BadgeId]; } + /// @notice Retrieve boolean balance for each badge + /// @param _owner The addresses to check + /// @return _balances The badges atomic balances function badgeBalances(address _owner) public view returns (bool[16] memory _balances) { for (uint256 i = 0; i < BADGE_COUNT; i++) { uint256 tokenId = getTokenId(_owner, i); @@ -269,6 +302,9 @@ contract TrailblazersBadgesS2 is return _balances; } + /// @notice Retrieve the total S2 unique badge balance of an address + /// @param _owner The address to check + /// @return _balance The total badge balance (count) function badgeBalanceOf(address _owner) public view returns (uint256 _balance) { bool[16] memory balances = badgeBalances(_owner); @@ -281,6 +317,18 @@ contract TrailblazersBadgesS2 is return _balance; } + /// @notice Disable all new migrations + /// @dev Doesn't allow for new migration attempts, but tampers and active migrations still run + function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) { + for (uint256 i = 0; i < 8; i++) { + if (enabledBadgeIds[i]) { + emit MigrationEnabled(i, false); + } + + enabledBadgeIds[i] = false; + } + } + /// @notice supportsInterface implementation /// @param interfaceId The interface ID /// @return Whether the interface is supported From 82d4fa07e3b2790db0d46722160f8ec4f33d20f4 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 2 Sep 2024 12:46:46 +0200 Subject: [PATCH 09/79] hekla deployment script and typo fix --- .../TrailblazersSeason2.sol | 2 +- .../trailblazers-badges/hekla.json | 5 +- packages/nfts/package.json | 3 +- .../trailblazers-badges/sol/DeployS2.s.sol | 119 ++++++++++++++++++ .../sol/{UpgradeV2.sol => UpgradeS1.sol} | 4 +- 5 files changed, 126 insertions(+), 7 deletions(-) create mode 100644 packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol rename packages/nfts/script/trailblazers-badges/sol/{UpgradeV2.sol => UpgradeS1.sol} (92%) diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol index 85efe5a1a67..8163e3ba8fb 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol @@ -115,7 +115,7 @@ interface TrailPass { /// @notice Upgrade a Trail Pass /// @param _tier The tier of the Trail Pass - /// @dev The price is determined by the tier, and substracted from the existing trail pass price + /// @dev The price is determined by the tier, and subtracted from the existing trail pass price function upgradeTrailPass(uint256 _tier) external payable; /// @notice Check if an account has a Trail Pass, any diff --git a/packages/nfts/deployments/trailblazers-badges/hekla.json b/packages/nfts/deployments/trailblazers-badges/hekla.json index 8a2ecea8f35..057a89104d9 100644 --- a/packages/nfts/deployments/trailblazers-badges/hekla.json +++ b/packages/nfts/deployments/trailblazers-badges/hekla.json @@ -1,5 +1,4 @@ { - "MintSigner": "0x3cda4F2EaC3fc2FdE78B3DFFe1A1A1Eff88c68c5", - "Owner": "0x7d70236E2517f5B95247AF1d806A9E3C328a7860", - "TrailblazersBadges": "0x010992985d1DA35676271bd5abA16E0E8D5582d3" + "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", + "TrailblazersBadgesS2": "0x2DA4DCe2292ac21c35aC683B218f701347cf375C" } diff --git a/packages/nfts/package.json b/packages/nfts/package.json index 241e323bfd3..862cfe009e8 100644 --- a/packages/nfts/package.json +++ b/packages/nfts/package.json @@ -27,7 +27,8 @@ "galxe:deploy:mainnet": "forge clean && pnpm compile && forge script script/galxe/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --legacy --with-gas-price 1", "tbzb:deploy:mainnet": "forge clean && pnpm compile && forge script script/trailblazers-badges/sol/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 13 ", "taikoon:deploy:v2": "forge clean && pnpm compile && forge script script/taikoon/sol/UpgradeV2.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast", - "kbw:deploy:hekla": "forge clean && pnpm compile && forge script script/party-ticket/sol/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200" + "kbw:deploy:hekla": "forge clean && pnpm compile && forge script script/party-ticket/sol/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", + "tbz:s2:deploy:hekla": "forge clean && pnpm compile && forge script script/trailblazers-badges/sol/DeployS2.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200" }, "devDependencies": { "@types/node": "^20.11.30", diff --git a/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol b/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol new file mode 100644 index 00000000000..0980b1cfcee --- /dev/null +++ b/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol @@ -0,0 +1,119 @@ +// 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 { TrailblazersBadgesS2 } from + "../../../contracts/trailblazers-badges/TrailblazersBadgesS2.sol"; + +contract DeployScript is Script { + UtilsScript public utils; + string public jsonLocation; + uint256 public deployerPrivateKey; + address public deployerAddress; + + // Taiko Mainnet Values + //address owner = 0xf8ff2AF0DC1D5BA4811f22aCb02936A1529fd2Be; + //bytes32 root = 0xa7e510d5aed347e65609cf6f0e0738cdd752ffdf5980749057c634489fd09fc3; + // string baseURI = "bafybeierqzehlrqeqqeb6fwmil4dj3ij2p6exgoj4lysl53fsxwob6wbdy"; + // IMinimalBlacklist blacklist = IMinimalBlacklist(0xfA5EA6f9A13532cd64e805996a941F101CCaAc9a); + + // Holesky Testnet Values + // address owner = 0xf8ff2AF0DC1D5BA4811f22aCb02936A1529fd2Be; + // bytes32 root = 0xf1359c4c4ba41a72025f2534ea8ad23c6b941b55a715838ebdc71202a78c6c87; + // string baseURI = "bafybeierqzehlrqeqqeb6fwmil4dj3ij2p6exgoj4lysl53fsxwob6wbdy"; + // IMinimalBlacklist blacklist = IMinimalBlacklist(0xe61E9034b5633977eC98E302b33e321e8140F105); + + // Hardhat Testnet Values + address owner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; + address mintSigner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; + string baseURI = + "https://taikonfts.4everland.link/ipfs/bafybeierqzehlrqeqqeb6fwmil4dj3ij2p6exgoj4lysl53fsxwob6wbdy"; + IMinimalBlacklist blacklist = IMinimalBlacklist(0xe61E9034b5633977eC98E302b33e321e8140F105); + + address s1Contract = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; + + function setUp() public { + utils = new UtilsScript(); + utils.setUp(); + + jsonLocation = utils.getContractJsonLocation(); + deployerPrivateKey = utils.getPrivateKey(); + deployerAddress = utils.getAddress(); + } + + function run() public { + string memory jsonRoot = "root"; + + require(owner != address(0), "Owner must be specified"); + + address impl; + address proxy; + TrailblazersBadges s1Token; + vm.startBroadcast(deployerPrivateKey); + + if (block.chainid == 167_000) { + // mainnet, use existing contract + s1Token = TrailblazersBadges(s1Contract); + } else { + // hekla/localhost, deploy a s1 contract + impl = address(new TrailblazersBadges()); + proxy = address( + new ERC1967Proxy( + impl, + abi.encodeCall( + TrailblazersBadges.initialize, (owner, baseURI, mintSigner, blacklist) + ) + ) + ); + + s1Token = TrailblazersBadges(proxy); + } + /* + + // deploy token with empty root + address impl = address(new TrailblazersBadges()); + address proxy = address( + new ERC1967Proxy( + impl, + abi.encodeCall( + TrailblazersBadges.initialize, (owner, baseURI, mintSigner, blacklist) + ) + ) + ); + + TrailblazersBadges token = TrailblazersBadges(proxy); + + console.log("Token Base URI:", baseURI); + console.log("Deployed TrailblazersBadges to:", address(token)); + + vm.serializeAddress(jsonRoot, "Owner", token.owner()); + vm.serializeAddress(jsonRoot, "MintSigner", token.mintSigner()); + + string memory finalJson = + vm.serializeAddress(jsonRoot, "TrailblazersBadges", address(token)); + vm.writeJson(finalJson, jsonLocation);*/ + + impl = address(new TrailblazersBadgesS2()); + proxy = address( + new ERC1967Proxy(impl, abi.encodeCall(TrailblazersBadgesS2.initialize, (s1Contract))) + ); + + TrailblazersBadgesS2 s2Token = TrailblazersBadgesS2(proxy); + + console.log("Token Base URI:", baseURI); + console.log("Deployed TrailblazersBadgesS2 to:", address(s2Token)); + + vm.serializeAddress(jsonRoot, "Owner", s2Token.owner()); + + string memory finalJson = + vm.serializeAddress(jsonRoot, "TrailblazersBadgesS2", address(s2Token)); + vm.writeJson(finalJson, jsonLocation); + + vm.stopBroadcast(); + } +} diff --git a/packages/nfts/script/trailblazers-badges/sol/UpgradeV2.sol b/packages/nfts/script/trailblazers-badges/sol/UpgradeS1.sol similarity index 92% rename from packages/nfts/script/trailblazers-badges/sol/UpgradeV2.sol rename to packages/nfts/script/trailblazers-badges/sol/UpgradeS1.sol index 0588945b84c..662a98a3561 100644 --- a/packages/nfts/script/trailblazers-badges/sol/UpgradeV2.sol +++ b/packages/nfts/script/trailblazers-badges/sol/UpgradeS1.sol @@ -14,7 +14,7 @@ contract UpgradeV2 is Script { uint256 public deployerPrivateKey; address public deployerAddress; - address tokenV1 = 0xa20a8856e00F5ad024a55A663F06DCc419FFc4d5; + address s1Token = 0xa20a8856e00F5ad024a55A663F06DCc419FFc4d5; TrailblazersBadges public token; function setUp() public { @@ -27,7 +27,7 @@ contract UpgradeV2 is Script { } function run() public { - token = TrailblazersBadges(tokenV1); + token = TrailblazersBadges(s1Token); vm.startBroadcast(deployerPrivateKey); token.upgradeToAndCall( From b6a1e2b07596e229068572f9885bcbaee6c61a86 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 2 Sep 2024 12:47:15 +0200 Subject: [PATCH 10/79] minor cleanup --- .../trailblazers-badges/sol/DeployS2.s.sol | 27 ++----------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol b/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol index 0980b1cfcee..1ae6e526ff0 100644 --- a/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol +++ b/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol @@ -73,31 +73,8 @@ contract DeployScript is Script { s1Token = TrailblazersBadges(proxy); } - /* - - // deploy token with empty root - address impl = address(new TrailblazersBadges()); - address proxy = address( - new ERC1967Proxy( - impl, - abi.encodeCall( - TrailblazersBadges.initialize, (owner, baseURI, mintSigner, blacklist) - ) - ) - ); - - TrailblazersBadges token = TrailblazersBadges(proxy); - - console.log("Token Base URI:", baseURI); - console.log("Deployed TrailblazersBadges to:", address(token)); - - vm.serializeAddress(jsonRoot, "Owner", token.owner()); - vm.serializeAddress(jsonRoot, "MintSigner", token.mintSigner()); - - string memory finalJson = - vm.serializeAddress(jsonRoot, "TrailblazersBadges", address(token)); - vm.writeJson(finalJson, jsonLocation);*/ + // deploy s2 contract impl = address(new TrailblazersBadgesS2()); proxy = address( new ERC1967Proxy(impl, abi.encodeCall(TrailblazersBadgesS2.initialize, (s1Contract))) @@ -109,7 +86,7 @@ contract DeployScript is Script { console.log("Deployed TrailblazersBadgesS2 to:", address(s2Token)); vm.serializeAddress(jsonRoot, "Owner", s2Token.owner()); - + vm.serializeAddress(jsonRoot, "TrailblazersBadgesS1", address(s1Token)); string memory finalJson = vm.serializeAddress(jsonRoot, "TrailblazersBadgesS2", address(s2Token)); vm.writeJson(finalJson, jsonLocation); From 8bc8fbfbf65aeff18098fa64a6c548c1c15f688b Mon Sep 17 00:00:00 2001 From: bearni95 Date: Tue, 3 Sep 2024 11:59:04 +0200 Subject: [PATCH 11/79] hekla testing --- .../TrailblazersBadgesS2.sol | 31 ++++++++---- .../trailblazers-badges/hekla.json | 3 +- packages/nfts/package.json | 28 +++++------ .../trailblazers-badges/sol/DeployS2.s.sol | 48 ++++++++++++++----- 4 files changed, 74 insertions(+), 36 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol index 6d23e1378e4..b8f477524c7 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol @@ -16,6 +16,7 @@ import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import "@taiko/blacklist/IMinimalBlacklist.sol"; @@ -28,7 +29,8 @@ contract TrailblazersBadgesS2 is UUPSUpgradeable, Ownable2StepUpgradeable, AccessControlUpgradeable, - ERC1155SupplyUpgradeable + ERC1155SupplyUpgradeable, + ERC721HolderUpgradeable { /// @notice Maximum tamper attempts, per color uint256 public constant MAX_TAMPERS = 3; @@ -80,9 +82,15 @@ contract TrailblazersBadgesS2 is error MIGRATION_NOT_READY(); error TOKEN_NOT_MINTED(); error MIGRATION_NOT_ENABLED(); + error TOKEN_NOT_OWNED(); /// @notice Events - event MigrationEnabled(uint256 _s1BadgeId, bool _enabled); + event MigrationToggled(uint256 _s1BadgeId, bool _enabled); + event MigrationStarted( + address _user, uint256 _s1BadgeId, uint256 _s1TokenId, uint256 _cooldownExpiration + ); + event MigrationTampered(address _user, bool _pinkOrPurple, uint256 _cooldownExpiration); + event MigrationEnded(address _user, uint256 _s2BadgeId, uint256 _s2TokenId); /// @notice Modifiers modifier whenUnpaused(uint256 _badgeId) { @@ -132,23 +140,27 @@ contract TrailblazersBadgesS2 is } /// @notice Start a migration for a badge - /// @param _s1BadgeId The badge token ID (s1) + /// @param _s1BadgeId The badge ID (s1) /// @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 migrationOpen(_s1BadgeId) isNotMigrating { uint256 s1TokenId = badges.getTokenId(_msgSender(), _s1BadgeId); + if (badges.ownerOf(s1TokenId) != _msgSender()) { - revert TOKEN_NOT_MINTED(); + revert TOKEN_NOT_OWNED(); } - // transfer the badge tokens to the migration contract - badges.transferFrom(_msgSender(), address(this), s1TokenId); + // set off the claim cooldown claimCooldowns[_msgSender()] = block.timestamp + 1 hours; migrationTampers[_msgSender()][true] = 0; migrationTampers[_msgSender()][false] = 0; migrationS1BadgeIds[_msgSender()] = _s1BadgeId; migrationS1TokenIds[_msgSender()] = s1TokenId; + // transfer the badge tokens to the migration contract + badges.transferFrom(_msgSender(), address(this), s1TokenId); + + emit MigrationStarted(_msgSender(), _s1BadgeId, s1TokenId, claimCooldowns[_msgSender()]); } /// @notice Tamper (alter) the chances during a migration @@ -162,6 +174,7 @@ contract TrailblazersBadgesS2 is } migrationTampers[_msgSender()][_pinkOrPurple]++; tamperCooldowns[_msgSender()] = block.timestamp + 1 hours; + emit MigrationTampered(_msgSender(), _pinkOrPurple, tamperCooldowns[_msgSender()]); } /// @notice End a migration @@ -200,6 +213,8 @@ contract TrailblazersBadgesS2 is migrationS1BadgeIds[_msgSender()] = 0; migrationS1TokenIds[_msgSender()] = 0; userBadges[_msgSender()][s2BadgeId] = s2TokenId; + + emit MigrationEnded(_msgSender(), s2BadgeId, s2TokenId); } /// @notice Enable migrations for a set of badges @@ -211,7 +226,7 @@ contract TrailblazersBadgesS2 is { for (uint256 i = 0; i < _s1BadgeIds.length; i++) { enabledBadgeIds[_s1BadgeIds[i]] = true; - emit MigrationEnabled(_s1BadgeIds[i], true); + emit MigrationToggled(_s1BadgeIds[i], true); } } @@ -322,7 +337,7 @@ contract TrailblazersBadgesS2 is function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) { for (uint256 i = 0; i < 8; i++) { if (enabledBadgeIds[i]) { - emit MigrationEnabled(i, false); + emit MigrationToggled(i, false); } enabledBadgeIds[i] = false; diff --git a/packages/nfts/deployments/trailblazers-badges/hekla.json b/packages/nfts/deployments/trailblazers-badges/hekla.json index 057a89104d9..66e3f36de21 100644 --- a/packages/nfts/deployments/trailblazers-badges/hekla.json +++ b/packages/nfts/deployments/trailblazers-badges/hekla.json @@ -1,4 +1,5 @@ { "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadgesS2": "0x2DA4DCe2292ac21c35aC683B218f701347cf375C" + "TrailblazersBadges": "0x45a7c3ff90f52f71b9C2FAdCaf2860d7B0E11FC4", + "TrailblazersBadgesS2": "0x7Da4EC218BA4478D0b8a41422DdCE1B2e9AEA736" } diff --git a/packages/nfts/package.json b/packages/nfts/package.json index 862cfe009e8..7cf6df445bd 100644 --- a/packages/nfts/package.json +++ b/packages/nfts/package.json @@ -13,22 +13,22 @@ "layout": "./deployments/gen-layouts.sh", "taikoon:merkle": "node script/taikoon/js/generate-merkle-tree.js", "snaefell:merkle": "node script/snaefell/js/generate-merkle-tree.js", - "taikoon:deploy:localhost": "forge clean && pnpm compile && forge script script/taikoon/sol/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast", - "snaefell:deploy:localhost": "forge clean && pnpm compile && forge script script/snaefell/sol/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast", + "taikoon:deploy:localhost": "forge clean && forge script script/taikoon/sol/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast", + "snaefell:deploy:localhost": "forge clean && forge script script/snaefell/sol/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast", "taikoon:deploy:ipfs": "rm -rf data/taikoon/metadata/* && node script/taikoon/js/4everland.js", "snaefell:deploy:ipfs": "rm -rf data/snaefell/metadata/* && node script/snaefell/js/4everland.js", - "taikoon:deploy:devnet": "forge clean && pnpm compile && forge script script/taikoon/sol/Deploy.s.sol --rpc-url https://rpc.internal.taiko.xyz --broadcast --gas-estimate-multiplier 200", - "snaefell:deploy:devnet": "forge clean && pnpm compile && forge script script/snaefell/sol/Deploy.s.sol --rpc-url https://rpc.internal.taiko.xyz --broadcast --gas-estimate-multiplier 200", - "taikoon:deploy:mainnet": "forge clean && pnpm compile && forge script script/taikoon/sol/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 13 ", - "snaefell:deploy:mainnet": "forge clean && pnpm compile && forge script script/snaefell/sol/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 13 ", - "taikoon:deploy:holesky": "forge clean && pnpm compile && forge script script/taikoon/sol/Deploy.s.sol --rpc-url https://1rpc.io/holesky --broadcast --gas-estimate-multiplier 200", - "tbzb:deploy:localhost": "forge clean && pnpm compile && forge script script/trailblazers-badges/sol/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast", - "tbzb:deploy:hekla": "forge clean && pnpm compile && forge script script/trailblazers-badges/sol/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", - "galxe:deploy:mainnet": "forge clean && pnpm compile && forge script script/galxe/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --legacy --with-gas-price 1", - "tbzb:deploy:mainnet": "forge clean && pnpm compile && forge script script/trailblazers-badges/sol/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 13 ", - "taikoon:deploy:v2": "forge clean && pnpm compile && forge script script/taikoon/sol/UpgradeV2.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast", - "kbw:deploy:hekla": "forge clean && pnpm compile && forge script script/party-ticket/sol/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", - "tbz:s2:deploy:hekla": "forge clean && pnpm compile && forge script script/trailblazers-badges/sol/DeployS2.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200" + "taikoon:deploy:devnet": "forge clean && forge script script/taikoon/sol/Deploy.s.sol --rpc-url https://rpc.internal.taiko.xyz --broadcast --gas-estimate-multiplier 200", + "snaefell:deploy:devnet": "forge clean && forge script script/snaefell/sol/Deploy.s.sol --rpc-url https://rpc.internal.taiko.xyz --broadcast --gas-estimate-multiplier 200", + "taikoon:deploy:mainnet": "forge clean && forge script script/taikoon/sol/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 13 ", + "snaefell:deploy:mainnet": "forge clean && forge script script/snaefell/sol/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 13 ", + "taikoon:deploy:holesky": "forge clean && forge script script/taikoon/sol/Deploy.s.sol --rpc-url https://1rpc.io/holesky --broadcast --gas-estimate-multiplier 200", + "tbzb:deploy:localhost": "forge clean && forge script script/trailblazers-badges/sol/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast", + "tbzb:deploy:hekla": "forge clean && forge script script/trailblazers-badges/sol/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", + "galxe:deploy:mainnet": "forge clean && forge script script/galxe/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --legacy --with-gas-price 1", + "tbzb:deploy:mainnet": "forge clean && forge script script/trailblazers-badges/sol/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 13 ", + "taikoon:deploy:v2": "forge clean && forge script script/taikoon/sol/UpgradeV2.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast", + "kbw:deploy:hekla": "forge clean && forge script script/party-ticket/sol/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", + "tbz:s2:deploy:hekla": "forge clean && forge script script/trailblazers-badges/sol/DeployS2.s.sol --tc DeployS2Script --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200" }, "devDependencies": { "@types/node": "^20.11.30", diff --git a/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol b/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol index 1ae6e526ff0..0b8230619c6 100644 --- a/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol +++ b/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol @@ -10,7 +10,16 @@ import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; import { TrailblazersBadgesS2 } from "../../../contracts/trailblazers-badges/TrailblazersBadgesS2.sol"; -contract DeployScript is Script { +contract MockBlacklist is IMinimalBlacklist { + function isBlacklisted(address _account) external pure returns (bool) { + if (_account == address(0)) { + return true; + } + return false; + } +} + +contract DeployS2Script is Script { UtilsScript public utils; string public jsonLocation; uint256 public deployerPrivateKey; @@ -23,17 +32,17 @@ contract DeployScript is Script { // IMinimalBlacklist blacklist = IMinimalBlacklist(0xfA5EA6f9A13532cd64e805996a941F101CCaAc9a); // Holesky Testnet Values - // address owner = 0xf8ff2AF0DC1D5BA4811f22aCb02936A1529fd2Be; - // bytes32 root = 0xf1359c4c4ba41a72025f2534ea8ad23c6b941b55a715838ebdc71202a78c6c87; - // string baseURI = "bafybeierqzehlrqeqqeb6fwmil4dj3ij2p6exgoj4lysl53fsxwob6wbdy"; - // IMinimalBlacklist blacklist = IMinimalBlacklist(0xe61E9034b5633977eC98E302b33e321e8140F105); + bytes32 root = 0xf1359c4c4ba41a72025f2534ea8ad23c6b941b55a715838ebdc71202a78c6c87; + string baseURI = "bafybeierqzehlrqeqqeb6fwmil4dj3ij2p6exgoj4lysl53fsxwob6wbdy"; + IMinimalBlacklist blacklist = IMinimalBlacklist(0xe61E9034b5633977eC98E302b33e321e8140F105); + address mintSigner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; // Hardhat Testnet Values - address owner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; - address mintSigner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; - string baseURI = - "https://taikonfts.4everland.link/ipfs/bafybeierqzehlrqeqqeb6fwmil4dj3ij2p6exgoj4lysl53fsxwob6wbdy"; - IMinimalBlacklist blacklist = IMinimalBlacklist(0xe61E9034b5633977eC98E302b33e321e8140F105); + // address owner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; + // address mintSigner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; + // string baseURI = "https://taikonfts.4everland.link/ipfs/bafybeierqzehlrqeqqeb6fwmil4dj3ij2p6exgoj4lysl53fsxwob6wbdy"; + // IMinimalBlacklist blacklist = + // IMinimalBlacklist(0xe61E9034b5633977eC98E302b33e321e8140F105); address s1Contract = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; @@ -48,7 +57,7 @@ contract DeployScript is Script { function run() public { string memory jsonRoot = "root"; - + address owner = deployerAddress; require(owner != address(0), "Owner must be specified"); address impl; @@ -62,6 +71,7 @@ contract DeployScript is Script { } else { // hekla/localhost, deploy a s1 contract impl = address(new TrailblazersBadges()); + blacklist = new MockBlacklist(); proxy = address( new ERC1967Proxy( impl, @@ -77,7 +87,9 @@ contract DeployScript is Script { // deploy s2 contract impl = address(new TrailblazersBadgesS2()); proxy = address( - new ERC1967Proxy(impl, abi.encodeCall(TrailblazersBadgesS2.initialize, (s1Contract))) + new ERC1967Proxy( + impl, abi.encodeCall(TrailblazersBadgesS2.initialize, address(s1Token)) + ) ); TrailblazersBadgesS2 s2Token = TrailblazersBadgesS2(proxy); @@ -86,11 +98,21 @@ contract DeployScript is Script { console.log("Deployed TrailblazersBadgesS2 to:", address(s2Token)); vm.serializeAddress(jsonRoot, "Owner", s2Token.owner()); - vm.serializeAddress(jsonRoot, "TrailblazersBadgesS1", address(s1Token)); + vm.serializeAddress(jsonRoot, "TrailblazersBadges", address(s1Token)); string memory finalJson = vm.serializeAddress(jsonRoot, "TrailblazersBadgesS2", address(s2Token)); vm.writeJson(finalJson, jsonLocation); + // open up migrations for all badges on hekla + if (block.chainid != 167_000) { + uint256[] memory tokenIds = new uint256[](s1Token.totalSupply()); + for (uint256 i = 0; i < s1Token.totalSupply(); i++) { + tokenIds[i] = i; + } + s2Token.enableMigrations(tokenIds); + console.log("Enabled migrations for all badges"); + } + vm.stopBroadcast(); } } From d898be469310a13ca611fe08aa824bc944bfac68 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Wed, 4 Sep 2024 10:46:04 +0200 Subject: [PATCH 12/79] frontend changes --- .../TrailblazersBadgesS2.sol | 18 +++++++++++++++--- .../deployments/trailblazers-badges/hekla.json | 4 ++-- .../TraiblazersBadgesS2.t.sol | 14 +++++++++++--- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol index b8f477524c7..314d42637be 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol @@ -32,6 +32,8 @@ contract TrailblazersBadgesS2 is ERC1155SupplyUpgradeable, ERC721HolderUpgradeable { + uint256 public constant COOLDOWN_MIGRATION = 6 hours; + uint256 public constant COOLDOWN_TAMPER = 1 hours; /// @notice Maximum tamper attempts, per color uint256 public constant MAX_TAMPERS = 3; /// @notice S2 Badge IDs @@ -152,11 +154,12 @@ contract TrailblazersBadgesS2 is } // set off the claim cooldown - claimCooldowns[_msgSender()] = block.timestamp + 1 hours; + claimCooldowns[_msgSender()] = block.timestamp + COOLDOWN_MIGRATION; migrationTampers[_msgSender()][true] = 0; migrationTampers[_msgSender()][false] = 0; migrationS1BadgeIds[_msgSender()] = _s1BadgeId; migrationS1TokenIds[_msgSender()] = s1TokenId; + tamperCooldowns[_msgSender()] = 0; // transfer the badge tokens to the migration contract badges.transferFrom(_msgSender(), address(this), s1TokenId); @@ -172,8 +175,13 @@ contract TrailblazersBadgesS2 is if (migrationTampers[_msgSender()][_pinkOrPurple] >= MAX_TAMPERS) { revert MAX_TAMPERS_REACHED(); } + + if (tamperCooldowns[_msgSender()] > block.timestamp) { + revert TAMPER_IN_PROGRESS(); + } + migrationTampers[_msgSender()][_pinkOrPurple]++; - tamperCooldowns[_msgSender()] = block.timestamp + 1 hours; + tamperCooldowns[_msgSender()] = block.timestamp + COOLDOWN_TAMPER; emit MigrationTampered(_msgSender(), _pinkOrPurple, tamperCooldowns[_msgSender()]); } @@ -181,8 +189,11 @@ contract TrailblazersBadgesS2 is /// @dev Can be called only during an active migration, after the cooldown is over /// @dev The final color is determined randomly, and affected by the tamper amounts function endMigration() external isMigrating { + if (tamperCooldowns[_msgSender()] > block.timestamp) { + revert TAMPER_IN_PROGRESS(); + } // check if the cooldown is over - if (block.timestamp < claimCooldowns[_msgSender()]) { + if (claimCooldowns[_msgSender()] > block.timestamp) { revert MIGRATION_NOT_READY(); } @@ -210,6 +221,7 @@ contract TrailblazersBadgesS2 is claimCooldowns[_msgSender()] = 0; migrationTampers[_msgSender()][true] = 0; migrationTampers[_msgSender()][false] = 0; + tamperCooldowns[_msgSender()] = 0; migrationS1BadgeIds[_msgSender()] = 0; migrationS1TokenIds[_msgSender()] = 0; userBadges[_msgSender()][s2BadgeId] = s2TokenId; diff --git a/packages/nfts/deployments/trailblazers-badges/hekla.json b/packages/nfts/deployments/trailblazers-badges/hekla.json index 66e3f36de21..2406d41095b 100644 --- a/packages/nfts/deployments/trailblazers-badges/hekla.json +++ b/packages/nfts/deployments/trailblazers-badges/hekla.json @@ -1,5 +1,5 @@ { "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x45a7c3ff90f52f71b9C2FAdCaf2860d7B0E11FC4", - "TrailblazersBadgesS2": "0x7Da4EC218BA4478D0b8a41422DdCE1B2e9AEA736" + "TrailblazersBadges": "0x9E93e00325baC45A90B7eF50Af7779B99220506C", + "TrailblazersBadgesS2": "0x6A220B7aA5fAC2Ac0Fb5D2804EAd46239382D268" } diff --git a/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol index e45e3ca9651..39c2edb00f6 100644 --- a/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol +++ b/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol @@ -230,18 +230,25 @@ contract TrailblazersBadgesTest is Test { assertEq(s2Badges.isMigrationActive(minters[0]), true); } + function wait(uint256 time) public { + vm.warp(block.timestamp + time); + } + // happy-path, make 3 pink tampers, and 2 purple ones function test_tamperMigration() public { test_startMigration(); vm.startPrank(minters[0]); - for (uint256 i = 0; i < MAX_TAMPERS; i++) { + wait(s2Badges.COOLDOWN_TAMPER()); s2Badges.tamperMigration(PINK_TAMPER); } + wait(s2Badges.COOLDOWN_TAMPER()); s2Badges.tamperMigration(PURPLE_TAMPER); + wait(s2Badges.COOLDOWN_TAMPER()); s2Badges.tamperMigration(PURPLE_TAMPER); + vm.stopPrank(); assertEq(s2Badges.isTamperActive(minters[0]), true); @@ -272,9 +279,10 @@ contract TrailblazersBadgesTest is Test { function test_endMigration() public { test_tamperMigration(); - // roll forward the block number 2 hours - vm.warp(2 hours); + wait(s2Badges.COOLDOWN_TAMPER()); + wait(s2Badges.COOLDOWN_MIGRATION()); + vm.startPrank(minters[0]); s2Badges.endMigration(); vm.stopPrank(); From f64468c2b6ce9a18c489374a23eef43cd0c52273 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 5 Sep 2024 09:50:36 +0200 Subject: [PATCH 13/79] ideal 8-participant structure, tests --- .../trailblazers-badges/BadgeChampions.sol | 438 ++++++++++++++++++ packages/nfts/script/profile/Deploy.s.sol | 13 +- .../trailblazers-badges/BadgeChampions.t.sol | 343 ++++++++++++++ 3 files changed, 785 insertions(+), 9 deletions(-) create mode 100644 packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol create mode 100644 packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol diff --git a/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol b/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol new file mode 100644 index 00000000000..481d342a482 --- /dev/null +++ b/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol @@ -0,0 +1,438 @@ +// SPDX-License-Identifier: MIT +// Compatible with OpenZeppelin Contracts ^5.0.0 +pragma solidity ^0.8.24; + +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; +import "@openzeppelin/contracts/access/AccessControl.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; +import { ERC721EnumerableUpgradeable } from + "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; +import { AccessControlUpgradeable } from + "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { PausableUpgradeable } from + "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; +import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; +import { UUPSUpgradeable } from + "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import { Ownable2StepUpgradeable } from + "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; +import "./TrailblazersBadges.sol"; + +contract BadgeChampions is + PausableUpgradeable, + UUPSUpgradeable, + Ownable2StepUpgradeable, + AccessControlUpgradeable +{ + struct Champion { + address badgeContract; + uint256 tokenId; + address owner; + uint256 color; // 0 = neutral, 1 = pink, 2 = purple + uint256 energy; + uint256 power; + } + + struct Tournament { + uint256 openTime; // registration starts + uint256 closeTime; // registration ends + uint256 startTime; // tournament starts (requires admin action) + uint256 endTime; + uint256 seed; + uint256 rounds; + address[] participants; + } + + mapping(address owner => Champion) public champions; + mapping(uint256 tournamentId => Tournament) public tournaments; + uint256 public currentTournamentId = 0; + + TrailblazersBadges public season1Badges; + + uint256[8] public powerLevels = [ + 4, // Ravers + 58, // Robots + 40, // Bouncers + 43, // Masters + 99, // Monks + 51, // Androids + 42, // Drummers + 77 // Shinto + ]; + + event TournamentCreated( + uint256 indexed tournamentId, uint256 openTime, uint256 startTime, uint256 endTime + ); + event TournamentStarted(uint256 tournamentId, uint256 seed); + event TournamentEnded(uint256 tournamentId, uint256 endTime); + + event ChampionRegistered( + uint256 tournamentId, address owner, uint256 tokenId, uint256 energy, uint256 power + ); + + error ELEMENT_NOT_FOUND(); + error TOURNAMENT_NOT_STARTED(); + error TOURNAMENT_NOT_OPEN(); + error TOURNAMENT_NOT_CLOSED(); + error TOURNAMENT_NOT_ENDED(); + error CHAMPION_NOT_OWNED(); + error INVALID_PARTICIPANT_COUNT(); + error INVALID_ROUND(); + + function initialize(address _season1Badges, address _season2Badges) external initializer { + __Context_init(); + _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); + _transferOwnership(_msgSender()); + season1Badges = TrailblazersBadges(_season1Badges); + } + + function calculateEnergy(uint256 _tokenId) public pure returns (uint256) { + return _tokenId % 100; + } + + function calculatePower(uint256 _badgeId) public view returns (uint256) { + return powerLevels[_badgeId]; + } + + function getCurrentTournament() + public + view + returns ( + uint256 openTime, + uint256 closeTime, + uint256 startTime, + uint256 endTime, + uint256 seed, + uint256 rounds, + address[] memory participants + ) + { + return getTournament(currentTournamentId); + } + + function getTournament(uint256 _tournamentId) + public + view + returns ( + uint256 openTime, + uint256 closeTime, + uint256 startTime, + uint256 endTime, + uint256 seed, + uint256 rounds, + address[] memory participants + ) + { + Tournament memory tournament = tournaments[_tournamentId]; + return ( + tournament.openTime, + tournament.closeTime, + tournament.startTime, + tournament.endTime, + tournament.seed, + tournament.rounds, + tournament.participants + ); + } + + function createTournament( + uint256 _openTime, + uint256 _closeTime, + uint256 _startTime, + uint256 _endTime + ) + public + onlyOwner + { + Tournament memory tournament = Tournament({ + openTime: _openTime, + closeTime: _closeTime, + startTime: _startTime, + endTime: _endTime, + seed: 0, + rounds: 0, + participants: new address[](0) + }); + currentTournamentId += 1; + + tournaments[currentTournamentId] = tournament; + + emit TournamentCreated(currentTournamentId, _openTime, _startTime, _endTime); + } + + modifier tournamentOpen(uint256 _tournamentId) { + Tournament memory tournament = tournaments[_tournamentId]; + if (block.timestamp < tournament.openTime || block.timestamp > tournament.closeTime) { + revert TOURNAMENT_NOT_OPEN(); + } + + _; + } + + modifier ownedToken(address _badgeContract, uint256 _badgeId) { + uint256 tokenId = season1Badges.getTokenId(_msgSender(), _badgeId); + + if ( + season1Badges.ownerOf(tokenId) != _msgSender() + && season1Badges.getApproved(tokenId) != address(this) + && season1Badges.isApprovedForAll(_msgSender(), address(this)) + ) { + revert CHAMPION_NOT_OWNED(); + } + + _; + } + + function registerChampion( + address _badgeContract, + uint256 _badgeId + ) + public + tournamentOpen(currentTournamentId) + ownedToken(_badgeContract, _badgeId) + { + uint256 color = 0; // TODO: make it based on the badge + + uint256 tokenId = season1Badges.getTokenId(_msgSender(), _badgeId); + uint256 energy = calculateEnergy(tokenId); + uint256 power = calculatePower(_badgeId); + + Champion memory champion = Champion({ + badgeContract: _badgeContract, + tokenId: tokenId, + owner: _msgSender(), + energy: energy, + color: color, + power: power + }); + + champions[_msgSender()] = champion; + Tournament storage tournament = tournaments[currentTournamentId]; + tournament.participants.push(_msgSender()); + + emit ChampionRegistered(currentTournamentId, _msgSender(), tokenId, energy, power); + } + + function calculateTotalRounds(uint256 participantCount) public pure returns (uint256) { + if (participantCount == 0) { + revert INVALID_PARTICIPANT_COUNT(); + } + + uint256 rounds = 0; + uint256 count = participantCount; + + while (count > 1) { + count = (count + 1) / 2; // Each round halves the number of participants + rounds++; + } + + return rounds; + } + + function startTournament(uint256 seed) public onlyOwner { + Tournament storage tournament = tournaments[currentTournamentId]; + tournament.seed = seed; + tournament.rounds = calculateTotalRounds(tournament.participants.length); + emit TournamentStarted(currentTournamentId, seed); + } + + function calculateAdvantage( + uint256 _colorLeft, + uint256 _colorRight + ) + public + pure + returns (bool leftAdvantage, bool rightAdvantage) + { + // neutral >> pink >> purple + // 0 >> 1 >> 2 + if (_colorLeft == 0 && _colorRight == 1) { + return (true, false); + } else if (_colorLeft == 0 && _colorRight == 2) { + return (true, false); + } else if (_colorLeft == 1 && _colorRight == 0) { + return (false, true); + } else if (_colorLeft == 1 && _colorRight == 2) { + return (true, false); + } else if (_colorLeft == 2 && _colorRight == 0) { + return (false, true); + } else if (_colorLeft == 2 && _colorRight == 1) { + return (false, true); + } else { + return (false, false); + } + } + + function _indexOf(address[] memory _array, address _element) internal pure returns (uint256) { + for (uint256 i = 0; i < _array.length; i++) { + if (_array[i] == _element) { + return i; + } + } + revert ELEMENT_NOT_FOUND(); + } + + function _seedBasedRandom(uint256 _extraSeed) internal view returns (uint256) { + Tournament memory tournament = tournaments[currentTournamentId]; + uint256 seed = tournament.seed + _extraSeed; + return seed; + } + + function _calculateBattle( + address _ownerLeft, + address _ownerRight + ) + internal + view + returns (bool leftWins) + { + Champion memory championLeft = champions[_ownerLeft]; + Champion memory championRight = champions[_ownerRight]; + + // calculate base powers + uint256 powerLeft = championLeft.power + championLeft.energy; + uint256 powerRight = championRight.power + championRight.energy; + + // determine color advantage + (bool leftAdvantage, bool rightAdvantage) = + calculateAdvantage(championLeft.color, championRight.color); + // apply color bonuses + if (leftAdvantage) { + powerLeft += championLeft.energy; + } else if (rightAdvantage) { + powerRight += championRight.energy; + } + + // determine winner + if (powerLeft > powerRight) { + return true; + } else if (powerRight > powerLeft) { + return false; + } else { + // if a tie, determine randomly + uint256 tieSeed = _seedBasedRandom(powerLeft); + return (tieSeed % 2 == 0); + } + } + + function _randomizeAddresses( + address[] memory addresses, + uint256 seed + ) + internal + pure + returns (address[] memory) + { + address[] memory shuffledAddresses = addresses; + uint256 n = shuffledAddresses.length; + + for (uint256 i = n - 1; i > 0; i--) { + uint256 j = uint256(keccak256(abi.encodePacked(seed, i))) % (i + 1); + // Swap elements + (shuffledAddresses[i], shuffledAddresses[j]) = + (shuffledAddresses[j], shuffledAddresses[i]); + } + + return shuffledAddresses; + } + + //////////////////////////////////////////////////////////////// + + function calculateMatchesInRound( + uint256 round, + uint256 initialParticipantCount + ) + public + pure + returns (uint256) + { + if (initialParticipantCount == 0) { + revert INVALID_PARTICIPANT_COUNT(); + } + + if (round == 0) { + revert INVALID_ROUND(); + } + // Calculate the number of participants in the given round + uint256 participantsInRound = initialParticipantCount / (2 ** (round - 1)); + + // Calculate the number of matches in the given round + uint256 matchesInRound = participantsInRound / 2; + + return matchesInRound; + } + + function getMatchup(uint256 round, uint256 matchIndex) public view returns (uint256, uint256) { + if (round == 0) { + revert INVALID_ROUND(); + } + Tournament memory tournament = tournaments[currentTournamentId]; + + uint256 firstIndex = matchIndex * 2; + uint256 secondIndex = firstIndex + 1; + + uint256 firstParticipantIndex = + deterministicIndex(tournament.seed, firstIndex, round, tournament.participants.length); + uint256 secondParticipantIndex = + deterministicIndex(tournament.seed, secondIndex, round, tournament.participants.length); + + // Ensure the indices are distinct + if (firstParticipantIndex == secondParticipantIndex) { + secondParticipantIndex = (secondParticipantIndex + 1) % tournament.participants.length; + } + + return (firstParticipantIndex, secondParticipantIndex); + } + + function deterministicIndex( + uint256 seed, + uint256 index, + uint256 round, + uint256 participantsLength + ) + internal + pure + returns (uint256) + { + return uint256(keccak256(abi.encode(seed, index, round))) % participantsLength; + } + + function getParticipants( + uint256 round, + uint256 matchIndex + ) + public + view + returns (address, address) + { + (uint256 first, uint256 second) = getMatchup(round, matchIndex); + Tournament memory tournament = tournaments[currentTournamentId]; + return (tournament.participants[first], tournament.participants[second]); + } + + function getWinner(uint256 round, uint256 matchIndex) public view returns (address) { + (uint256 first, uint256 second) = getMatchup(round, matchIndex); + Tournament memory tournament = tournaments[currentTournamentId]; + + bool result = + _calculateBattle(tournament.participants[first], tournament.participants[second]); + if (result) { + return tournament.participants[first]; + } else { + return tournament.participants[second]; + } + } + + //////////////////////////////////////////////////////////////// + function supportsInterface(bytes4 interfaceId) + public + view + override(AccessControlUpgradeable) + returns (bool) + { + return super.supportsInterface(interfaceId); + } + + function _authorizeUpgrade(address) internal virtual override onlyOwner { } +} diff --git a/packages/nfts/script/profile/Deploy.s.sol b/packages/nfts/script/profile/Deploy.s.sol index 6fd08ba8ad3..0523376c945 100644 --- a/packages/nfts/script/profile/Deploy.s.sol +++ b/packages/nfts/script/profile/Deploy.s.sol @@ -28,20 +28,15 @@ contract DeployScript is Script { // deploy token with empty root address impl = address(new RegisterProfilePicture()); - address proxy = address( - new ERC1967Proxy( - impl, - abi.encodeCall( - RegisterProfilePicture.initialize, () - ) - ) - ); + address proxy = + address(new ERC1967Proxy(impl, abi.encodeCall(RegisterProfilePicture.initialize, ()))); RegisterProfilePicture profile = RegisterProfilePicture(proxy); console.log("Deployed TaikoPartyTicket to:", address(profile)); - string memory finalJson = vm.serializeAddress(jsonRoot, "RegisterProfilePicture", address(profile)); + string memory finalJson = + vm.serializeAddress(jsonRoot, "RegisterProfilePicture", address(profile)); vm.writeJson(finalJson, jsonLocation); vm.stopBroadcast(); diff --git a/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol b/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol new file mode 100644 index 00000000000..43c863bb43a --- /dev/null +++ b/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol @@ -0,0 +1,343 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import { Test } from "forge-std/src/Test.sol"; + +import { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; +import { BadgeChampions } from "../../contracts/trailblazers-badges/BadgeChampions.sol"; +import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; +import { UtilsScript } from "../../script/taikoon/sol/Utils.s.sol"; +import { MockBlacklist } from "../util/Blacklist.sol"; +import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; + +contract BadgeChampionsTest is Test { + UtilsScript public utils; + + TrailblazersBadges public token; + + address public owner = vm.addr(0x5); + + address[8] public minters = [ + vm.addr(0x1), + vm.addr(0x2), + vm.addr(0x3), + vm.addr(0x4), + vm.addr(0x5), + vm.addr(0x6), + vm.addr(0x7), + vm.addr(0x8) + ]; + + uint256 constant TOURNAMENT_SEED = 1_234_567_890; + + uint256[8] public BADGE_IDS = [0, 1, 2, 3, 4, 5, 6, 7]; + + MockBlacklist public blacklist; + + address mintSigner; + uint256 mintSignerPk; + + BadgeChampions public badgeChampions; + + mapping(address player => uint256 badgeId) public playersToBadgeIds; + + uint256 constant OPEN_TIME = 10_000; + uint256 constant CLOSE_TIME = 20_000; + uint256 constant START_TIME = 30_000; + uint256 constant END_TIME = 40_000; + + function setUp() public { + utils = new UtilsScript(); + utils.setUp(); + blacklist = new MockBlacklist(); + // create whitelist merkle tree + vm.startPrank(owner); + + (mintSigner, mintSignerPk) = makeAddrAndKey("mintSigner"); + + // deploy s1 badges token + address impl = address(new TrailblazersBadges()); + address proxy = address( + new ERC1967Proxy( + impl, + abi.encodeCall( + TrailblazersBadges.initialize, (owner, "ipfs://", mintSigner, blacklist) + ) + ) + ); + + token = TrailblazersBadges(proxy); + + // deploy badge champions + impl = address(new BadgeChampions()); + proxy = address( + new ERC1967Proxy( + impl, abi.encodeCall(BadgeChampions.initialize, (address(token), address(0x0))) + ) + ); + + badgeChampions = BadgeChampions(proxy); + vm.stopPrank(); + + // mint some badges + for (uint256 i = 0; i < minters.length; i++) { + bytes32 _hash = token.getHash(minters[i], BADGE_IDS[i]); + + (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); + + vm.startPrank(minters[i]); + token.mint(abi.encodePacked(r, s, v), BADGE_IDS[i]); + vm.stopPrank(); + + playersToBadgeIds[minters[i]] = BADGE_IDS[i]; + } + } + + function test_metadata_badges() public view { + assertEq(token.BADGE_RAVERS(), 0); + assertEq(token.BADGE_ROBOTS(), 1); + assertEq(token.BADGE_BOUNCERS(), 2); + assertEq(token.BADGE_MASTERS(), 3); + assertEq(token.BADGE_MONKS(), 4); + assertEq(token.BADGE_DRUMMERS(), 5); + assertEq(token.BADGE_ANDROIDS(), 6); + assertEq(token.BADGE_SHINTO(), 7); + } + + function test_admin_createTournament() public { + // create tournament + vm.prank(owner); + badgeChampions.createTournament(OPEN_TIME, CLOSE_TIME, START_TIME, END_TIME); + + // check tournament + ( + uint256 openTime, + uint256 closeTime, + uint256 startTime, + uint256 endTime, + uint256 seed, + uint256 rounds, + address[] memory participants + ) = badgeChampions.getCurrentTournament(); + + assertEq(openTime, OPEN_TIME); + assertEq(closeTime, CLOSE_TIME); + assertEq(startTime, START_TIME); + assertEq(endTime, END_TIME); + assertEq(seed, 0); + assertEq(participants.length, 0); + } + + function test_revert_tournamentNotOpen() public { + test_admin_createTournament(); + vm.startPrank(minters[0]); + vm.expectRevert(); + badgeChampions.registerChampion(address(token), playersToBadgeIds[minters[0]]); + vm.stopPrank(); + } + + function wait(uint256 time) public { + vm.warp(block.timestamp + time); + } + + function test_registerChampion() public { + test_admin_createTournament(); + + wait(OPEN_TIME + 1); + // register champion + vm.prank(minters[0]); + badgeChampions.registerChampion(address(token), BADGE_IDS[0]); + + // check tournament + ( + uint256 openTime, + uint256 closeTime, + uint256 startTime, + uint256 endTime, + uint256 seed, + uint256 rounds, + address[] memory participants + ) = badgeChampions.getCurrentTournament(); + + assertEq(openTime, OPEN_TIME); + assertEq(closeTime, CLOSE_TIME); + assertEq(startTime, START_TIME); + assertEq(endTime, END_TIME); + assertEq(seed, 0); + assertEq(rounds, 0); + assertEq(participants.length, 1); + assertEq(participants[0], minters[0]); + } + + function test_revert_registerChampion_notOwned() public { + test_admin_createTournament(); + + wait(OPEN_TIME + 1); + // register champion + vm.startPrank(minters[1]); + vm.expectRevert(); + badgeChampions.registerChampion(address(token), playersToBadgeIds[minters[0]]); + vm.stopPrank(); + } + + function test_registerChampion_all() public { + test_admin_createTournament(); + + wait(OPEN_TIME + 1); + // register champion + for (uint256 i = 0; i < minters.length; i++) { + vm.prank(minters[i]); + badgeChampions.registerChampion(address(token), BADGE_IDS[i]); + } + + // check tournament + ( + uint256 openTime, + uint256 closeTime, + uint256 startTime, + uint256 endTime, + uint256 seed, + uint256 rounds, + address[] memory participants + ) = badgeChampions.getCurrentTournament(); + + assertEq(openTime, OPEN_TIME); + assertEq(closeTime, CLOSE_TIME); + assertEq(startTime, START_TIME); + assertEq(endTime, END_TIME); + assertEq(seed, 0); + assertEq(rounds, 0); + assertEq(participants.length, minters.length); + for (uint256 i = 0; i < minters.length; i++) { + assertEq(participants[i], minters[i]); + } + } + + function test_admin_startTournament() public { + test_registerChampion_all(); + + wait(CLOSE_TIME + 1); + // start tournament + vm.prank(owner); + badgeChampions.startTournament(TOURNAMENT_SEED); + + // check tournament + ( + uint256 openTime, + uint256 closeTime, + uint256 startTime, + uint256 endTime, + uint256 seed, + uint256 rounds, + address[] memory participants + ) = badgeChampions.getCurrentTournament(); + + assertEq(openTime, OPEN_TIME); + assertEq(closeTime, CLOSE_TIME); + assertEq(startTime, START_TIME); + assertEq(endTime, END_TIME); + assertEq(seed, TOURNAMENT_SEED); + assertEq(rounds, 3); // 3 for 8 participants + assertEq(participants.length, minters.length); + for (uint256 i = 0; i < minters.length; i++) { + assertEq(participants[i], minters[i]); + } + } + + function test_revert_startTournament_notAdmin() public { + test_registerChampion_all(); + + wait(CLOSE_TIME + 1); + // start tournament + vm.startPrank(minters[0]); + vm.expectRevert(); + badgeChampions.startTournament(TOURNAMENT_SEED); + vm.stopPrank(); + } + + function test_getWinner_single() public { + test_admin_startTournament(); + + wait(START_TIME + 1); + + uint256 _round = 1; + uint256 _match = 0; + + (address leftParticipant, address rightParticipant) = + badgeChampions.getParticipants(_round, _match); + + (uint256 leftId, uint256 rightId) = badgeChampions.getMatchup(_round, _match); + + assertTrue(leftId != rightId); + // get winner + address winner = badgeChampions.getWinner(_round, _match); + + assertTrue(leftParticipant != rightParticipant); + assertEq(winner, leftParticipant); + assertFalse(winner == rightParticipant); + } + + function test_getWinner_round() public { + test_admin_startTournament(); + + wait(START_TIME + 1); + uint256 round = 1; // Assuming we are testing round 1 + uint256 numMatches = minters.length / 2; // Assuming we have an even number of participants + + for (uint256 matchIndex = 0; matchIndex < numMatches; matchIndex++) { + // Retrieve participants for the match + (address participant1, address participant2) = + badgeChampions.getParticipants(round, matchIndex); + + // Simulate a battle and get the winner + address winner = badgeChampions.getWinner(round, matchIndex); + + // Assertions to ensure correctness + assertTrue(participant1 != participant2); + assertTrue(participant1 == winner || participant2 == winner); + } + } + + function test_getWinner_tournament() public { + test_admin_startTournament(); + + wait(START_TIME + 1); + // uint256 numRounds = 3; // Assuming we have 3 rounds + // uint256 numMatches = minters.length / 2; // Assuming we have an even number of + // participants + + ( + uint256 openTime, + uint256 closeTime, + uint256 startTime, + uint256 endTime, + uint256 seed, + uint256 rounds, + address[] memory participants + ) = badgeChampions.getCurrentTournament(); + + uint256[] memory participantCount = new uint256[](rounds + 1); + + participantCount[1] = participants.length / 2; + participantCount[2] = participantCount[1] / 2; + participantCount[3] = participantCount[2] / 2; + + for (uint256 roundIndex = 1; roundIndex <= rounds; roundIndex++) { + uint256 numMatches = + badgeChampions.calculateMatchesInRound(roundIndex, participants.length); + assertEq(numMatches, participantCount[roundIndex]); + for (uint256 matchIndex = 0; matchIndex < numMatches; matchIndex++) { + // Retrieve participants for the match + (address participant1, address participant2) = + badgeChampions.getParticipants(roundIndex, matchIndex); + + // Simulate a battle and get the winner + address winner = badgeChampions.getWinner(roundIndex, matchIndex); + + // Assertions to ensure correctness + assertTrue(participant1 != participant2); + assertTrue(participant1 == winner || participant2 == winner); + } + } + } +} From de828340bc8c3d47fc3f2ea046f9a34324cb8604 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 5 Sep 2024 17:14:12 +0200 Subject: [PATCH 14/79] latest hekla deployment --- packages/nfts/deployments/trailblazers-badges/hekla.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nfts/deployments/trailblazers-badges/hekla.json b/packages/nfts/deployments/trailblazers-badges/hekla.json index 2406d41095b..a3883b23722 100644 --- a/packages/nfts/deployments/trailblazers-badges/hekla.json +++ b/packages/nfts/deployments/trailblazers-badges/hekla.json @@ -1,5 +1,5 @@ { "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x9E93e00325baC45A90B7eF50Af7779B99220506C", - "TrailblazersBadgesS2": "0x6A220B7aA5fAC2Ac0Fb5D2804EAd46239382D268" + "TrailblazersBadges": "0xB5b0Ab3215341E3E1E2095429FC5E1C07A96aA3f", + "TrailblazersBadgesS2": "0xDD025c2A938be668458eA3d9fBAB3917f657b73a" } From af66ab9220b9c38a8fde9b4b6dba16d76e0deceb Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 5 Sep 2024 17:16:51 +0200 Subject: [PATCH 15/79] pnpm scripts cleanup --- packages/nfts/package.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/nfts/package.json b/packages/nfts/package.json index 67da8e1c63e..8a6524992f6 100644 --- a/packages/nfts/package.json +++ b/packages/nfts/package.json @@ -12,24 +12,24 @@ "node": "anvil", "layout": "./deployments/gen-layouts.sh", "taikoon:merkle": "node script/taikoon/js/generate-merkle-tree.js", - "snaefell:merkle": "node script/snaefell/js/generate-merkle-tree.js", "taikoon:deploy:localhost": "forge clean && forge script script/taikoon/sol/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast", - "snaefell:deploy:localhost": "forge clean && forge script script/snaefell/sol/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast", "taikoon:deploy:ipfs": "rm -rf data/taikoon/metadata/* && node script/taikoon/js/4everland.js", + "taikoon:deploy:devnet": "forge clean && forge script script/taikoon/sol/Deploy.s.sol --rpc-url https://rpc.internal.taiko.xyz --broadcast --gas-estimate-multiplier 200", + "taikoon:deploy:mainnet": "forge clean && forge script script/taikoon/sol/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 13 ", + "taikoon:deploy:holesky": "forge clean && forge script script/taikoon/sol/Deploy.s.sol --rpc-url https://1rpc.io/holesky --broadcast --gas-estimate-multiplier 200", + "taikoon:deploy:v2": "forge clean && forge script script/taikoon/sol/UpgradeV2.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast", + "snaefell:merkle": "node script/snaefell/js/generate-merkle-tree.js", + "snaefell:deploy:localhost": "forge clean && forge script script/snaefell/sol/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast", "snaefell:deploy:ipfs": "rm -rf data/snaefell/metadata/* && node script/snaefell/js/4everland.js", + "snaefell:deploy:devnet": "forge clean && forge script script/snaefell/sol/Deploy.s.sol --rpc-url https://rpc.internal.taiko.xyz --broadcast --gas-estimate-multiplier 200", + "snaefell:deploy:mainnet": "forge clean && forge script script/snaefell/sol/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 13 ", "kbw:deploy:mainnet": "forge clean && pnpm compile && forge script script/party-ticket/sol/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 30 ", "kbw:upgradeV2:hekla": "forge clean && pnpm compile && forge script script/party-ticket/sol/UpgradeV2.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", "kbw:upgradeV2:mainnet": "forge clean && pnpm compile && forge script script/party-ticket/sol/UpgradeV2.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast", - "taikoon:deploy:devnet": "forge clean && forge script script/taikoon/sol/Deploy.s.sol --rpc-url https://rpc.internal.taiko.xyz --broadcast --gas-estimate-multiplier 200", - "snaefell:deploy:devnet": "forge clean && forge script script/snaefell/sol/Deploy.s.sol --rpc-url https://rpc.internal.taiko.xyz --broadcast --gas-estimate-multiplier 200", - "taikoon:deploy:mainnet": "forge clean && forge script script/taikoon/sol/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 13 ", - "snaefell:deploy:mainnet": "forge clean && forge script script/snaefell/sol/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 13 ", - "taikoon:deploy:holesky": "forge clean && forge script script/taikoon/sol/Deploy.s.sol --rpc-url https://1rpc.io/holesky --broadcast --gas-estimate-multiplier 200", "tbzb:deploy:localhost": "forge clean && forge script script/trailblazers-badges/sol/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast", "tbzb:deploy:hekla": "forge clean && forge script script/trailblazers-badges/sol/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", "galxe:deploy:mainnet": "forge clean && forge script script/galxe/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --legacy --with-gas-price 1", "tbzb:deploy:mainnet": "forge clean && forge script script/trailblazers-badges/sol/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 13 ", - "taikoon:deploy:v2": "forge clean && forge script script/taikoon/sol/UpgradeV2.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast", "kbw:deploy:hekla": "forge clean && forge script script/party-ticket/sol/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", "tbz:s2:deploy:hekla": "forge clean && forge script script/trailblazers-badges/sol/DeployS2.s.sol --tc DeployS2Script --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200" }, From 4ad9fbe040bacdec9027a2951ea250f5e3a919f6 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Fri, 6 Sep 2024 00:38:53 +0200 Subject: [PATCH 16/79] game implementation with leagues --- .../trailblazers-badges/BadgeChampions.sol | 273 ++++++++++-------- .../TrailblazersBadges.sol | 15 + .../trailblazers-badges/hekla.json | 5 +- packages/nfts/package.json | 3 +- .../trailblazers-badges/sol/DeployS2.s.sol | 29 +- .../trailblazers-badges/sol/RunCommand.s.sol | 98 +++++++ .../trailblazers-badges/BadgeChampions.t.sol | 148 ++-------- 7 files changed, 314 insertions(+), 257 deletions(-) create mode 100644 packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol diff --git a/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol b/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol index 481d342a482..2c6428a2c86 100644 --- a/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol +++ b/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol @@ -6,18 +6,17 @@ import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; -import { ERC721EnumerableUpgradeable } from - "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; -import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; +// import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import { Ownable2StepUpgradeable } from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; import "./TrailblazersBadges.sol"; +import "./TrailblazersBadgesS2.sol"; contract BadgeChampions is PausableUpgradeable, @@ -26,29 +25,28 @@ contract BadgeChampions is AccessControlUpgradeable { struct Champion { + address owner; + uint256 leagueId; address badgeContract; uint256 tokenId; - address owner; uint256 color; // 0 = neutral, 1 = pink, 2 = purple - uint256 energy; uint256 power; } - struct Tournament { + struct League { uint256 openTime; // registration starts uint256 closeTime; // registration ends - uint256 startTime; // tournament starts (requires admin action) - uint256 endTime; + uint256 startTime; // league starts (requires admin action) uint256 seed; - uint256 rounds; address[] participants; } - mapping(address owner => Champion) public champions; - mapping(uint256 tournamentId => Tournament) public tournaments; - uint256 public currentTournamentId = 0; + mapping(address owner => Champion champion) public champions; + mapping(uint256 leagueId => League league) public leagues; + uint256 public currentLeagueId = 0; TrailblazersBadges public season1Badges; + TrailblazersBadgesS2 public season2Badges; uint256[8] public powerLevels = [ 4, // Ravers @@ -59,16 +57,18 @@ contract BadgeChampions is 51, // Androids 42, // Drummers 77 // Shinto - ]; + ]; - event TournamentCreated( - uint256 indexed tournamentId, uint256 openTime, uint256 startTime, uint256 endTime + + + event LeagueCreated( + uint256 indexed leagueId, uint256 openTime, uint256 startTime, uint256 endTime ); - event TournamentStarted(uint256 tournamentId, uint256 seed); - event TournamentEnded(uint256 tournamentId, uint256 endTime); + event LeagueStarted(uint256 leagueId, uint256 seed); event ChampionRegistered( - uint256 tournamentId, address owner, uint256 tokenId, uint256 energy, uint256 power + uint256 indexed leagueId, address indexed owner, + address badgesContract, uint256 tokenId, uint256 power ); error ELEMENT_NOT_FOUND(); @@ -79,91 +79,78 @@ contract BadgeChampions is error CHAMPION_NOT_OWNED(); error INVALID_PARTICIPANT_COUNT(); error INVALID_ROUND(); +error INVALID_CHAMPION_CONTRACT(); +error INVALID_MATCH(); function initialize(address _season1Badges, address _season2Badges) external initializer { __Context_init(); _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); _transferOwnership(_msgSender()); season1Badges = TrailblazersBadges(_season1Badges); + season2Badges = TrailblazersBadgesS2(_season2Badges); } - function calculateEnergy(uint256 _tokenId) public pure returns (uint256) { - return _tokenId % 100; - } - - function calculatePower(uint256 _badgeId) public view returns (uint256) { - return powerLevels[_badgeId]; - } - - function getCurrentTournament() + function getCurrentLeague() public view returns ( uint256 openTime, uint256 closeTime, uint256 startTime, - uint256 endTime, uint256 seed, - uint256 rounds, address[] memory participants ) { - return getTournament(currentTournamentId); + return getLeague(currentLeagueId); } - function getTournament(uint256 _tournamentId) + function getLeague(uint256 _leagueId) public view returns ( uint256 openTime, uint256 closeTime, uint256 startTime, - uint256 endTime, uint256 seed, - uint256 rounds, address[] memory participants ) { - Tournament memory tournament = tournaments[_tournamentId]; + League memory league = leagues[_leagueId]; return ( - tournament.openTime, - tournament.closeTime, - tournament.startTime, - tournament.endTime, - tournament.seed, - tournament.rounds, - tournament.participants + league.openTime, + league.closeTime, + league.startTime, + league.seed, + league.participants ); } - function createTournament( + function createLeague( uint256 _openTime, uint256 _closeTime, - uint256 _startTime, - uint256 _endTime + uint256 _startTime ) public onlyOwner { - Tournament memory tournament = Tournament({ + League memory league = League({ openTime: _openTime, closeTime: _closeTime, startTime: _startTime, - endTime: _endTime, seed: 0, - rounds: 0, participants: new address[](0) }); - currentTournamentId += 1; + currentLeagueId += 1; - tournaments[currentTournamentId] = tournament; + leagues[currentLeagueId] = league; - emit TournamentCreated(currentTournamentId, _openTime, _startTime, _endTime); - } + emit LeagueCreated(currentLeagueId, _openTime, _closeTime, _startTime + ); + } - modifier tournamentOpen(uint256 _tournamentId) { - Tournament memory tournament = tournaments[_tournamentId]; - if (block.timestamp < tournament.openTime || block.timestamp > tournament.closeTime) { + modifier leagueOpen(uint256 _leagueId) { + League memory league = leagues[_leagueId]; + if (block.timestamp < league.openTime || block.timestamp > league.closeTime) { revert TOURNAMENT_NOT_OPEN(); } @@ -184,34 +171,61 @@ contract BadgeChampions is _; } - function registerChampion( + function calculatePower(uint256 _badgeId) public view returns (uint256) { + return powerLevels[_badgeId % powerLevels.length]; + } + + function _registerChampionFor( + address _player, address _badgeContract, uint256 _badgeId - ) - public - tournamentOpen(currentTournamentId) - ownedToken(_badgeContract, _badgeId) + ) internal { + if (_badgeContract != address(season1Badges) && _badgeContract != address(season2Badges)) { + revert INVALID_CHAMPION_CONTRACT(); + } uint256 color = 0; // TODO: make it based on the badge - uint256 tokenId = season1Badges.getTokenId(_msgSender(), _badgeId); - uint256 energy = calculateEnergy(tokenId); + uint256 tokenId = season1Badges.getTokenId(_player, _badgeId); uint256 power = calculatePower(_badgeId); Champion memory champion = Champion({ + leagueId: currentLeagueId, badgeContract: _badgeContract, tokenId: tokenId, - owner: _msgSender(), - energy: energy, + owner: _player, color: color, power: power }); - champions[_msgSender()] = champion; - Tournament storage tournament = tournaments[currentTournamentId]; - tournament.participants.push(_msgSender()); + champions[_player] = champion; + League storage league = leagues[currentLeagueId]; + league.participants.push(_player); + + emit ChampionRegistered( + currentLeagueId, _player, _badgeContract, tokenId, power); + } + + function registerChampionFor( + address _player, + address _badgeContract, + uint256 _badgeId + ) + public + onlyOwner + { + _registerChampionFor(_player, _badgeContract, _badgeId); + } - emit ChampionRegistered(currentTournamentId, _msgSender(), tokenId, energy, power); + function registerChampion( + address _badgeContract, + uint256 _badgeId + ) + public + leagueOpen(currentLeagueId) + ownedToken(_badgeContract, _badgeId) + { + _registerChampionFor(_msgSender(), _badgeContract, _badgeId); } function calculateTotalRounds(uint256 participantCount) public pure returns (uint256) { @@ -230,11 +244,10 @@ contract BadgeChampions is return rounds; } - function startTournament(uint256 seed) public onlyOwner { - Tournament storage tournament = tournaments[currentTournamentId]; - tournament.seed = seed; - tournament.rounds = calculateTotalRounds(tournament.participants.length); - emit TournamentStarted(currentTournamentId, seed); + function startLeague(uint256 seed) public onlyOwner { + League storage league = leagues[currentLeagueId]; + league.seed = seed; + emit LeagueStarted(currentLeagueId, seed); } function calculateAdvantage( @@ -274,47 +287,11 @@ contract BadgeChampions is } function _seedBasedRandom(uint256 _extraSeed) internal view returns (uint256) { - Tournament memory tournament = tournaments[currentTournamentId]; - uint256 seed = tournament.seed + _extraSeed; + League memory league = leagues[currentLeagueId]; + uint256 seed = league.seed + _extraSeed; return seed; } - function _calculateBattle( - address _ownerLeft, - address _ownerRight - ) - internal - view - returns (bool leftWins) - { - Champion memory championLeft = champions[_ownerLeft]; - Champion memory championRight = champions[_ownerRight]; - - // calculate base powers - uint256 powerLeft = championLeft.power + championLeft.energy; - uint256 powerRight = championRight.power + championRight.energy; - - // determine color advantage - (bool leftAdvantage, bool rightAdvantage) = - calculateAdvantage(championLeft.color, championRight.color); - // apply color bonuses - if (leftAdvantage) { - powerLeft += championLeft.energy; - } else if (rightAdvantage) { - powerRight += championRight.energy; - } - - // determine winner - if (powerLeft > powerRight) { - return true; - } else if (powerRight > powerLeft) { - return false; - } else { - // if a tie, determine randomly - uint256 tieSeed = _seedBasedRandom(powerLeft); - return (tieSeed % 2 == 0); - } - } function _randomizeAddresses( address[] memory addresses, @@ -367,19 +344,19 @@ contract BadgeChampions is if (round == 0) { revert INVALID_ROUND(); } - Tournament memory tournament = tournaments[currentTournamentId]; + League memory league = leagues[currentLeagueId]; uint256 firstIndex = matchIndex * 2; uint256 secondIndex = firstIndex + 1; uint256 firstParticipantIndex = - deterministicIndex(tournament.seed, firstIndex, round, tournament.participants.length); + deterministicIndex(league.seed, firstIndex, round, league.participants.length); uint256 secondParticipantIndex = - deterministicIndex(tournament.seed, secondIndex, round, tournament.participants.length); + deterministicIndex(league.seed, secondIndex, round, league.participants.length); // Ensure the indices are distinct if (firstParticipantIndex == secondParticipantIndex) { - secondParticipantIndex = (secondParticipantIndex + 1) % tournament.participants.length; + secondParticipantIndex = (secondParticipantIndex + 1) % league.participants.length; } return (firstParticipantIndex, secondParticipantIndex); @@ -406,23 +383,17 @@ contract BadgeChampions is view returns (address, address) { + uint256 maxMatchIndex = calculateMatchesInRound(round, leagues[currentLeagueId].participants.length); + if (matchIndex >= maxMatchIndex) { + revert INVALID_MATCH(); + } (uint256 first, uint256 second) = getMatchup(round, matchIndex); - Tournament memory tournament = tournaments[currentTournamentId]; - return (tournament.participants[first], tournament.participants[second]); + League memory league = leagues[currentLeagueId]; + return (league.participants[first], league.participants[second]); } - function getWinner(uint256 round, uint256 matchIndex) public view returns (address) { - (uint256 first, uint256 second) = getMatchup(round, matchIndex); - Tournament memory tournament = tournaments[currentTournamentId]; - bool result = - _calculateBattle(tournament.participants[first], tournament.participants[second]); - if (result) { - return tournament.participants[first]; - } else { - return tournament.participants[second]; - } - } + //////////////////////////////////////////////////////////////// function supportsInterface(bytes4 interfaceId) @@ -435,4 +406,52 @@ contract BadgeChampions is } function _authorizeUpgrade(address) internal virtual override onlyOwner { } + + + + //////////////////////////////////////////////////////////////// + + +// Deterministically shuffle an array of addresses based on a uint256 seed + // Simple linear congruential generator (LCG) + function linearCongruentialGenerator(uint256 seed) private pure returns (uint256) { + // Parameters for LCG + uint256 a = 1664525; + uint256 c = 1013904223; + uint256 m = 2**32; + + return (a * seed + c) % m; + } + + function shuffleAddresses(address[] calldata addresses, uint256 seed) public pure returns (address[] memory) { + uint256 n = addresses.length; + // Create a memory copy of the calldata array since calldata is read-only + address[] memory shuffled = new address[](n); + + for (uint256 i = 0; i < n; i++) { + shuffled[i] = addresses[i]; + } + + // Perform the Fisher-Yates shuffle on the memory array + for (uint256 i = n - 1; i > 0; i--) { + // Generate a pseudo-random index based on the seed + uint256 randomIndex = (linearCongruentialGenerator(seed + i) % (i + 1)); + + // Swap the current element with the random index + address temp = shuffled[i]; + shuffled[i] = shuffled[randomIndex]; + shuffled[randomIndex] = temp; + } + + return shuffled; + } + + /* + we relly on a seed-sort for the participants + implement js iterator to extract results + - the blocknumber at use is startBlockNumber + round + + + + */ } diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadges.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadges.sol index c0997ac36bd..bc9f5ca210e 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadges.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadges.sol @@ -240,4 +240,19 @@ contract TrailblazersBadges is ERC721EnumerableUpgradeable, ECDSAWhitelist { function burn(uint256 _tokenId) public onlySeason2BadgeContract { _burn(_tokenId); } + + /// @notice V4 + + // admin function for easy minting + // for testing only, remove from production + function mintTo(address _minter, uint256 _badgeId) public onlyOwner { + if (_badgeId > BADGE_SHINTO) revert INVALID_BADGE_ID(); + + uint256 tokenId = totalSupply() + 1; + badges[tokenId] = _badgeId; + + _mint(_minter, tokenId); + + emit BadgeCreated(tokenId, _minter, _badgeId); + } } diff --git a/packages/nfts/deployments/trailblazers-badges/hekla.json b/packages/nfts/deployments/trailblazers-badges/hekla.json index a3883b23722..7bab27ab660 100644 --- a/packages/nfts/deployments/trailblazers-badges/hekla.json +++ b/packages/nfts/deployments/trailblazers-badges/hekla.json @@ -1,5 +1,6 @@ { + "BadgeChampions": "0xaa0FbbA5dFa39C8469890DB3BDe003c9BaAC6c1a", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0xB5b0Ab3215341E3E1E2095429FC5E1C07A96aA3f", - "TrailblazersBadgesS2": "0xDD025c2A938be668458eA3d9fBAB3917f657b73a" + "TrailblazersBadges": "0xdbf205a18518D2Bf8092E59Ff8d1572557A3e65D", + "TrailblazersBadgesS2": "0xb93b8F9E74232B2B4D801313281a39fEA94c3b8B" } diff --git a/packages/nfts/package.json b/packages/nfts/package.json index 8a6524992f6..3b625262482 100644 --- a/packages/nfts/package.json +++ b/packages/nfts/package.json @@ -31,7 +31,8 @@ "galxe:deploy:mainnet": "forge clean && forge script script/galxe/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --legacy --with-gas-price 1", "tbzb:deploy:mainnet": "forge clean && forge script script/trailblazers-badges/sol/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 13 ", "kbw:deploy:hekla": "forge clean && forge script script/party-ticket/sol/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", - "tbz:s2:deploy:hekla": "forge clean && forge script script/trailblazers-badges/sol/DeployS2.s.sol --tc DeployS2Script --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200" + "tbz:s2:deploy:hekla": "forge clean && forge script script/trailblazers-badges/sol/DeployS2.s.sol --tc DeployS2Script --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", + "tbz:command:hekla": "forge script script/trailblazers-badges/sol/RunCommand.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200" }, "devDependencies": { "@types/node": "^20.11.30", diff --git a/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol b/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol index 0b8230619c6..1b40bdfd4ba 100644 --- a/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol +++ b/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol @@ -9,6 +9,7 @@ import { TrailblazersBadges } from "../../../contracts/trailblazers-badges/Trail import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; import { TrailblazersBadgesS2 } from "../../../contracts/trailblazers-badges/TrailblazersBadgesS2.sol"; +import { BadgeChampions } from "../../../contracts/trailblazers-badges/BadgeChampions.sol"; contract MockBlacklist is IMinimalBlacklist { function isBlacklisted(address _account) external pure returns (bool) { @@ -63,6 +64,9 @@ contract DeployS2Script is Script { address impl; address proxy; TrailblazersBadges s1Token; + TrailblazersBadgesS2 s2Token; + BadgeChampions badgeChampions; + vm.startBroadcast(deployerPrivateKey); if (block.chainid == 167_000) { @@ -92,21 +96,34 @@ contract DeployS2Script is Script { ) ); - TrailblazersBadgesS2 s2Token = TrailblazersBadgesS2(proxy); + s2Token = TrailblazersBadgesS2(proxy); console.log("Token Base URI:", baseURI); console.log("Deployed TrailblazersBadgesS2 to:", address(s2Token)); - vm.serializeAddress(jsonRoot, "Owner", s2Token.owner()); + // Deploy Badge Champions + impl = address(new BadgeChampions()); + proxy = address( + new ERC1967Proxy( + impl, + abi.encodeCall(BadgeChampions.initialize, (address(s1Token), address(s2Token))) + ) + ); + + badgeChampions = BadgeChampions(proxy); + + // Register deployment + vm.serializeAddress(jsonRoot, "TrailblazersBadges", address(s1Token)); - string memory finalJson = - vm.serializeAddress(jsonRoot, "TrailblazersBadgesS2", address(s2Token)); + vm.serializeAddress(jsonRoot, "TrailblazersBadgesS2", address(s2Token)); + vm.serializeAddress(jsonRoot, "BadgeChampions", address(badgeChampions)); + string memory finalJson = vm.serializeAddress(jsonRoot, "Owner", s2Token.owner()); vm.writeJson(finalJson, jsonLocation); // open up migrations for all badges on hekla if (block.chainid != 167_000) { - uint256[] memory tokenIds = new uint256[](s1Token.totalSupply()); - for (uint256 i = 0; i < s1Token.totalSupply(); i++) { + uint256[] memory tokenIds = new uint256[](8); + for (uint256 i = 0; i < tokenIds.length; i++) { tokenIds[i] = i; } s2Token.enableMigrations(tokenIds); diff --git a/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol b/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol new file mode 100644 index 00000000000..d532b14a139 --- /dev/null +++ b/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol @@ -0,0 +1,98 @@ +// 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 { TrailblazersBadges } from "../../../contracts/trailblazers-badges/TrailblazersBadges.sol"; +import { TrailblazersBadgesS2 } from + "../../../contracts/trailblazers-badges/TrailblazersBadgesS2.sol"; +import { BadgeChampions } from "../../../contracts/trailblazers-badges/BadgeChampions.sol"; + +contract DeployScript is Script { + UtilsScript public utils; + uint256 public deployerPrivateKey; + address public deployerAddress; + + TrailblazersBadges public trailblazersBadges; + TrailblazersBadgesS2 public trailblazersBadgesS2; + BadgeChampions public badgeChampions; + + // Hekla + address constant S1_ADDRESS = 0x251a530c6C4Cb0839496ca38613F1e33a8AA2984; + address constant S2_ADDRESS = 0xcc75A678b91076f8840a0BD4b269c8D6e0Ab2c26; + address constant CHAMPIONS_ADDRESS = 0xc8fFF08D23C1176061a261CC5DB57c3B1CE43C04; + + address[] public participants = [ + // @bearni - taiko:hekla + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9), + address(0x10) + ]; + + function setUp() public { + utils = new UtilsScript(); + utils.setUp(); + + deployerPrivateKey = utils.getPrivateKey(); + deployerAddress = utils.getAddress(); + + trailblazersBadges = TrailblazersBadges(S1_ADDRESS); + trailblazersBadgesS2 = TrailblazersBadgesS2(S2_ADDRESS); + badgeChampions = BadgeChampions(CHAMPIONS_ADDRESS); + } + + function createFreshTournament() public { + vm.startBroadcast(deployerPrivateKey); + + uint256 OPEN_TIME = block.timestamp - 3 minutes; + uint256 CLOSE_TIME = block.timestamp - 2 minutes; + uint256 START_TIME = block.timestamp -1 minutes; + + + badgeChampions.createLeague( + OPEN_TIME, CLOSE_TIME, START_TIME); + + + for (uint256 i = 0; i < participants.length; i++) { + uint256 badgeId = i % 7; + trailblazersBadges.mintTo(participants[i], badgeId); + badgeChampions.registerChampionFor( + participants[i], + address(trailblazersBadges), + badgeId + ); + } + + vm.stopBroadcast(); + + } + + + + function run() public { + + + createFreshTournament(); + + + // close signups and start the tournament + vm.startBroadcast(deployerPrivateKey); + + uint256 TOURNAMENT_SEED = block.number * 123456789; + badgeChampions.startLeague(TOURNAMENT_SEED); + vm.stopBroadcast(); + + } +} diff --git a/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol b/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol index 43c863bb43a..2662a89d65a 100644 --- a/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol +++ b/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol @@ -44,7 +44,7 @@ contract BadgeChampionsTest is Test { uint256 constant OPEN_TIME = 10_000; uint256 constant CLOSE_TIME = 20_000; uint256 constant START_TIME = 30_000; - uint256 constant END_TIME = 40_000; + function setUp() public { utils = new UtilsScript(); @@ -104,32 +104,30 @@ contract BadgeChampionsTest is Test { assertEq(token.BADGE_SHINTO(), 7); } - function test_admin_createTournament() public { - // create tournament + function test_admin_createLeague() public { + // create league vm.prank(owner); - badgeChampions.createTournament(OPEN_TIME, CLOSE_TIME, START_TIME, END_TIME); + badgeChampions.createLeague(OPEN_TIME, CLOSE_TIME, START_TIME); - // check tournament + // check league ( uint256 openTime, uint256 closeTime, uint256 startTime, - uint256 endTime, uint256 seed, - uint256 rounds, address[] memory participants - ) = badgeChampions.getCurrentTournament(); + ) = badgeChampions.getCurrentLeague(); assertEq(openTime, OPEN_TIME); assertEq(closeTime, CLOSE_TIME); assertEq(startTime, START_TIME); - assertEq(endTime, END_TIME); + assertEq(seed, 0); assertEq(participants.length, 0); } - function test_revert_tournamentNotOpen() public { - test_admin_createTournament(); + function test_revert_leagueNotOpen() public { + test_admin_createLeague(); vm.startPrank(minters[0]); vm.expectRevert(); badgeChampions.registerChampion(address(token), playersToBadgeIds[minters[0]]); @@ -141,36 +139,33 @@ contract BadgeChampionsTest is Test { } function test_registerChampion() public { - test_admin_createTournament(); + test_admin_createLeague(); wait(OPEN_TIME + 1); // register champion vm.prank(minters[0]); badgeChampions.registerChampion(address(token), BADGE_IDS[0]); - // check tournament + // check league ( uint256 openTime, uint256 closeTime, uint256 startTime, - uint256 endTime, uint256 seed, - uint256 rounds, address[] memory participants - ) = badgeChampions.getCurrentTournament(); + ) = badgeChampions.getCurrentLeague(); assertEq(openTime, OPEN_TIME); assertEq(closeTime, CLOSE_TIME); assertEq(startTime, START_TIME); - assertEq(endTime, END_TIME); + assertEq(seed, 0); - assertEq(rounds, 0); assertEq(participants.length, 1); assertEq(participants[0], minters[0]); } function test_revert_registerChampion_notOwned() public { - test_admin_createTournament(); + test_admin_createLeague(); wait(OPEN_TIME + 1); // register champion @@ -181,7 +176,7 @@ contract BadgeChampionsTest is Test { } function test_registerChampion_all() public { - test_admin_createTournament(); + test_admin_createLeague(); wait(OPEN_TIME + 1); // register champion @@ -190,154 +185,65 @@ contract BadgeChampionsTest is Test { badgeChampions.registerChampion(address(token), BADGE_IDS[i]); } - // check tournament + // check league ( uint256 openTime, uint256 closeTime, uint256 startTime, - uint256 endTime, uint256 seed, - uint256 rounds, address[] memory participants - ) = badgeChampions.getCurrentTournament(); + ) = badgeChampions.getCurrentLeague(); assertEq(openTime, OPEN_TIME); assertEq(closeTime, CLOSE_TIME); assertEq(startTime, START_TIME); - assertEq(endTime, END_TIME); + assertEq(seed, 0); - assertEq(rounds, 0); assertEq(participants.length, minters.length); for (uint256 i = 0; i < minters.length; i++) { assertEq(participants[i], minters[i]); } } - function test_admin_startTournament() public { + function test_admin_startLeague() public { test_registerChampion_all(); wait(CLOSE_TIME + 1); - // start tournament + // start league vm.prank(owner); - badgeChampions.startTournament(TOURNAMENT_SEED); + badgeChampions.startLeague(TOURNAMENT_SEED); - // check tournament + // check league ( uint256 openTime, uint256 closeTime, uint256 startTime, - uint256 endTime, uint256 seed, - uint256 rounds, address[] memory participants - ) = badgeChampions.getCurrentTournament(); + ) = badgeChampions.getCurrentLeague(); assertEq(openTime, OPEN_TIME); assertEq(closeTime, CLOSE_TIME); assertEq(startTime, START_TIME); - assertEq(endTime, END_TIME); + assertEq(seed, TOURNAMENT_SEED); - assertEq(rounds, 3); // 3 for 8 participants assertEq(participants.length, minters.length); for (uint256 i = 0; i < minters.length; i++) { assertEq(participants[i], minters[i]); } } - function test_revert_startTournament_notAdmin() public { + function test_revert_startLeague_notAdmin() public { test_registerChampion_all(); wait(CLOSE_TIME + 1); - // start tournament + // start league vm.startPrank(minters[0]); vm.expectRevert(); - badgeChampions.startTournament(TOURNAMENT_SEED); + badgeChampions.startLeague(TOURNAMENT_SEED); vm.stopPrank(); } - function test_getWinner_single() public { - test_admin_startTournament(); - - wait(START_TIME + 1); - - uint256 _round = 1; - uint256 _match = 0; - - (address leftParticipant, address rightParticipant) = - badgeChampions.getParticipants(_round, _match); - - (uint256 leftId, uint256 rightId) = badgeChampions.getMatchup(_round, _match); - - assertTrue(leftId != rightId); - // get winner - address winner = badgeChampions.getWinner(_round, _match); - - assertTrue(leftParticipant != rightParticipant); - assertEq(winner, leftParticipant); - assertFalse(winner == rightParticipant); - } - - function test_getWinner_round() public { - test_admin_startTournament(); - - wait(START_TIME + 1); - uint256 round = 1; // Assuming we are testing round 1 - uint256 numMatches = minters.length / 2; // Assuming we have an even number of participants - - for (uint256 matchIndex = 0; matchIndex < numMatches; matchIndex++) { - // Retrieve participants for the match - (address participant1, address participant2) = - badgeChampions.getParticipants(round, matchIndex); - - // Simulate a battle and get the winner - address winner = badgeChampions.getWinner(round, matchIndex); - - // Assertions to ensure correctness - assertTrue(participant1 != participant2); - assertTrue(participant1 == winner || participant2 == winner); - } - } - - function test_getWinner_tournament() public { - test_admin_startTournament(); - wait(START_TIME + 1); - // uint256 numRounds = 3; // Assuming we have 3 rounds - // uint256 numMatches = minters.length / 2; // Assuming we have an even number of - // participants - ( - uint256 openTime, - uint256 closeTime, - uint256 startTime, - uint256 endTime, - uint256 seed, - uint256 rounds, - address[] memory participants - ) = badgeChampions.getCurrentTournament(); - - uint256[] memory participantCount = new uint256[](rounds + 1); - - participantCount[1] = participants.length / 2; - participantCount[2] = participantCount[1] / 2; - participantCount[3] = participantCount[2] / 2; - - for (uint256 roundIndex = 1; roundIndex <= rounds; roundIndex++) { - uint256 numMatches = - badgeChampions.calculateMatchesInRound(roundIndex, participants.length); - assertEq(numMatches, participantCount[roundIndex]); - for (uint256 matchIndex = 0; matchIndex < numMatches; matchIndex++) { - // Retrieve participants for the match - (address participant1, address participant2) = - badgeChampions.getParticipants(roundIndex, matchIndex); - - // Simulate a battle and get the winner - address winner = badgeChampions.getWinner(roundIndex, matchIndex); - - // Assertions to ensure correctness - assertTrue(participant1 != participant2); - assertTrue(participant1 == winner || participant2 == winner); - } - } - } } From 64fcd42dc53f9717062d8bbfef5826de47361af5 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Fri, 6 Sep 2024 01:01:58 +0200 Subject: [PATCH 17/79] contract simplification: pending event-driven tests --- .../trailblazers-badges/BadgeChampions.sol | 274 +++--------------- .../trailblazers-badges/hekla.json | 6 +- .../trailblazers-badges/sol/RunCommand.s.sol | 29 +- .../trailblazers-badges/BadgeChampions.t.sol | 51 +--- 4 files changed, 53 insertions(+), 307 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol b/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol index 2c6428a2c86..5388eff9e38 100644 --- a/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol +++ b/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol @@ -25,10 +25,10 @@ contract BadgeChampions is AccessControlUpgradeable { struct Champion { - address owner; - uint256 leagueId; + address owner; address badgeContract; uint256 tokenId; + uint256 leagueId; uint256 color; // 0 = neutral, 1 = pink, 2 = purple uint256 power; } @@ -38,10 +38,8 @@ contract BadgeChampions is uint256 closeTime; // registration ends uint256 startTime; // league starts (requires admin action) uint256 seed; - address[] participants; } - mapping(address owner => Champion champion) public champions; mapping(uint256 leagueId => League league) public leagues; uint256 public currentLeagueId = 0; @@ -57,9 +55,20 @@ contract BadgeChampions is 51, // Androids 42, // Drummers 77 // Shinto - ]; - + ]; + function getChampionId( + uint256 _leagueId, + address _owner, + address _badgeContract, + uint256 _tokenId + ) + public + pure + returns (bytes memory) + { + return abi.encodePacked(_owner, _badgeContract, _tokenId, _leagueId); + } event LeagueCreated( uint256 indexed leagueId, uint256 openTime, uint256 startTime, uint256 endTime @@ -67,8 +76,11 @@ contract BadgeChampions is event LeagueStarted(uint256 leagueId, uint256 seed); event ChampionRegistered( - uint256 indexed leagueId, address indexed owner, - address badgesContract, uint256 tokenId, uint256 power + uint256 indexed leagueId, + address indexed owner, + address badgesContract, + uint256 tokenId, + uint256 power ); error ELEMENT_NOT_FOUND(); @@ -79,8 +91,8 @@ contract BadgeChampions is error CHAMPION_NOT_OWNED(); error INVALID_PARTICIPANT_COUNT(); error INVALID_ROUND(); -error INVALID_CHAMPION_CONTRACT(); -error INVALID_MATCH(); + error INVALID_CHAMPION_CONTRACT(); + error INVALID_MATCH(); function initialize(address _season1Badges, address _season2Badges) external initializer { __Context_init(); @@ -93,13 +105,7 @@ error INVALID_MATCH(); function getCurrentLeague() public view - returns ( - uint256 openTime, - uint256 closeTime, - uint256 startTime, - uint256 seed, - address[] memory participants - ) + returns (uint256 openTime, uint256 closeTime, uint256 startTime, uint256 seed) { return getLeague(currentLeagueId); } @@ -107,22 +113,10 @@ error INVALID_MATCH(); function getLeague(uint256 _leagueId) public view - returns ( - uint256 openTime, - uint256 closeTime, - uint256 startTime, - uint256 seed, - address[] memory participants - ) + returns (uint256 openTime, uint256 closeTime, uint256 startTime, uint256 seed) { League memory league = leagues[_leagueId]; - return ( - league.openTime, - league.closeTime, - league.startTime, - league.seed, - league.participants - ); + return (league.openTime, league.closeTime, league.startTime, league.seed); } function createLeague( @@ -133,20 +127,14 @@ error INVALID_MATCH(); public onlyOwner { - League memory league = League({ - openTime: _openTime, - closeTime: _closeTime, - startTime: _startTime, - seed: 0, - participants: new address[](0) - }); + League memory league = + League({ openTime: _openTime, closeTime: _closeTime, startTime: _startTime, seed: 0 }); currentLeagueId += 1; leagues[currentLeagueId] = league; - emit LeagueCreated(currentLeagueId, _openTime, _closeTime, _startTime - ); - } + emit LeagueCreated(currentLeagueId, _openTime, _closeTime, _startTime); + } modifier leagueOpen(uint256 _leagueId) { League memory league = leagues[_leagueId]; @@ -158,6 +146,7 @@ error INVALID_MATCH(); } modifier ownedToken(address _badgeContract, uint256 _badgeId) { + // TODO: erc1155 ownership checkup for s2 badges uint256 tokenId = season1Badges.getTokenId(_msgSender(), _badgeId); if ( @@ -179,31 +168,17 @@ error INVALID_MATCH(); address _player, address _badgeContract, uint256 _badgeId - ) internal + ) + internal { if (_badgeContract != address(season1Badges) && _badgeContract != address(season2Badges)) { revert INVALID_CHAMPION_CONTRACT(); } - uint256 color = 0; // TODO: make it based on the badge uint256 tokenId = season1Badges.getTokenId(_player, _badgeId); uint256 power = calculatePower(_badgeId); - Champion memory champion = Champion({ - leagueId: currentLeagueId, - badgeContract: _badgeContract, - tokenId: tokenId, - owner: _player, - color: color, - power: power - }); - - champions[_player] = champion; - League storage league = leagues[currentLeagueId]; - league.participants.push(_player); - - emit ChampionRegistered( - currentLeagueId, _player, _badgeContract, tokenId, power); + emit ChampionRegistered(currentLeagueId, _player, _badgeContract, tokenId, power); } function registerChampionFor( @@ -228,22 +203,6 @@ error INVALID_MATCH(); _registerChampionFor(_msgSender(), _badgeContract, _badgeId); } - function calculateTotalRounds(uint256 participantCount) public pure returns (uint256) { - if (participantCount == 0) { - revert INVALID_PARTICIPANT_COUNT(); - } - - uint256 rounds = 0; - uint256 count = participantCount; - - while (count > 1) { - count = (count + 1) / 2; // Each round halves the number of participants - rounds++; - } - - return rounds; - } - function startLeague(uint256 seed) public onlyOwner { League storage league = leagues[currentLeagueId]; league.seed = seed; @@ -277,125 +236,6 @@ error INVALID_MATCH(); } } - function _indexOf(address[] memory _array, address _element) internal pure returns (uint256) { - for (uint256 i = 0; i < _array.length; i++) { - if (_array[i] == _element) { - return i; - } - } - revert ELEMENT_NOT_FOUND(); - } - - function _seedBasedRandom(uint256 _extraSeed) internal view returns (uint256) { - League memory league = leagues[currentLeagueId]; - uint256 seed = league.seed + _extraSeed; - return seed; - } - - - function _randomizeAddresses( - address[] memory addresses, - uint256 seed - ) - internal - pure - returns (address[] memory) - { - address[] memory shuffledAddresses = addresses; - uint256 n = shuffledAddresses.length; - - for (uint256 i = n - 1; i > 0; i--) { - uint256 j = uint256(keccak256(abi.encodePacked(seed, i))) % (i + 1); - // Swap elements - (shuffledAddresses[i], shuffledAddresses[j]) = - (shuffledAddresses[j], shuffledAddresses[i]); - } - - return shuffledAddresses; - } - - //////////////////////////////////////////////////////////////// - - function calculateMatchesInRound( - uint256 round, - uint256 initialParticipantCount - ) - public - pure - returns (uint256) - { - if (initialParticipantCount == 0) { - revert INVALID_PARTICIPANT_COUNT(); - } - - if (round == 0) { - revert INVALID_ROUND(); - } - // Calculate the number of participants in the given round - uint256 participantsInRound = initialParticipantCount / (2 ** (round - 1)); - - // Calculate the number of matches in the given round - uint256 matchesInRound = participantsInRound / 2; - - return matchesInRound; - } - - function getMatchup(uint256 round, uint256 matchIndex) public view returns (uint256, uint256) { - if (round == 0) { - revert INVALID_ROUND(); - } - League memory league = leagues[currentLeagueId]; - - uint256 firstIndex = matchIndex * 2; - uint256 secondIndex = firstIndex + 1; - - uint256 firstParticipantIndex = - deterministicIndex(league.seed, firstIndex, round, league.participants.length); - uint256 secondParticipantIndex = - deterministicIndex(league.seed, secondIndex, round, league.participants.length); - - // Ensure the indices are distinct - if (firstParticipantIndex == secondParticipantIndex) { - secondParticipantIndex = (secondParticipantIndex + 1) % league.participants.length; - } - - return (firstParticipantIndex, secondParticipantIndex); - } - - function deterministicIndex( - uint256 seed, - uint256 index, - uint256 round, - uint256 participantsLength - ) - internal - pure - returns (uint256) - { - return uint256(keccak256(abi.encode(seed, index, round))) % participantsLength; - } - - function getParticipants( - uint256 round, - uint256 matchIndex - ) - public - view - returns (address, address) - { - uint256 maxMatchIndex = calculateMatchesInRound(round, leagues[currentLeagueId].participants.length); - if (matchIndex >= maxMatchIndex) { - revert INVALID_MATCH(); - } - (uint256 first, uint256 second) = getMatchup(round, matchIndex); - League memory league = leagues[currentLeagueId]; - return (league.participants[first], league.participants[second]); - } - - - - - //////////////////////////////////////////////////////////////// function supportsInterface(bytes4 interfaceId) public view @@ -406,52 +246,4 @@ error INVALID_MATCH(); } function _authorizeUpgrade(address) internal virtual override onlyOwner { } - - - - //////////////////////////////////////////////////////////////// - - -// Deterministically shuffle an array of addresses based on a uint256 seed - // Simple linear congruential generator (LCG) - function linearCongruentialGenerator(uint256 seed) private pure returns (uint256) { - // Parameters for LCG - uint256 a = 1664525; - uint256 c = 1013904223; - uint256 m = 2**32; - - return (a * seed + c) % m; - } - - function shuffleAddresses(address[] calldata addresses, uint256 seed) public pure returns (address[] memory) { - uint256 n = addresses.length; - // Create a memory copy of the calldata array since calldata is read-only - address[] memory shuffled = new address[](n); - - for (uint256 i = 0; i < n; i++) { - shuffled[i] = addresses[i]; - } - - // Perform the Fisher-Yates shuffle on the memory array - for (uint256 i = n - 1; i > 0; i--) { - // Generate a pseudo-random index based on the seed - uint256 randomIndex = (linearCongruentialGenerator(seed + i) % (i + 1)); - - // Swap the current element with the random index - address temp = shuffled[i]; - shuffled[i] = shuffled[randomIndex]; - shuffled[randomIndex] = temp; - } - - return shuffled; - } - - /* - we relly on a seed-sort for the participants - implement js iterator to extract results - - the blocknumber at use is startBlockNumber + round - - - - */ } diff --git a/packages/nfts/deployments/trailblazers-badges/hekla.json b/packages/nfts/deployments/trailblazers-badges/hekla.json index 7bab27ab660..13a895d971f 100644 --- a/packages/nfts/deployments/trailblazers-badges/hekla.json +++ b/packages/nfts/deployments/trailblazers-badges/hekla.json @@ -1,6 +1,6 @@ { - "BadgeChampions": "0xaa0FbbA5dFa39C8469890DB3BDe003c9BaAC6c1a", + "BadgeChampions": "0x97AC51cF04Af3ccB71b96Ae9e05d5973EEa2F709", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0xdbf205a18518D2Bf8092E59Ff8d1572557A3e65D", - "TrailblazersBadgesS2": "0xb93b8F9E74232B2B4D801313281a39fEA94c3b8B" + "TrailblazersBadges": "0x04585cd8f5e11574d4f01bFAa1600a7313A8A5fD", + "TrailblazersBadgesS2": "0xc9Ae80a53A3225206eFbCD094dE9e24e3EFa6D13" } diff --git a/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol b/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol index d532b14a139..c63ef0e5abf 100644 --- a/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol +++ b/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol @@ -22,13 +22,14 @@ contract DeployScript is Script { BadgeChampions public badgeChampions; // Hekla - address constant S1_ADDRESS = 0x251a530c6C4Cb0839496ca38613F1e33a8AA2984; - address constant S2_ADDRESS = 0xcc75A678b91076f8840a0BD4b269c8D6e0Ab2c26; - address constant CHAMPIONS_ADDRESS = 0xc8fFF08D23C1176061a261CC5DB57c3B1CE43C04; + address constant S1_ADDRESS = 0x04585cd8f5e11574d4f01bFAa1600a7313A8A5fD; + address constant S2_ADDRESS = 0xc9Ae80a53A3225206eFbCD094dE9e24e3EFa6D13; + address constant CHAMPIONS_ADDRESS = 0x97AC51cF04Af3ccB71b96Ae9e05d5973EEa2F709; address[] public participants = [ // @bearni - taiko:hekla 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, address(0x1), address(0x2), address(0x3), @@ -58,41 +59,29 @@ contract DeployScript is Script { uint256 OPEN_TIME = block.timestamp - 3 minutes; uint256 CLOSE_TIME = block.timestamp - 2 minutes; - uint256 START_TIME = block.timestamp -1 minutes; - - - badgeChampions.createLeague( - OPEN_TIME, CLOSE_TIME, START_TIME); + uint256 START_TIME = block.timestamp - 1 minutes; + badgeChampions.createLeague(OPEN_TIME, CLOSE_TIME, START_TIME); for (uint256 i = 0; i < participants.length; i++) { uint256 badgeId = i % 7; trailblazersBadges.mintTo(participants[i], badgeId); badgeChampions.registerChampionFor( - participants[i], - address(trailblazersBadges), - badgeId + participants[i], address(trailblazersBadges), badgeId ); } vm.stopBroadcast(); - } - - function run() public { - - - createFreshTournament(); - + createFreshTournament(); // close signups and start the tournament vm.startBroadcast(deployerPrivateKey); - uint256 TOURNAMENT_SEED = block.number * 123456789; + uint256 TOURNAMENT_SEED = block.number * 123_456_789; badgeChampions.startLeague(TOURNAMENT_SEED); vm.stopBroadcast(); - } } diff --git a/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol b/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol index 2662a89d65a..86f8854f640 100644 --- a/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol +++ b/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol @@ -45,7 +45,6 @@ contract BadgeChampionsTest is Test { uint256 constant CLOSE_TIME = 20_000; uint256 constant START_TIME = 30_000; - function setUp() public { utils = new UtilsScript(); utils.setUp(); @@ -110,20 +109,14 @@ contract BadgeChampionsTest is Test { badgeChampions.createLeague(OPEN_TIME, CLOSE_TIME, START_TIME); // check league - ( - uint256 openTime, - uint256 closeTime, - uint256 startTime, - uint256 seed, - address[] memory participants - ) = badgeChampions.getCurrentLeague(); + (uint256 openTime, uint256 closeTime, uint256 startTime, uint256 seed) = + badgeChampions.getCurrentLeague(); assertEq(openTime, OPEN_TIME); assertEq(closeTime, CLOSE_TIME); assertEq(startTime, START_TIME); assertEq(seed, 0); - assertEq(participants.length, 0); } function test_revert_leagueNotOpen() public { @@ -147,21 +140,14 @@ contract BadgeChampionsTest is Test { badgeChampions.registerChampion(address(token), BADGE_IDS[0]); // check league - ( - uint256 openTime, - uint256 closeTime, - uint256 startTime, - uint256 seed, - address[] memory participants - ) = badgeChampions.getCurrentLeague(); + (uint256 openTime, uint256 closeTime, uint256 startTime, uint256 seed) = + badgeChampions.getCurrentLeague(); assertEq(openTime, OPEN_TIME); assertEq(closeTime, CLOSE_TIME); assertEq(startTime, START_TIME); assertEq(seed, 0); - assertEq(participants.length, 1); - assertEq(participants[0], minters[0]); } function test_revert_registerChampion_notOwned() public { @@ -186,23 +172,14 @@ contract BadgeChampionsTest is Test { } // check league - ( - uint256 openTime, - uint256 closeTime, - uint256 startTime, - uint256 seed, - address[] memory participants - ) = badgeChampions.getCurrentLeague(); + (uint256 openTime, uint256 closeTime, uint256 startTime, uint256 seed) = + badgeChampions.getCurrentLeague(); assertEq(openTime, OPEN_TIME); assertEq(closeTime, CLOSE_TIME); assertEq(startTime, START_TIME); assertEq(seed, 0); - assertEq(participants.length, minters.length); - for (uint256 i = 0; i < minters.length; i++) { - assertEq(participants[i], minters[i]); - } } function test_admin_startLeague() public { @@ -214,23 +191,14 @@ contract BadgeChampionsTest is Test { badgeChampions.startLeague(TOURNAMENT_SEED); // check league - ( - uint256 openTime, - uint256 closeTime, - uint256 startTime, - uint256 seed, - address[] memory participants - ) = badgeChampions.getCurrentLeague(); + (uint256 openTime, uint256 closeTime, uint256 startTime, uint256 seed) = + badgeChampions.getCurrentLeague(); assertEq(openTime, OPEN_TIME); assertEq(closeTime, CLOSE_TIME); assertEq(startTime, START_TIME); assertEq(seed, TOURNAMENT_SEED); - assertEq(participants.length, minters.length); - for (uint256 i = 0; i < minters.length; i++) { - assertEq(participants[i], minters[i]); - } } function test_revert_startLeague_notAdmin() public { @@ -243,7 +211,4 @@ contract BadgeChampionsTest is Test { badgeChampions.startLeague(TOURNAMENT_SEED); vm.stopPrank(); } - - - } From 506492fce9806a351df1ef09fc635c497c5487ef Mon Sep 17 00:00:00 2001 From: bearni95 Date: Fri, 6 Sep 2024 19:39:54 +0200 Subject: [PATCH 18/79] runcommand added --- .../trailblazers-badges/sol/RunCommand.s.sol | 1013 ++++++++++++++++- 1 file changed, 1012 insertions(+), 1 deletion(-) diff --git a/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol b/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol index c63ef0e5abf..ab6c8d0452f 100644 --- a/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol +++ b/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol @@ -39,6 +39,1017 @@ contract DeployScript is Script { address(0x7), address(0x8), address(0x9), + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, + address(0x1), + address(0x2), + address(0x3), + address(0x4), + address(0x5), + address(0x6), + address(0x7), + address(0x8), + address(0x9), address(0x10) ]; @@ -75,7 +1086,7 @@ contract DeployScript is Script { } function run() public { - createFreshTournament(); + //createFreshTournament(); // close signups and start the tournament vm.startBroadcast(deployerPrivateKey); From 8979d9d48cdba63dd5a32473073a59bf0627e384 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Sat, 7 Sep 2024 19:30:56 +0200 Subject: [PATCH 19/79] badge champions update --- .../trailblazers-badges/BadgeChampions.sol | 10 +- .../trailblazers-badges/hekla.json | 6 +- .../trailblazers-badges/sol/RunCommand.s.sol | 1029 +---------------- 3 files changed, 14 insertions(+), 1031 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol b/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol index 5388eff9e38..926e3afb9ac 100644 --- a/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol +++ b/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol @@ -80,7 +80,8 @@ contract BadgeChampions is address indexed owner, address badgesContract, uint256 tokenId, - uint256 power + uint256 power, + uint256 badgeId ); error ELEMENT_NOT_FOUND(); @@ -160,8 +161,9 @@ contract BadgeChampions is _; } - function calculatePower(uint256 _badgeId) public view returns (uint256) { - return powerLevels[_badgeId % powerLevels.length]; + function calculatePower(uint256 _badgeId) public pure returns (uint256) { + return ((1 + _badgeId) * 125) / 10; + //return powerLevels[_badgeId % powerLevels.length]; } function _registerChampionFor( @@ -178,7 +180,7 @@ contract BadgeChampions is uint256 tokenId = season1Badges.getTokenId(_player, _badgeId); uint256 power = calculatePower(_badgeId); - emit ChampionRegistered(currentLeagueId, _player, _badgeContract, tokenId, power); + emit ChampionRegistered(currentLeagueId, _player, _badgeContract, tokenId, power, _badgeId); } function registerChampionFor( diff --git a/packages/nfts/deployments/trailblazers-badges/hekla.json b/packages/nfts/deployments/trailblazers-badges/hekla.json index 13a895d971f..209de728ce5 100644 --- a/packages/nfts/deployments/trailblazers-badges/hekla.json +++ b/packages/nfts/deployments/trailblazers-badges/hekla.json @@ -1,6 +1,6 @@ { - "BadgeChampions": "0x97AC51cF04Af3ccB71b96Ae9e05d5973EEa2F709", + "BadgeChampions": "0x854f29e8b3cE90521eEDBaC9BC3B50c92C32f00e", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x04585cd8f5e11574d4f01bFAa1600a7313A8A5fD", - "TrailblazersBadgesS2": "0xc9Ae80a53A3225206eFbCD094dE9e24e3EFa6D13" + "TrailblazersBadges": "0x075B858dA6eaf29b157925F4243135C565075842", + "TrailblazersBadgesS2": "0x3B20B6c42EDa78355beC5126cD4abB1fF4C218dd" } diff --git a/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol b/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol index ab6c8d0452f..a025d48e9be 100644 --- a/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol +++ b/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol @@ -22,1035 +22,16 @@ contract DeployScript is Script { BadgeChampions public badgeChampions; // Hekla - address constant S1_ADDRESS = 0x04585cd8f5e11574d4f01bFAa1600a7313A8A5fD; - address constant S2_ADDRESS = 0xc9Ae80a53A3225206eFbCD094dE9e24e3EFa6D13; - address constant CHAMPIONS_ADDRESS = 0x97AC51cF04Af3ccB71b96Ae9e05d5973EEa2F709; + address constant S1_ADDRESS = 0x075B858dA6eaf29b157925F4243135C565075842; + address constant S2_ADDRESS = 0x3B20B6c42EDa78355beC5126cD4abB1fF4C218dd; + address constant CHAMPIONS_ADDRESS = 0x854f29e8b3cE90521eEDBaC9BC3B50c92C32f00e; address[] public participants = [ // @bearni - taiko:hekla 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9), - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9),0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, address(0x1), address(0x2), - address(0x3), - address(0x4), - address(0x5), - address(0x6), - address(0x7), - address(0x8), - address(0x9), - address(0x10) + address(0x3) ]; function setUp() public { @@ -1086,7 +67,7 @@ contract DeployScript is Script { } function run() public { - //createFreshTournament(); + createFreshTournament(); // close signups and start the tournament vm.startBroadcast(deployerPrivateKey); From 46cdf8ba5f298b1578522fe8ce3ba874aa97a89c Mon Sep 17 00:00:00 2001 From: bearni95 Date: Wed, 11 Sep 2024 10:50:04 +0000 Subject: [PATCH 20/79] forge fmt & update contract layout table --- packages/protocol/contract_layout_layer1.md | 1452 ++++++++--------- packages/protocol/contract_layout_layer2.md | 687 ++++---- packages/protocol/contracts/L1/TaikoData.sol | 2 +- .../protocol/script/DeployERC20Airdrop.s.sol | 2 +- packages/protocol/script/DeployOnL1.s.sol | 10 +- .../protocol/script/tokenunlock/Deploy.s.sol | 2 +- packages/protocol/test/L2/DelegateOwner.t.sol | 2 +- packages/protocol/test/L2/TaikoL2.t.sol | 2 +- .../protocol/test/L2/TaikoL2NoFeeCheck.t.sol | 2 +- .../common/AttestationBase.t.sol | 2 +- .../test/team/airdrop/ERC20Airdrop.t.sol | 4 +- .../test/tokenvault/BridgedERC20V2.t.sol | 2 +- .../protocol/test/tokenvault/ERC20Vault.t.sol | 6 +- 13 files changed, 1055 insertions(+), 1120 deletions(-) diff --git a/packages/protocol/contract_layout_layer1.md b/packages/protocol/contract_layout_layer1.md index d497d91ab7a..45b2f5ce7dd 100644 --- a/packages/protocol/contract_layout_layer1.md +++ b/packages/protocol/contract_layout_layer1.md @@ -1,509 +1,487 @@ ## ERC1155Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ------------ | -| \_initialized | uint8 | 0 | 0 | 1 | ERC1155Vault | -| \_initializing | bool | 0 | 1 | 1 | ERC1155Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ERC1155Vault | -| \_owner | address | 51 | 0 | 20 | ERC1155Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ERC1155Vault | -| \_pendingOwner | address | 101 | 0 | 20 | ERC1155Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ERC1155Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|----------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ERC1155Vault | +| _initializing | bool | 0 | 1 | 1 | ERC1155Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | ERC1155Vault | +| _owner | address | 51 | 0 | 20 | ERC1155Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | ERC1155Vault | +| _pendingOwner | address | 101 | 0 | 20 | ERC1155Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | ERC1155Vault | | addressManager | address | 151 | 0 | 20 | ERC1155Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ERC1155Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | ERC1155Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | ERC1155Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | ERC1155Vault | +| __reentry | uint8 | 201 | 0 | 1 | ERC1155Vault | +| __paused | uint8 | 201 | 1 | 1 | ERC1155Vault | | lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC1155Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ERC1155Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ERC1155Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | ERC1155Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | ERC1155Vault | | bridgedToCanonical | mapping(address => struct BaseNFTVault.CanonicalNFT) | 301 | 0 | 32 | ERC1155Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | ERC1155Vault | -| \_\_gap | uint256[48] | 303 | 0 | 1536 | ERC1155Vault | -| \_\_gap | uint256[50] | 351 | 0 | 1600 | ERC1155Vault | -| \_\_gap | uint256[50] | 401 | 0 | 1600 | ERC1155Vault | -| \_\_gap | uint256[50] | 451 | 0 | 1600 | ERC1155Vault | +| __gap | uint256[48] | 303 | 0 | 1536 | ERC1155Vault | +| __gap | uint256[50] | 351 | 0 | 1600 | ERC1155Vault | +| __gap | uint256[50] | 401 | 0 | 1600 | ERC1155Vault | +| __gap | uint256[50] | 451 | 0 | 1600 | ERC1155Vault | ## ERC20Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ---------- | -| \_initialized | uint8 | 0 | 0 | 1 | ERC20Vault | -| \_initializing | bool | 0 | 1 | 1 | ERC20Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ERC20Vault | -| \_owner | address | 51 | 0 | 20 | ERC20Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ERC20Vault | -| \_pendingOwner | address | 101 | 0 | 20 | ERC20Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ERC20Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ERC20Vault | +| _initializing | bool | 0 | 1 | 1 | ERC20Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | ERC20Vault | +| _owner | address | 51 | 0 | 20 | ERC20Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | ERC20Vault | +| _pendingOwner | address | 101 | 0 | 20 | ERC20Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | ERC20Vault | | addressManager | address | 151 | 0 | 20 | ERC20Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ERC20Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | ERC20Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | ERC20Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | ERC20Vault | +| __reentry | uint8 | 201 | 0 | 1 | ERC20Vault | +| __paused | uint8 | 201 | 1 | 1 | ERC20Vault | | lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC20Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ERC20Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ERC20Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | ERC20Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | ERC20Vault | | bridgedToCanonical | mapping(address => struct ERC20Vault.CanonicalERC20) | 301 | 0 | 32 | ERC20Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | ERC20Vault | | btokenDenylist | mapping(address => bool) | 303 | 0 | 32 | ERC20Vault | | lastMigrationStart | mapping(uint256 => mapping(address => uint256)) | 304 | 0 | 32 | ERC20Vault | -| \_\_gap | uint256[46] | 305 | 0 | 1472 | ERC20Vault | +| __gap | uint256[46] | 305 | 0 | 1472 | ERC20Vault | ## ERC721Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ----------- | -| \_initialized | uint8 | 0 | 0 | 1 | ERC721Vault | -| \_initializing | bool | 0 | 1 | 1 | ERC721Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ERC721Vault | -| \_owner | address | 51 | 0 | 20 | ERC721Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ERC721Vault | -| \_pendingOwner | address | 101 | 0 | 20 | ERC721Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ERC721Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|--------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ERC721Vault | +| _initializing | bool | 0 | 1 | 1 | ERC721Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | ERC721Vault | +| _owner | address | 51 | 0 | 20 | ERC721Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | ERC721Vault | +| _pendingOwner | address | 101 | 0 | 20 | ERC721Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | ERC721Vault | | addressManager | address | 151 | 0 | 20 | ERC721Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ERC721Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | ERC721Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | ERC721Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | ERC721Vault | +| __reentry | uint8 | 201 | 0 | 1 | ERC721Vault | +| __paused | uint8 | 201 | 1 | 1 | ERC721Vault | | lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC721Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ERC721Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ERC721Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | ERC721Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | ERC721Vault | | bridgedToCanonical | mapping(address => struct BaseNFTVault.CanonicalNFT) | 301 | 0 | 32 | ERC721Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | ERC721Vault | -| \_\_gap | uint256[48] | 303 | 0 | 1536 | ERC721Vault | -| \_\_gap | uint256[50] | 351 | 0 | 1600 | ERC721Vault | +| __gap | uint256[48] | 303 | 0 | 1536 | ERC721Vault | +| __gap | uint256[50] | 351 | 0 | 1600 | ERC721Vault | ## BridgedERC20 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ---------------- | ----------------------------------------------- | ---- | ------ | ----- | ------------ | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedERC20 | -| \_initializing | bool | 0 | 1 | 1 | BridgedERC20 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20 | -| \_owner | address | 51 | 0 | 20 | BridgedERC20 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedERC20 | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedERC20 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedERC20 | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------------------------------------------|------|--------|-------|----------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedERC20 | +| _initializing | bool | 0 | 1 | 1 | BridgedERC20 | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20 | +| _owner | address | 51 | 0 | 20 | BridgedERC20 | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedERC20 | +| _pendingOwner | address | 101 | 0 | 20 | BridgedERC20 | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedERC20 | | addressManager | address | 151 | 0 | 20 | BridgedERC20 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedERC20 | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedERC20 | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedERC20 | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedERC20 | +| __reentry | uint8 | 201 | 0 | 1 | BridgedERC20 | +| __paused | uint8 | 201 | 1 | 1 | BridgedERC20 | | lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC20 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedERC20 | -| \_balances | mapping(address => uint256) | 251 | 0 | 32 | BridgedERC20 | -| \_allowances | mapping(address => mapping(address => uint256)) | 252 | 0 | 32 | BridgedERC20 | -| \_totalSupply | uint256 | 253 | 0 | 32 | BridgedERC20 | -| \_name | string | 254 | 0 | 32 | BridgedERC20 | -| \_symbol | string | 255 | 0 | 32 | BridgedERC20 | -| \_\_gap | uint256[45] | 256 | 0 | 1440 | BridgedERC20 | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedERC20 | +| _balances | mapping(address => uint256) | 251 | 0 | 32 | BridgedERC20 | +| _allowances | mapping(address => mapping(address => uint256)) | 252 | 0 | 32 | BridgedERC20 | +| _totalSupply | uint256 | 253 | 0 | 32 | BridgedERC20 | +| _name | string | 254 | 0 | 32 | BridgedERC20 | +| _symbol | string | 255 | 0 | 32 | BridgedERC20 | +| __gap | uint256[45] | 256 | 0 | 1440 | BridgedERC20 | | srcToken | address | 301 | 0 | 20 | BridgedERC20 | -| \_\_srcDecimals | uint8 | 301 | 20 | 1 | BridgedERC20 | +| __srcDecimals | uint8 | 301 | 20 | 1 | BridgedERC20 | | srcChainId | uint256 | 302 | 0 | 32 | BridgedERC20 | | migratingAddress | address | 303 | 0 | 20 | BridgedERC20 | | migratingInbound | bool | 303 | 20 | 1 | BridgedERC20 | -| \_\_gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20 | +| __gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20 | ## BridgedERC20V2 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ---------------- | ------------------------------------------------------ | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedERC20V2 | -| \_initializing | bool | 0 | 1 | 1 | BridgedERC20V2 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20V2 | -| \_owner | address | 51 | 0 | 20 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedERC20V2 | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedERC20V2 | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|--------------------------------------------------------|------|--------|-------|--------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedERC20V2 | +| _initializing | bool | 0 | 1 | 1 | BridgedERC20V2 | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20V2 | +| _owner | address | 51 | 0 | 20 | BridgedERC20V2 | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedERC20V2 | +| _pendingOwner | address | 101 | 0 | 20 | BridgedERC20V2 | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedERC20V2 | | addressManager | address | 151 | 0 | 20 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedERC20V2 | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedERC20V2 | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedERC20V2 | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedERC20V2 | +| __reentry | uint8 | 201 | 0 | 1 | BridgedERC20V2 | +| __paused | uint8 | 201 | 1 | 1 | BridgedERC20V2 | | lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedERC20V2 | -| \_balances | mapping(address => uint256) | 251 | 0 | 32 | BridgedERC20V2 | -| \_allowances | mapping(address => mapping(address => uint256)) | 252 | 0 | 32 | BridgedERC20V2 | -| \_totalSupply | uint256 | 253 | 0 | 32 | BridgedERC20V2 | -| \_name | string | 254 | 0 | 32 | BridgedERC20V2 | -| \_symbol | string | 255 | 0 | 32 | BridgedERC20V2 | -| \_\_gap | uint256[45] | 256 | 0 | 1440 | BridgedERC20V2 | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedERC20V2 | +| _balances | mapping(address => uint256) | 251 | 0 | 32 | BridgedERC20V2 | +| _allowances | mapping(address => mapping(address => uint256)) | 252 | 0 | 32 | BridgedERC20V2 | +| _totalSupply | uint256 | 253 | 0 | 32 | BridgedERC20V2 | +| _name | string | 254 | 0 | 32 | BridgedERC20V2 | +| _symbol | string | 255 | 0 | 32 | BridgedERC20V2 | +| __gap | uint256[45] | 256 | 0 | 1440 | BridgedERC20V2 | | srcToken | address | 301 | 0 | 20 | BridgedERC20V2 | -| \_\_srcDecimals | uint8 | 301 | 20 | 1 | BridgedERC20V2 | +| __srcDecimals | uint8 | 301 | 20 | 1 | BridgedERC20V2 | | srcChainId | uint256 | 302 | 0 | 32 | BridgedERC20V2 | | migratingAddress | address | 303 | 0 | 20 | BridgedERC20V2 | | migratingInbound | bool | 303 | 20 | 1 | BridgedERC20V2 | -| \_\_gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20V2 | -| \_hashedName | bytes32 | 351 | 0 | 32 | BridgedERC20V2 | -| \_hashedVersion | bytes32 | 352 | 0 | 32 | BridgedERC20V2 | -| \_name | string | 353 | 0 | 32 | BridgedERC20V2 | -| \_version | string | 354 | 0 | 32 | BridgedERC20V2 | -| \_\_gap | uint256[48] | 355 | 0 | 1536 | BridgedERC20V2 | -| \_nonces | mapping(address => struct CountersUpgradeable.Counter) | 403 | 0 | 32 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 404 | 0 | 1568 | BridgedERC20V2 | +| __gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20V2 | +| _hashedName | bytes32 | 351 | 0 | 32 | BridgedERC20V2 | +| _hashedVersion | bytes32 | 352 | 0 | 32 | BridgedERC20V2 | +| _name | string | 353 | 0 | 32 | BridgedERC20V2 | +| _version | string | 354 | 0 | 32 | BridgedERC20V2 | +| __gap | uint256[48] | 355 | 0 | 1536 | BridgedERC20V2 | +| _nonces | mapping(address => struct CountersUpgradeable.Counter) | 403 | 0 | 32 | BridgedERC20V2 | +| __gap | uint256[49] | 404 | 0 | 1568 | BridgedERC20V2 | ## BridgedERC721 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------- | -------------------------------------------- | ---- | ------ | ----- | ------------- | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedERC721 | -| \_initializing | bool | 0 | 1 | 1 | BridgedERC721 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedERC721 | -| \_owner | address | 51 | 0 | 20 | BridgedERC721 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedERC721 | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedERC721 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedERC721 | -| addressManager | address | 151 | 0 | 20 | BridgedERC721 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedERC721 | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedERC721 | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedERC721 | -| lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC721 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedERC721 | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | BridgedERC721 | -| \_name | string | 301 | 0 | 32 | BridgedERC721 | -| \_symbol | string | 302 | 0 | 32 | BridgedERC721 | -| \_owners | mapping(uint256 => address) | 303 | 0 | 32 | BridgedERC721 | -| \_balances | mapping(address => uint256) | 304 | 0 | 32 | BridgedERC721 | -| \_tokenApprovals | mapping(uint256 => address) | 305 | 0 | 32 | BridgedERC721 | -| \_operatorApprovals | mapping(address => mapping(address => bool)) | 306 | 0 | 32 | BridgedERC721 | -| \_\_gap | uint256[44] | 307 | 0 | 1408 | BridgedERC721 | -| srcToken | address | 351 | 0 | 20 | BridgedERC721 | -| srcChainId | uint256 | 352 | 0 | 32 | BridgedERC721 | -| \_\_gap | uint256[48] | 353 | 0 | 1536 | BridgedERC721 | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|----------------------------------------------|------|--------|-------|------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedERC721 | +| _initializing | bool | 0 | 1 | 1 | BridgedERC721 | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC721 | +| _owner | address | 51 | 0 | 20 | BridgedERC721 | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedERC721 | +| _pendingOwner | address | 101 | 0 | 20 | BridgedERC721 | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedERC721 | +| addressManager | address | 151 | 0 | 20 | BridgedERC721 | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedERC721 | +| __reentry | uint8 | 201 | 0 | 1 | BridgedERC721 | +| __paused | uint8 | 201 | 1 | 1 | BridgedERC721 | +| lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC721 | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedERC721 | +| __gap | uint256[50] | 251 | 0 | 1600 | BridgedERC721 | +| _name | string | 301 | 0 | 32 | BridgedERC721 | +| _symbol | string | 302 | 0 | 32 | BridgedERC721 | +| _owners | mapping(uint256 => address) | 303 | 0 | 32 | BridgedERC721 | +| _balances | mapping(address => uint256) | 304 | 0 | 32 | BridgedERC721 | +| _tokenApprovals | mapping(uint256 => address) | 305 | 0 | 32 | BridgedERC721 | +| _operatorApprovals | mapping(address => mapping(address => bool)) | 306 | 0 | 32 | BridgedERC721 | +| __gap | uint256[44] | 307 | 0 | 1408 | BridgedERC721 | +| srcToken | address | 351 | 0 | 20 | BridgedERC721 | +| srcChainId | uint256 | 352 | 0 | 32 | BridgedERC721 | +| __gap | uint256[48] | 353 | 0 | 1536 | BridgedERC721 | ## BridgedERC1155 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------- | ----------------------------------------------- | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedERC1155 | -| \_initializing | bool | 0 | 1 | 1 | BridgedERC1155 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedERC1155 | -| \_owner | address | 51 | 0 | 20 | BridgedERC1155 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedERC1155 | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedERC1155 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedERC1155 | -| addressManager | address | 151 | 0 | 20 | BridgedERC1155 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedERC1155 | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedERC1155 | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedERC1155 | -| lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC1155 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedERC1155 | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | BridgedERC1155 | -| \_balances | mapping(uint256 => mapping(address => uint256)) | 301 | 0 | 32 | BridgedERC1155 | -| \_operatorApprovals | mapping(address => mapping(address => bool)) | 302 | 0 | 32 | BridgedERC1155 | -| \_uri | string | 303 | 0 | 32 | BridgedERC1155 | -| \_\_gap | uint256[47] | 304 | 0 | 1504 | BridgedERC1155 | -| srcToken | address | 351 | 0 | 20 | BridgedERC1155 | -| srcChainId | uint256 | 352 | 0 | 32 | BridgedERC1155 | -| symbol | string | 353 | 0 | 32 | BridgedERC1155 | -| name | string | 354 | 0 | 32 | BridgedERC1155 | -| \_\_gap | uint256[46] | 355 | 0 | 1472 | BridgedERC1155 | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|-------------------------------------------------|------|--------|-------|--------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedERC1155 | +| _initializing | bool | 0 | 1 | 1 | BridgedERC1155 | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC1155 | +| _owner | address | 51 | 0 | 20 | BridgedERC1155 | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedERC1155 | +| _pendingOwner | address | 101 | 0 | 20 | BridgedERC1155 | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedERC1155 | +| addressManager | address | 151 | 0 | 20 | BridgedERC1155 | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedERC1155 | +| __reentry | uint8 | 201 | 0 | 1 | BridgedERC1155 | +| __paused | uint8 | 201 | 1 | 1 | BridgedERC1155 | +| lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC1155 | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedERC1155 | +| __gap | uint256[50] | 251 | 0 | 1600 | BridgedERC1155 | +| _balances | mapping(uint256 => mapping(address => uint256)) | 301 | 0 | 32 | BridgedERC1155 | +| _operatorApprovals | mapping(address => mapping(address => bool)) | 302 | 0 | 32 | BridgedERC1155 | +| _uri | string | 303 | 0 | 32 | BridgedERC1155 | +| __gap | uint256[47] | 304 | 0 | 1504 | BridgedERC1155 | +| srcToken | address | 351 | 0 | 20 | BridgedERC1155 | +| srcChainId | uint256 | 352 | 0 | 32 | BridgedERC1155 | +| symbol | string | 353 | 0 | 32 | BridgedERC1155 | +| name | string | 354 | 0 | 32 | BridgedERC1155 | +| __gap | uint256[46] | 355 | 0 | 1472 | BridgedERC1155 | ## Bridge - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | --------------------------------------- | ---- | ------ | ----- | -------- | -| \_initialized | uint8 | 0 | 0 | 1 | Bridge | -| \_initializing | bool | 0 | 1 | 1 | Bridge | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | Bridge | -| \_owner | address | 51 | 0 | 20 | Bridge | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | Bridge | -| \_pendingOwner | address | 101 | 0 | 20 | Bridge | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | Bridge | -| addressManager | address | 151 | 0 | 20 | Bridge | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | Bridge | -| \_\_reentry | uint8 | 201 | 0 | 1 | Bridge | -| \_\_paused | uint8 | 201 | 1 | 1 | Bridge | -| lastUnpausedAt | uint64 | 201 | 2 | 8 | Bridge | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | Bridge | -| \_\_reserved1 | uint64 | 251 | 0 | 8 | Bridge | -| nextMessageId | uint64 | 251 | 8 | 8 | Bridge | -| messageStatus | mapping(bytes32 => enum IBridge.Status) | 252 | 0 | 32 | Bridge | -| \_\_ctx | struct IBridge.Context | 253 | 0 | 64 | Bridge | -| \_\_reserved2 | uint256 | 255 | 0 | 32 | Bridge | -| \_\_reserved3 | uint256 | 256 | 0 | 32 | Bridge | -| \_\_gap | uint256[44] | 257 | 0 | 1408 | Bridge | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-----------------------------------------|------|--------|-------|------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | Bridge | +| _initializing | bool | 0 | 1 | 1 | Bridge | +| __gap | uint256[50] | 1 | 0 | 1600 | Bridge | +| _owner | address | 51 | 0 | 20 | Bridge | +| __gap | uint256[49] | 52 | 0 | 1568 | Bridge | +| _pendingOwner | address | 101 | 0 | 20 | Bridge | +| __gap | uint256[49] | 102 | 0 | 1568 | Bridge | +| addressManager | address | 151 | 0 | 20 | Bridge | +| __gap | uint256[49] | 152 | 0 | 1568 | Bridge | +| __reentry | uint8 | 201 | 0 | 1 | Bridge | +| __paused | uint8 | 201 | 1 | 1 | Bridge | +| lastUnpausedAt | uint64 | 201 | 2 | 8 | Bridge | +| __gap | uint256[49] | 202 | 0 | 1568 | Bridge | +| __reserved1 | uint64 | 251 | 0 | 8 | Bridge | +| nextMessageId | uint64 | 251 | 8 | 8 | Bridge | +| messageStatus | mapping(bytes32 => enum IBridge.Status) | 252 | 0 | 32 | Bridge | +| __ctx | struct IBridge.Context | 253 | 0 | 64 | Bridge | +| __reserved2 | uint256 | 255 | 0 | 32 | Bridge | +| __reserved3 | uint256 | 256 | 0 | 32 | Bridge | +| __gap | uint256[44] | 257 | 0 | 1408 | Bridge | ## QuotaManager - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | --------------------------------------------- | ---- | ------ | ----- | ------------ | -| \_initialized | uint8 | 0 | 0 | 1 | QuotaManager | -| \_initializing | bool | 0 | 1 | 1 | QuotaManager | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | QuotaManager | -| \_owner | address | 51 | 0 | 20 | QuotaManager | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | QuotaManager | -| \_pendingOwner | address | 101 | 0 | 20 | QuotaManager | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | QuotaManager | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-----------------------------------------------|------|--------|-------|------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | QuotaManager | +| _initializing | bool | 0 | 1 | 1 | QuotaManager | +| __gap | uint256[50] | 1 | 0 | 1600 | QuotaManager | +| _owner | address | 51 | 0 | 20 | QuotaManager | +| __gap | uint256[49] | 52 | 0 | 1568 | QuotaManager | +| _pendingOwner | address | 101 | 0 | 20 | QuotaManager | +| __gap | uint256[49] | 102 | 0 | 1568 | QuotaManager | | addressManager | address | 151 | 0 | 20 | QuotaManager | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | QuotaManager | -| \_\_reentry | uint8 | 201 | 0 | 1 | QuotaManager | -| \_\_paused | uint8 | 201 | 1 | 1 | QuotaManager | +| __gap | uint256[49] | 152 | 0 | 1568 | QuotaManager | +| __reentry | uint8 | 201 | 0 | 1 | QuotaManager | +| __paused | uint8 | 201 | 1 | 1 | QuotaManager | | lastUnpausedAt | uint64 | 201 | 2 | 8 | QuotaManager | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | QuotaManager | +| __gap | uint256[49] | 202 | 0 | 1568 | QuotaManager | | tokenQuota | mapping(address => struct QuotaManager.Quota) | 251 | 0 | 32 | QuotaManager | | quotaPeriod | uint24 | 252 | 0 | 3 | QuotaManager | -| \_\_gap | uint256[48] | 253 | 0 | 1536 | QuotaManager | +| __gap | uint256[48] | 253 | 0 | 1536 | QuotaManager | ## AddressManager - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------------------------------------------- | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | AddressManager | -| \_initializing | bool | 0 | 1 | 1 | AddressManager | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | AddressManager | -| \_owner | address | 51 | 0 | 20 | AddressManager | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | AddressManager | -| \_pendingOwner | address | 101 | 0 | 20 | AddressManager | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | AddressManager | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------------------------------------------|------|--------|-------|----------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | AddressManager | +| _initializing | bool | 0 | 1 | 1 | AddressManager | +| __gap | uint256[50] | 1 | 0 | 1600 | AddressManager | +| _owner | address | 51 | 0 | 20 | AddressManager | +| __gap | uint256[49] | 52 | 0 | 1568 | AddressManager | +| _pendingOwner | address | 101 | 0 | 20 | AddressManager | +| __gap | uint256[49] | 102 | 0 | 1568 | AddressManager | | addressManager | address | 151 | 0 | 20 | AddressManager | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | AddressManager | -| \_\_reentry | uint8 | 201 | 0 | 1 | AddressManager | -| \_\_paused | uint8 | 201 | 1 | 1 | AddressManager | +| __gap | uint256[49] | 152 | 0 | 1568 | AddressManager | +| __reentry | uint8 | 201 | 0 | 1 | AddressManager | +| __paused | uint8 | 201 | 1 | 1 | AddressManager | | lastUnpausedAt | uint64 | 201 | 2 | 8 | AddressManager | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | AddressManager | -| \_\_addresses | mapping(uint256 => mapping(bytes32 => address)) | 251 | 0 | 32 | AddressManager | -| \_\_gap | uint256[49] | 252 | 0 | 1568 | AddressManager | +| __gap | uint256[49] | 202 | 0 | 1568 | AddressManager | +| __addresses | mapping(uint256 => mapping(bytes32 => address)) | 251 | 0 | 32 | AddressManager | +| __gap | uint256[49] | 252 | 0 | 1568 | AddressManager | ## AddressResolver - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------- | ---- | ------ | ----- | --------------- | -| \_initialized | uint8 | 0 | 0 | 1 | AddressResolver | -| \_initializing | bool | 0 | 1 | 1 | AddressResolver | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | AddressResolver | +| _initializing | bool | 0 | 1 | 1 | AddressResolver | | addressManager | address | 0 | 2 | 20 | AddressResolver | -| \_\_gap | uint256[49] | 1 | 0 | 1568 | AddressResolver | +| __gap | uint256[49] | 1 | 0 | 1568 | AddressResolver | ## EssentialContract - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------- | ---- | ------ | ----- | ----------------- | -| \_initialized | uint8 | 0 | 0 | 1 | EssentialContract | -| \_initializing | bool | 0 | 1 | 1 | EssentialContract | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | EssentialContract | -| \_owner | address | 51 | 0 | 20 | EssentialContract | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | EssentialContract | -| \_pendingOwner | address | 101 | 0 | 20 | EssentialContract | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | EssentialContract | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|----------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | EssentialContract | +| _initializing | bool | 0 | 1 | 1 | EssentialContract | +| __gap | uint256[50] | 1 | 0 | 1600 | EssentialContract | +| _owner | address | 51 | 0 | 20 | EssentialContract | +| __gap | uint256[49] | 52 | 0 | 1568 | EssentialContract | +| _pendingOwner | address | 101 | 0 | 20 | EssentialContract | +| __gap | uint256[49] | 102 | 0 | 1568 | EssentialContract | | addressManager | address | 151 | 0 | 20 | EssentialContract | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | EssentialContract | -| \_\_reentry | uint8 | 201 | 0 | 1 | EssentialContract | -| \_\_paused | uint8 | 201 | 1 | 1 | EssentialContract | +| __gap | uint256[49] | 152 | 0 | 1568 | EssentialContract | +| __reentry | uint8 | 201 | 0 | 1 | EssentialContract | +| __paused | uint8 | 201 | 1 | 1 | EssentialContract | | lastUnpausedAt | uint64 | 201 | 2 | 8 | EssentialContract | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | EssentialContract | +| __gap | uint256[49] | 202 | 0 | 1568 | EssentialContract | ## SignalService - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | --------------------------------------------- | ---- | ------ | ----- | ------------- | -| \_initialized | uint8 | 0 | 0 | 1 | SignalService | -| \_initializing | bool | 0 | 1 | 1 | SignalService | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | SignalService | -| \_owner | address | 51 | 0 | 20 | SignalService | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | SignalService | -| \_pendingOwner | address | 101 | 0 | 20 | SignalService | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | SignalService | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-----------------------------------------------|------|--------|-------|--------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | SignalService | +| _initializing | bool | 0 | 1 | 1 | SignalService | +| __gap | uint256[50] | 1 | 0 | 1600 | SignalService | +| _owner | address | 51 | 0 | 20 | SignalService | +| __gap | uint256[49] | 52 | 0 | 1568 | SignalService | +| _pendingOwner | address | 101 | 0 | 20 | SignalService | +| __gap | uint256[49] | 102 | 0 | 1568 | SignalService | | addressManager | address | 151 | 0 | 20 | SignalService | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | SignalService | -| \_\_reentry | uint8 | 201 | 0 | 1 | SignalService | -| \_\_paused | uint8 | 201 | 1 | 1 | SignalService | +| __gap | uint256[49] | 152 | 0 | 1568 | SignalService | +| __reentry | uint8 | 201 | 0 | 1 | SignalService | +| __paused | uint8 | 201 | 1 | 1 | SignalService | | lastUnpausedAt | uint64 | 201 | 2 | 8 | SignalService | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | SignalService | +| __gap | uint256[49] | 202 | 0 | 1568 | SignalService | | topBlockId | mapping(uint64 => mapping(bytes32 => uint64)) | 251 | 0 | 32 | SignalService | | isAuthorized | mapping(address => bool) | 252 | 0 | 32 | SignalService | -| \_\_gap | uint256[48] | 253 | 0 | 1536 | SignalService | +| __gap | uint256[48] | 253 | 0 | 1536 | SignalService | ## TaikoToken - -| Name | Type | Slot | Offset | Bytes | Contract | -| ----------------------------------------------------- | ------------------------------------------------------------- | ---- | ------ | ----- | ---------- | -| \_initialized | uint8 | 0 | 0 | 1 | TaikoToken | -| \_initializing | bool | 0 | 1 | 1 | TaikoToken | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | TaikoToken | -| \_owner | address | 51 | 0 | 20 | TaikoToken | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | TaikoToken | -| \_pendingOwner | address | 101 | 0 | 20 | TaikoToken | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | TaikoToken | -| addressManager | address | 151 | 0 | 20 | TaikoToken | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | TaikoToken | -| \_\_reentry | uint8 | 201 | 0 | 1 | TaikoToken | -| \_\_paused | uint8 | 201 | 1 | 1 | TaikoToken | -| lastUnpausedAt | uint64 | 201 | 2 | 8 | TaikoToken | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | TaikoToken | -| \_\_slots_previously_used_by_ERC20SnapshotUpgradeable | uint256[50] | 251 | 0 | 1600 | TaikoToken | -| \_balances | mapping(address => uint256) | 301 | 0 | 32 | TaikoToken | -| \_allowances | mapping(address => mapping(address => uint256)) | 302 | 0 | 32 | TaikoToken | -| \_totalSupply | uint256 | 303 | 0 | 32 | TaikoToken | -| \_name | string | 304 | 0 | 32 | TaikoToken | -| \_symbol | string | 305 | 0 | 32 | TaikoToken | -| \_\_gap | uint256[45] | 306 | 0 | 1440 | TaikoToken | -| \_hashedName | bytes32 | 351 | 0 | 32 | TaikoToken | -| \_hashedVersion | bytes32 | 352 | 0 | 32 | TaikoToken | -| \_name | string | 353 | 0 | 32 | TaikoToken | -| \_version | string | 354 | 0 | 32 | TaikoToken | -| \_\_gap | uint256[48] | 355 | 0 | 1536 | TaikoToken | -| \_nonces | mapping(address => struct CountersUpgradeable.Counter) | 403 | 0 | 32 | TaikoToken | -| \_PERMIT_TYPEHASH_DEPRECATED_SLOT | bytes32 | 404 | 0 | 32 | TaikoToken | -| \_\_gap | uint256[49] | 405 | 0 | 1568 | TaikoToken | -| \_delegates | mapping(address => address) | 454 | 0 | 32 | TaikoToken | -| \_checkpoints | mapping(address => struct ERC20VotesUpgradeable.Checkpoint[]) | 455 | 0 | 32 | TaikoToken | -| \_totalSupplyCheckpoints | struct ERC20VotesUpgradeable.Checkpoint[] | 456 | 0 | 32 | TaikoToken | -| \_\_gap | uint256[47] | 457 | 0 | 1504 | TaikoToken | -| \_\_gap | uint256[50] | 504 | 0 | 1600 | TaikoToken | +| Name | Type | Slot | Offset | Bytes | Contract | +|-----------------------------------------------------|---------------------------------------------------------------|------|--------|-------|-----------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | TaikoToken | +| _initializing | bool | 0 | 1 | 1 | TaikoToken | +| __gap | uint256[50] | 1 | 0 | 1600 | TaikoToken | +| _owner | address | 51 | 0 | 20 | TaikoToken | +| __gap | uint256[49] | 52 | 0 | 1568 | TaikoToken | +| _pendingOwner | address | 101 | 0 | 20 | TaikoToken | +| __gap | uint256[49] | 102 | 0 | 1568 | TaikoToken | +| addressManager | address | 151 | 0 | 20 | TaikoToken | +| __gap | uint256[49] | 152 | 0 | 1568 | TaikoToken | +| __reentry | uint8 | 201 | 0 | 1 | TaikoToken | +| __paused | uint8 | 201 | 1 | 1 | TaikoToken | +| lastUnpausedAt | uint64 | 201 | 2 | 8 | TaikoToken | +| __gap | uint256[49] | 202 | 0 | 1568 | TaikoToken | +| __slots_previously_used_by_ERC20SnapshotUpgradeable | uint256[50] | 251 | 0 | 1600 | TaikoToken | +| _balances | mapping(address => uint256) | 301 | 0 | 32 | TaikoToken | +| _allowances | mapping(address => mapping(address => uint256)) | 302 | 0 | 32 | TaikoToken | +| _totalSupply | uint256 | 303 | 0 | 32 | TaikoToken | +| _name | string | 304 | 0 | 32 | TaikoToken | +| _symbol | string | 305 | 0 | 32 | TaikoToken | +| __gap | uint256[45] | 306 | 0 | 1440 | TaikoToken | +| _hashedName | bytes32 | 351 | 0 | 32 | TaikoToken | +| _hashedVersion | bytes32 | 352 | 0 | 32 | TaikoToken | +| _name | string | 353 | 0 | 32 | TaikoToken | +| _version | string | 354 | 0 | 32 | TaikoToken | +| __gap | uint256[48] | 355 | 0 | 1536 | TaikoToken | +| _nonces | mapping(address => struct CountersUpgradeable.Counter) | 403 | 0 | 32 | TaikoToken | +| _PERMIT_TYPEHASH_DEPRECATED_SLOT | bytes32 | 404 | 0 | 32 | TaikoToken | +| __gap | uint256[49] | 405 | 0 | 1568 | TaikoToken | +| _delegates | mapping(address => address) | 454 | 0 | 32 | TaikoToken | +| _checkpoints | mapping(address => struct ERC20VotesUpgradeable.Checkpoint[]) | 455 | 0 | 32 | TaikoToken | +| _totalSupplyCheckpoints | struct ERC20VotesUpgradeable.Checkpoint[] | 456 | 0 | 32 | TaikoToken | +| __gap | uint256[47] | 457 | 0 | 1504 | TaikoToken | +| __gap | uint256[50] | 504 | 0 | 1600 | TaikoToken | ## ComposeVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------- | ---- | ------ | ----- | --------------- | -| \_initialized | uint8 | 0 | 0 | 1 | ComposeVerifier | -| \_initializing | bool | 0 | 1 | 1 | ComposeVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ComposeVerifier | -| \_owner | address | 51 | 0 | 20 | ComposeVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ComposeVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | ComposeVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ComposeVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|-----------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ComposeVerifier | +| _initializing | bool | 0 | 1 | 1 | ComposeVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | ComposeVerifier | +| _owner | address | 51 | 0 | 20 | ComposeVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | ComposeVerifier | +| _pendingOwner | address | 101 | 0 | 20 | ComposeVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | ComposeVerifier | | addressManager | address | 151 | 0 | 20 | ComposeVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ComposeVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | ComposeVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | ComposeVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | ComposeVerifier | +| __reentry | uint8 | 201 | 0 | 1 | ComposeVerifier | +| __paused | uint8 | 201 | 1 | 1 | ComposeVerifier | | lastUnpausedAt | uint64 | 201 | 2 | 8 | ComposeVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ComposeVerifier | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ComposeVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | ComposeVerifier | +| __gap | uint256[50] | 251 | 0 | 1600 | ComposeVerifier | ## TeeAnyVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------- | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | TeeAnyVerifier | -| \_initializing | bool | 0 | 1 | 1 | TeeAnyVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | TeeAnyVerifier | -| \_owner | address | 51 | 0 | 20 | TeeAnyVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | TeeAnyVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | TeeAnyVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | TeeAnyVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|---------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | TeeAnyVerifier | +| _initializing | bool | 0 | 1 | 1 | TeeAnyVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | TeeAnyVerifier | +| _owner | address | 51 | 0 | 20 | TeeAnyVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | TeeAnyVerifier | +| _pendingOwner | address | 101 | 0 | 20 | TeeAnyVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | TeeAnyVerifier | | addressManager | address | 151 | 0 | 20 | TeeAnyVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | TeeAnyVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | TeeAnyVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | TeeAnyVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | TeeAnyVerifier | +| __reentry | uint8 | 201 | 0 | 1 | TeeAnyVerifier | +| __paused | uint8 | 201 | 1 | 1 | TeeAnyVerifier | | lastUnpausedAt | uint64 | 201 | 2 | 8 | TeeAnyVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | TeeAnyVerifier | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | TeeAnyVerifier | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | TeeAnyVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | TeeAnyVerifier | +| __gap | uint256[50] | 251 | 0 | 1600 | TeeAnyVerifier | +| __gap | uint256[50] | 301 | 0 | 1600 | TeeAnyVerifier | ## ZkAndTeeVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------- | ---- | ------ | ----- | ---------------- | -| \_initialized | uint8 | 0 | 0 | 1 | ZkAndTeeVerifier | -| \_initializing | bool | 0 | 1 | 1 | ZkAndTeeVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ZkAndTeeVerifier | -| \_owner | address | 51 | 0 | 20 | ZkAndTeeVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ZkAndTeeVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | ZkAndTeeVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ZkAndTeeVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|-------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ZkAndTeeVerifier | +| _initializing | bool | 0 | 1 | 1 | ZkAndTeeVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | ZkAndTeeVerifier | +| _owner | address | 51 | 0 | 20 | ZkAndTeeVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | ZkAndTeeVerifier | +| _pendingOwner | address | 101 | 0 | 20 | ZkAndTeeVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | ZkAndTeeVerifier | | addressManager | address | 151 | 0 | 20 | ZkAndTeeVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ZkAndTeeVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | ZkAndTeeVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | ZkAndTeeVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | ZkAndTeeVerifier | +| __reentry | uint8 | 201 | 0 | 1 | ZkAndTeeVerifier | +| __paused | uint8 | 201 | 1 | 1 | ZkAndTeeVerifier | | lastUnpausedAt | uint64 | 201 | 2 | 8 | ZkAndTeeVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ZkAndTeeVerifier | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ZkAndTeeVerifier | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | ZkAndTeeVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | ZkAndTeeVerifier | +| __gap | uint256[50] | 251 | 0 | 1600 | ZkAndTeeVerifier | +| __gap | uint256[50] | 301 | 0 | 1600 | ZkAndTeeVerifier | ## ZkAnyVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------- | ---- | ------ | ----- | ------------- | -| \_initialized | uint8 | 0 | 0 | 1 | ZkAnyVerifier | -| \_initializing | bool | 0 | 1 | 1 | ZkAnyVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ZkAnyVerifier | -| \_owner | address | 51 | 0 | 20 | ZkAnyVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ZkAnyVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | ZkAnyVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ZkAnyVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|-------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ZkAnyVerifier | +| _initializing | bool | 0 | 1 | 1 | ZkAnyVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | ZkAnyVerifier | +| _owner | address | 51 | 0 | 20 | ZkAnyVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | ZkAnyVerifier | +| _pendingOwner | address | 101 | 0 | 20 | ZkAnyVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | ZkAnyVerifier | | addressManager | address | 151 | 0 | 20 | ZkAnyVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ZkAnyVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | ZkAnyVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | ZkAnyVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | ZkAnyVerifier | +| __reentry | uint8 | 201 | 0 | 1 | ZkAnyVerifier | +| __paused | uint8 | 201 | 1 | 1 | ZkAnyVerifier | | lastUnpausedAt | uint64 | 201 | 2 | 8 | ZkAnyVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ZkAnyVerifier | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ZkAnyVerifier | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | ZkAnyVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | ZkAnyVerifier | +| __gap | uint256[50] | 251 | 0 | 1600 | ZkAnyVerifier | +| __gap | uint256[50] | 301 | 0 | 1600 | ZkAnyVerifier | ## Risc0Verifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ------------------------ | ---- | ------ | ----- | ------------- | -| \_initialized | uint8 | 0 | 0 | 1 | Risc0Verifier | -| \_initializing | bool | 0 | 1 | 1 | Risc0Verifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | Risc0Verifier | -| \_owner | address | 51 | 0 | 20 | Risc0Verifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | Risc0Verifier | -| \_pendingOwner | address | 101 | 0 | 20 | Risc0Verifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | Risc0Verifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|--------------------------|------|--------|-------|-----------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | Risc0Verifier | +| _initializing | bool | 0 | 1 | 1 | Risc0Verifier | +| __gap | uint256[50] | 1 | 0 | 1600 | Risc0Verifier | +| _owner | address | 51 | 0 | 20 | Risc0Verifier | +| __gap | uint256[49] | 52 | 0 | 1568 | Risc0Verifier | +| _pendingOwner | address | 101 | 0 | 20 | Risc0Verifier | +| __gap | uint256[49] | 102 | 0 | 1568 | Risc0Verifier | | addressManager | address | 151 | 0 | 20 | Risc0Verifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | Risc0Verifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | Risc0Verifier | -| \_\_paused | uint8 | 201 | 1 | 1 | Risc0Verifier | +| __gap | uint256[49] | 152 | 0 | 1568 | Risc0Verifier | +| __reentry | uint8 | 201 | 0 | 1 | Risc0Verifier | +| __paused | uint8 | 201 | 1 | 1 | Risc0Verifier | | lastUnpausedAt | uint64 | 201 | 2 | 8 | Risc0Verifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | Risc0Verifier | +| __gap | uint256[49] | 202 | 0 | 1568 | Risc0Verifier | | isImageTrusted | mapping(bytes32 => bool) | 251 | 0 | 32 | Risc0Verifier | -| \_\_gap | uint256[49] | 252 | 0 | 1568 | Risc0Verifier | +| __gap | uint256[49] | 252 | 0 | 1568 | Risc0Verifier | ## SP1Verifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| ---------------- | ------------------------ | ---- | ------ | ----- | ----------- | -| \_initialized | uint8 | 0 | 0 | 1 | SP1Verifier | -| \_initializing | bool | 0 | 1 | 1 | SP1Verifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | SP1Verifier | -| \_owner | address | 51 | 0 | 20 | SP1Verifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | SP1Verifier | -| \_pendingOwner | address | 101 | 0 | 20 | SP1Verifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | SP1Verifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|--------------------------|------|--------|-------|-------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | SP1Verifier | +| _initializing | bool | 0 | 1 | 1 | SP1Verifier | +| __gap | uint256[50] | 1 | 0 | 1600 | SP1Verifier | +| _owner | address | 51 | 0 | 20 | SP1Verifier | +| __gap | uint256[49] | 52 | 0 | 1568 | SP1Verifier | +| _pendingOwner | address | 101 | 0 | 20 | SP1Verifier | +| __gap | uint256[49] | 102 | 0 | 1568 | SP1Verifier | | addressManager | address | 151 | 0 | 20 | SP1Verifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | SP1Verifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | SP1Verifier | -| \_\_paused | uint8 | 201 | 1 | 1 | SP1Verifier | +| __gap | uint256[49] | 152 | 0 | 1568 | SP1Verifier | +| __reentry | uint8 | 201 | 0 | 1 | SP1Verifier | +| __paused | uint8 | 201 | 1 | 1 | SP1Verifier | | lastUnpausedAt | uint64 | 201 | 2 | 8 | SP1Verifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | SP1Verifier | +| __gap | uint256[49] | 202 | 0 | 1568 | SP1Verifier | | isProgramTrusted | mapping(bytes32 => bool) | 251 | 0 | 32 | SP1Verifier | -| \_\_gap | uint256[49] | 252 | 0 | 1568 | SP1Verifier | +| __gap | uint256[49] | 252 | 0 | 1568 | SP1Verifier | ## SgxVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| ----------------- | ----------------------------------------------- | ---- | ------ | ----- | ----------- | -| \_initialized | uint8 | 0 | 0 | 1 | SgxVerifier | -| \_initializing | bool | 0 | 1 | 1 | SgxVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | SgxVerifier | -| \_owner | address | 51 | 0 | 20 | SgxVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | SgxVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | SgxVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | SgxVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|-------------------|-------------------------------------------------|------|--------|-------|-------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | SgxVerifier | +| _initializing | bool | 0 | 1 | 1 | SgxVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | SgxVerifier | +| _owner | address | 51 | 0 | 20 | SgxVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | SgxVerifier | +| _pendingOwner | address | 101 | 0 | 20 | SgxVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | SgxVerifier | | addressManager | address | 151 | 0 | 20 | SgxVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | SgxVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | SgxVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | SgxVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | SgxVerifier | +| __reentry | uint8 | 201 | 0 | 1 | SgxVerifier | +| __paused | uint8 | 201 | 1 | 1 | SgxVerifier | | lastUnpausedAt | uint64 | 201 | 2 | 8 | SgxVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | SgxVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | SgxVerifier | | nextInstanceId | uint256 | 251 | 0 | 32 | SgxVerifier | | instances | mapping(uint256 => struct SgxVerifier.Instance) | 252 | 0 | 32 | SgxVerifier | | addressRegistered | mapping(address => bool) | 253 | 0 | 32 | SgxVerifier | -| \_\_gap | uint256[47] | 254 | 0 | 1504 | SgxVerifier | +| __gap | uint256[47] | 254 | 0 | 1504 | SgxVerifier | ## AutomataDcapV3Attestation - -| Name | Type | Slot | Offset | Bytes | Contract | -| ----------------------- | ----------------------------------------------- | ---- | ------ | ----- | ------------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | AutomataDcapV3Attestation | -| \_initializing | bool | 0 | 1 | 1 | AutomataDcapV3Attestation | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | AutomataDcapV3Attestation | -| \_owner | address | 51 | 0 | 20 | AutomataDcapV3Attestation | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | AutomataDcapV3Attestation | -| \_pendingOwner | address | 101 | 0 | 20 | AutomataDcapV3Attestation | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | AutomataDcapV3Attestation | +| Name | Type | Slot | Offset | Bytes | Contract | +|-------------------------|-------------------------------------------------|------|--------|-------|----------------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | AutomataDcapV3Attestation | +| _initializing | bool | 0 | 1 | 1 | AutomataDcapV3Attestation | +| __gap | uint256[50] | 1 | 0 | 1600 | AutomataDcapV3Attestation | +| _owner | address | 51 | 0 | 20 | AutomataDcapV3Attestation | +| __gap | uint256[49] | 52 | 0 | 1568 | AutomataDcapV3Attestation | +| _pendingOwner | address | 101 | 0 | 20 | AutomataDcapV3Attestation | +| __gap | uint256[49] | 102 | 0 | 1568 | AutomataDcapV3Attestation | | addressManager | address | 151 | 0 | 20 | AutomataDcapV3Attestation | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | AutomataDcapV3Attestation | -| \_\_reentry | uint8 | 201 | 0 | 1 | AutomataDcapV3Attestation | -| \_\_paused | uint8 | 201 | 1 | 1 | AutomataDcapV3Attestation | +| __gap | uint256[49] | 152 | 0 | 1568 | AutomataDcapV3Attestation | +| __reentry | uint8 | 201 | 0 | 1 | AutomataDcapV3Attestation | +| __paused | uint8 | 201 | 1 | 1 | AutomataDcapV3Attestation | | lastUnpausedAt | uint64 | 201 | 2 | 8 | AutomataDcapV3Attestation | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | AutomataDcapV3Attestation | +| __gap | uint256[49] | 202 | 0 | 1568 | AutomataDcapV3Attestation | | sigVerifyLib | contract ISigVerifyLib | 251 | 0 | 20 | AutomataDcapV3Attestation | | pemCertLib | contract IPEMCertChainLib | 252 | 0 | 20 | AutomataDcapV3Attestation | | checkLocalEnclaveReport | bool | 252 | 20 | 1 | AutomataDcapV3Attestation | @@ -512,350 +490,330 @@ | serialNumIsRevoked | mapping(uint256 => mapping(bytes => bool)) | 255 | 0 | 32 | AutomataDcapV3Attestation | | tcbInfo | mapping(string => struct TCBInfoStruct.TCBInfo) | 256 | 0 | 32 | AutomataDcapV3Attestation | | qeIdentity | struct EnclaveIdStruct.EnclaveId | 257 | 0 | 128 | AutomataDcapV3Attestation | -| \_\_gap | uint256[39] | 261 | 0 | 1248 | AutomataDcapV3Attestation | +| __gap | uint256[39] | 261 | 0 | 1248 | AutomataDcapV3Attestation | ## TaikoL1 - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ---------------------- | ---- | ------ | ----- | -------- | -| \_initialized | uint8 | 0 | 0 | 1 | TaikoL1 | -| \_initializing | bool | 0 | 1 | 1 | TaikoL1 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | TaikoL1 | -| \_owner | address | 51 | 0 | 20 | TaikoL1 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | TaikoL1 | -| \_pendingOwner | address | 101 | 0 | 20 | TaikoL1 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | TaikoL1 | -| addressManager | address | 151 | 0 | 20 | TaikoL1 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | TaikoL1 | -| \_\_reentry | uint8 | 201 | 0 | 1 | TaikoL1 | -| \_\_paused | uint8 | 201 | 1 | 1 | TaikoL1 | -| lastUnpausedAt | uint64 | 201 | 2 | 8 | TaikoL1 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | TaikoL1 | -| state | struct TaikoData.State | 251 | 0 | 1600 | TaikoL1 | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | TaikoL1 | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|------------------------|------|--------|-------|----------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | TaikoL1 | +| _initializing | bool | 0 | 1 | 1 | TaikoL1 | +| __gap | uint256[50] | 1 | 0 | 1600 | TaikoL1 | +| _owner | address | 51 | 0 | 20 | TaikoL1 | +| __gap | uint256[49] | 52 | 0 | 1568 | TaikoL1 | +| _pendingOwner | address | 101 | 0 | 20 | TaikoL1 | +| __gap | uint256[49] | 102 | 0 | 1568 | TaikoL1 | +| addressManager | address | 151 | 0 | 20 | TaikoL1 | +| __gap | uint256[49] | 152 | 0 | 1568 | TaikoL1 | +| __reentry | uint8 | 201 | 0 | 1 | TaikoL1 | +| __paused | uint8 | 201 | 1 | 1 | TaikoL1 | +| lastUnpausedAt | uint64 | 201 | 2 | 8 | TaikoL1 | +| __gap | uint256[49] | 202 | 0 | 1568 | TaikoL1 | +| state | struct TaikoData.State | 251 | 0 | 1600 | TaikoL1 | +| __gap | uint256[50] | 301 | 0 | 1600 | TaikoL1 | ## TierProviderV2 - | Name | Type | Slot | Offset | Bytes | Contract | -| ---- | ---- | ---- | ------ | ----- | -------- | +|------|------|------|--------|-------|----------| ## HeklaTaikoL1 - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ---------------------- | ---- | ------ | ----- | ------------ | -| \_initialized | uint8 | 0 | 0 | 1 | HeklaTaikoL1 | -| \_initializing | bool | 0 | 1 | 1 | HeklaTaikoL1 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | HeklaTaikoL1 | -| \_owner | address | 51 | 0 | 20 | HeklaTaikoL1 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | HeklaTaikoL1 | -| \_pendingOwner | address | 101 | 0 | 20 | HeklaTaikoL1 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | HeklaTaikoL1 | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|------------------------|------|--------|-------|-----------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | HeklaTaikoL1 | +| _initializing | bool | 0 | 1 | 1 | HeklaTaikoL1 | +| __gap | uint256[50] | 1 | 0 | 1600 | HeklaTaikoL1 | +| _owner | address | 51 | 0 | 20 | HeklaTaikoL1 | +| __gap | uint256[49] | 52 | 0 | 1568 | HeklaTaikoL1 | +| _pendingOwner | address | 101 | 0 | 20 | HeklaTaikoL1 | +| __gap | uint256[49] | 102 | 0 | 1568 | HeklaTaikoL1 | | addressManager | address | 151 | 0 | 20 | HeklaTaikoL1 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | HeklaTaikoL1 | -| \_\_reentry | uint8 | 201 | 0 | 1 | HeklaTaikoL1 | -| \_\_paused | uint8 | 201 | 1 | 1 | HeklaTaikoL1 | +| __gap | uint256[49] | 152 | 0 | 1568 | HeklaTaikoL1 | +| __reentry | uint8 | 201 | 0 | 1 | HeklaTaikoL1 | +| __paused | uint8 | 201 | 1 | 1 | HeklaTaikoL1 | | lastUnpausedAt | uint64 | 201 | 2 | 8 | HeklaTaikoL1 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | HeklaTaikoL1 | +| __gap | uint256[49] | 202 | 0 | 1568 | HeklaTaikoL1 | | state | struct TaikoData.State | 251 | 0 | 1600 | HeklaTaikoL1 | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | HeklaTaikoL1 | +| __gap | uint256[50] | 301 | 0 | 1600 | HeklaTaikoL1 | ## HeklaTierProvider - | Name | Type | Slot | Offset | Bytes | Contract | -| ---- | ---- | ---- | ------ | ----- | -------- | +|------|------|------|--------|-------|----------| ## MainnetBridge - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | --------------------------------------- | ---- | ------ | ----- | ------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetBridge | -| \_initializing | bool | 0 | 1 | 1 | MainnetBridge | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetBridge | -| \_owner | address | 51 | 0 | 20 | MainnetBridge | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetBridge | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetBridge | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetBridge | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-----------------------------------------|------|--------|-------|----------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetBridge | +| _initializing | bool | 0 | 1 | 1 | MainnetBridge | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetBridge | +| _owner | address | 51 | 0 | 20 | MainnetBridge | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetBridge | +| _pendingOwner | address | 101 | 0 | 20 | MainnetBridge | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetBridge | | addressManager | address | 151 | 0 | 20 | MainnetBridge | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetBridge | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetBridge | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetBridge | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetBridge | +| __reentry | uint8 | 201 | 0 | 1 | MainnetBridge | +| __paused | uint8 | 201 | 1 | 1 | MainnetBridge | | lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetBridge | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetBridge | -| \_\_reserved1 | uint64 | 251 | 0 | 8 | MainnetBridge | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetBridge | +| __reserved1 | uint64 | 251 | 0 | 8 | MainnetBridge | | nextMessageId | uint64 | 251 | 8 | 8 | MainnetBridge | | messageStatus | mapping(bytes32 => enum IBridge.Status) | 252 | 0 | 32 | MainnetBridge | -| \_\_ctx | struct IBridge.Context | 253 | 0 | 64 | MainnetBridge | -| \_\_reserved2 | uint256 | 255 | 0 | 32 | MainnetBridge | -| \_\_reserved3 | uint256 | 256 | 0 | 32 | MainnetBridge | -| \_\_gap | uint256[44] | 257 | 0 | 1408 | MainnetBridge | +| __ctx | struct IBridge.Context | 253 | 0 | 64 | MainnetBridge | +| __reserved2 | uint256 | 255 | 0 | 32 | MainnetBridge | +| __reserved3 | uint256 | 256 | 0 | 32 | MainnetBridge | +| __gap | uint256[44] | 257 | 0 | 1408 | MainnetBridge | ## MainnetSignalService - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | --------------------------------------------- | ---- | ------ | ----- | -------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetSignalService | -| \_initializing | bool | 0 | 1 | 1 | MainnetSignalService | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetSignalService | -| \_owner | address | 51 | 0 | 20 | MainnetSignalService | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetSignalService | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetSignalService | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetSignalService | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-----------------------------------------------|------|--------|-------|------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetSignalService | +| _initializing | bool | 0 | 1 | 1 | MainnetSignalService | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetSignalService | +| _owner | address | 51 | 0 | 20 | MainnetSignalService | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetSignalService | +| _pendingOwner | address | 101 | 0 | 20 | MainnetSignalService | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetSignalService | | addressManager | address | 151 | 0 | 20 | MainnetSignalService | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetSignalService | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetSignalService | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetSignalService | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetSignalService | +| __reentry | uint8 | 201 | 0 | 1 | MainnetSignalService | +| __paused | uint8 | 201 | 1 | 1 | MainnetSignalService | | lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetSignalService | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetSignalService | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetSignalService | | topBlockId | mapping(uint64 => mapping(bytes32 => uint64)) | 251 | 0 | 32 | MainnetSignalService | | isAuthorized | mapping(address => bool) | 252 | 0 | 32 | MainnetSignalService | -| \_\_gap | uint256[48] | 253 | 0 | 1536 | MainnetSignalService | +| __gap | uint256[48] | 253 | 0 | 1536 | MainnetSignalService | ## MainnetERC20Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ----------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetERC20Vault | -| \_initializing | bool | 0 | 1 | 1 | MainnetERC20Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetERC20Vault | -| \_owner | address | 51 | 0 | 20 | MainnetERC20Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetERC20Vault | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetERC20Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetERC20Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetERC20Vault | +| _initializing | bool | 0 | 1 | 1 | MainnetERC20Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetERC20Vault | +| _owner | address | 51 | 0 | 20 | MainnetERC20Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetERC20Vault | +| _pendingOwner | address | 101 | 0 | 20 | MainnetERC20Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetERC20Vault | | addressManager | address | 151 | 0 | 20 | MainnetERC20Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetERC20Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetERC20Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetERC20Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetERC20Vault | +| __reentry | uint8 | 201 | 0 | 1 | MainnetERC20Vault | +| __paused | uint8 | 201 | 1 | 1 | MainnetERC20Vault | | lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetERC20Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetERC20Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | MainnetERC20Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetERC20Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | MainnetERC20Vault | | bridgedToCanonical | mapping(address => struct ERC20Vault.CanonicalERC20) | 301 | 0 | 32 | MainnetERC20Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | MainnetERC20Vault | | btokenDenylist | mapping(address => bool) | 303 | 0 | 32 | MainnetERC20Vault | | lastMigrationStart | mapping(uint256 => mapping(address => uint256)) | 304 | 0 | 32 | MainnetERC20Vault | -| \_\_gap | uint256[46] | 305 | 0 | 1472 | MainnetERC20Vault | +| __gap | uint256[46] | 305 | 0 | 1472 | MainnetERC20Vault | ## MainnetERC1155Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetERC1155Vault | -| \_initializing | bool | 0 | 1 | 1 | MainnetERC1155Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetERC1155Vault | -| \_owner | address | 51 | 0 | 20 | MainnetERC1155Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetERC1155Vault | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetERC1155Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetERC1155Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|----------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetERC1155Vault | +| _initializing | bool | 0 | 1 | 1 | MainnetERC1155Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetERC1155Vault | +| _owner | address | 51 | 0 | 20 | MainnetERC1155Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetERC1155Vault | +| _pendingOwner | address | 101 | 0 | 20 | MainnetERC1155Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetERC1155Vault | | addressManager | address | 151 | 0 | 20 | MainnetERC1155Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetERC1155Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetERC1155Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetERC1155Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetERC1155Vault | +| __reentry | uint8 | 201 | 0 | 1 | MainnetERC1155Vault | +| __paused | uint8 | 201 | 1 | 1 | MainnetERC1155Vault | | lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetERC1155Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetERC1155Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | MainnetERC1155Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetERC1155Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | MainnetERC1155Vault | | bridgedToCanonical | mapping(address => struct BaseNFTVault.CanonicalNFT) | 301 | 0 | 32 | MainnetERC1155Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | MainnetERC1155Vault | -| \_\_gap | uint256[48] | 303 | 0 | 1536 | MainnetERC1155Vault | -| \_\_gap | uint256[50] | 351 | 0 | 1600 | MainnetERC1155Vault | -| \_\_gap | uint256[50] | 401 | 0 | 1600 | MainnetERC1155Vault | -| \_\_gap | uint256[50] | 451 | 0 | 1600 | MainnetERC1155Vault | +| __gap | uint256[48] | 303 | 0 | 1536 | MainnetERC1155Vault | +| __gap | uint256[50] | 351 | 0 | 1600 | MainnetERC1155Vault | +| __gap | uint256[50] | 401 | 0 | 1600 | MainnetERC1155Vault | +| __gap | uint256[50] | 451 | 0 | 1600 | MainnetERC1155Vault | ## MainnetERC721Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ------------------ | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetERC721Vault | -| \_initializing | bool | 0 | 1 | 1 | MainnetERC721Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetERC721Vault | -| \_owner | address | 51 | 0 | 20 | MainnetERC721Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetERC721Vault | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetERC721Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetERC721Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|--------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetERC721Vault | +| _initializing | bool | 0 | 1 | 1 | MainnetERC721Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetERC721Vault | +| _owner | address | 51 | 0 | 20 | MainnetERC721Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetERC721Vault | +| _pendingOwner | address | 101 | 0 | 20 | MainnetERC721Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetERC721Vault | | addressManager | address | 151 | 0 | 20 | MainnetERC721Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetERC721Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetERC721Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetERC721Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetERC721Vault | +| __reentry | uint8 | 201 | 0 | 1 | MainnetERC721Vault | +| __paused | uint8 | 201 | 1 | 1 | MainnetERC721Vault | | lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetERC721Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetERC721Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | MainnetERC721Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetERC721Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | MainnetERC721Vault | | bridgedToCanonical | mapping(address => struct BaseNFTVault.CanonicalNFT) | 301 | 0 | 32 | MainnetERC721Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | MainnetERC721Vault | -| \_\_gap | uint256[48] | 303 | 0 | 1536 | MainnetERC721Vault | -| \_\_gap | uint256[50] | 351 | 0 | 1600 | MainnetERC721Vault | +| __gap | uint256[48] | 303 | 0 | 1536 | MainnetERC721Vault | +| __gap | uint256[50] | 351 | 0 | 1600 | MainnetERC721Vault | ## MainnetSharedAddressManager - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------------------------------------------- | ---- | ------ | ----- | --------------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetSharedAddressManager | -| \_initializing | bool | 0 | 1 | 1 | MainnetSharedAddressManager | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetSharedAddressManager | -| \_owner | address | 51 | 0 | 20 | MainnetSharedAddressManager | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetSharedAddressManager | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetSharedAddressManager | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetSharedAddressManager | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------------------------------------------|------|--------|-------|--------------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetSharedAddressManager | +| _initializing | bool | 0 | 1 | 1 | MainnetSharedAddressManager | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetSharedAddressManager | +| _owner | address | 51 | 0 | 20 | MainnetSharedAddressManager | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetSharedAddressManager | +| _pendingOwner | address | 101 | 0 | 20 | MainnetSharedAddressManager | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetSharedAddressManager | | addressManager | address | 151 | 0 | 20 | MainnetSharedAddressManager | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetSharedAddressManager | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetSharedAddressManager | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetSharedAddressManager | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetSharedAddressManager | +| __reentry | uint8 | 201 | 0 | 1 | MainnetSharedAddressManager | +| __paused | uint8 | 201 | 1 | 1 | MainnetSharedAddressManager | | lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetSharedAddressManager | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetSharedAddressManager | -| \_\_addresses | mapping(uint256 => mapping(bytes32 => address)) | 251 | 0 | 32 | MainnetSharedAddressManager | -| \_\_gap | uint256[49] | 252 | 0 | 1568 | MainnetSharedAddressManager | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetSharedAddressManager | +| __addresses | mapping(uint256 => mapping(bytes32 => address)) | 251 | 0 | 32 | MainnetSharedAddressManager | +| __gap | uint256[49] | 252 | 0 | 1568 | MainnetSharedAddressManager | ## RollupAddressCache - | Name | Type | Slot | Offset | Bytes | Contract | -| ---- | ---- | ---- | ------ | ----- | -------- | +|------|------|------|--------|-------|----------| ## SharedAddressCache - | Name | Type | Slot | Offset | Bytes | Contract | -| ---- | ---- | ---- | ------ | ----- | -------- | +|------|------|------|--------|-------|----------| ## AddressCache - | Name | Type | Slot | Offset | Bytes | Contract | -| ---- | ---- | ---- | ------ | ----- | -------- | +|------|------|------|--------|-------|----------| ## MainnetSgxVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| ----------------- | ----------------------------------------------- | ---- | ------ | ----- | ------------------ | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetSgxVerifier | -| \_initializing | bool | 0 | 1 | 1 | MainnetSgxVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetSgxVerifier | -| \_owner | address | 51 | 0 | 20 | MainnetSgxVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetSgxVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetSgxVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetSgxVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|-------------------|-------------------------------------------------|------|--------|-------|------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetSgxVerifier | +| _initializing | bool | 0 | 1 | 1 | MainnetSgxVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetSgxVerifier | +| _owner | address | 51 | 0 | 20 | MainnetSgxVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetSgxVerifier | +| _pendingOwner | address | 101 | 0 | 20 | MainnetSgxVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetSgxVerifier | | addressManager | address | 151 | 0 | 20 | MainnetSgxVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetSgxVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetSgxVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetSgxVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetSgxVerifier | +| __reentry | uint8 | 201 | 0 | 1 | MainnetSgxVerifier | +| __paused | uint8 | 201 | 1 | 1 | MainnetSgxVerifier | | lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetSgxVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetSgxVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetSgxVerifier | | nextInstanceId | uint256 | 251 | 0 | 32 | MainnetSgxVerifier | | instances | mapping(uint256 => struct SgxVerifier.Instance) | 252 | 0 | 32 | MainnetSgxVerifier | | addressRegistered | mapping(address => bool) | 253 | 0 | 32 | MainnetSgxVerifier | -| \_\_gap | uint256[47] | 254 | 0 | 1504 | MainnetSgxVerifier | +| __gap | uint256[47] | 254 | 0 | 1504 | MainnetSgxVerifier | ## MainnetSP1Verifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| ---------------- | ------------------------ | ---- | ------ | ----- | ------------------ | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetSP1Verifier | -| \_initializing | bool | 0 | 1 | 1 | MainnetSP1Verifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetSP1Verifier | -| \_owner | address | 51 | 0 | 20 | MainnetSP1Verifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetSP1Verifier | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetSP1Verifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetSP1Verifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|--------------------------|------|--------|-------|------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetSP1Verifier | +| _initializing | bool | 0 | 1 | 1 | MainnetSP1Verifier | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetSP1Verifier | +| _owner | address | 51 | 0 | 20 | MainnetSP1Verifier | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetSP1Verifier | +| _pendingOwner | address | 101 | 0 | 20 | MainnetSP1Verifier | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetSP1Verifier | | addressManager | address | 151 | 0 | 20 | MainnetSP1Verifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetSP1Verifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetSP1Verifier | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetSP1Verifier | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetSP1Verifier | +| __reentry | uint8 | 201 | 0 | 1 | MainnetSP1Verifier | +| __paused | uint8 | 201 | 1 | 1 | MainnetSP1Verifier | | lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetSP1Verifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetSP1Verifier | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetSP1Verifier | | isProgramTrusted | mapping(bytes32 => bool) | 251 | 0 | 32 | MainnetSP1Verifier | -| \_\_gap | uint256[49] | 252 | 0 | 1568 | MainnetSP1Verifier | +| __gap | uint256[49] | 252 | 0 | 1568 | MainnetSP1Verifier | ## MainnetZkAnyVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------- | ---- | ------ | ----- | -------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetZkAnyVerifier | -| \_initializing | bool | 0 | 1 | 1 | MainnetZkAnyVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetZkAnyVerifier | -| \_owner | address | 51 | 0 | 20 | MainnetZkAnyVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetZkAnyVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetZkAnyVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetZkAnyVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|----------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetZkAnyVerifier | +| _initializing | bool | 0 | 1 | 1 | MainnetZkAnyVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetZkAnyVerifier | +| _owner | address | 51 | 0 | 20 | MainnetZkAnyVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetZkAnyVerifier | +| _pendingOwner | address | 101 | 0 | 20 | MainnetZkAnyVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetZkAnyVerifier | | addressManager | address | 151 | 0 | 20 | MainnetZkAnyVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetZkAnyVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetZkAnyVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetZkAnyVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetZkAnyVerifier | +| __reentry | uint8 | 201 | 0 | 1 | MainnetZkAnyVerifier | +| __paused | uint8 | 201 | 1 | 1 | MainnetZkAnyVerifier | | lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetZkAnyVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetZkAnyVerifier | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | MainnetZkAnyVerifier | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | MainnetZkAnyVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetZkAnyVerifier | +| __gap | uint256[50] | 251 | 0 | 1600 | MainnetZkAnyVerifier | +| __gap | uint256[50] | 301 | 0 | 1600 | MainnetZkAnyVerifier | ## MainnetRisc0Verifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ------------------------ | ---- | ------ | ----- | -------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetRisc0Verifier | -| \_initializing | bool | 0 | 1 | 1 | MainnetRisc0Verifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetRisc0Verifier | -| \_owner | address | 51 | 0 | 20 | MainnetRisc0Verifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetRisc0Verifier | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetRisc0Verifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetRisc0Verifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|--------------------------|------|--------|-------|----------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetRisc0Verifier | +| _initializing | bool | 0 | 1 | 1 | MainnetRisc0Verifier | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetRisc0Verifier | +| _owner | address | 51 | 0 | 20 | MainnetRisc0Verifier | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetRisc0Verifier | +| _pendingOwner | address | 101 | 0 | 20 | MainnetRisc0Verifier | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetRisc0Verifier | | addressManager | address | 151 | 0 | 20 | MainnetRisc0Verifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetRisc0Verifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetRisc0Verifier | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetRisc0Verifier | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetRisc0Verifier | +| __reentry | uint8 | 201 | 0 | 1 | MainnetRisc0Verifier | +| __paused | uint8 | 201 | 1 | 1 | MainnetRisc0Verifier | | lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetRisc0Verifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetRisc0Verifier | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetRisc0Verifier | | isImageTrusted | mapping(bytes32 => bool) | 251 | 0 | 32 | MainnetRisc0Verifier | -| \_\_gap | uint256[49] | 252 | 0 | 1568 | MainnetRisc0Verifier | +| __gap | uint256[49] | 252 | 0 | 1568 | MainnetRisc0Verifier | ## MainnetZkAndTeeVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------- | ---- | ------ | ----- | ----------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetZkAndTeeVerifier | -| \_initializing | bool | 0 | 1 | 1 | MainnetZkAndTeeVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetZkAndTeeVerifier | -| \_owner | address | 51 | 0 | 20 | MainnetZkAndTeeVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetZkAndTeeVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetZkAndTeeVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetZkAndTeeVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|----------------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetZkAndTeeVerifier | +| _initializing | bool | 0 | 1 | 1 | MainnetZkAndTeeVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetZkAndTeeVerifier | +| _owner | address | 51 | 0 | 20 | MainnetZkAndTeeVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetZkAndTeeVerifier | +| _pendingOwner | address | 101 | 0 | 20 | MainnetZkAndTeeVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetZkAndTeeVerifier | | addressManager | address | 151 | 0 | 20 | MainnetZkAndTeeVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetZkAndTeeVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetZkAndTeeVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetZkAndTeeVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetZkAndTeeVerifier | +| __reentry | uint8 | 201 | 0 | 1 | MainnetZkAndTeeVerifier | +| __paused | uint8 | 201 | 1 | 1 | MainnetZkAndTeeVerifier | | lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetZkAndTeeVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetZkAndTeeVerifier | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | MainnetZkAndTeeVerifier | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | MainnetZkAndTeeVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetZkAndTeeVerifier | +| __gap | uint256[50] | 251 | 0 | 1600 | MainnetZkAndTeeVerifier | +| __gap | uint256[50] | 301 | 0 | 1600 | MainnetZkAndTeeVerifier | ## MainnetTeeAnyVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------- | ---- | ------ | ----- | --------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetTeeAnyVerifier | -| \_initializing | bool | 0 | 1 | 1 | MainnetTeeAnyVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetTeeAnyVerifier | -| \_owner | address | 51 | 0 | 20 | MainnetTeeAnyVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetTeeAnyVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetTeeAnyVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetTeeAnyVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|------------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetTeeAnyVerifier | +| _initializing | bool | 0 | 1 | 1 | MainnetTeeAnyVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetTeeAnyVerifier | +| _owner | address | 51 | 0 | 20 | MainnetTeeAnyVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetTeeAnyVerifier | +| _pendingOwner | address | 101 | 0 | 20 | MainnetTeeAnyVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetTeeAnyVerifier | | addressManager | address | 151 | 0 | 20 | MainnetTeeAnyVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetTeeAnyVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetTeeAnyVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetTeeAnyVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetTeeAnyVerifier | +| __reentry | uint8 | 201 | 0 | 1 | MainnetTeeAnyVerifier | +| __paused | uint8 | 201 | 1 | 1 | MainnetTeeAnyVerifier | | lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetTeeAnyVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetTeeAnyVerifier | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | MainnetTeeAnyVerifier | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | MainnetTeeAnyVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetTeeAnyVerifier | +| __gap | uint256[50] | 251 | 0 | 1600 | MainnetTeeAnyVerifier | +| __gap | uint256[50] | 301 | 0 | 1600 | MainnetTeeAnyVerifier | ## MainnetGuardianProver - -| Name | Type | Slot | Offset | Bytes | Contract | -| ----------------------- | ----------------------------------------------- | ---- | ------ | ----- | --------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetGuardianProver | -| \_initializing | bool | 0 | 1 | 1 | MainnetGuardianProver | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetGuardianProver | -| \_owner | address | 51 | 0 | 20 | MainnetGuardianProver | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetGuardianProver | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetGuardianProver | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetGuardianProver | +| Name | Type | Slot | Offset | Bytes | Contract | +|-------------------------|-------------------------------------------------|------|--------|-------|--------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetGuardianProver | +| _initializing | bool | 0 | 1 | 1 | MainnetGuardianProver | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetGuardianProver | +| _owner | address | 51 | 0 | 20 | MainnetGuardianProver | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetGuardianProver | +| _pendingOwner | address | 101 | 0 | 20 | MainnetGuardianProver | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetGuardianProver | | addressManager | address | 151 | 0 | 20 | MainnetGuardianProver | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetGuardianProver | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetGuardianProver | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetGuardianProver | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetGuardianProver | +| __reentry | uint8 | 201 | 0 | 1 | MainnetGuardianProver | +| __paused | uint8 | 201 | 1 | 1 | MainnetGuardianProver | | lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetGuardianProver | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetGuardianProver | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetGuardianProver | | guardianIds | mapping(address => uint256) | 251 | 0 | 32 | MainnetGuardianProver | | approvals | mapping(uint256 => mapping(bytes32 => uint256)) | 252 | 0 | 32 | MainnetGuardianProver | | guardians | address[] | 253 | 0 | 32 | MainnetGuardianProver | @@ -863,135 +821,128 @@ | minGuardians | uint32 | 254 | 4 | 4 | MainnetGuardianProver | | provingAutoPauseEnabled | bool | 254 | 8 | 1 | MainnetGuardianProver | | latestProofHash | mapping(uint256 => mapping(uint256 => bytes32)) | 255 | 0 | 32 | MainnetGuardianProver | -| \_\_gap | uint256[45] | 256 | 0 | 1440 | MainnetGuardianProver | +| __gap | uint256[45] | 256 | 0 | 1440 | MainnetGuardianProver | ## MainnetTaikoL1 - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ---------------------- | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetTaikoL1 | -| \_initializing | bool | 0 | 1 | 1 | MainnetTaikoL1 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetTaikoL1 | -| \_owner | address | 51 | 0 | 20 | MainnetTaikoL1 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetTaikoL1 | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetTaikoL1 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetTaikoL1 | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|------------------------|------|--------|-------|------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetTaikoL1 | +| _initializing | bool | 0 | 1 | 1 | MainnetTaikoL1 | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetTaikoL1 | +| _owner | address | 51 | 0 | 20 | MainnetTaikoL1 | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetTaikoL1 | +| _pendingOwner | address | 101 | 0 | 20 | MainnetTaikoL1 | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetTaikoL1 | | addressManager | address | 151 | 0 | 20 | MainnetTaikoL1 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetTaikoL1 | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetTaikoL1 | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetTaikoL1 | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetTaikoL1 | +| __reentry | uint8 | 201 | 0 | 1 | MainnetTaikoL1 | +| __paused | uint8 | 201 | 1 | 1 | MainnetTaikoL1 | | lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetTaikoL1 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetTaikoL1 | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetTaikoL1 | | state | struct TaikoData.State | 251 | 0 | 1600 | MainnetTaikoL1 | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | MainnetTaikoL1 | +| __gap | uint256[50] | 301 | 0 | 1600 | MainnetTaikoL1 | ## MainnetRollupAddressManager - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------------------------------------------- | ---- | ------ | ----- | --------------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetRollupAddressManager | -| \_initializing | bool | 0 | 1 | 1 | MainnetRollupAddressManager | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetRollupAddressManager | -| \_owner | address | 51 | 0 | 20 | MainnetRollupAddressManager | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetRollupAddressManager | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetRollupAddressManager | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetRollupAddressManager | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------------------------------------------|------|--------|-------|--------------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetRollupAddressManager | +| _initializing | bool | 0 | 1 | 1 | MainnetRollupAddressManager | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetRollupAddressManager | +| _owner | address | 51 | 0 | 20 | MainnetRollupAddressManager | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetRollupAddressManager | +| _pendingOwner | address | 101 | 0 | 20 | MainnetRollupAddressManager | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetRollupAddressManager | | addressManager | address | 151 | 0 | 20 | MainnetRollupAddressManager | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetRollupAddressManager | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetRollupAddressManager | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetRollupAddressManager | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetRollupAddressManager | +| __reentry | uint8 | 201 | 0 | 1 | MainnetRollupAddressManager | +| __paused | uint8 | 201 | 1 | 1 | MainnetRollupAddressManager | | lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetRollupAddressManager | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetRollupAddressManager | -| \_\_addresses | mapping(uint256 => mapping(bytes32 => address)) | 251 | 0 | 32 | MainnetRollupAddressManager | -| \_\_gap | uint256[49] | 252 | 0 | 1568 | MainnetRollupAddressManager | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetRollupAddressManager | +| __addresses | mapping(uint256 => mapping(bytes32 => address)) | 251 | 0 | 32 | MainnetRollupAddressManager | +| __gap | uint256[49] | 252 | 0 | 1568 | MainnetRollupAddressManager | ## MainnetTierRouter - | Name | Type | Slot | Offset | Bytes | Contract | -| ---- | ---- | ---- | ------ | ----- | -------- | +|------|------|------|--------|-------|----------| ## MainnetProverSet - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ------------------------ | ---- | ------ | ----- | ---------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetProverSet | -| \_initializing | bool | 0 | 1 | 1 | MainnetProverSet | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetProverSet | -| \_owner | address | 51 | 0 | 20 | MainnetProverSet | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetProverSet | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetProverSet | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetProverSet | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|--------------------------|------|--------|-------|----------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetProverSet | +| _initializing | bool | 0 | 1 | 1 | MainnetProverSet | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetProverSet | +| _owner | address | 51 | 0 | 20 | MainnetProverSet | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetProverSet | +| _pendingOwner | address | 101 | 0 | 20 | MainnetProverSet | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetProverSet | | addressManager | address | 151 | 0 | 20 | MainnetProverSet | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetProverSet | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetProverSet | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetProverSet | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetProverSet | +| __reentry | uint8 | 201 | 0 | 1 | MainnetProverSet | +| __paused | uint8 | 201 | 1 | 1 | MainnetProverSet | | lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetProverSet | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetProverSet | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetProverSet | | isProver | mapping(address => bool) | 251 | 0 | 32 | MainnetProverSet | | admin | address | 252 | 0 | 20 | MainnetProverSet | -| \_\_gap | uint256[48] | 253 | 0 | 1536 | MainnetProverSet | +| __gap | uint256[48] | 253 | 0 | 1536 | MainnetProverSet | ## TokenUnlock - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ------------------------ | ---- | ------ | ----- | ----------- | -| \_initialized | uint8 | 0 | 0 | 1 | TokenUnlock | -| \_initializing | bool | 0 | 1 | 1 | TokenUnlock | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | TokenUnlock | -| \_owner | address | 51 | 0 | 20 | TokenUnlock | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | TokenUnlock | -| \_pendingOwner | address | 101 | 0 | 20 | TokenUnlock | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | TokenUnlock | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|--------------------------|------|--------|-------|--------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | TokenUnlock | +| _initializing | bool | 0 | 1 | 1 | TokenUnlock | +| __gap | uint256[50] | 1 | 0 | 1600 | TokenUnlock | +| _owner | address | 51 | 0 | 20 | TokenUnlock | +| __gap | uint256[49] | 52 | 0 | 1568 | TokenUnlock | +| _pendingOwner | address | 101 | 0 | 20 | TokenUnlock | +| __gap | uint256[49] | 102 | 0 | 1568 | TokenUnlock | | addressManager | address | 151 | 0 | 20 | TokenUnlock | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | TokenUnlock | -| \_\_reentry | uint8 | 201 | 0 | 1 | TokenUnlock | -| \_\_paused | uint8 | 201 | 1 | 1 | TokenUnlock | +| __gap | uint256[49] | 152 | 0 | 1568 | TokenUnlock | +| __reentry | uint8 | 201 | 0 | 1 | TokenUnlock | +| __paused | uint8 | 201 | 1 | 1 | TokenUnlock | | lastUnpausedAt | uint64 | 201 | 2 | 8 | TokenUnlock | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | TokenUnlock | +| __gap | uint256[49] | 202 | 0 | 1568 | TokenUnlock | | amountVested | uint256 | 251 | 0 | 32 | TokenUnlock | | recipient | address | 252 | 0 | 20 | TokenUnlock | | tgeTimestamp | uint64 | 252 | 20 | 8 | TokenUnlock | | isProverSet | mapping(address => bool) | 253 | 0 | 32 | TokenUnlock | -| \_\_gap | uint256[47] | 254 | 0 | 1504 | TokenUnlock | +| __gap | uint256[47] | 254 | 0 | 1504 | TokenUnlock | ## ProverSet - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ------------------------ | ---- | ------ | ----- | --------- | -| \_initialized | uint8 | 0 | 0 | 1 | ProverSet | -| \_initializing | bool | 0 | 1 | 1 | ProverSet | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ProverSet | -| \_owner | address | 51 | 0 | 20 | ProverSet | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ProverSet | -| \_pendingOwner | address | 101 | 0 | 20 | ProverSet | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ProverSet | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|--------------------------|------|--------|-------|------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ProverSet | +| _initializing | bool | 0 | 1 | 1 | ProverSet | +| __gap | uint256[50] | 1 | 0 | 1600 | ProverSet | +| _owner | address | 51 | 0 | 20 | ProverSet | +| __gap | uint256[49] | 52 | 0 | 1568 | ProverSet | +| _pendingOwner | address | 101 | 0 | 20 | ProverSet | +| __gap | uint256[49] | 102 | 0 | 1568 | ProverSet | | addressManager | address | 151 | 0 | 20 | ProverSet | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ProverSet | -| \_\_reentry | uint8 | 201 | 0 | 1 | ProverSet | -| \_\_paused | uint8 | 201 | 1 | 1 | ProverSet | +| __gap | uint256[49] | 152 | 0 | 1568 | ProverSet | +| __reentry | uint8 | 201 | 0 | 1 | ProverSet | +| __paused | uint8 | 201 | 1 | 1 | ProverSet | | lastUnpausedAt | uint64 | 201 | 2 | 8 | ProverSet | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ProverSet | +| __gap | uint256[49] | 202 | 0 | 1568 | ProverSet | | isProver | mapping(address => bool) | 251 | 0 | 32 | ProverSet | | admin | address | 252 | 0 | 20 | ProverSet | -| \_\_gap | uint256[48] | 253 | 0 | 1536 | ProverSet | +| __gap | uint256[48] | 253 | 0 | 1536 | ProverSet | ## GuardianProver - -| Name | Type | Slot | Offset | Bytes | Contract | -| ----------------------- | ----------------------------------------------- | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | GuardianProver | -| \_initializing | bool | 0 | 1 | 1 | GuardianProver | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | GuardianProver | -| \_owner | address | 51 | 0 | 20 | GuardianProver | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | GuardianProver | -| \_pendingOwner | address | 101 | 0 | 20 | GuardianProver | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | GuardianProver | +| Name | Type | Slot | Offset | Bytes | Contract | +|-------------------------|-------------------------------------------------|------|--------|-------|--------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | GuardianProver | +| _initializing | bool | 0 | 1 | 1 | GuardianProver | +| __gap | uint256[50] | 1 | 0 | 1600 | GuardianProver | +| _owner | address | 51 | 0 | 20 | GuardianProver | +| __gap | uint256[49] | 52 | 0 | 1568 | GuardianProver | +| _pendingOwner | address | 101 | 0 | 20 | GuardianProver | +| __gap | uint256[49] | 102 | 0 | 1568 | GuardianProver | | addressManager | address | 151 | 0 | 20 | GuardianProver | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | GuardianProver | -| \_\_reentry | uint8 | 201 | 0 | 1 | GuardianProver | -| \_\_paused | uint8 | 201 | 1 | 1 | GuardianProver | +| __gap | uint256[49] | 152 | 0 | 1568 | GuardianProver | +| __reentry | uint8 | 201 | 0 | 1 | GuardianProver | +| __paused | uint8 | 201 | 1 | 1 | GuardianProver | | lastUnpausedAt | uint64 | 201 | 2 | 8 | GuardianProver | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | GuardianProver | +| __gap | uint256[49] | 202 | 0 | 1568 | GuardianProver | | guardianIds | mapping(address => uint256) | 251 | 0 | 32 | GuardianProver | | approvals | mapping(uint256 => mapping(bytes32 => uint256)) | 252 | 0 | 32 | GuardianProver | | guardians | address[] | 253 | 0 | 32 | GuardianProver | @@ -999,4 +950,5 @@ | minGuardians | uint32 | 254 | 4 | 4 | GuardianProver | | provingAutoPauseEnabled | bool | 254 | 8 | 1 | GuardianProver | | latestProofHash | mapping(uint256 => mapping(uint256 => bytes32)) | 255 | 0 | 32 | GuardianProver | -| \_\_gap | uint256[45] | 256 | 0 | 1440 | GuardianProver | +| __gap | uint256[45] | 256 | 0 | 1440 | GuardianProver | + diff --git a/packages/protocol/contract_layout_layer2.md b/packages/protocol/contract_layout_layer2.md index ef57af6bcee..c412e161389 100644 --- a/packages/protocol/contract_layout_layer2.md +++ b/packages/protocol/contract_layout_layer2.md @@ -1,448 +1,431 @@ ## ERC1155Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ------------ | -| \_initialized | uint8 | 0 | 0 | 1 | ERC1155Vault | -| \_initializing | bool | 0 | 1 | 1 | ERC1155Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ERC1155Vault | -| \_owner | address | 51 | 0 | 20 | ERC1155Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ERC1155Vault | -| \_pendingOwner | address | 101 | 0 | 20 | ERC1155Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ERC1155Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|----------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ERC1155Vault | +| _initializing | bool | 0 | 1 | 1 | ERC1155Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | ERC1155Vault | +| _owner | address | 51 | 0 | 20 | ERC1155Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | ERC1155Vault | +| _pendingOwner | address | 101 | 0 | 20 | ERC1155Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | ERC1155Vault | | addressManager | address | 151 | 0 | 20 | ERC1155Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ERC1155Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | ERC1155Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | ERC1155Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | ERC1155Vault | +| __reentry | uint8 | 201 | 0 | 1 | ERC1155Vault | +| __paused | uint8 | 201 | 1 | 1 | ERC1155Vault | | lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC1155Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ERC1155Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ERC1155Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | ERC1155Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | ERC1155Vault | | bridgedToCanonical | mapping(address => struct BaseNFTVault.CanonicalNFT) | 301 | 0 | 32 | ERC1155Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | ERC1155Vault | -| \_\_gap | uint256[48] | 303 | 0 | 1536 | ERC1155Vault | -| \_\_gap | uint256[50] | 351 | 0 | 1600 | ERC1155Vault | -| \_\_gap | uint256[50] | 401 | 0 | 1600 | ERC1155Vault | -| \_\_gap | uint256[50] | 451 | 0 | 1600 | ERC1155Vault | +| __gap | uint256[48] | 303 | 0 | 1536 | ERC1155Vault | +| __gap | uint256[50] | 351 | 0 | 1600 | ERC1155Vault | +| __gap | uint256[50] | 401 | 0 | 1600 | ERC1155Vault | +| __gap | uint256[50] | 451 | 0 | 1600 | ERC1155Vault | ## ERC20Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ---------- | -| \_initialized | uint8 | 0 | 0 | 1 | ERC20Vault | -| \_initializing | bool | 0 | 1 | 1 | ERC20Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ERC20Vault | -| \_owner | address | 51 | 0 | 20 | ERC20Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ERC20Vault | -| \_pendingOwner | address | 101 | 0 | 20 | ERC20Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ERC20Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ERC20Vault | +| _initializing | bool | 0 | 1 | 1 | ERC20Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | ERC20Vault | +| _owner | address | 51 | 0 | 20 | ERC20Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | ERC20Vault | +| _pendingOwner | address | 101 | 0 | 20 | ERC20Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | ERC20Vault | | addressManager | address | 151 | 0 | 20 | ERC20Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ERC20Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | ERC20Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | ERC20Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | ERC20Vault | +| __reentry | uint8 | 201 | 0 | 1 | ERC20Vault | +| __paused | uint8 | 201 | 1 | 1 | ERC20Vault | | lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC20Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ERC20Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ERC20Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | ERC20Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | ERC20Vault | | bridgedToCanonical | mapping(address => struct ERC20Vault.CanonicalERC20) | 301 | 0 | 32 | ERC20Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | ERC20Vault | | btokenDenylist | mapping(address => bool) | 303 | 0 | 32 | ERC20Vault | | lastMigrationStart | mapping(uint256 => mapping(address => uint256)) | 304 | 0 | 32 | ERC20Vault | -| \_\_gap | uint256[46] | 305 | 0 | 1472 | ERC20Vault | +| __gap | uint256[46] | 305 | 0 | 1472 | ERC20Vault | ## ERC721Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ----------- | -| \_initialized | uint8 | 0 | 0 | 1 | ERC721Vault | -| \_initializing | bool | 0 | 1 | 1 | ERC721Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ERC721Vault | -| \_owner | address | 51 | 0 | 20 | ERC721Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ERC721Vault | -| \_pendingOwner | address | 101 | 0 | 20 | ERC721Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ERC721Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|--------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ERC721Vault | +| _initializing | bool | 0 | 1 | 1 | ERC721Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | ERC721Vault | +| _owner | address | 51 | 0 | 20 | ERC721Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | ERC721Vault | +| _pendingOwner | address | 101 | 0 | 20 | ERC721Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | ERC721Vault | | addressManager | address | 151 | 0 | 20 | ERC721Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ERC721Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | ERC721Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | ERC721Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | ERC721Vault | +| __reentry | uint8 | 201 | 0 | 1 | ERC721Vault | +| __paused | uint8 | 201 | 1 | 1 | ERC721Vault | | lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC721Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ERC721Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ERC721Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | ERC721Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | ERC721Vault | | bridgedToCanonical | mapping(address => struct BaseNFTVault.CanonicalNFT) | 301 | 0 | 32 | ERC721Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | ERC721Vault | -| \_\_gap | uint256[48] | 303 | 0 | 1536 | ERC721Vault | -| \_\_gap | uint256[50] | 351 | 0 | 1600 | ERC721Vault | +| __gap | uint256[48] | 303 | 0 | 1536 | ERC721Vault | +| __gap | uint256[50] | 351 | 0 | 1600 | ERC721Vault | ## BridgedERC20 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ---------------- | ----------------------------------------------- | ---- | ------ | ----- | ------------ | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedERC20 | -| \_initializing | bool | 0 | 1 | 1 | BridgedERC20 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20 | -| \_owner | address | 51 | 0 | 20 | BridgedERC20 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedERC20 | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedERC20 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedERC20 | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------------------------------------------|------|--------|-------|----------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedERC20 | +| _initializing | bool | 0 | 1 | 1 | BridgedERC20 | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20 | +| _owner | address | 51 | 0 | 20 | BridgedERC20 | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedERC20 | +| _pendingOwner | address | 101 | 0 | 20 | BridgedERC20 | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedERC20 | | addressManager | address | 151 | 0 | 20 | BridgedERC20 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedERC20 | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedERC20 | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedERC20 | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedERC20 | +| __reentry | uint8 | 201 | 0 | 1 | BridgedERC20 | +| __paused | uint8 | 201 | 1 | 1 | BridgedERC20 | | lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC20 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedERC20 | -| \_balances | mapping(address => uint256) | 251 | 0 | 32 | BridgedERC20 | -| \_allowances | mapping(address => mapping(address => uint256)) | 252 | 0 | 32 | BridgedERC20 | -| \_totalSupply | uint256 | 253 | 0 | 32 | BridgedERC20 | -| \_name | string | 254 | 0 | 32 | BridgedERC20 | -| \_symbol | string | 255 | 0 | 32 | BridgedERC20 | -| \_\_gap | uint256[45] | 256 | 0 | 1440 | BridgedERC20 | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedERC20 | +| _balances | mapping(address => uint256) | 251 | 0 | 32 | BridgedERC20 | +| _allowances | mapping(address => mapping(address => uint256)) | 252 | 0 | 32 | BridgedERC20 | +| _totalSupply | uint256 | 253 | 0 | 32 | BridgedERC20 | +| _name | string | 254 | 0 | 32 | BridgedERC20 | +| _symbol | string | 255 | 0 | 32 | BridgedERC20 | +| __gap | uint256[45] | 256 | 0 | 1440 | BridgedERC20 | | srcToken | address | 301 | 0 | 20 | BridgedERC20 | -| \_\_srcDecimals | uint8 | 301 | 20 | 1 | BridgedERC20 | +| __srcDecimals | uint8 | 301 | 20 | 1 | BridgedERC20 | | srcChainId | uint256 | 302 | 0 | 32 | BridgedERC20 | | migratingAddress | address | 303 | 0 | 20 | BridgedERC20 | | migratingInbound | bool | 303 | 20 | 1 | BridgedERC20 | -| \_\_gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20 | +| __gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20 | ## BridgedERC20V2 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ---------------- | ------------------------------------------------------ | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedERC20V2 | -| \_initializing | bool | 0 | 1 | 1 | BridgedERC20V2 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20V2 | -| \_owner | address | 51 | 0 | 20 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedERC20V2 | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedERC20V2 | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|--------------------------------------------------------|------|--------|-------|--------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedERC20V2 | +| _initializing | bool | 0 | 1 | 1 | BridgedERC20V2 | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20V2 | +| _owner | address | 51 | 0 | 20 | BridgedERC20V2 | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedERC20V2 | +| _pendingOwner | address | 101 | 0 | 20 | BridgedERC20V2 | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedERC20V2 | | addressManager | address | 151 | 0 | 20 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedERC20V2 | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedERC20V2 | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedERC20V2 | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedERC20V2 | +| __reentry | uint8 | 201 | 0 | 1 | BridgedERC20V2 | +| __paused | uint8 | 201 | 1 | 1 | BridgedERC20V2 | | lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedERC20V2 | -| \_balances | mapping(address => uint256) | 251 | 0 | 32 | BridgedERC20V2 | -| \_allowances | mapping(address => mapping(address => uint256)) | 252 | 0 | 32 | BridgedERC20V2 | -| \_totalSupply | uint256 | 253 | 0 | 32 | BridgedERC20V2 | -| \_name | string | 254 | 0 | 32 | BridgedERC20V2 | -| \_symbol | string | 255 | 0 | 32 | BridgedERC20V2 | -| \_\_gap | uint256[45] | 256 | 0 | 1440 | BridgedERC20V2 | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedERC20V2 | +| _balances | mapping(address => uint256) | 251 | 0 | 32 | BridgedERC20V2 | +| _allowances | mapping(address => mapping(address => uint256)) | 252 | 0 | 32 | BridgedERC20V2 | +| _totalSupply | uint256 | 253 | 0 | 32 | BridgedERC20V2 | +| _name | string | 254 | 0 | 32 | BridgedERC20V2 | +| _symbol | string | 255 | 0 | 32 | BridgedERC20V2 | +| __gap | uint256[45] | 256 | 0 | 1440 | BridgedERC20V2 | | srcToken | address | 301 | 0 | 20 | BridgedERC20V2 | -| \_\_srcDecimals | uint8 | 301 | 20 | 1 | BridgedERC20V2 | +| __srcDecimals | uint8 | 301 | 20 | 1 | BridgedERC20V2 | | srcChainId | uint256 | 302 | 0 | 32 | BridgedERC20V2 | | migratingAddress | address | 303 | 0 | 20 | BridgedERC20V2 | | migratingInbound | bool | 303 | 20 | 1 | BridgedERC20V2 | -| \_\_gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20V2 | -| \_hashedName | bytes32 | 351 | 0 | 32 | BridgedERC20V2 | -| \_hashedVersion | bytes32 | 352 | 0 | 32 | BridgedERC20V2 | -| \_name | string | 353 | 0 | 32 | BridgedERC20V2 | -| \_version | string | 354 | 0 | 32 | BridgedERC20V2 | -| \_\_gap | uint256[48] | 355 | 0 | 1536 | BridgedERC20V2 | -| \_nonces | mapping(address => struct CountersUpgradeable.Counter) | 403 | 0 | 32 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 404 | 0 | 1568 | BridgedERC20V2 | +| __gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20V2 | +| _hashedName | bytes32 | 351 | 0 | 32 | BridgedERC20V2 | +| _hashedVersion | bytes32 | 352 | 0 | 32 | BridgedERC20V2 | +| _name | string | 353 | 0 | 32 | BridgedERC20V2 | +| _version | string | 354 | 0 | 32 | BridgedERC20V2 | +| __gap | uint256[48] | 355 | 0 | 1536 | BridgedERC20V2 | +| _nonces | mapping(address => struct CountersUpgradeable.Counter) | 403 | 0 | 32 | BridgedERC20V2 | +| __gap | uint256[49] | 404 | 0 | 1568 | BridgedERC20V2 | ## BridgedERC721 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------- | -------------------------------------------- | ---- | ------ | ----- | ------------- | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedERC721 | -| \_initializing | bool | 0 | 1 | 1 | BridgedERC721 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedERC721 | -| \_owner | address | 51 | 0 | 20 | BridgedERC721 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedERC721 | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedERC721 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedERC721 | -| addressManager | address | 151 | 0 | 20 | BridgedERC721 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedERC721 | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedERC721 | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedERC721 | -| lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC721 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedERC721 | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | BridgedERC721 | -| \_name | string | 301 | 0 | 32 | BridgedERC721 | -| \_symbol | string | 302 | 0 | 32 | BridgedERC721 | -| \_owners | mapping(uint256 => address) | 303 | 0 | 32 | BridgedERC721 | -| \_balances | mapping(address => uint256) | 304 | 0 | 32 | BridgedERC721 | -| \_tokenApprovals | mapping(uint256 => address) | 305 | 0 | 32 | BridgedERC721 | -| \_operatorApprovals | mapping(address => mapping(address => bool)) | 306 | 0 | 32 | BridgedERC721 | -| \_\_gap | uint256[44] | 307 | 0 | 1408 | BridgedERC721 | -| srcToken | address | 351 | 0 | 20 | BridgedERC721 | -| srcChainId | uint256 | 352 | 0 | 32 | BridgedERC721 | -| \_\_gap | uint256[48] | 353 | 0 | 1536 | BridgedERC721 | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|----------------------------------------------|------|--------|-------|------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedERC721 | +| _initializing | bool | 0 | 1 | 1 | BridgedERC721 | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC721 | +| _owner | address | 51 | 0 | 20 | BridgedERC721 | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedERC721 | +| _pendingOwner | address | 101 | 0 | 20 | BridgedERC721 | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedERC721 | +| addressManager | address | 151 | 0 | 20 | BridgedERC721 | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedERC721 | +| __reentry | uint8 | 201 | 0 | 1 | BridgedERC721 | +| __paused | uint8 | 201 | 1 | 1 | BridgedERC721 | +| lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC721 | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedERC721 | +| __gap | uint256[50] | 251 | 0 | 1600 | BridgedERC721 | +| _name | string | 301 | 0 | 32 | BridgedERC721 | +| _symbol | string | 302 | 0 | 32 | BridgedERC721 | +| _owners | mapping(uint256 => address) | 303 | 0 | 32 | BridgedERC721 | +| _balances | mapping(address => uint256) | 304 | 0 | 32 | BridgedERC721 | +| _tokenApprovals | mapping(uint256 => address) | 305 | 0 | 32 | BridgedERC721 | +| _operatorApprovals | mapping(address => mapping(address => bool)) | 306 | 0 | 32 | BridgedERC721 | +| __gap | uint256[44] | 307 | 0 | 1408 | BridgedERC721 | +| srcToken | address | 351 | 0 | 20 | BridgedERC721 | +| srcChainId | uint256 | 352 | 0 | 32 | BridgedERC721 | +| __gap | uint256[48] | 353 | 0 | 1536 | BridgedERC721 | ## BridgedERC1155 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------- | ----------------------------------------------- | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedERC1155 | -| \_initializing | bool | 0 | 1 | 1 | BridgedERC1155 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedERC1155 | -| \_owner | address | 51 | 0 | 20 | BridgedERC1155 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedERC1155 | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedERC1155 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedERC1155 | -| addressManager | address | 151 | 0 | 20 | BridgedERC1155 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedERC1155 | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedERC1155 | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedERC1155 | -| lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC1155 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedERC1155 | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | BridgedERC1155 | -| \_balances | mapping(uint256 => mapping(address => uint256)) | 301 | 0 | 32 | BridgedERC1155 | -| \_operatorApprovals | mapping(address => mapping(address => bool)) | 302 | 0 | 32 | BridgedERC1155 | -| \_uri | string | 303 | 0 | 32 | BridgedERC1155 | -| \_\_gap | uint256[47] | 304 | 0 | 1504 | BridgedERC1155 | -| srcToken | address | 351 | 0 | 20 | BridgedERC1155 | -| srcChainId | uint256 | 352 | 0 | 32 | BridgedERC1155 | -| symbol | string | 353 | 0 | 32 | BridgedERC1155 | -| name | string | 354 | 0 | 32 | BridgedERC1155 | -| \_\_gap | uint256[46] | 355 | 0 | 1472 | BridgedERC1155 | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|-------------------------------------------------|------|--------|-------|--------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedERC1155 | +| _initializing | bool | 0 | 1 | 1 | BridgedERC1155 | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC1155 | +| _owner | address | 51 | 0 | 20 | BridgedERC1155 | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedERC1155 | +| _pendingOwner | address | 101 | 0 | 20 | BridgedERC1155 | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedERC1155 | +| addressManager | address | 151 | 0 | 20 | BridgedERC1155 | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedERC1155 | +| __reentry | uint8 | 201 | 0 | 1 | BridgedERC1155 | +| __paused | uint8 | 201 | 1 | 1 | BridgedERC1155 | +| lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC1155 | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedERC1155 | +| __gap | uint256[50] | 251 | 0 | 1600 | BridgedERC1155 | +| _balances | mapping(uint256 => mapping(address => uint256)) | 301 | 0 | 32 | BridgedERC1155 | +| _operatorApprovals | mapping(address => mapping(address => bool)) | 302 | 0 | 32 | BridgedERC1155 | +| _uri | string | 303 | 0 | 32 | BridgedERC1155 | +| __gap | uint256[47] | 304 | 0 | 1504 | BridgedERC1155 | +| srcToken | address | 351 | 0 | 20 | BridgedERC1155 | +| srcChainId | uint256 | 352 | 0 | 32 | BridgedERC1155 | +| symbol | string | 353 | 0 | 32 | BridgedERC1155 | +| name | string | 354 | 0 | 32 | BridgedERC1155 | +| __gap | uint256[46] | 355 | 0 | 1472 | BridgedERC1155 | ## Bridge - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | --------------------------------------- | ---- | ------ | ----- | -------- | -| \_initialized | uint8 | 0 | 0 | 1 | Bridge | -| \_initializing | bool | 0 | 1 | 1 | Bridge | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | Bridge | -| \_owner | address | 51 | 0 | 20 | Bridge | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | Bridge | -| \_pendingOwner | address | 101 | 0 | 20 | Bridge | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | Bridge | -| addressManager | address | 151 | 0 | 20 | Bridge | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | Bridge | -| \_\_reentry | uint8 | 201 | 0 | 1 | Bridge | -| \_\_paused | uint8 | 201 | 1 | 1 | Bridge | -| lastUnpausedAt | uint64 | 201 | 2 | 8 | Bridge | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | Bridge | -| \_\_reserved1 | uint64 | 251 | 0 | 8 | Bridge | -| nextMessageId | uint64 | 251 | 8 | 8 | Bridge | -| messageStatus | mapping(bytes32 => enum IBridge.Status) | 252 | 0 | 32 | Bridge | -| \_\_ctx | struct IBridge.Context | 253 | 0 | 64 | Bridge | -| \_\_reserved2 | uint256 | 255 | 0 | 32 | Bridge | -| \_\_reserved3 | uint256 | 256 | 0 | 32 | Bridge | -| \_\_gap | uint256[44] | 257 | 0 | 1408 | Bridge | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-----------------------------------------|------|--------|-------|------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | Bridge | +| _initializing | bool | 0 | 1 | 1 | Bridge | +| __gap | uint256[50] | 1 | 0 | 1600 | Bridge | +| _owner | address | 51 | 0 | 20 | Bridge | +| __gap | uint256[49] | 52 | 0 | 1568 | Bridge | +| _pendingOwner | address | 101 | 0 | 20 | Bridge | +| __gap | uint256[49] | 102 | 0 | 1568 | Bridge | +| addressManager | address | 151 | 0 | 20 | Bridge | +| __gap | uint256[49] | 152 | 0 | 1568 | Bridge | +| __reentry | uint8 | 201 | 0 | 1 | Bridge | +| __paused | uint8 | 201 | 1 | 1 | Bridge | +| lastUnpausedAt | uint64 | 201 | 2 | 8 | Bridge | +| __gap | uint256[49] | 202 | 0 | 1568 | Bridge | +| __reserved1 | uint64 | 251 | 0 | 8 | Bridge | +| nextMessageId | uint64 | 251 | 8 | 8 | Bridge | +| messageStatus | mapping(bytes32 => enum IBridge.Status) | 252 | 0 | 32 | Bridge | +| __ctx | struct IBridge.Context | 253 | 0 | 64 | Bridge | +| __reserved2 | uint256 | 255 | 0 | 32 | Bridge | +| __reserved3 | uint256 | 256 | 0 | 32 | Bridge | +| __gap | uint256[44] | 257 | 0 | 1408 | Bridge | ## QuotaManager - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | --------------------------------------------- | ---- | ------ | ----- | ------------ | -| \_initialized | uint8 | 0 | 0 | 1 | QuotaManager | -| \_initializing | bool | 0 | 1 | 1 | QuotaManager | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | QuotaManager | -| \_owner | address | 51 | 0 | 20 | QuotaManager | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | QuotaManager | -| \_pendingOwner | address | 101 | 0 | 20 | QuotaManager | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | QuotaManager | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-----------------------------------------------|------|--------|-------|------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | QuotaManager | +| _initializing | bool | 0 | 1 | 1 | QuotaManager | +| __gap | uint256[50] | 1 | 0 | 1600 | QuotaManager | +| _owner | address | 51 | 0 | 20 | QuotaManager | +| __gap | uint256[49] | 52 | 0 | 1568 | QuotaManager | +| _pendingOwner | address | 101 | 0 | 20 | QuotaManager | +| __gap | uint256[49] | 102 | 0 | 1568 | QuotaManager | | addressManager | address | 151 | 0 | 20 | QuotaManager | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | QuotaManager | -| \_\_reentry | uint8 | 201 | 0 | 1 | QuotaManager | -| \_\_paused | uint8 | 201 | 1 | 1 | QuotaManager | +| __gap | uint256[49] | 152 | 0 | 1568 | QuotaManager | +| __reentry | uint8 | 201 | 0 | 1 | QuotaManager | +| __paused | uint8 | 201 | 1 | 1 | QuotaManager | | lastUnpausedAt | uint64 | 201 | 2 | 8 | QuotaManager | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | QuotaManager | +| __gap | uint256[49] | 202 | 0 | 1568 | QuotaManager | | tokenQuota | mapping(address => struct QuotaManager.Quota) | 251 | 0 | 32 | QuotaManager | | quotaPeriod | uint24 | 252 | 0 | 3 | QuotaManager | -| \_\_gap | uint256[48] | 253 | 0 | 1536 | QuotaManager | +| __gap | uint256[48] | 253 | 0 | 1536 | QuotaManager | ## AddressManager - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------------------------------------------- | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | AddressManager | -| \_initializing | bool | 0 | 1 | 1 | AddressManager | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | AddressManager | -| \_owner | address | 51 | 0 | 20 | AddressManager | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | AddressManager | -| \_pendingOwner | address | 101 | 0 | 20 | AddressManager | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | AddressManager | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------------------------------------------|------|--------|-------|----------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | AddressManager | +| _initializing | bool | 0 | 1 | 1 | AddressManager | +| __gap | uint256[50] | 1 | 0 | 1600 | AddressManager | +| _owner | address | 51 | 0 | 20 | AddressManager | +| __gap | uint256[49] | 52 | 0 | 1568 | AddressManager | +| _pendingOwner | address | 101 | 0 | 20 | AddressManager | +| __gap | uint256[49] | 102 | 0 | 1568 | AddressManager | | addressManager | address | 151 | 0 | 20 | AddressManager | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | AddressManager | -| \_\_reentry | uint8 | 201 | 0 | 1 | AddressManager | -| \_\_paused | uint8 | 201 | 1 | 1 | AddressManager | +| __gap | uint256[49] | 152 | 0 | 1568 | AddressManager | +| __reentry | uint8 | 201 | 0 | 1 | AddressManager | +| __paused | uint8 | 201 | 1 | 1 | AddressManager | | lastUnpausedAt | uint64 | 201 | 2 | 8 | AddressManager | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | AddressManager | -| \_\_addresses | mapping(uint256 => mapping(bytes32 => address)) | 251 | 0 | 32 | AddressManager | -| \_\_gap | uint256[49] | 252 | 0 | 1568 | AddressManager | +| __gap | uint256[49] | 202 | 0 | 1568 | AddressManager | +| __addresses | mapping(uint256 => mapping(bytes32 => address)) | 251 | 0 | 32 | AddressManager | +| __gap | uint256[49] | 252 | 0 | 1568 | AddressManager | ## AddressResolver - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------- | ---- | ------ | ----- | --------------- | -| \_initialized | uint8 | 0 | 0 | 1 | AddressResolver | -| \_initializing | bool | 0 | 1 | 1 | AddressResolver | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | AddressResolver | +| _initializing | bool | 0 | 1 | 1 | AddressResolver | | addressManager | address | 0 | 2 | 20 | AddressResolver | -| \_\_gap | uint256[49] | 1 | 0 | 1568 | AddressResolver | +| __gap | uint256[49] | 1 | 0 | 1568 | AddressResolver | ## EssentialContract - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------- | ---- | ------ | ----- | ----------------- | -| \_initialized | uint8 | 0 | 0 | 1 | EssentialContract | -| \_initializing | bool | 0 | 1 | 1 | EssentialContract | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | EssentialContract | -| \_owner | address | 51 | 0 | 20 | EssentialContract | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | EssentialContract | -| \_pendingOwner | address | 101 | 0 | 20 | EssentialContract | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | EssentialContract | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|----------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | EssentialContract | +| _initializing | bool | 0 | 1 | 1 | EssentialContract | +| __gap | uint256[50] | 1 | 0 | 1600 | EssentialContract | +| _owner | address | 51 | 0 | 20 | EssentialContract | +| __gap | uint256[49] | 52 | 0 | 1568 | EssentialContract | +| _pendingOwner | address | 101 | 0 | 20 | EssentialContract | +| __gap | uint256[49] | 102 | 0 | 1568 | EssentialContract | | addressManager | address | 151 | 0 | 20 | EssentialContract | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | EssentialContract | -| \_\_reentry | uint8 | 201 | 0 | 1 | EssentialContract | -| \_\_paused | uint8 | 201 | 1 | 1 | EssentialContract | +| __gap | uint256[49] | 152 | 0 | 1568 | EssentialContract | +| __reentry | uint8 | 201 | 0 | 1 | EssentialContract | +| __paused | uint8 | 201 | 1 | 1 | EssentialContract | | lastUnpausedAt | uint64 | 201 | 2 | 8 | EssentialContract | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | EssentialContract | +| __gap | uint256[49] | 202 | 0 | 1568 | EssentialContract | ## SignalService - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | --------------------------------------------- | ---- | ------ | ----- | ------------- | -| \_initialized | uint8 | 0 | 0 | 1 | SignalService | -| \_initializing | bool | 0 | 1 | 1 | SignalService | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | SignalService | -| \_owner | address | 51 | 0 | 20 | SignalService | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | SignalService | -| \_pendingOwner | address | 101 | 0 | 20 | SignalService | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | SignalService | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-----------------------------------------------|------|--------|-------|--------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | SignalService | +| _initializing | bool | 0 | 1 | 1 | SignalService | +| __gap | uint256[50] | 1 | 0 | 1600 | SignalService | +| _owner | address | 51 | 0 | 20 | SignalService | +| __gap | uint256[49] | 52 | 0 | 1568 | SignalService | +| _pendingOwner | address | 101 | 0 | 20 | SignalService | +| __gap | uint256[49] | 102 | 0 | 1568 | SignalService | | addressManager | address | 151 | 0 | 20 | SignalService | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | SignalService | -| \_\_reentry | uint8 | 201 | 0 | 1 | SignalService | -| \_\_paused | uint8 | 201 | 1 | 1 | SignalService | +| __gap | uint256[49] | 152 | 0 | 1568 | SignalService | +| __reentry | uint8 | 201 | 0 | 1 | SignalService | +| __paused | uint8 | 201 | 1 | 1 | SignalService | | lastUnpausedAt | uint64 | 201 | 2 | 8 | SignalService | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | SignalService | +| __gap | uint256[49] | 202 | 0 | 1568 | SignalService | | topBlockId | mapping(uint64 => mapping(bytes32 => uint64)) | 251 | 0 | 32 | SignalService | | isAuthorized | mapping(address => bool) | 252 | 0 | 32 | SignalService | -| \_\_gap | uint256[48] | 253 | 0 | 1536 | SignalService | +| __gap | uint256[48] | 253 | 0 | 1536 | SignalService | ## BridgedTaikoToken - -| Name | Type | Slot | Offset | Bytes | Contract | -| ----------------------------------------------------- | ------------------------------------------------------------- | ---- | ------ | ----- | ----------------- | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedTaikoToken | -| \_initializing | bool | 0 | 1 | 1 | BridgedTaikoToken | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedTaikoToken | -| \_owner | address | 51 | 0 | 20 | BridgedTaikoToken | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedTaikoToken | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedTaikoToken | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedTaikoToken | -| addressManager | address | 151 | 0 | 20 | BridgedTaikoToken | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedTaikoToken | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedTaikoToken | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedTaikoToken | -| lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedTaikoToken | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedTaikoToken | -| \_\_slots_previously_used_by_ERC20SnapshotUpgradeable | uint256[50] | 251 | 0 | 1600 | BridgedTaikoToken | -| \_balances | mapping(address => uint256) | 301 | 0 | 32 | BridgedTaikoToken | -| \_allowances | mapping(address => mapping(address => uint256)) | 302 | 0 | 32 | BridgedTaikoToken | -| \_totalSupply | uint256 | 303 | 0 | 32 | BridgedTaikoToken | -| \_name | string | 304 | 0 | 32 | BridgedTaikoToken | -| \_symbol | string | 305 | 0 | 32 | BridgedTaikoToken | -| \_\_gap | uint256[45] | 306 | 0 | 1440 | BridgedTaikoToken | -| \_hashedName | bytes32 | 351 | 0 | 32 | BridgedTaikoToken | -| \_hashedVersion | bytes32 | 352 | 0 | 32 | BridgedTaikoToken | -| \_name | string | 353 | 0 | 32 | BridgedTaikoToken | -| \_version | string | 354 | 0 | 32 | BridgedTaikoToken | -| \_\_gap | uint256[48] | 355 | 0 | 1536 | BridgedTaikoToken | -| \_nonces | mapping(address => struct CountersUpgradeable.Counter) | 403 | 0 | 32 | BridgedTaikoToken | -| \_PERMIT_TYPEHASH_DEPRECATED_SLOT | bytes32 | 404 | 0 | 32 | BridgedTaikoToken | -| \_\_gap | uint256[49] | 405 | 0 | 1568 | BridgedTaikoToken | -| \_delegates | mapping(address => address) | 454 | 0 | 32 | BridgedTaikoToken | -| \_checkpoints | mapping(address => struct ERC20VotesUpgradeable.Checkpoint[]) | 455 | 0 | 32 | BridgedTaikoToken | -| \_totalSupplyCheckpoints | struct ERC20VotesUpgradeable.Checkpoint[] | 456 | 0 | 32 | BridgedTaikoToken | -| \_\_gap | uint256[47] | 457 | 0 | 1504 | BridgedTaikoToken | -| \_\_gap | uint256[50] | 504 | 0 | 1600 | BridgedTaikoToken | +| Name | Type | Slot | Offset | Bytes | Contract | +|-----------------------------------------------------|---------------------------------------------------------------|------|--------|-------|-------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedTaikoToken | +| _initializing | bool | 0 | 1 | 1 | BridgedTaikoToken | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedTaikoToken | +| _owner | address | 51 | 0 | 20 | BridgedTaikoToken | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedTaikoToken | +| _pendingOwner | address | 101 | 0 | 20 | BridgedTaikoToken | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedTaikoToken | +| addressManager | address | 151 | 0 | 20 | BridgedTaikoToken | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedTaikoToken | +| __reentry | uint8 | 201 | 0 | 1 | BridgedTaikoToken | +| __paused | uint8 | 201 | 1 | 1 | BridgedTaikoToken | +| lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedTaikoToken | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedTaikoToken | +| __slots_previously_used_by_ERC20SnapshotUpgradeable | uint256[50] | 251 | 0 | 1600 | BridgedTaikoToken | +| _balances | mapping(address => uint256) | 301 | 0 | 32 | BridgedTaikoToken | +| _allowances | mapping(address => mapping(address => uint256)) | 302 | 0 | 32 | BridgedTaikoToken | +| _totalSupply | uint256 | 303 | 0 | 32 | BridgedTaikoToken | +| _name | string | 304 | 0 | 32 | BridgedTaikoToken | +| _symbol | string | 305 | 0 | 32 | BridgedTaikoToken | +| __gap | uint256[45] | 306 | 0 | 1440 | BridgedTaikoToken | +| _hashedName | bytes32 | 351 | 0 | 32 | BridgedTaikoToken | +| _hashedVersion | bytes32 | 352 | 0 | 32 | BridgedTaikoToken | +| _name | string | 353 | 0 | 32 | BridgedTaikoToken | +| _version | string | 354 | 0 | 32 | BridgedTaikoToken | +| __gap | uint256[48] | 355 | 0 | 1536 | BridgedTaikoToken | +| _nonces | mapping(address => struct CountersUpgradeable.Counter) | 403 | 0 | 32 | BridgedTaikoToken | +| _PERMIT_TYPEHASH_DEPRECATED_SLOT | bytes32 | 404 | 0 | 32 | BridgedTaikoToken | +| __gap | uint256[49] | 405 | 0 | 1568 | BridgedTaikoToken | +| _delegates | mapping(address => address) | 454 | 0 | 32 | BridgedTaikoToken | +| _checkpoints | mapping(address => struct ERC20VotesUpgradeable.Checkpoint[]) | 455 | 0 | 32 | BridgedTaikoToken | +| _totalSupplyCheckpoints | struct ERC20VotesUpgradeable.Checkpoint[] | 456 | 0 | 32 | BridgedTaikoToken | +| __gap | uint256[47] | 457 | 0 | 1504 | BridgedTaikoToken | +| __gap | uint256[50] | 504 | 0 | 1600 | BridgedTaikoToken | ## DelegateOwner - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------- | ---- | ------ | ----- | ------------- | -| \_initialized | uint8 | 0 | 0 | 1 | DelegateOwner | -| \_initializing | bool | 0 | 1 | 1 | DelegateOwner | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | DelegateOwner | -| \_owner | address | 51 | 0 | 20 | DelegateOwner | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | DelegateOwner | -| \_pendingOwner | address | 101 | 0 | 20 | DelegateOwner | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | DelegateOwner | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|----------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | DelegateOwner | +| _initializing | bool | 0 | 1 | 1 | DelegateOwner | +| __gap | uint256[50] | 1 | 0 | 1600 | DelegateOwner | +| _owner | address | 51 | 0 | 20 | DelegateOwner | +| __gap | uint256[49] | 52 | 0 | 1568 | DelegateOwner | +| _pendingOwner | address | 101 | 0 | 20 | DelegateOwner | +| __gap | uint256[49] | 102 | 0 | 1568 | DelegateOwner | | addressManager | address | 151 | 0 | 20 | DelegateOwner | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | DelegateOwner | -| \_\_reentry | uint8 | 201 | 0 | 1 | DelegateOwner | -| \_\_paused | uint8 | 201 | 1 | 1 | DelegateOwner | +| __gap | uint256[49] | 152 | 0 | 1568 | DelegateOwner | +| __reentry | uint8 | 201 | 0 | 1 | DelegateOwner | +| __paused | uint8 | 201 | 1 | 1 | DelegateOwner | | lastUnpausedAt | uint64 | 201 | 2 | 8 | DelegateOwner | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | DelegateOwner | +| __gap | uint256[49] | 202 | 0 | 1568 | DelegateOwner | | remoteChainId | uint64 | 251 | 0 | 8 | DelegateOwner | | admin | address | 251 | 8 | 20 | DelegateOwner | | nextTxId | uint64 | 252 | 0 | 8 | DelegateOwner | | remoteOwner | address | 252 | 8 | 20 | DelegateOwner | -| \_\_gap | uint256[48] | 253 | 0 | 1536 | DelegateOwner | +| __gap | uint256[48] | 253 | 0 | 1536 | DelegateOwner | ## TaikoL2 - -| Name | Type | Slot | Offset | Bytes | Contract | -| --------------- | --------------------------- | ---- | ------ | ----- | -------- | -| \_initialized | uint8 | 0 | 0 | 1 | TaikoL2 | -| \_initializing | bool | 0 | 1 | 1 | TaikoL2 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | TaikoL2 | -| \_owner | address | 51 | 0 | 20 | TaikoL2 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | TaikoL2 | -| \_pendingOwner | address | 101 | 0 | 20 | TaikoL2 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | TaikoL2 | -| addressManager | address | 151 | 0 | 20 | TaikoL2 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | TaikoL2 | -| \_\_reentry | uint8 | 201 | 0 | 1 | TaikoL2 | -| \_\_paused | uint8 | 201 | 1 | 1 | TaikoL2 | -| lastUnpausedAt | uint64 | 201 | 2 | 8 | TaikoL2 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | TaikoL2 | -| \_blockhashes | mapping(uint256 => bytes32) | 251 | 0 | 32 | TaikoL2 | -| publicInputHash | bytes32 | 252 | 0 | 32 | TaikoL2 | -| parentGasExcess | uint64 | 253 | 0 | 8 | TaikoL2 | -| lastSyncedBlock | uint64 | 253 | 8 | 8 | TaikoL2 | -| parentTimestamp | uint64 | 253 | 16 | 8 | TaikoL2 | -| parentGasTarget | uint64 | 253 | 24 | 8 | TaikoL2 | -| l1ChainId | uint64 | 254 | 0 | 8 | TaikoL2 | -| \_\_gap | uint256[46] | 255 | 0 | 1472 | TaikoL2 | +| Name | Type | Slot | Offset | Bytes | Contract | +|-----------------|-----------------------------|------|--------|-------|----------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | TaikoL2 | +| _initializing | bool | 0 | 1 | 1 | TaikoL2 | +| __gap | uint256[50] | 1 | 0 | 1600 | TaikoL2 | +| _owner | address | 51 | 0 | 20 | TaikoL2 | +| __gap | uint256[49] | 52 | 0 | 1568 | TaikoL2 | +| _pendingOwner | address | 101 | 0 | 20 | TaikoL2 | +| __gap | uint256[49] | 102 | 0 | 1568 | TaikoL2 | +| addressManager | address | 151 | 0 | 20 | TaikoL2 | +| __gap | uint256[49] | 152 | 0 | 1568 | TaikoL2 | +| __reentry | uint8 | 201 | 0 | 1 | TaikoL2 | +| __paused | uint8 | 201 | 1 | 1 | TaikoL2 | +| lastUnpausedAt | uint64 | 201 | 2 | 8 | TaikoL2 | +| __gap | uint256[49] | 202 | 0 | 1568 | TaikoL2 | +| _blockhashes | mapping(uint256 => bytes32) | 251 | 0 | 32 | TaikoL2 | +| publicInputHash | bytes32 | 252 | 0 | 32 | TaikoL2 | +| parentGasExcess | uint64 | 253 | 0 | 8 | TaikoL2 | +| lastSyncedBlock | uint64 | 253 | 8 | 8 | TaikoL2 | +| parentTimestamp | uint64 | 253 | 16 | 8 | TaikoL2 | +| parentGasTarget | uint64 | 253 | 24 | 8 | TaikoL2 | +| l1ChainId | uint64 | 254 | 0 | 8 | TaikoL2 | +| __gap | uint256[46] | 255 | 0 | 1472 | TaikoL2 | ## HeklaTaikoL2 - -| Name | Type | Slot | Offset | Bytes | Contract | -| --------------- | --------------------------- | ---- | ------ | ----- | ------------ | -| \_initialized | uint8 | 0 | 0 | 1 | HeklaTaikoL2 | -| \_initializing | bool | 0 | 1 | 1 | HeklaTaikoL2 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | HeklaTaikoL2 | -| \_owner | address | 51 | 0 | 20 | HeklaTaikoL2 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | HeklaTaikoL2 | -| \_pendingOwner | address | 101 | 0 | 20 | HeklaTaikoL2 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | HeklaTaikoL2 | +| Name | Type | Slot | Offset | Bytes | Contract | +|-----------------|-----------------------------|------|--------|-------|-----------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | HeklaTaikoL2 | +| _initializing | bool | 0 | 1 | 1 | HeklaTaikoL2 | +| __gap | uint256[50] | 1 | 0 | 1600 | HeklaTaikoL2 | +| _owner | address | 51 | 0 | 20 | HeklaTaikoL2 | +| __gap | uint256[49] | 52 | 0 | 1568 | HeklaTaikoL2 | +| _pendingOwner | address | 101 | 0 | 20 | HeklaTaikoL2 | +| __gap | uint256[49] | 102 | 0 | 1568 | HeklaTaikoL2 | | addressManager | address | 151 | 0 | 20 | HeklaTaikoL2 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | HeklaTaikoL2 | -| \_\_reentry | uint8 | 201 | 0 | 1 | HeklaTaikoL2 | -| \_\_paused | uint8 | 201 | 1 | 1 | HeklaTaikoL2 | +| __gap | uint256[49] | 152 | 0 | 1568 | HeklaTaikoL2 | +| __reentry | uint8 | 201 | 0 | 1 | HeklaTaikoL2 | +| __paused | uint8 | 201 | 1 | 1 | HeklaTaikoL2 | | lastUnpausedAt | uint64 | 201 | 2 | 8 | HeklaTaikoL2 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | HeklaTaikoL2 | -| \_blockhashes | mapping(uint256 => bytes32) | 251 | 0 | 32 | HeklaTaikoL2 | +| __gap | uint256[49] | 202 | 0 | 1568 | HeklaTaikoL2 | +| _blockhashes | mapping(uint256 => bytes32) | 251 | 0 | 32 | HeklaTaikoL2 | | publicInputHash | bytes32 | 252 | 0 | 32 | HeklaTaikoL2 | | parentGasExcess | uint64 | 253 | 0 | 8 | HeklaTaikoL2 | | lastSyncedBlock | uint64 | 253 | 8 | 8 | HeklaTaikoL2 | | parentTimestamp | uint64 | 253 | 16 | 8 | HeklaTaikoL2 | | parentGasTarget | uint64 | 253 | 24 | 8 | HeklaTaikoL2 | | l1ChainId | uint64 | 254 | 0 | 8 | HeklaTaikoL2 | -| \_\_gap | uint256[46] | 255 | 0 | 1472 | HeklaTaikoL2 | +| __gap | uint256[46] | 255 | 0 | 1472 | HeklaTaikoL2 | ## MainnetTaikoL2 - -| Name | Type | Slot | Offset | Bytes | Contract | -| --------------- | --------------------------- | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetTaikoL2 | -| \_initializing | bool | 0 | 1 | 1 | MainnetTaikoL2 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetTaikoL2 | -| \_owner | address | 51 | 0 | 20 | MainnetTaikoL2 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetTaikoL2 | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetTaikoL2 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetTaikoL2 | +| Name | Type | Slot | Offset | Bytes | Contract | +|-----------------|-----------------------------|------|--------|-------|------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetTaikoL2 | +| _initializing | bool | 0 | 1 | 1 | MainnetTaikoL2 | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetTaikoL2 | +| _owner | address | 51 | 0 | 20 | MainnetTaikoL2 | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetTaikoL2 | +| _pendingOwner | address | 101 | 0 | 20 | MainnetTaikoL2 | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetTaikoL2 | | addressManager | address | 151 | 0 | 20 | MainnetTaikoL2 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetTaikoL2 | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetTaikoL2 | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetTaikoL2 | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetTaikoL2 | +| __reentry | uint8 | 201 | 0 | 1 | MainnetTaikoL2 | +| __paused | uint8 | 201 | 1 | 1 | MainnetTaikoL2 | | lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetTaikoL2 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetTaikoL2 | -| \_blockhashes | mapping(uint256 => bytes32) | 251 | 0 | 32 | MainnetTaikoL2 | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetTaikoL2 | +| _blockhashes | mapping(uint256 => bytes32) | 251 | 0 | 32 | MainnetTaikoL2 | | publicInputHash | bytes32 | 252 | 0 | 32 | MainnetTaikoL2 | | parentGasExcess | uint64 | 253 | 0 | 8 | MainnetTaikoL2 | | lastSyncedBlock | uint64 | 253 | 8 | 8 | MainnetTaikoL2 | | parentTimestamp | uint64 | 253 | 16 | 8 | MainnetTaikoL2 | | parentGasTarget | uint64 | 253 | 24 | 8 | MainnetTaikoL2 | | l1ChainId | uint64 | 254 | 0 | 8 | MainnetTaikoL2 | -| \_\_gap | uint256[46] | 255 | 0 | 1472 | MainnetTaikoL2 | +| __gap | uint256[46] | 255 | 0 | 1472 | MainnetTaikoL2 | + diff --git a/packages/protocol/contracts/L1/TaikoData.sol b/packages/protocol/contracts/L1/TaikoData.sol index 948d2bd0b77..035be119737 100644 --- a/packages/protocol/contracts/L1/TaikoData.sol +++ b/packages/protocol/contracts/L1/TaikoData.sol @@ -237,7 +237,7 @@ library TaikoData { mapping( uint64 blockId_mod_blockRingBufferSize => mapping(uint32 transitionId => TransitionState ts) - ) transitions; + ) transitions; bytes32 __reserve1; // Used as a ring buffer for Ether deposits SlotA slotA; // slot 5 SlotB slotB; // slot 6 diff --git a/packages/protocol/script/DeployERC20Airdrop.s.sol b/packages/protocol/script/DeployERC20Airdrop.s.sol index d68acda1d84..68fd8581106 100644 --- a/packages/protocol/script/DeployERC20Airdrop.s.sol +++ b/packages/protocol/script/DeployERC20Airdrop.s.sol @@ -37,7 +37,7 @@ contract DeployERC20Airdrop is DeployCapability { impl: address(new ERC20Airdrop()), data: abi.encodeCall( ERC20Airdrop.init, (address(0), 0, 0, bytes32(0), bridgedTko, vaultAddress) - ) + ) }) ); diff --git a/packages/protocol/script/DeployOnL1.s.sol b/packages/protocol/script/DeployOnL1.s.sol index d1935fa1ce1..c935f913aed 100644 --- a/packages/protocol/script/DeployOnL1.s.sol +++ b/packages/protocol/script/DeployOnL1.s.sol @@ -151,7 +151,7 @@ contract DeployOnL1 is DeployCapability { impl: address(new TaikoToken()), data: abi.encodeCall( TaikoToken.init, (owner, vm.envAddress("TAIKO_TOKEN_PREMINT_RECIPIENT")) - ), + ), registerTo: sharedAddressManager }); } @@ -287,7 +287,7 @@ contract DeployOnL1 is DeployCapability { vm.envBytes32("L2_GENESIS_HASH"), vm.envBool("PAUSE_TAIKO_L1") ) - ) + ) }); TaikoL1 taikoL1; @@ -309,7 +309,7 @@ contract DeployOnL1 is DeployCapability { vm.envBytes32("L2_GENESIS_HASH"), vm.envBool("PAUSE_TAIKO_L1") ) - ), + ), registerTo: rollupAddressManager }); @@ -380,7 +380,7 @@ contract DeployOnL1 is DeployCapability { impl: automateDcapV3AttestationImpl, data: abi.encodeCall( AutomataDcapV3Attestation.init, (owner, address(sigVerifyLib), address(pemCertChainLib)) - ), + ), registerTo: rollupAddressManager }); @@ -394,7 +394,7 @@ contract DeployOnL1 is DeployCapability { impl: address(new ProverSet()), data: abi.encodeCall( ProverSet.init, (owner, vm.envAddress("PROVER_SET_ADMIN"), rollupAddressManager) - ) + ) }); deployZKVerifiers(owner, rollupAddressManager); diff --git a/packages/protocol/script/tokenunlock/Deploy.s.sol b/packages/protocol/script/tokenunlock/Deploy.s.sol index ffafd7ca65d..14200c9ab2a 100644 --- a/packages/protocol/script/tokenunlock/Deploy.s.sol +++ b/packages/protocol/script/tokenunlock/Deploy.s.sol @@ -35,7 +35,7 @@ contract DeployTokenUnlock is DeployCapability { impl: TOKEN_UNLOCK_IMPL, data: abi.encodeCall( TokenUnlock.init, (OWNER, ROLLUP_ADDRESS_MANAGER, recipients[i], TGE) - ) + ) }); vm.stopBroadcast(); console2.log("grantee:", recipients[i]); diff --git a/packages/protocol/test/L2/DelegateOwner.t.sol b/packages/protocol/test/L2/DelegateOwner.t.sol index 36806f1cbe3..e9e2f342f94 100644 --- a/packages/protocol/test/L2/DelegateOwner.t.sol +++ b/packages/protocol/test/L2/DelegateOwner.t.sol @@ -47,7 +47,7 @@ contract TestDelegateOwner is TaikoTest { data: abi.encodeCall( DelegateOwner.init, (remoteOwner, address(addressManager), remoteChainId, address(0)) - ), + ), registerTo: address(addressManager) }) ); diff --git a/packages/protocol/test/L2/TaikoL2.t.sol b/packages/protocol/test/L2/TaikoL2.t.sol index b6f382b6d20..ac8103786aa 100644 --- a/packages/protocol/test/L2/TaikoL2.t.sol +++ b/packages/protocol/test/L2/TaikoL2.t.sol @@ -49,7 +49,7 @@ contract TestTaikoL2 is TaikoTest { impl: address(new TaikoL2EIP1559Configurable()), data: abi.encodeCall( TaikoL2.init, (address(0), addressManager, l1ChainId, gasExcess) - ), + ), registerTo: addressManager }) ) diff --git a/packages/protocol/test/L2/TaikoL2NoFeeCheck.t.sol b/packages/protocol/test/L2/TaikoL2NoFeeCheck.t.sol index 26d6c67b0df..e32738ebce6 100644 --- a/packages/protocol/test/L2/TaikoL2NoFeeCheck.t.sol +++ b/packages/protocol/test/L2/TaikoL2NoFeeCheck.t.sol @@ -49,7 +49,7 @@ contract TestTaikoL2NoFeeCheck is TaikoTest { impl: address(new SkipBasefeeCheckL2()), data: abi.encodeCall( TaikoL2.init, (address(0), addressManager, l1ChainId, gasExcess) - ), + ), registerTo: addressManager }) ) diff --git a/packages/protocol/test/automata-attestation/common/AttestationBase.t.sol b/packages/protocol/test/automata-attestation/common/AttestationBase.t.sol index 9e8398dbf5b..df72befa33a 100644 --- a/packages/protocol/test/automata-attestation/common/AttestationBase.t.sol +++ b/packages/protocol/test/automata-attestation/common/AttestationBase.t.sol @@ -70,7 +70,7 @@ contract AttestationBase is Test, DcapTestUtils, V3QuoteParseUtils { data: abi.encodeCall( AutomataDcapV3Attestation.init, (admin, address(sigVerifyLib), address(pemCertChainLib)) - ) + ) }) ); diff --git a/packages/protocol/test/team/airdrop/ERC20Airdrop.t.sol b/packages/protocol/test/team/airdrop/ERC20Airdrop.t.sol index 6dafd23cbe4..c7d769502ed 100644 --- a/packages/protocol/test/team/airdrop/ERC20Airdrop.t.sol +++ b/packages/protocol/test/team/airdrop/ERC20Airdrop.t.sol @@ -102,7 +102,7 @@ contract TestERC20Airdrop is TaikoTest { data: abi.encodeCall( BridgedERC20.init, (address(0), address(addressManager), randAddress(), 100, 18, "TKO", "Taiko Token") - ) + ) }) ); @@ -129,7 +129,7 @@ contract TestERC20Airdrop is TaikoTest { data: abi.encodeCall( ERC20Airdrop.init, (address(0), claimStart, claimEnd, merkleRoot, address(token), address(vault)) - ) + ) }) ); diff --git a/packages/protocol/test/tokenvault/BridgedERC20V2.t.sol b/packages/protocol/test/tokenvault/BridgedERC20V2.t.sol index dadbb81196f..0ba20904a7a 100644 --- a/packages/protocol/test/tokenvault/BridgedERC20V2.t.sol +++ b/packages/protocol/test/tokenvault/BridgedERC20V2.t.sol @@ -131,7 +131,7 @@ contract TestBridgedERC20 is TaikoTest { data: abi.encodeCall( BridgedERC20.init, (owner, address(manager), srcToken, srcChainId, srcDecimals, name, name) - ), + ), registerTo: manager }) ); diff --git a/packages/protocol/test/tokenvault/ERC20Vault.t.sol b/packages/protocol/test/tokenvault/ERC20Vault.t.sol index 8ad91ab9739..26526463d05 100644 --- a/packages/protocol/test/tokenvault/ERC20Vault.t.sol +++ b/packages/protocol/test/tokenvault/ERC20Vault.t.sol @@ -177,7 +177,7 @@ contract TestERC20Vault is TaikoTest { data: abi.encodeCall( BridgedERC20.init, (address(0), address(addressManager), randAddress(), 100, 18, "USDC", "USDC coin") - ) + ) }) ); @@ -188,7 +188,7 @@ contract TestERC20Vault is TaikoTest { data: abi.encodeCall( BridgedERC20.init, (address(0), address(addressManager), randAddress(), 100, 18, "USDT", "USDT coin") - ) + ) }) ); @@ -207,7 +207,7 @@ contract TestERC20Vault is TaikoTest { "stETH", "Lido Staked ETH" ) - ) + ) }) ); vm.stopPrank(); From 284112f81195aad39c51a830b371d6ed41e7353a Mon Sep 17 00:00:00 2001 From: bearni95 Date: Wed, 11 Sep 2024 16:04:11 +0200 Subject: [PATCH 21/79] s2 deployments hekla updates --- .../trailblazers-badges/hekla.json | 6 ++--- .../trailblazers-badges/sol/Deploy.s.sol | 8 ++++++- .../trailblazers-badges/sol/DeployS2.s.sol | 23 +++++++++---------- .../trailblazers-badges/sol/Utils.s.sol | 10 +++++++- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/packages/nfts/deployments/trailblazers-badges/hekla.json b/packages/nfts/deployments/trailblazers-badges/hekla.json index 209de728ce5..ac51c80a8bc 100644 --- a/packages/nfts/deployments/trailblazers-badges/hekla.json +++ b/packages/nfts/deployments/trailblazers-badges/hekla.json @@ -1,6 +1,6 @@ { - "BadgeChampions": "0x854f29e8b3cE90521eEDBaC9BC3B50c92C32f00e", + "BadgeChampions": "0xB492401A992111C33F81322dB438ab26d2414A21", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x075B858dA6eaf29b157925F4243135C565075842", - "TrailblazersBadgesS2": "0x3B20B6c42EDa78355beC5126cD4abB1fF4C218dd" + "TrailblazersBadges": "0x624489EC638F3D50494Cf9f2AA7477a6518281f6", + "TrailblazersBadgesS2": "0xB581723C1A4f6E1C5795410202B5BD11b7234deF" } diff --git a/packages/nfts/script/trailblazers-badges/sol/Deploy.s.sol b/packages/nfts/script/trailblazers-badges/sol/Deploy.s.sol index 7c380fac890..932321e9237 100644 --- a/packages/nfts/script/trailblazers-badges/sol/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-badges/sol/Deploy.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.24; -import { UtilsScript } from "./Utils.s.sol"; +import { UtilsScript, MockBlacklist } 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"; @@ -49,6 +49,12 @@ contract DeployScript is Script { vm.startBroadcast(deployerPrivateKey); + if (block.chainid == 167_000) { + // mainnet, use existing blacklist + } else { + blacklist = new MockBlacklist(); + } + // deploy token with empty root address impl = address(new TrailblazersBadges()); address proxy = address( diff --git a/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol b/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol index 1b40bdfd4ba..f91f552f264 100644 --- a/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol +++ b/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.24; -import { UtilsScript } from "./Utils.s.sol"; +import { UtilsScript, MockBlacklist } 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"; @@ -11,15 +11,6 @@ import { TrailblazersBadgesS2 } from "../../../contracts/trailblazers-badges/TrailblazersBadgesS2.sol"; import { BadgeChampions } from "../../../contracts/trailblazers-badges/BadgeChampions.sol"; -contract MockBlacklist is IMinimalBlacklist { - function isBlacklisted(address _account) external pure returns (bool) { - if (_account == address(0)) { - return true; - } - return false; - } -} - contract DeployS2Script is Script { UtilsScript public utils; string public jsonLocation; @@ -32,9 +23,11 @@ contract DeployS2Script is Script { // string baseURI = "bafybeierqzehlrqeqqeb6fwmil4dj3ij2p6exgoj4lysl53fsxwob6wbdy"; // IMinimalBlacklist blacklist = IMinimalBlacklist(0xfA5EA6f9A13532cd64e805996a941F101CCaAc9a); - // Holesky Testnet Values + // Hekla Testnet Values bytes32 root = 0xf1359c4c4ba41a72025f2534ea8ad23c6b941b55a715838ebdc71202a78c6c87; - string baseURI = "bafybeierqzehlrqeqqeb6fwmil4dj3ij2p6exgoj4lysl53fsxwob6wbdy"; + string baseURI = + "https://taikonfts.4everland.link/ipfs/bafybeiebmvj6roz4iuoinackb5c6eeshvppctkydrckqrnxexdnzh6odq4"; + IMinimalBlacklist blacklist = IMinimalBlacklist(0xe61E9034b5633977eC98E302b33e321e8140F105); address mintSigner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; @@ -52,6 +45,12 @@ contract DeployS2Script is Script { utils.setUp(); jsonLocation = utils.getContractJsonLocation(); + + string memory projectRoot = vm.projectRoot(); + jsonLocation = string.concat( + projectRoot, "/deployments/trailblazers-badges/", utils.lowercaseNetworkKey(), ".json" + ); + deployerPrivateKey = utils.getPrivateKey(); deployerAddress = utils.getAddress(); } diff --git a/packages/nfts/script/trailblazers-badges/sol/Utils.s.sol b/packages/nfts/script/trailblazers-badges/sol/Utils.s.sol index 6e3a113feea..70db86618b5 100644 --- a/packages/nfts/script/trailblazers-badges/sol/Utils.s.sol +++ b/packages/nfts/script/trailblazers-badges/sol/Utils.s.sol @@ -4,7 +4,6 @@ pragma solidity 0.8.24; import { Script, console } from "forge-std/src/Script.sol"; import "forge-std/src/StdJson.sol"; import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; -import { MockBlacklist } from "../../../test/util/Blacklist.sol"; contract UtilsScript is Script { using stdJson for string; @@ -76,3 +75,12 @@ contract UtilsScript is Script { function run() public { } } + +contract MockBlacklist is IMinimalBlacklist { + function isBlacklisted(address _account) external pure returns (bool) { + if (_account == address(0)) { + return true; + } + return false; + } +} From c53cb862df11027f3a292cbcf079f56c90b1aef5 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 12 Sep 2024 18:55:12 +0200 Subject: [PATCH 22/79] swapping branches --- .../nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol index 314d42637be..9bfcc9f1972 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol @@ -371,3 +371,4 @@ contract TrailblazersBadgesS2 is /// @notice Internal method to authorize an upgrade function _authorizeUpgrade(address) internal virtual override onlyOwner { } } + From 934104ef272aab06fa7dccbc0c396c3f5fa75faf Mon Sep 17 00:00:00 2001 From: bearni95 Date: Wed, 18 Sep 2024 15:14:49 +0200 Subject: [PATCH 23/79] s2 badges rework --- .../TrailblazersBadges.sol | 15 -- .../TrailblazersBadgesS2.sol | 131 ++++++++++++---- .../TrailblazersSeason2.sol | 143 ------------------ .../trailblazers-badges/sol/DeployS2.s.sol | 3 +- .../trailblazers-badges/sol/RunCommand.s.sol | 5 +- .../TraiblazersBadgesS2.t.sol | 86 ++++++++++- .../test/util/TrailblazerBadgesS1MintTo.sol | 23 +++ 7 files changed, 211 insertions(+), 195 deletions(-) delete mode 100644 packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol create mode 100644 packages/nfts/test/util/TrailblazerBadgesS1MintTo.sol diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadges.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadges.sol index bc9f5ca210e..c0997ac36bd 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadges.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadges.sol @@ -240,19 +240,4 @@ contract TrailblazersBadges is ERC721EnumerableUpgradeable, ECDSAWhitelist { function burn(uint256 _tokenId) public onlySeason2BadgeContract { _burn(_tokenId); } - - /// @notice V4 - - // admin function for easy minting - // for testing only, remove from production - function mintTo(address _minter, uint256 _badgeId) public onlyOwner { - if (_badgeId > BADGE_SHINTO) revert INVALID_BADGE_ID(); - - uint256 tokenId = totalSupply() + 1; - badges[tokenId] = _badgeId; - - _mint(_minter, tokenId); - - emit BadgeCreated(tokenId, _minter, _badgeId); - } } diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol index 9bfcc9f1972..fc5d6ccb0f6 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol @@ -23,6 +23,7 @@ import "@taiko/blacklist/IMinimalBlacklist.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; import "./TrailblazersBadges.sol"; +import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; contract TrailblazersBadgesS2 is PausableUpgradeable, @@ -32,8 +33,12 @@ contract TrailblazersBadgesS2 is ERC1155SupplyUpgradeable, ERC721HolderUpgradeable { + /// @notice Time between start and end of a migration uint256 public constant COOLDOWN_MIGRATION = 6 hours; + /// @notice Time between tamper attempts uint256 public constant COOLDOWN_TAMPER = 1 hours; + /// @notice Weight of tamper attempts, in % + uint256 public constant TAMPER_WEIGHT_PERCENT = 5; /// @notice Maximum tamper attempts, per color uint256 public constant MAX_TAMPERS = 3; /// @notice S2 Badge IDs @@ -68,10 +73,19 @@ contract TrailblazersBadgesS2 is mapping(address _user => uint256 _tokenId) private migrationS1TokenIds; /// @notice User to badge ID, token ID mapping mapping(address _user => mapping(uint256 _badgeId => uint256 _tokenId)) public userBadges; - /// @notice Migration-enabled badge IDs - mapping(uint256 _s1BadgeId => bool _enabled) public enabledBadgeIds; + /// @notice Migration-enabled badge IDs per cycle + mapping(uint256 _cycle => mapping(uint256 _s1BadgeId => bool _enabled)) public enabledBadgeIds; /// @notice S1 Badge contract TrailblazersBadges public badges; + /// @notice Address authorized to sign the random seeds + address public randomSigner; + /// @notice Current migration cycle + uint256 public migrationCycle; + /// @notice Mapping of unique user-per-mint-per-cycle + mapping( + uint256 _migrationCycle + => mapping(address _minter => mapping(uint256 _s1BadgeId => bool _mintEnded)) + ) public migrationCycleUniqueMints; /// @notice Gap for upgrade safety uint256[43] private __gap; @@ -85,6 +99,8 @@ contract TrailblazersBadgesS2 is error TOKEN_NOT_MINTED(); error MIGRATION_NOT_ENABLED(); error TOKEN_NOT_OWNED(); + error NOT_RANDOM_SIGNER(); + error ALREADY_MIGRATED_IN_CYCLE(); /// @notice Events event MigrationToggled(uint256 _s1BadgeId, bool _enabled); @@ -95,19 +111,13 @@ contract TrailblazersBadgesS2 is event MigrationEnded(address _user, uint256 _s2BadgeId, uint256 _s2TokenId); /// @notice Modifiers - modifier whenUnpaused(uint256 _badgeId) { - if (!canMigrate(_badgeId) || paused()) { - revert CONTRACT_PAUSED(); - } - _; - } - modifier isMigrating() { if (claimCooldowns[_msgSender()] == 0) { revert MIGRATION_NOT_STARTED(); } _; } + /// @notice Reverts if sender is already migrating modifier isNotMigrating() { if (claimCooldowns[_msgSender()] != 0) { @@ -115,30 +125,34 @@ contract TrailblazersBadgesS2 is } _; } + /// @notice Reverts if migrations aren't enabled for that badge - modifier isNotTampering() { - if (tamperCooldowns[_msgSender()] < block.timestamp) { - revert TAMPER_IN_PROGRESS(); + modifier migrationOpen(uint256 _s1BadgeId) { + if (!enabledBadgeIds[migrationCycle][_s1BadgeId]) { + revert MIGRATION_NOT_ENABLED(); } _; } - modifier migrationOpen(uint256 _s1BadgeId) { - if (!enabledBadgeIds[_s1BadgeId]) { - revert MIGRATION_NOT_ENABLED(); + /// @notice Limits migrations to one per user, badge and cycle + modifier hasntMigratedInCycle(uint256 _s1BadgeId, address _minter) { + // check that the minter hasn't used the migration within this cycle + if (migrationCycleUniqueMints[migrationCycle][_minter][_s1BadgeId]) { + revert ALREADY_MIGRATED_IN_CYCLE(); } _; } /// @notice Contract initializer /// @param _badges The address of the S1 badges contract - function initialize(address _badges) external initializer { + function initialize(address _badges, address _randomSigner) external initializer { __ERC1155_init(""); __ERC1155Supply_init(); _transferOwnership(_msgSender()); __Context_init(); _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); badges = TrailblazersBadges(_badges); + randomSigner = _randomSigner; } /// @notice Start a migration for a badge @@ -146,7 +160,12 @@ 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 migrationOpen(_s1BadgeId) isNotMigrating { + function startMigration(uint256 _s1BadgeId) + external + migrationOpen(_s1BadgeId) + isNotMigrating + hasntMigratedInCycle(_s1BadgeId, _msgSender()) + { uint256 s1TokenId = badges.getTokenId(_msgSender(), _s1BadgeId); if (badges.ownerOf(s1TokenId) != _msgSender()) { @@ -185,10 +204,18 @@ contract TrailblazersBadgesS2 is emit MigrationTampered(_msgSender(), _pinkOrPurple, tamperCooldowns[_msgSender()]); } + /// @notice Reset the tamper counts + /// @dev Can be called only during an active migration + function resetTampers() external isMigrating { + migrationTampers[_msgSender()][true] = 0; + migrationTampers[_msgSender()][false] = 0; + tamperCooldowns[_msgSender()] = 0; + } + /// @notice End a migration /// @dev Can be called only during an active migration, after the cooldown is over /// @dev The final color is determined randomly, and affected by the tamper amounts - function endMigration() external isMigrating { + function endMigration(bytes32 _hash, uint8 v, bytes32 r, bytes32 s) external isMigrating { if (tamperCooldowns[_msgSender()] > block.timestamp) { revert TAMPER_IN_PROGRESS(); } @@ -201,13 +228,25 @@ contract TrailblazersBadgesS2 is uint256 pinkTampers = migrationTampers[_msgSender()][true]; uint256 purpleTampers = migrationTampers[_msgSender()][false]; - // determine the final color, with the tampers adding a max 50% chance if maxxed out - bool isPink = - pinkTampers < 3 && purpleTampers < 3 ? block.timestamp % 2 == 0 : pinkTampers < 3; + uint256 randomSeed = randomFromSignature(_hash, v, r, s); + bool isPinkOrPurple; + // Calculate the difference in tampers and adjust chances + if (pinkTampers > purpleTampers) { + uint256 extraChance = (pinkTampers - purpleTampers) * TAMPER_WEIGHT_PERCENT; + uint256 chance = 50 + extraChance; // Base 50% + extra chance + isPinkOrPurple = (randomSeed % 100) < chance; // True for pink + } else if (purpleTampers > pinkTampers) { + uint256 extraChance = (purpleTampers - pinkTampers) * TAMPER_WEIGHT_PERCENT; + uint256 chance = 50 + extraChance; // Base 50% + extra chance + isPinkOrPurple = (randomSeed % 100) >= chance; // False for purple + } else { + // Equal number of pink and purple tampers, 50/50 chance + isPinkOrPurple = (randomSeed % 100) < 50; + } - (uint256 pinkBadgeId, uint256 purpleBadgeId) = - getSeason2BadgeIds(migrationS1BadgeIds[_msgSender()]); - uint256 s2BadgeId = isPink ? pinkBadgeId : purpleBadgeId; + uint256 s1BadgeId = migrationS1BadgeIds[_msgSender()]; + (uint256 pinkBadgeId, uint256 purpleBadgeId) = getSeason2BadgeIds(s1BadgeId); + uint256 s2BadgeId = isPinkOrPurple ? pinkBadgeId : purpleBadgeId; // burn the s1 badge uint256 s1TokenId = migrationS1TokenIds[_msgSender()]; @@ -225,7 +264,7 @@ contract TrailblazersBadgesS2 is migrationS1BadgeIds[_msgSender()] = 0; migrationS1TokenIds[_msgSender()] = 0; userBadges[_msgSender()][s2BadgeId] = s2TokenId; - + migrationCycleUniqueMints[migrationCycle][_msgSender()][s1BadgeId] = true; emit MigrationEnded(_msgSender(), s2BadgeId, s2TokenId); } @@ -236,8 +275,9 @@ contract TrailblazersBadgesS2 is external onlyRole(DEFAULT_ADMIN_ROLE) { + migrationCycle++; for (uint256 i = 0; i < _s1BadgeIds.length; i++) { - enabledBadgeIds[_s1BadgeIds[i]] = true; + enabledBadgeIds[migrationCycle][_s1BadgeIds[i]] = true; emit MigrationToggled(_s1BadgeIds[i], true); } } @@ -247,7 +287,7 @@ contract TrailblazersBadgesS2 is /// @return Whether the badge is enabled for migration function canMigrate(uint256 _s1Badge) public view returns (bool) { for (uint256 i = 0; i < 8; i++) { - if (enabledBadgeIds[i] && i == _s1Badge) { + if (enabledBadgeIds[migrationCycle][i] && i == _s1Badge) { return true; } } @@ -348,14 +388,46 @@ contract TrailblazersBadgesS2 is /// @dev Doesn't allow for new migration attempts, but tampers and active migrations still run function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) { for (uint256 i = 0; i < 8; i++) { - if (enabledBadgeIds[i]) { + if (enabledBadgeIds[migrationCycle][i]) { emit MigrationToggled(i, false); } - enabledBadgeIds[i] = false; + enabledBadgeIds[migrationCycle][i] = false; } } + /// @notice Generate a unique hash for each migration uniquely + /// @param _user The user address + /// @return _hash The unique hash + function generateClaimHash(address _user) external view returns (bytes32) { + if (claimCooldowns[_user] == 0) { + revert MIGRATION_NOT_STARTED(); + } + return keccak256(abi.encodePacked(_user, claimCooldowns[_user])); + } + + /// @notice Generates a random number from a signature + /// @param _hash The hash to sign (keccak256(startMigrationBlockHash, _msgSender())) + /// @param v signature V field + /// @param r signature R field + /// @param s signature S field + /// @return _random The pseudo-random number + function randomFromSignature( + bytes32 _hash, + uint8 v, + bytes32 r, + bytes32 s + ) + public + view + returns (uint256 _random) + { + (address _recovered,,) = ECDSA.tryRecover(_hash, v, r, s); + if (_recovered != randomSigner) revert NOT_RANDOM_SIGNER(); + // Hash the signature parts to get a deterministic pseudo-random number + return uint256(keccak256(abi.encodePacked(r, s, v))); + } + /// @notice supportsInterface implementation /// @param interfaceId The interface ID /// @return Whether the interface is supported @@ -371,4 +443,3 @@ contract TrailblazersBadgesS2 is /// @notice Internal method to authorize an upgrade function _authorizeUpgrade(address) internal virtual override onlyOwner { } } - diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol deleted file mode 100644 index 8163e3ba8fb..00000000000 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersSeason2.sol +++ /dev/null @@ -1,143 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.24; - -interface BadgeMigration { - /// @notice Start a migration for a badge - /// @param _badgeTokenId The badge token ID (s1) - /// @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 _badgeTokenId) external; - - /// @notice Tamper (alter) the chances during a migration - /// @param _pinkOrPurple true for pink, false for purple - /// @dev Can be called only during an active migration - /// @dev Implements a cooldown before allowing to re-tamper - /// @dev The max tamper amount is determined by Pass Tier - function tamperMigration(bool _pinkOrPurple) external; - - /// @notice End a migration - /// @dev Can be called only during an active migration, after the cooldown is over - /// @dev The final color is determined randomly, and affected by the tamper amounts - function endMigration() external; - - /// @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); -} - -interface TrailRewardVault { - /// @notice Claim rewards - /// @param _experience The experience amount - /// @param _signature The signature to verify - /// @dev The user is the _msgSender() - function claimRewards(uint256 _experience, bytes memory _signature) external; - - /// @notice Internal method to mint s2 badges from claimRewards - /// @param _account The account to mint the badge to - /// @param _tokenId The badge token ID - /// @param _experience The experience amount - /// @param _signature The signature to verify - function _mintBadge( - address _account, - uint256 _tokenId, - uint256 _experience, - bytes memory _signature - ) - external; - - /// @notice Check if an account can claim rewards - /// @param _account The account to check - function canClaim(address _account) external view returns (bool); -} - -interface TrailRaffle { - /// @notice Create a new raffle - /// @param _startTime The start time of the raffle - /// @param _endTime The end time of the raffle - /// @param _erc20TokenRewards array of erc20 addresses for rewards - /// @param _erc20TokenAmounts array of erc20 amounts for rewards - /// @param _erc721TokenRewards array of erc721 addresses for rewards - /// @param _erc721TokenIds array of erc721 token ids for rewards - /// @param _erc1155TokenRewards array of erc1155 addresses for rewards - /// @param _erc1155TokenIds array of erc1155 token ids for rewards - /// @param _erc1155TokenAmounts array of erc1155 token amounts for rewards - /// @dev The raffle will be settled after the end time - /// @dev Each Pass Tier multiplies the raffle chances - function createRaffle( - uint256 _startTime, - uint256 _endTime, - address[] calldata _erc20TokenRewards, - uint256[] calldata _erc20TokenAmounts, - address[] calldata _erc721TokenRewards, - uint256[] calldata _erc721TokenIds, - address[] calldata _erc1155TokenRewards, - uint256[] calldata _erc1155TokenIds, - uint256[] calldata _erc1155TokenAmounts - ) - external - returns (uint256 _raffleId); - - /// @notice Check if a raffle is settled - /// @param _raffleId The raffle ID - /// @return Whether the raffle is settled - function isRaffleSettled(uint256 _raffleId) external view returns (bool); - - /// @notice Settle a raffle - /// @param _raffleId The raffle ID - /// @dev Can be called only after the end time of the raffle - function settleRaffle(uint256 _raffleId) external; - - /// @notice Check if an account is a winner in a raffle - /// @param _account The account to check - /// @param _raffleId The raffle ID - /// @return Whether the account is a winner - function isWinner(address _account, uint256 _raffleId) external view returns (bool); - - /// @notice Claim the rewards of a raffle - /// @param _raffleId The raffle ID - /// @dev Can be called once, only after the raffle is settled, and only by the winner - function claimRaffleRewards(uint256 _raffleId) external; - - /// @notice Get the amount of participations in raffles for an account - /// @param _account The account to check - /// @dev Determined by a user's TrailPass Tier - function getRaffleParticipations(address _account) external view returns (uint256); -} - -interface TrailPass { - /// @notice Purchase a Trail Pass - /// @param _tier The tier of the Trail Pass - /// @dev The price is determined by the tier - /// @dev The tier is determined by the amount of participations in raffles - /// @dev The tier also increases the max amount of tampering during a migration - function purchaseTrailPass(uint256 _tier) external payable; - - /// @notice Upgrade a Trail Pass - /// @param _tier The tier of the Trail Pass - /// @dev The price is determined by the tier, and subtracted from the existing trail pass price - function upgradeTrailPass(uint256 _tier) external payable; - - /// @notice Check if an account has a Trail Pass, any - /// @param _account The account to check - function hasTrailPass(address _account) external view returns (bool); - - /// @notice Check if an account has a Trail Pass, specific tier - /// @param _account The account to check - function hasTrailPass(address _account, uint256 _tier) external view returns (bool); - - /// @notice Check if an account has one of the Trail Passes (OR) - /// @param _account The account to check - /// @param _tiers The tiers to check, OR - function hasTrailPass( - address _account, - uint256[] calldata _tiers - ) - external - view - returns (bool); - - /// @notice Get the tier of a Trail Pass - /// @param _account The account to check - function getTrailPass(address _account) external view returns (uint256 _tier); -} diff --git a/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol b/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol index f91f552f264..c497aa67dee 100644 --- a/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol +++ b/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol @@ -91,7 +91,8 @@ contract DeployS2Script is Script { impl = address(new TrailblazersBadgesS2()); proxy = address( new ERC1967Proxy( - impl, abi.encodeCall(TrailblazersBadgesS2.initialize, address(s1Token)) + impl, + abi.encodeCall(TrailblazersBadgesS2.initialize, (address(s1Token), mintSigner)) ) ); diff --git a/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol b/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol index a025d48e9be..8d713a77ebe 100644 --- a/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol +++ b/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol @@ -11,6 +11,7 @@ import { TrailblazersBadges } from "../../../contracts/trailblazers-badges/Trail import { TrailblazersBadgesS2 } from "../../../contracts/trailblazers-badges/TrailblazersBadgesS2.sol"; import { BadgeChampions } from "../../../contracts/trailblazers-badges/BadgeChampions.sol"; +import { TrailblazerBadgesS1MintTo } from "../../../test/util/TrailblazerBadgesS1MintTo.sol"; contract DeployScript is Script { UtilsScript public utils; @@ -54,7 +55,7 @@ contract DeployScript is Script { uint256 START_TIME = block.timestamp - 1 minutes; badgeChampions.createLeague(OPEN_TIME, CLOSE_TIME, START_TIME); - + /* for (uint256 i = 0; i < participants.length; i++) { uint256 badgeId = i % 7; trailblazersBadges.mintTo(participants[i], badgeId); @@ -62,7 +63,7 @@ contract DeployScript is Script { participants[i], address(trailblazersBadges), badgeId ); } - + */ vm.stopBroadcast(); } diff --git a/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol index 39c2edb00f6..34190d27bc6 100644 --- a/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol +++ b/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol @@ -10,12 +10,14 @@ import { UtilsScript } from "../../script/taikoon/sol/Utils.s.sol"; import { MockBlacklist } from "../util/Blacklist.sol"; import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import { TrailblazersBadgesS2 } from "../../contracts/trailblazers-badges/TrailblazersBadgesS2.sol"; +import { TrailblazerBadgesS1MintTo } from "../util/TrailblazerBadgesS1MintTo.sol"; -contract TrailblazersBadgesTest is Test { +contract TrailblazersBadgesS2Test is Test { UtilsScript public utils; TrailblazersBadges public s1Badges; TrailblazersBadgesS2 public s2Badges; + TrailblazerBadgesS1MintTo public s1BadgesMock; address public owner = vm.addr(0x5); @@ -55,6 +57,15 @@ contract TrailblazersBadgesTest is Test { s1Badges = TrailblazersBadges(proxy); + // upgrade s1 badges contract to use the mock version + + s1Badges.upgradeToAndCall( + address(new TrailblazerBadgesS1MintTo()), + abi.encodeCall(TrailblazerBadgesS1MintTo.version, ()) + ); + + s1BadgesMock = TrailblazerBadgesS1MintTo(address(s1Badges)); + BADGE_ID = s1Badges.BADGE_RAVERS(); // deploy the s2 contract @@ -62,7 +73,8 @@ contract TrailblazersBadgesTest is Test { impl = address(new TrailblazersBadgesS2()); proxy = address( new ERC1967Proxy( - impl, abi.encodeCall(TrailblazersBadgesS2.initialize, (address(s1Badges))) + impl, + abi.encodeCall(TrailblazersBadgesS2.initialize, (address(s1Badges), mintSigner)) ) ); @@ -259,7 +271,6 @@ contract TrailblazersBadgesTest is Test { assertEq(purpleTampers, 2); } - // revert when attempting a 4th pink tamper function test_revert_tooManyTampers() public { test_tamperMigration(); vm.startPrank(minters[0]); @@ -269,22 +280,50 @@ contract TrailblazersBadgesTest is Test { vm.stopPrank(); } + function test_resetTampers() public { + test_tamperMigration(); + assertEq(s2Badges.isTamperActive(minters[0]), true); + (uint256 pinkTampers, uint256 purpleTampers) = s2Badges.getMigrationTampers(minters[0]); + assertEq(pinkTampers, MAX_TAMPERS); + assertEq(purpleTampers, 2); + + vm.prank(minters[0]); + s2Badges.resetTampers(); + + assertEq(s2Badges.isTamperActive(minters[0]), false); + (pinkTampers, purpleTampers) = s2Badges.getMigrationTampers(minters[0]); + assertEq(pinkTampers, 0); + assertEq(purpleTampers, 0); + } + + /* function test_revert_early_endMigration() public { test_tamperMigration(); vm.startPrank(minters[0]); vm.expectRevert(); + + s2Badges.endMigration(); vm.stopPrank(); } + */ function test_endMigration() public { test_tamperMigration(); wait(s2Badges.COOLDOWN_TAMPER()); wait(s2Badges.COOLDOWN_MIGRATION()); + // generate the claim hash for the current migration + bytes32 claimHash = s2Badges.generateClaimHash(minters[0]); + + // simulate the backend signing the hash + (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, claimHash); + + // exercise the randomFromSignature function + vm.startPrank(minters[0]); - s2Badges.endMigration(); + s2Badges.endMigration(claimHash, v, r, s); vm.stopPrank(); // check for s1 burn @@ -373,4 +412,43 @@ contract TrailblazersBadgesTest is Test { assertEq(s1Badges.ownerOf(tokenId), minters[0]); assertEq(s2Badges.isMigrationActive(minters[0]), false); } + + function test_randomFromSignature() public view { + bytes32 signatureHash = keccak256( + abi.encodePacked( + keccak256("1234567890"), // should use the block's hash + minters[0] + ) + ); + + (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, signatureHash); + + uint256 random = s2Badges.randomFromSignature(signatureHash, v, r, s); + + assertEq( + random, + 28_417_844_340_632_250_945_870_465_294_567_768_196_388_504_060_802_704_441_612_911_129_119_444_309_664 + ); + } + + function test_generateClaimHash_revert() public { + vm.expectRevert(); + s2Badges.generateClaimHash(minters[0]); + } + + function test_migrateSameBadgeId_revert() public { + // run a first migration + test_endMigration(); + + // mint a second badge to the user + vm.prank(owner); + s1BadgesMock.mintTo(minters[0], BADGE_ID); + + // fail the second migration for that badge + vm.startPrank(minters[0]); + s1Badges.approve(address(s2Badges), s1Badges.tokenOfOwnerByIndex(minters[0], 0)); + vm.expectRevert(); + s2Badges.startMigration(BADGE_ID); + vm.stopPrank(); + } } diff --git a/packages/nfts/test/util/TrailblazerBadgesS1MintTo.sol b/packages/nfts/test/util/TrailblazerBadgesS1MintTo.sol new file mode 100644 index 00000000000..0504fdb19e4 --- /dev/null +++ b/packages/nfts/test/util/TrailblazerBadgesS1MintTo.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import { Test } from "forge-std/src/Test.sol"; + +import { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; + +contract TrailblazerBadgesS1MintTo is TrailblazersBadges { + function mintTo(address _minter, uint256 _badgeId) public onlyOwner { + if (_badgeId > BADGE_SHINTO) revert INVALID_BADGE_ID(); + + uint256 tokenId = totalSupply() + 1; + badges[tokenId] = _badgeId; + + _mint(_minter, tokenId); + + emit BadgeCreated(tokenId, _minter, _badgeId); + } + + function version() public pure returns (string memory) { + return "mock"; + } +} From b6211bf4cb237cb128ef61c98c5983ca06af6b7b Mon Sep 17 00:00:00 2001 From: bearni95 Date: Wed, 18 Sep 2024 23:50:14 +0200 Subject: [PATCH 24/79] added pfps mainnet deployment --- packages/nfts/deployments/profile/mainnet.json | 2 +- packages/nfts/package.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/nfts/deployments/profile/mainnet.json b/packages/nfts/deployments/profile/mainnet.json index eb752c06c71..4093af55cab 100644 --- a/packages/nfts/deployments/profile/mainnet.json +++ b/packages/nfts/deployments/profile/mainnet.json @@ -1,3 +1,3 @@ { - "RegisterProfilePicture": "0xCbC7846351BaEaB1ed51f8FF57e10C367E01488A" + "RegisterProfilePicture": "0x58617427f3d42e5435908661d3c788d7d2EAf3fa" } diff --git a/packages/nfts/package.json b/packages/nfts/package.json index 930903015fd..1c14eee7ff7 100644 --- a/packages/nfts/package.json +++ b/packages/nfts/package.json @@ -34,7 +34,8 @@ "tbz:s2:deploy:hekla": "forge clean && forge script script/trailblazers-badges/sol/DeployS2.s.sol --tc DeployS2Script --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", "tbz:command:hekla": "forge script script/trailblazers-badges/sol/RunCommand.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", "taikoon:deploy:hekla": "forge clean && pnpm compile && forge script script/taikoon/sol/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", - "pfp:deploy:hekla": "forge clean && pnpm compile && forge script script/profile/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200" + "pfp:deploy:hekla": "forge clean && pnpm compile && forge script script/profile/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", + "pfp:deploy:mainnet": "forge clean && pnpm compile && forge script script/profile/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --gas-estimate-multiplier 200" }, "devDependencies": { "@types/node": "^20.11.30", From e6a0f9a35b3064eb3edfef16c6ea2dd6f184b477 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Tue, 1 Oct 2024 10:49:28 +0200 Subject: [PATCH 25/79] updated hash method --- .../TrailblazersBadgesS2.sol | 18 ++++++++++++++++-- .../TraiblazersBadgesS2.t.sol | 8 ++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol index fc5d6ccb0f6..cb14fa46c10 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol @@ -213,6 +213,10 @@ contract TrailblazersBadgesS2 is } /// @notice End a migration + /// @param _hash The hash to sign + /// @param v signature V field + /// @param r signature R field + /// @param s signature S field /// @dev Can be called only during an active migration, after the cooldown is over /// @dev The final color is determined randomly, and affected by the tamper amounts function endMigration(bytes32 _hash, uint8 v, bytes32 r, bytes32 s) external isMigrating { @@ -398,12 +402,22 @@ contract TrailblazersBadgesS2 is /// @notice Generate a unique hash for each migration uniquely /// @param _user The user address + /// @param _exp The users experience points + /// @param _blockNumber The block number /// @return _hash The unique hash - function generateClaimHash(address _user) external view returns (bytes32) { + function generateClaimHash( + address _user, + uint256 _exp, + uint256 _blockNumber + ) + external + view + returns (bytes32) + { if (claimCooldowns[_user] == 0) { revert MIGRATION_NOT_STARTED(); } - return keccak256(abi.encodePacked(_user, claimCooldowns[_user])); + return keccak256(abi.encodePacked(_user, claimCooldowns[_user], _exp, _blockNumber)); } /// @notice Generates a random number from a signature diff --git a/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol index 34190d27bc6..9e941d1d746 100644 --- a/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol +++ b/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol @@ -315,7 +315,11 @@ contract TrailblazersBadgesS2Test is Test { wait(s2Badges.COOLDOWN_MIGRATION()); // generate the claim hash for the current migration - bytes32 claimHash = s2Badges.generateClaimHash(minters[0]); + bytes32 claimHash = s2Badges.generateClaimHash( + minters[0], + 0, // experience points + 0 // block number + ); // simulate the backend signing the hash (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, claimHash); @@ -433,7 +437,7 @@ contract TrailblazersBadgesS2Test is Test { function test_generateClaimHash_revert() public { vm.expectRevert(); - s2Badges.generateClaimHash(minters[0]); + s2Badges.generateClaimHash(minters[0], 0, 0); } function test_migrateSameBadgeId_revert() public { From 0d66eb2f00c634d46c271ea0979cd9309b401a0c Mon Sep 17 00:00:00 2001 From: bearni95 Date: Tue, 1 Oct 2024 10:54:25 +0200 Subject: [PATCH 26/79] badge champions comment corrections --- .../trailblazers-badges/BadgeChampions.sol | 101 ++++++++---------- 1 file changed, 46 insertions(+), 55 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol b/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol index 926e3afb9ac..39482433fb6 100644 --- a/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol +++ b/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol @@ -34,9 +34,9 @@ contract BadgeChampions is } struct League { - uint256 openTime; // registration starts - uint256 closeTime; // registration ends - uint256 startTime; // league starts (requires admin action) + uint64 openTime; // registration starts + uint64 closeTime; // registration ends + uint64 startTime; // league starts (requires admin action) uint256 seed; } @@ -57,19 +57,6 @@ contract BadgeChampions is 77 // Shinto ]; - function getChampionId( - uint256 _leagueId, - address _owner, - address _badgeContract, - uint256 _tokenId - ) - public - pure - returns (bytes memory) - { - return abi.encodePacked(_owner, _badgeContract, _tokenId, _leagueId); - } - event LeagueCreated( uint256 indexed leagueId, uint256 openTime, uint256 startTime, uint256 endTime ); @@ -95,6 +82,30 @@ contract BadgeChampions is error INVALID_CHAMPION_CONTRACT(); error INVALID_MATCH(); + modifier leagueOpen(uint256 _leagueId) { + League memory league = leagues[_leagueId]; + if (block.timestamp < league.openTime || block.timestamp > league.closeTime) { + revert TOURNAMENT_NOT_OPEN(); + } + + _; + } + + modifier ownedToken(address _badgeContract, uint256 _badgeId) { + // TODO: erc1155 ownership checkup for s2 badges + uint256 tokenId = season1Badges.getTokenId(_msgSender(), _badgeId); + + if ( + season1Badges.ownerOf(tokenId) != _msgSender() + && season1Badges.getApproved(tokenId) != address(this) + && season1Badges.isApprovedForAll(_msgSender(), address(this)) + ) { + revert CHAMPION_NOT_OWNED(); + } + + _; + } + function initialize(address _season1Badges, address _season2Badges) external initializer { __Context_init(); _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); @@ -103,27 +114,18 @@ contract BadgeChampions is season2Badges = TrailblazersBadgesS2(_season2Badges); } - function getCurrentLeague() - public - view - returns (uint256 openTime, uint256 closeTime, uint256 startTime, uint256 seed) - { + function getCurrentLeague() public view returns (League memory league) { return getLeague(currentLeagueId); } - function getLeague(uint256 _leagueId) - public - view - returns (uint256 openTime, uint256 closeTime, uint256 startTime, uint256 seed) - { - League memory league = leagues[_leagueId]; - return (league.openTime, league.closeTime, league.startTime, league.seed); + function getLeague(uint256 _leagueId) public view returns (League memory league) { + return leagues[_leagueId]; } function createLeague( - uint256 _openTime, - uint256 _closeTime, - uint256 _startTime + uint64 _openTime, + uint64 _closeTime, + uint64 _startTime ) public onlyOwner @@ -137,30 +139,6 @@ contract BadgeChampions is emit LeagueCreated(currentLeagueId, _openTime, _closeTime, _startTime); } - modifier leagueOpen(uint256 _leagueId) { - League memory league = leagues[_leagueId]; - if (block.timestamp < league.openTime || block.timestamp > league.closeTime) { - revert TOURNAMENT_NOT_OPEN(); - } - - _; - } - - modifier ownedToken(address _badgeContract, uint256 _badgeId) { - // TODO: erc1155 ownership checkup for s2 badges - uint256 tokenId = season1Badges.getTokenId(_msgSender(), _badgeId); - - if ( - season1Badges.ownerOf(tokenId) != _msgSender() - && season1Badges.getApproved(tokenId) != address(this) - && season1Badges.isApprovedForAll(_msgSender(), address(this)) - ) { - revert CHAMPION_NOT_OWNED(); - } - - _; - } - function calculatePower(uint256 _badgeId) public pure returns (uint256) { return ((1 + _badgeId) * 125) / 10; //return powerLevels[_badgeId % powerLevels.length]; @@ -238,6 +216,19 @@ contract BadgeChampions is } } + function getChampionId( + uint256 _leagueId, + address _owner, + address _badgeContract, + uint256 _tokenId + ) + public + pure + returns (bytes32) + { + return keccak256(abi.encodePacked(_owner, _badgeContract, _tokenId, _leagueId)); + } + function supportsInterface(bytes4 interfaceId) public view From 03301d2314b738524d2f5e7bd34acf7629d150cd Mon Sep 17 00:00:00 2001 From: bearni95 Date: Tue, 1 Oct 2024 10:56:58 +0200 Subject: [PATCH 27/79] badge champions comment corrections --- .../trailblazers-badges/sol/RunCommand.s.sol | 6 +-- .../trailblazers-badges/BadgeChampions.t.sol | 50 +++++++++---------- 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol b/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol index 8d713a77ebe..cb8618ca97a 100644 --- a/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol +++ b/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol @@ -50,9 +50,9 @@ contract DeployScript is Script { function createFreshTournament() public { vm.startBroadcast(deployerPrivateKey); - uint256 OPEN_TIME = block.timestamp - 3 minutes; - uint256 CLOSE_TIME = block.timestamp - 2 minutes; - uint256 START_TIME = block.timestamp - 1 minutes; + uint64 OPEN_TIME = uint64(block.timestamp - 3 minutes); + uint64 CLOSE_TIME = uint64(block.timestamp - 2 minutes); + uint64 START_TIME = uint64(block.timestamp - 1 minutes); badgeChampions.createLeague(OPEN_TIME, CLOSE_TIME, START_TIME); /* diff --git a/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol b/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol index 86f8854f640..cd95d585351 100644 --- a/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol +++ b/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol @@ -41,9 +41,9 @@ contract BadgeChampionsTest is Test { mapping(address player => uint256 badgeId) public playersToBadgeIds; - uint256 constant OPEN_TIME = 10_000; - uint256 constant CLOSE_TIME = 20_000; - uint256 constant START_TIME = 30_000; + uint64 constant OPEN_TIME = 10_000; + uint64 constant CLOSE_TIME = 20_000; + uint64 constant START_TIME = 30_000; function setUp() public { utils = new UtilsScript(); @@ -109,14 +109,13 @@ contract BadgeChampionsTest is Test { badgeChampions.createLeague(OPEN_TIME, CLOSE_TIME, START_TIME); // check league - (uint256 openTime, uint256 closeTime, uint256 startTime, uint256 seed) = - badgeChampions.getCurrentLeague(); + BadgeChampions.League memory league = badgeChampions.getCurrentLeague(); - assertEq(openTime, OPEN_TIME); - assertEq(closeTime, CLOSE_TIME); - assertEq(startTime, START_TIME); + assertEq(league.openTime, OPEN_TIME); + assertEq(league.closeTime, CLOSE_TIME); + assertEq(league.startTime, START_TIME); - assertEq(seed, 0); + assertEq(league.seed, 0); } function test_revert_leagueNotOpen() public { @@ -140,14 +139,13 @@ contract BadgeChampionsTest is Test { badgeChampions.registerChampion(address(token), BADGE_IDS[0]); // check league - (uint256 openTime, uint256 closeTime, uint256 startTime, uint256 seed) = - badgeChampions.getCurrentLeague(); + BadgeChampions.League memory league = badgeChampions.getCurrentLeague(); - assertEq(openTime, OPEN_TIME); - assertEq(closeTime, CLOSE_TIME); - assertEq(startTime, START_TIME); + assertEq(league.openTime, OPEN_TIME); + assertEq(league.closeTime, CLOSE_TIME); + assertEq(league.startTime, START_TIME); - assertEq(seed, 0); + assertEq(league.seed, 0); } function test_revert_registerChampion_notOwned() public { @@ -172,14 +170,13 @@ contract BadgeChampionsTest is Test { } // check league - (uint256 openTime, uint256 closeTime, uint256 startTime, uint256 seed) = - badgeChampions.getCurrentLeague(); + BadgeChampions.League memory league = badgeChampions.getCurrentLeague(); - assertEq(openTime, OPEN_TIME); - assertEq(closeTime, CLOSE_TIME); - assertEq(startTime, START_TIME); + assertEq(league.openTime, OPEN_TIME); + assertEq(league.closeTime, CLOSE_TIME); + assertEq(league.startTime, START_TIME); - assertEq(seed, 0); + assertEq(league.seed, 0); } function test_admin_startLeague() public { @@ -191,14 +188,13 @@ contract BadgeChampionsTest is Test { badgeChampions.startLeague(TOURNAMENT_SEED); // check league - (uint256 openTime, uint256 closeTime, uint256 startTime, uint256 seed) = - badgeChampions.getCurrentLeague(); + BadgeChampions.League memory league = badgeChampions.getCurrentLeague(); - assertEq(openTime, OPEN_TIME); - assertEq(closeTime, CLOSE_TIME); - assertEq(startTime, START_TIME); + assertEq(league.openTime, OPEN_TIME); + assertEq(league.closeTime, CLOSE_TIME); + assertEq(league.startTime, START_TIME); - assertEq(seed, TOURNAMENT_SEED); + assertEq(league.seed, TOURNAMENT_SEED); } function test_revert_startLeague_notAdmin() public { From 87e1e7bd64e43aeb37bc93f609ad3d25fbf15dd3 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Wed, 2 Oct 2024 12:16:31 +0200 Subject: [PATCH 28/79] cleanup --- .../trailblazers-badges/BadgeChampions.sol | 242 ------------------ .../TrailblazersBadgesS2.sol | 39 +-- .../trailblazers-badges/sol/DeployS2.s.sol | 14 - .../trailblazers-badges/sol/RunCommand.s.sol | 80 ------ .../trailblazers-badges/BadgeChampions.t.sol | 210 --------------- .../TraiblazersBadgesS2.t.sol | 7 +- 6 files changed, 26 insertions(+), 566 deletions(-) delete mode 100644 packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol delete mode 100644 packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol delete mode 100644 packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol diff --git a/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol b/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol deleted file mode 100644 index 39482433fb6..00000000000 --- a/packages/nfts/contracts/trailblazers-badges/BadgeChampions.sol +++ /dev/null @@ -1,242 +0,0 @@ -// SPDX-License-Identifier: MIT -// Compatible with OpenZeppelin Contracts ^5.0.0 -pragma solidity ^0.8.24; - -import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; -import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; -import "@openzeppelin/contracts/access/AccessControl.sol"; -import "@openzeppelin/contracts/utils/Strings.sol"; -import { AccessControlUpgradeable } from - "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import { PausableUpgradeable } from - "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; -// import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; -import { UUPSUpgradeable } from - "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; -import { Ownable2StepUpgradeable } from - "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; -import "./TrailblazersBadges.sol"; -import "./TrailblazersBadgesS2.sol"; - -contract BadgeChampions is - PausableUpgradeable, - UUPSUpgradeable, - Ownable2StepUpgradeable, - AccessControlUpgradeable -{ - struct Champion { - address owner; - address badgeContract; - uint256 tokenId; - uint256 leagueId; - uint256 color; // 0 = neutral, 1 = pink, 2 = purple - uint256 power; - } - - struct League { - uint64 openTime; // registration starts - uint64 closeTime; // registration ends - uint64 startTime; // league starts (requires admin action) - uint256 seed; - } - - mapping(uint256 leagueId => League league) public leagues; - uint256 public currentLeagueId = 0; - - TrailblazersBadges public season1Badges; - TrailblazersBadgesS2 public season2Badges; - - uint256[8] public powerLevels = [ - 4, // Ravers - 58, // Robots - 40, // Bouncers - 43, // Masters - 99, // Monks - 51, // Androids - 42, // Drummers - 77 // Shinto - ]; - - event LeagueCreated( - uint256 indexed leagueId, uint256 openTime, uint256 startTime, uint256 endTime - ); - event LeagueStarted(uint256 leagueId, uint256 seed); - - event ChampionRegistered( - uint256 indexed leagueId, - address indexed owner, - address badgesContract, - uint256 tokenId, - uint256 power, - uint256 badgeId - ); - - error ELEMENT_NOT_FOUND(); - error TOURNAMENT_NOT_STARTED(); - error TOURNAMENT_NOT_OPEN(); - error TOURNAMENT_NOT_CLOSED(); - error TOURNAMENT_NOT_ENDED(); - error CHAMPION_NOT_OWNED(); - error INVALID_PARTICIPANT_COUNT(); - error INVALID_ROUND(); - error INVALID_CHAMPION_CONTRACT(); - error INVALID_MATCH(); - - modifier leagueOpen(uint256 _leagueId) { - League memory league = leagues[_leagueId]; - if (block.timestamp < league.openTime || block.timestamp > league.closeTime) { - revert TOURNAMENT_NOT_OPEN(); - } - - _; - } - - modifier ownedToken(address _badgeContract, uint256 _badgeId) { - // TODO: erc1155 ownership checkup for s2 badges - uint256 tokenId = season1Badges.getTokenId(_msgSender(), _badgeId); - - if ( - season1Badges.ownerOf(tokenId) != _msgSender() - && season1Badges.getApproved(tokenId) != address(this) - && season1Badges.isApprovedForAll(_msgSender(), address(this)) - ) { - revert CHAMPION_NOT_OWNED(); - } - - _; - } - - function initialize(address _season1Badges, address _season2Badges) external initializer { - __Context_init(); - _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); - _transferOwnership(_msgSender()); - season1Badges = TrailblazersBadges(_season1Badges); - season2Badges = TrailblazersBadgesS2(_season2Badges); - } - - function getCurrentLeague() public view returns (League memory league) { - return getLeague(currentLeagueId); - } - - function getLeague(uint256 _leagueId) public view returns (League memory league) { - return leagues[_leagueId]; - } - - function createLeague( - uint64 _openTime, - uint64 _closeTime, - uint64 _startTime - ) - public - onlyOwner - { - League memory league = - League({ openTime: _openTime, closeTime: _closeTime, startTime: _startTime, seed: 0 }); - currentLeagueId += 1; - - leagues[currentLeagueId] = league; - - emit LeagueCreated(currentLeagueId, _openTime, _closeTime, _startTime); - } - - function calculatePower(uint256 _badgeId) public pure returns (uint256) { - return ((1 + _badgeId) * 125) / 10; - //return powerLevels[_badgeId % powerLevels.length]; - } - - function _registerChampionFor( - address _player, - address _badgeContract, - uint256 _badgeId - ) - internal - { - if (_badgeContract != address(season1Badges) && _badgeContract != address(season2Badges)) { - revert INVALID_CHAMPION_CONTRACT(); - } - - uint256 tokenId = season1Badges.getTokenId(_player, _badgeId); - uint256 power = calculatePower(_badgeId); - - emit ChampionRegistered(currentLeagueId, _player, _badgeContract, tokenId, power, _badgeId); - } - - function registerChampionFor( - address _player, - address _badgeContract, - uint256 _badgeId - ) - public - onlyOwner - { - _registerChampionFor(_player, _badgeContract, _badgeId); - } - - function registerChampion( - address _badgeContract, - uint256 _badgeId - ) - public - leagueOpen(currentLeagueId) - ownedToken(_badgeContract, _badgeId) - { - _registerChampionFor(_msgSender(), _badgeContract, _badgeId); - } - - function startLeague(uint256 seed) public onlyOwner { - League storage league = leagues[currentLeagueId]; - league.seed = seed; - emit LeagueStarted(currentLeagueId, seed); - } - - function calculateAdvantage( - uint256 _colorLeft, - uint256 _colorRight - ) - public - pure - returns (bool leftAdvantage, bool rightAdvantage) - { - // neutral >> pink >> purple - // 0 >> 1 >> 2 - if (_colorLeft == 0 && _colorRight == 1) { - return (true, false); - } else if (_colorLeft == 0 && _colorRight == 2) { - return (true, false); - } else if (_colorLeft == 1 && _colorRight == 0) { - return (false, true); - } else if (_colorLeft == 1 && _colorRight == 2) { - return (true, false); - } else if (_colorLeft == 2 && _colorRight == 0) { - return (false, true); - } else if (_colorLeft == 2 && _colorRight == 1) { - return (false, true); - } else { - return (false, false); - } - } - - function getChampionId( - uint256 _leagueId, - address _owner, - address _badgeContract, - uint256 _tokenId - ) - public - pure - returns (bytes32) - { - return keccak256(abi.encodePacked(_owner, _badgeContract, _tokenId, _leagueId)); - } - - function supportsInterface(bytes4 interfaceId) - public - view - override(AccessControlUpgradeable) - returns (bool) - { - return super.supportsInterface(interfaceId); - } - - function _authorizeUpgrade(address) internal virtual override onlyOwner { } -} diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol index cb14fa46c10..ee2c8126fb3 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol @@ -8,7 +8,6 @@ import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; -import "@taiko/blacklist/IMinimalBlacklist.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; @@ -19,7 +18,6 @@ import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721Enumer import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; -import "@taiko/blacklist/IMinimalBlacklist.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; import "./TrailblazersBadges.sol"; @@ -101,6 +99,7 @@ contract TrailblazersBadgesS2 is error TOKEN_NOT_OWNED(); error NOT_RANDOM_SIGNER(); error ALREADY_MIGRATED_IN_CYCLE(); + error HASH_MISMATCH(); /// @notice Events event MigrationToggled(uint256 _s1BadgeId, bool _enabled); @@ -117,16 +116,16 @@ contract TrailblazersBadgesS2 is } _; } - /// @notice Reverts if sender is already migrating + /// @notice Reverts if sender is already migrating modifier isNotMigrating() { if (claimCooldowns[_msgSender()] != 0) { revert MIGRATION_ALREADY_STARTED(); } _; } - /// @notice Reverts if migrations aren't enabled for that badge + /// @notice Reverts if migrations aren't enabled for that badge modifier migrationOpen(uint256 _s1BadgeId) { if (!enabledBadgeIds[migrationCycle][_s1BadgeId]) { revert MIGRATION_NOT_ENABLED(); @@ -217,9 +216,19 @@ contract TrailblazersBadgesS2 is /// @param v signature V field /// @param r signature R field /// @param s signature S field + /// @param exp The user's experience points /// @dev Can be called only during an active migration, after the cooldown is over /// @dev The final color is determined randomly, and affected by the tamper amounts - function endMigration(bytes32 _hash, uint8 v, bytes32 r, bytes32 s) external isMigrating { + function endMigration( + bytes32 _hash, + uint8 v, + bytes32 r, + bytes32 s, + uint256 exp + ) + external + isMigrating + { if (tamperCooldowns[_msgSender()] > block.timestamp) { revert TAMPER_IN_PROGRESS(); } @@ -228,6 +237,13 @@ contract TrailblazersBadgesS2 is revert MIGRATION_NOT_READY(); } + // ensure the hash corresponds to the start time + bytes32 calculatedHash = generateClaimHash(_msgSender(), exp); + + if (calculatedHash != _hash) { + revert HASH_MISMATCH(); + } + // get the tamper amounts uint256 pinkTampers = migrationTampers[_msgSender()][true]; uint256 purpleTampers = migrationTampers[_msgSender()][false]; @@ -403,21 +419,12 @@ contract TrailblazersBadgesS2 is /// @notice Generate a unique hash for each migration uniquely /// @param _user The user address /// @param _exp The users experience points - /// @param _blockNumber The block number /// @return _hash The unique hash - function generateClaimHash( - address _user, - uint256 _exp, - uint256 _blockNumber - ) - external - view - returns (bytes32) - { + function generateClaimHash(address _user, uint256 _exp) public view returns (bytes32) { if (claimCooldowns[_user] == 0) { revert MIGRATION_NOT_STARTED(); } - return keccak256(abi.encodePacked(_user, claimCooldowns[_user], _exp, _blockNumber)); + return keccak256(abi.encodePacked(_user, claimCooldowns[_user], _exp)); } /// @notice Generates a random number from a signature diff --git a/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol b/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol index c497aa67dee..e5b97a6649c 100644 --- a/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol +++ b/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol @@ -9,7 +9,6 @@ import { TrailblazersBadges } from "../../../contracts/trailblazers-badges/Trail import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; import { TrailblazersBadgesS2 } from "../../../contracts/trailblazers-badges/TrailblazersBadgesS2.sol"; -import { BadgeChampions } from "../../../contracts/trailblazers-badges/BadgeChampions.sol"; contract DeployS2Script is Script { UtilsScript public utils; @@ -64,7 +63,6 @@ contract DeployS2Script is Script { address proxy; TrailblazersBadges s1Token; TrailblazersBadgesS2 s2Token; - BadgeChampions badgeChampions; vm.startBroadcast(deployerPrivateKey); @@ -101,22 +99,10 @@ contract DeployS2Script is Script { console.log("Token Base URI:", baseURI); console.log("Deployed TrailblazersBadgesS2 to:", address(s2Token)); - // Deploy Badge Champions - impl = address(new BadgeChampions()); - proxy = address( - new ERC1967Proxy( - impl, - abi.encodeCall(BadgeChampions.initialize, (address(s1Token), address(s2Token))) - ) - ); - - badgeChampions = BadgeChampions(proxy); - // Register deployment vm.serializeAddress(jsonRoot, "TrailblazersBadges", address(s1Token)); vm.serializeAddress(jsonRoot, "TrailblazersBadgesS2", address(s2Token)); - vm.serializeAddress(jsonRoot, "BadgeChampions", address(badgeChampions)); string memory finalJson = vm.serializeAddress(jsonRoot, "Owner", s2Token.owner()); vm.writeJson(finalJson, jsonLocation); diff --git a/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol b/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol deleted file mode 100644 index cb8618ca97a..00000000000 --- a/packages/nfts/script/trailblazers-badges/sol/RunCommand.s.sol +++ /dev/null @@ -1,80 +0,0 @@ -// 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 { TrailblazersBadges } from "../../../contracts/trailblazers-badges/TrailblazersBadges.sol"; -import { TrailblazersBadgesS2 } from - "../../../contracts/trailblazers-badges/TrailblazersBadgesS2.sol"; -import { BadgeChampions } from "../../../contracts/trailblazers-badges/BadgeChampions.sol"; -import { TrailblazerBadgesS1MintTo } from "../../../test/util/TrailblazerBadgesS1MintTo.sol"; - -contract DeployScript is Script { - UtilsScript public utils; - uint256 public deployerPrivateKey; - address public deployerAddress; - - TrailblazersBadges public trailblazersBadges; - TrailblazersBadgesS2 public trailblazersBadgesS2; - BadgeChampions public badgeChampions; - - // Hekla - address constant S1_ADDRESS = 0x075B858dA6eaf29b157925F4243135C565075842; - address constant S2_ADDRESS = 0x3B20B6c42EDa78355beC5126cD4abB1fF4C218dd; - address constant CHAMPIONS_ADDRESS = 0x854f29e8b3cE90521eEDBaC9BC3B50c92C32f00e; - - address[] public participants = [ - // @bearni - taiko:hekla - 0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e, - address(0x1), - address(0x2), - address(0x3) - ]; - - function setUp() public { - utils = new UtilsScript(); - utils.setUp(); - - deployerPrivateKey = utils.getPrivateKey(); - deployerAddress = utils.getAddress(); - - trailblazersBadges = TrailblazersBadges(S1_ADDRESS); - trailblazersBadgesS2 = TrailblazersBadgesS2(S2_ADDRESS); - badgeChampions = BadgeChampions(CHAMPIONS_ADDRESS); - } - - function createFreshTournament() public { - vm.startBroadcast(deployerPrivateKey); - - uint64 OPEN_TIME = uint64(block.timestamp - 3 minutes); - uint64 CLOSE_TIME = uint64(block.timestamp - 2 minutes); - uint64 START_TIME = uint64(block.timestamp - 1 minutes); - - badgeChampions.createLeague(OPEN_TIME, CLOSE_TIME, START_TIME); - /* - for (uint256 i = 0; i < participants.length; i++) { - uint256 badgeId = i % 7; - trailblazersBadges.mintTo(participants[i], badgeId); - badgeChampions.registerChampionFor( - participants[i], address(trailblazersBadges), badgeId - ); - } - */ - vm.stopBroadcast(); - } - - function run() public { - createFreshTournament(); - - // close signups and start the tournament - vm.startBroadcast(deployerPrivateKey); - - uint256 TOURNAMENT_SEED = block.number * 123_456_789; - badgeChampions.startLeague(TOURNAMENT_SEED); - vm.stopBroadcast(); - } -} diff --git a/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol b/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol deleted file mode 100644 index cd95d585351..00000000000 --- a/packages/nfts/test/trailblazers-badges/BadgeChampions.t.sol +++ /dev/null @@ -1,210 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.24; - -import { Test } from "forge-std/src/Test.sol"; - -import { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; -import { BadgeChampions } from "../../contracts/trailblazers-badges/BadgeChampions.sol"; -import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; -import { UtilsScript } from "../../script/taikoon/sol/Utils.s.sol"; -import { MockBlacklist } from "../util/Blacklist.sol"; -import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; - -contract BadgeChampionsTest is Test { - UtilsScript public utils; - - TrailblazersBadges public token; - - address public owner = vm.addr(0x5); - - address[8] public minters = [ - vm.addr(0x1), - vm.addr(0x2), - vm.addr(0x3), - vm.addr(0x4), - vm.addr(0x5), - vm.addr(0x6), - vm.addr(0x7), - vm.addr(0x8) - ]; - - uint256 constant TOURNAMENT_SEED = 1_234_567_890; - - uint256[8] public BADGE_IDS = [0, 1, 2, 3, 4, 5, 6, 7]; - - MockBlacklist public blacklist; - - address mintSigner; - uint256 mintSignerPk; - - BadgeChampions public badgeChampions; - - mapping(address player => uint256 badgeId) public playersToBadgeIds; - - uint64 constant OPEN_TIME = 10_000; - uint64 constant CLOSE_TIME = 20_000; - uint64 constant START_TIME = 30_000; - - function setUp() public { - utils = new UtilsScript(); - utils.setUp(); - blacklist = new MockBlacklist(); - // create whitelist merkle tree - vm.startPrank(owner); - - (mintSigner, mintSignerPk) = makeAddrAndKey("mintSigner"); - - // deploy s1 badges token - address impl = address(new TrailblazersBadges()); - address proxy = address( - new ERC1967Proxy( - impl, - abi.encodeCall( - TrailblazersBadges.initialize, (owner, "ipfs://", mintSigner, blacklist) - ) - ) - ); - - token = TrailblazersBadges(proxy); - - // deploy badge champions - impl = address(new BadgeChampions()); - proxy = address( - new ERC1967Proxy( - impl, abi.encodeCall(BadgeChampions.initialize, (address(token), address(0x0))) - ) - ); - - badgeChampions = BadgeChampions(proxy); - vm.stopPrank(); - - // mint some badges - for (uint256 i = 0; i < minters.length; i++) { - bytes32 _hash = token.getHash(minters[i], BADGE_IDS[i]); - - (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); - - vm.startPrank(minters[i]); - token.mint(abi.encodePacked(r, s, v), BADGE_IDS[i]); - vm.stopPrank(); - - playersToBadgeIds[minters[i]] = BADGE_IDS[i]; - } - } - - function test_metadata_badges() public view { - assertEq(token.BADGE_RAVERS(), 0); - assertEq(token.BADGE_ROBOTS(), 1); - assertEq(token.BADGE_BOUNCERS(), 2); - assertEq(token.BADGE_MASTERS(), 3); - assertEq(token.BADGE_MONKS(), 4); - assertEq(token.BADGE_DRUMMERS(), 5); - assertEq(token.BADGE_ANDROIDS(), 6); - assertEq(token.BADGE_SHINTO(), 7); - } - - function test_admin_createLeague() public { - // create league - vm.prank(owner); - badgeChampions.createLeague(OPEN_TIME, CLOSE_TIME, START_TIME); - - // check league - BadgeChampions.League memory league = badgeChampions.getCurrentLeague(); - - assertEq(league.openTime, OPEN_TIME); - assertEq(league.closeTime, CLOSE_TIME); - assertEq(league.startTime, START_TIME); - - assertEq(league.seed, 0); - } - - function test_revert_leagueNotOpen() public { - test_admin_createLeague(); - vm.startPrank(minters[0]); - vm.expectRevert(); - badgeChampions.registerChampion(address(token), playersToBadgeIds[minters[0]]); - vm.stopPrank(); - } - - function wait(uint256 time) public { - vm.warp(block.timestamp + time); - } - - function test_registerChampion() public { - test_admin_createLeague(); - - wait(OPEN_TIME + 1); - // register champion - vm.prank(minters[0]); - badgeChampions.registerChampion(address(token), BADGE_IDS[0]); - - // check league - BadgeChampions.League memory league = badgeChampions.getCurrentLeague(); - - assertEq(league.openTime, OPEN_TIME); - assertEq(league.closeTime, CLOSE_TIME); - assertEq(league.startTime, START_TIME); - - assertEq(league.seed, 0); - } - - function test_revert_registerChampion_notOwned() public { - test_admin_createLeague(); - - wait(OPEN_TIME + 1); - // register champion - vm.startPrank(minters[1]); - vm.expectRevert(); - badgeChampions.registerChampion(address(token), playersToBadgeIds[minters[0]]); - vm.stopPrank(); - } - - function test_registerChampion_all() public { - test_admin_createLeague(); - - wait(OPEN_TIME + 1); - // register champion - for (uint256 i = 0; i < minters.length; i++) { - vm.prank(minters[i]); - badgeChampions.registerChampion(address(token), BADGE_IDS[i]); - } - - // check league - BadgeChampions.League memory league = badgeChampions.getCurrentLeague(); - - assertEq(league.openTime, OPEN_TIME); - assertEq(league.closeTime, CLOSE_TIME); - assertEq(league.startTime, START_TIME); - - assertEq(league.seed, 0); - } - - function test_admin_startLeague() public { - test_registerChampion_all(); - - wait(CLOSE_TIME + 1); - // start league - vm.prank(owner); - badgeChampions.startLeague(TOURNAMENT_SEED); - - // check league - BadgeChampions.League memory league = badgeChampions.getCurrentLeague(); - - assertEq(league.openTime, OPEN_TIME); - assertEq(league.closeTime, CLOSE_TIME); - assertEq(league.startTime, START_TIME); - - assertEq(league.seed, TOURNAMENT_SEED); - } - - function test_revert_startLeague_notAdmin() public { - test_registerChampion_all(); - - wait(CLOSE_TIME + 1); - // start league - vm.startPrank(minters[0]); - vm.expectRevert(); - badgeChampions.startLeague(TOURNAMENT_SEED); - vm.stopPrank(); - } -} diff --git a/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol index 9e941d1d746..fa98e4f32c5 100644 --- a/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol +++ b/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol @@ -317,8 +317,7 @@ contract TrailblazersBadgesS2Test is Test { // generate the claim hash for the current migration bytes32 claimHash = s2Badges.generateClaimHash( minters[0], - 0, // experience points - 0 // block number + 0 // experience points ); // simulate the backend signing the hash @@ -327,7 +326,7 @@ contract TrailblazersBadgesS2Test is Test { // exercise the randomFromSignature function vm.startPrank(minters[0]); - s2Badges.endMigration(claimHash, v, r, s); + s2Badges.endMigration(claimHash, v, r, s, 0); vm.stopPrank(); // check for s1 burn @@ -437,7 +436,7 @@ contract TrailblazersBadgesS2Test is Test { function test_generateClaimHash_revert() public { vm.expectRevert(); - s2Badges.generateClaimHash(minters[0], 0, 0); + s2Badges.generateClaimHash(minters[0], 0); } function test_migrateSameBadgeId_revert() public { From 521b7de11fb9ed6812e565d14c6de0a352def9b9 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 3 Oct 2024 12:39:50 +0200 Subject: [PATCH 29/79] refactored s2 contracts onto their own locations --- .../TrailblazersBadgesS2.sol | 4 +- .../trailblazers-badges/hekla.json | 5 +- .../trailblazers-season-2/hekla.json | 5 ++ .../trailblazers-season-2/mainnet.json | 5 ++ packages/nfts/package.json | 9 +- .../{sol => }/Deploy.s.sol | 2 +- .../{sol => }/UpgradeS1.sol | 2 +- .../{sol => }/UpgradeV3.sol | 4 +- .../trailblazers-badges/{sol => }/Utils.s.sol | 0 .../Deploy.s.sol} | 9 +- .../script/trailblazers-season-2/Utils.s.sol | 86 +++++++++++++++++++ .../TraiblazersBadgesS2.t.sol | 2 +- 12 files changed, 111 insertions(+), 22 deletions(-) rename packages/nfts/contracts/{trailblazers-badges => trailblazers-season-2}/TrailblazersBadgesS2.sol (99%) create mode 100644 packages/nfts/deployments/trailblazers-season-2/hekla.json create mode 100644 packages/nfts/deployments/trailblazers-season-2/mainnet.json rename packages/nfts/script/trailblazers-badges/{sol => }/Deploy.s.sol (96%) rename packages/nfts/script/trailblazers-badges/{sol => }/UpgradeS1.sol (92%) rename packages/nfts/script/trailblazers-badges/{sol => }/UpgradeV3.sol (89%) rename packages/nfts/script/trailblazers-badges/{sol => }/Utils.s.sol (100%) rename packages/nfts/script/{trailblazers-badges/sol/DeployS2.s.sol => trailblazers-season-2/Deploy.s.sol} (92%) create mode 100644 packages/nfts/script/trailblazers-season-2/Utils.s.sol rename packages/nfts/test/{trailblazers-badges => trailblazers-season-2}/TraiblazersBadgesS2.t.sol (99%) diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol similarity index 99% rename from packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol rename to packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol index ee2c8126fb3..8d6b351c6b8 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.24; import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol"; -import "./ECDSAWhitelist.sol"; +import "../trailblazers-badges/ECDSAWhitelist.sol"; import "@taiko/blacklist/IMinimalBlacklist.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; @@ -20,7 +20,7 @@ import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol" import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; -import "./TrailblazersBadges.sol"; +import "../trailblazers-badges/TrailblazersBadges.sol"; import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; contract TrailblazersBadgesS2 is diff --git a/packages/nfts/deployments/trailblazers-badges/hekla.json b/packages/nfts/deployments/trailblazers-badges/hekla.json index ac51c80a8bc..ecc500a7b7c 100644 --- a/packages/nfts/deployments/trailblazers-badges/hekla.json +++ b/packages/nfts/deployments/trailblazers-badges/hekla.json @@ -1,6 +1,5 @@ { - "BadgeChampions": "0xB492401A992111C33F81322dB438ab26d2414A21", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x624489EC638F3D50494Cf9f2AA7477a6518281f6", - "TrailblazersBadgesS2": "0xB581723C1A4f6E1C5795410202B5BD11b7234deF" + "TrailblazersBadges": "0xe20616Be39a58cC990c3B8ab069F31e230BeD74D", + "TrailblazersBadgesS2": "0x5dC1F8ef5c7f4f40AdA892B0988b563e71f03eEd" } diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json new file mode 100644 index 00000000000..91512ed23a8 --- /dev/null +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -0,0 +1,5 @@ +{ + "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", + "TrailblazersBadges": "0xA951f812D8B52db3E001c6f1F061Be941208a918", + "TrailblazersBadgesS2": "0x5fb9662549105Ba46f3153b4e3DCA9CC7923D323" +} diff --git a/packages/nfts/deployments/trailblazers-season-2/mainnet.json b/packages/nfts/deployments/trailblazers-season-2/mainnet.json new file mode 100644 index 00000000000..91512ed23a8 --- /dev/null +++ b/packages/nfts/deployments/trailblazers-season-2/mainnet.json @@ -0,0 +1,5 @@ +{ + "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", + "TrailblazersBadges": "0xA951f812D8B52db3E001c6f1F061Be941208a918", + "TrailblazersBadgesS2": "0x5fb9662549105Ba46f3153b4e3DCA9CC7923D323" +} diff --git a/packages/nfts/package.json b/packages/nfts/package.json index 1c14eee7ff7..e4c5f844d36 100644 --- a/packages/nfts/package.json +++ b/packages/nfts/package.json @@ -26,13 +26,12 @@ "kbw:deploy:mainnet": "forge clean && pnpm compile && forge script script/party-ticket/sol/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 30 ", "kbw:upgradeV2:hekla": "forge clean && pnpm compile && forge script script/party-ticket/sol/UpgradeV2.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", "kbw:upgradeV2:mainnet": "forge clean && pnpm compile && forge script script/party-ticket/sol/UpgradeV2.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast", - "tbzb:deploy:localhost": "forge clean && forge script script/trailblazers-badges/sol/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast", - "tbzb:deploy:hekla": "forge clean && forge script script/trailblazers-badges/sol/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", + "tbzb:deploy:localhost": "forge clean && forge script script/trailblazers-badges/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast", + "tbzb:deploy:hekla": "forge clean && forge script script/trailblazers-badges/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", "galxe:deploy:mainnet": "forge clean && forge script script/galxe/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --legacy --with-gas-price 1", - "tbzb:deploy:mainnet": "forge clean && forge script script/trailblazers-badges/sol/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 13 ", + "tbzb:deploy:mainnet": "forge clean && forge script script/trailblazers-badges/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 13 ", "kbw:deploy:hekla": "forge clean && forge script script/party-ticket/sol/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", - "tbz:s2:deploy:hekla": "forge clean && forge script script/trailblazers-badges/sol/DeployS2.s.sol --tc DeployS2Script --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", - "tbz:command:hekla": "forge script script/trailblazers-badges/sol/RunCommand.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", + "tbz:s2:deploy:hekla": "forge clean && forge script script/trailblazers-season-2/Deploy.s.sol --tc DeployS2Script --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", "taikoon:deploy:hekla": "forge clean && pnpm compile && forge script script/taikoon/sol/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", "pfp:deploy:hekla": "forge clean && pnpm compile && forge script script/profile/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", "pfp:deploy:mainnet": "forge clean && pnpm compile && forge script script/profile/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --gas-estimate-multiplier 200" diff --git a/packages/nfts/script/trailblazers-badges/sol/Deploy.s.sol b/packages/nfts/script/trailblazers-badges/Deploy.s.sol similarity index 96% rename from packages/nfts/script/trailblazers-badges/sol/Deploy.s.sol rename to packages/nfts/script/trailblazers-badges/Deploy.s.sol index 932321e9237..a48ce45cdc8 100644 --- a/packages/nfts/script/trailblazers-badges/sol/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-badges/Deploy.s.sol @@ -5,7 +5,7 @@ import { UtilsScript, MockBlacklist } 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 { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; contract DeployScript is Script { diff --git a/packages/nfts/script/trailblazers-badges/sol/UpgradeS1.sol b/packages/nfts/script/trailblazers-badges/UpgradeS1.sol similarity index 92% rename from packages/nfts/script/trailblazers-badges/sol/UpgradeS1.sol rename to packages/nfts/script/trailblazers-badges/UpgradeS1.sol index 662a98a3561..3fd1ea77341 100644 --- a/packages/nfts/script/trailblazers-badges/sol/UpgradeS1.sol +++ b/packages/nfts/script/trailblazers-badges/UpgradeS1.sol @@ -5,7 +5,7 @@ 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 { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; contract UpgradeV2 is Script { diff --git a/packages/nfts/script/trailblazers-badges/sol/UpgradeV3.sol b/packages/nfts/script/trailblazers-badges/UpgradeV3.sol similarity index 89% rename from packages/nfts/script/trailblazers-badges/sol/UpgradeV3.sol rename to packages/nfts/script/trailblazers-badges/UpgradeV3.sol index d51919abf5f..a28142f2f11 100644 --- a/packages/nfts/script/trailblazers-badges/sol/UpgradeV3.sol +++ b/packages/nfts/script/trailblazers-badges/UpgradeV3.sol @@ -5,10 +5,10 @@ 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 { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; import { TrailblazersBadgesV3 } from - "../../../contracts/trailblazers-badges/TrailblazersBadgesV3.sol"; + "../../contracts/trailblazers-badges/TrailblazersBadgesV3.sol"; contract UpgradeV2 is Script { UtilsScript public utils; diff --git a/packages/nfts/script/trailblazers-badges/sol/Utils.s.sol b/packages/nfts/script/trailblazers-badges/Utils.s.sol similarity index 100% rename from packages/nfts/script/trailblazers-badges/sol/Utils.s.sol rename to packages/nfts/script/trailblazers-badges/Utils.s.sol diff --git a/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol similarity index 92% rename from packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol rename to packages/nfts/script/trailblazers-season-2/Deploy.s.sol index e5b97a6649c..1400d7e3ea9 100644 --- a/packages/nfts/script/trailblazers-badges/sol/DeployS2.s.sol +++ b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol @@ -5,10 +5,10 @@ import { UtilsScript, MockBlacklist } 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 { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; import { TrailblazersBadgesS2 } from - "../../../contracts/trailblazers-badges/TrailblazersBadgesS2.sol"; + "../../contracts/trailblazers-season-2/TrailblazersBadgesS2.sol"; contract DeployS2Script is Script { UtilsScript public utils; @@ -45,11 +45,6 @@ contract DeployS2Script is Script { jsonLocation = utils.getContractJsonLocation(); - string memory projectRoot = vm.projectRoot(); - jsonLocation = string.concat( - projectRoot, "/deployments/trailblazers-badges/", utils.lowercaseNetworkKey(), ".json" - ); - deployerPrivateKey = utils.getPrivateKey(); deployerAddress = utils.getAddress(); } diff --git a/packages/nfts/script/trailblazers-season-2/Utils.s.sol b/packages/nfts/script/trailblazers-season-2/Utils.s.sol new file mode 100644 index 00000000000..f52d15f54c8 --- /dev/null +++ b/packages/nfts/script/trailblazers-season-2/Utils.s.sol @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import { Script, console } from "forge-std/src/Script.sol"; +import "forge-std/src/StdJson.sol"; +import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; + +contract UtilsScript is Script { + using stdJson for string; + + address public nounsTokenAddress; + + uint256 public chainId; + + string public lowercaseNetworkKey; + string public uppercaseNetworkKey; + + function setUp() public { + // load all network configs + chainId = block.chainid; + + if (chainId == 31_337) { + lowercaseNetworkKey = "localhost"; + uppercaseNetworkKey = "LOCALHOST"; + } else if (chainId == 17_000) { + lowercaseNetworkKey = "holesky"; + uppercaseNetworkKey = "HOLESKY"; + } else if (chainId == 167_001) { + lowercaseNetworkKey = "devnet"; + uppercaseNetworkKey = "DEVNET"; + } else if (chainId == 11_155_111) { + lowercaseNetworkKey = "sepolia"; + uppercaseNetworkKey = "SEPOLIA"; + } else if (chainId == 167_008) { + lowercaseNetworkKey = "katla"; + uppercaseNetworkKey = "KATLA"; + } else if (chainId == 167_000) { + lowercaseNetworkKey = "mainnet"; + uppercaseNetworkKey = "MAINNET"; + } else if (chainId == 167_009) { + lowercaseNetworkKey = "hekla"; + uppercaseNetworkKey = "HEKLA"; + } else { + revert("Unsupported chainId"); + } + } + + function getPrivateKey() public view returns (uint256) { + string memory lookupKey = string.concat(uppercaseNetworkKey, "_PRIVATE_KEY"); + return vm.envUint(lookupKey); + } + + function getAddress() public view returns (address) { + string memory lookupKey = string.concat(uppercaseNetworkKey, "_ADDRESS"); + return vm.envAddress(lookupKey); + } + + function getContractJsonLocation() public view returns (string memory) { + string memory root = vm.projectRoot(); + return + string.concat(root, "/deployments/trailblazers-season-2/", lowercaseNetworkKey, ".json"); + } + + function getBlacklist() public view returns (IMinimalBlacklist blacklistAddress) { + if (block.chainid == 167_000) { + // mainnet blacklist address + blacklistAddress = IMinimalBlacklist(vm.envAddress("BLACKLIST_ADDRESS")); + } else { + // deploy a mock blacklist otherwise + blacklistAddress = IMinimalBlacklist(0xbdEd0D2bf404bdcBa897a74E6657f1f12e5C6fb6); + } + + return blacklistAddress; + } + + function run() public { } +} + +contract MockBlacklist is IMinimalBlacklist { + function isBlacklisted(address _account) external pure returns (bool) { + if (_account == address(0)) { + return true; + } + return false; + } +} diff --git a/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol similarity index 99% rename from packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol rename to packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol index fa98e4f32c5..06ccd3ba34c 100644 --- a/packages/nfts/test/trailblazers-badges/TraiblazersBadgesS2.t.sol +++ b/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol @@ -9,7 +9,7 @@ import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy import { UtilsScript } from "../../script/taikoon/sol/Utils.s.sol"; import { MockBlacklist } from "../util/Blacklist.sol"; import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -import { TrailblazersBadgesS2 } from "../../contracts/trailblazers-badges/TrailblazersBadgesS2.sol"; +import { TrailblazersBadgesS2 } from "../../contracts/trailblazers-season-2/TrailblazersBadgesS2.sol"; import { TrailblazerBadgesS1MintTo } from "../util/TrailblazerBadgesS1MintTo.sol"; contract TrailblazersBadgesS2Test is Test { From 44ac3accbb45e3b024cd13d62442c96e20d9e915 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 3 Oct 2024 12:40:07 +0200 Subject: [PATCH 30/79] fmt, lint --- packages/nfts/script/trailblazers-badges/UpgradeV3.sol | 3 +-- .../nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nfts/script/trailblazers-badges/UpgradeV3.sol b/packages/nfts/script/trailblazers-badges/UpgradeV3.sol index a28142f2f11..b4662e80473 100644 --- a/packages/nfts/script/trailblazers-badges/UpgradeV3.sol +++ b/packages/nfts/script/trailblazers-badges/UpgradeV3.sol @@ -7,8 +7,7 @@ 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 { TrailblazersBadgesV3 } from - "../../contracts/trailblazers-badges/TrailblazersBadgesV3.sol"; +import { TrailblazersBadgesV3 } from "../../contracts/trailblazers-badges/TrailblazersBadgesV3.sol"; contract UpgradeV2 is Script { UtilsScript public utils; diff --git a/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol index 06ccd3ba34c..e418cf0f480 100644 --- a/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol +++ b/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol @@ -9,7 +9,8 @@ import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy import { UtilsScript } from "../../script/taikoon/sol/Utils.s.sol"; import { MockBlacklist } from "../util/Blacklist.sol"; import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -import { TrailblazersBadgesS2 } from "../../contracts/trailblazers-season-2/TrailblazersBadgesS2.sol"; +import { TrailblazersBadgesS2 } from + "../../contracts/trailblazers-season-2/TrailblazersBadgesS2.sol"; import { TrailblazerBadgesS1MintTo } from "../util/TrailblazerBadgesS1MintTo.sol"; contract TrailblazersBadgesS2Test is Test { From edf7704b990f0177820473d8dc5ed7ef54853d40 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Fri, 4 Oct 2024 11:06:12 +0200 Subject: [PATCH 31/79] latest hekla deployment --- .../contracts/trailblazers-season-2/TrailblazersBadgesS2.sol | 3 --- packages/nfts/deployments/trailblazers-season-2/hekla.json | 4 ++-- .../test/trailblazers-season-2/TraiblazersBadgesS2.t.sol | 5 ----- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol index 8d6b351c6b8..bb2c5a35887 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol @@ -421,9 +421,6 @@ contract TrailblazersBadgesS2 is /// @param _exp The users experience points /// @return _hash The unique hash function generateClaimHash(address _user, uint256 _exp) public view returns (bytes32) { - if (claimCooldowns[_user] == 0) { - revert MIGRATION_NOT_STARTED(); - } return keccak256(abi.encodePacked(_user, claimCooldowns[_user], _exp)); } diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index 91512ed23a8..af19ddebbb2 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,5 +1,5 @@ { "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0xA951f812D8B52db3E001c6f1F061Be941208a918", - "TrailblazersBadgesS2": "0x5fb9662549105Ba46f3153b4e3DCA9CC7923D323" + "TrailblazersBadges": "0x772A9a8d404c7B9E763F23E1cc9391Fd7FB98346", + "TrailblazersBadgesS2": "0x5A3b9b63429152bD20f4Ad8EBD56034B06a714D6" } diff --git a/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol index e418cf0f480..f19a1e11c95 100644 --- a/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol +++ b/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol @@ -435,11 +435,6 @@ contract TrailblazersBadgesS2Test is Test { ); } - function test_generateClaimHash_revert() public { - vm.expectRevert(); - s2Badges.generateClaimHash(minters[0], 0); - } - function test_migrateSameBadgeId_revert() public { // run a first migration test_endMigration(); From 1a28ce72efeedf426842496c52df94f14cf8b619 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Wed, 9 Oct 2024 14:24:40 +0200 Subject: [PATCH 32/79] safekeeping --- .../trailblazers-season-2/TrailblazersBadgesS2.sol | 6 +++--- packages/nfts/deployments/trailblazers-airdrop/mainnet.json | 4 ++++ packages/nfts/deployments/trailblazers-season-2/hekla.json | 4 ++-- packages/nfts/package.json | 4 +++- packages/nfts/script/trailblazers-airdrop/Deploy.s.sol | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol index bb2c5a35887..4a50a565a4e 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol @@ -102,7 +102,7 @@ contract TrailblazersBadgesS2 is error HASH_MISMATCH(); /// @notice Events - event MigrationToggled(uint256 _s1BadgeId, bool _enabled); + event MigrationToggled(uint256 indexed _migrationCycleId, uint256 _s1BadgeId, bool _enabled); event MigrationStarted( address _user, uint256 _s1BadgeId, uint256 _s1TokenId, uint256 _cooldownExpiration ); @@ -298,7 +298,7 @@ contract TrailblazersBadgesS2 is migrationCycle++; for (uint256 i = 0; i < _s1BadgeIds.length; i++) { enabledBadgeIds[migrationCycle][_s1BadgeIds[i]] = true; - emit MigrationToggled(_s1BadgeIds[i], true); + emit MigrationToggled(migrationCycle, _s1BadgeIds[i], true); } } @@ -409,7 +409,7 @@ contract TrailblazersBadgesS2 is function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) { for (uint256 i = 0; i < 8; i++) { if (enabledBadgeIds[migrationCycle][i]) { - emit MigrationToggled(i, false); + emit MigrationToggled(migrationCycle, i, false); } enabledBadgeIds[migrationCycle][i] = false; diff --git a/packages/nfts/deployments/trailblazers-airdrop/mainnet.json b/packages/nfts/deployments/trailblazers-airdrop/mainnet.json index e69de29bb2d..1bc5a45df72 100644 --- a/packages/nfts/deployments/trailblazers-airdrop/mainnet.json +++ b/packages/nfts/deployments/trailblazers-airdrop/mainnet.json @@ -0,0 +1,4 @@ +{ + "ERC20Airdrop": "0xa45eF4bc885811e5d487c3C99f05b6c8e25268d5", + "MerkleRoot": "0xbe8ec647626f95185f551887b3eee43ea9e8965c7baf558a9f8cb22b020597f0" +} diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index af19ddebbb2..afcda6fc072 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,5 +1,5 @@ { "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x772A9a8d404c7B9E763F23E1cc9391Fd7FB98346", - "TrailblazersBadgesS2": "0x5A3b9b63429152bD20f4Ad8EBD56034B06a714D6" + "TrailblazersBadges": "0x291ac81710b10BC9920De6aab3dEFDAbB1a852e6", + "TrailblazersBadgesS2": "0x230a20a477043A93067FF92B8909e0E4561Dd121" } diff --git a/packages/nfts/package.json b/packages/nfts/package.json index 6995c7f224b..00cedce8d1a 100644 --- a/packages/nfts/package.json +++ b/packages/nfts/package.json @@ -32,10 +32,12 @@ "tbzb:deploy:mainnet": "forge clean && forge script script/trailblazers-badges/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --legacy --with-gas-price 13 ", "kbw:deploy:hekla": "forge clean && forge script script/party-ticket/sol/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", "tbz:s2:deploy:hekla": "forge clean && forge script script/trailblazers-season-2/Deploy.s.sol --tc DeployS2Script --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", + "tbz:s2:deploy:mainnet": "forge clean && forge script script/trailblazers-season-2/Deploy.s.sol --tc DeployS2Script --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --gas-estimate-multiplier 200", "taikoon:deploy:hekla": "forge clean && pnpm compile && forge script script/taikoon/sol/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", "pfp:deploy:hekla": "forge clean && pnpm compile && forge script script/profile/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", "pfp:deploy:mainnet": "forge clean && pnpm compile && forge script script/profile/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --gas-estimate-multiplier 200", - "tbz:airdrop:hekla": "forge clean && pnpm compile && forge script script/trailblazers-airdrop/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200" + "tbz:airdrop:hekla": "forge clean && pnpm compile && forge script script/trailblazers-airdrop/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", + "tbz:airdrop:mainnet": "forge clean && pnpm compile && forge script script/trailblazers-airdrop/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --gas-estimate-multiplier 200" }, "devDependencies": { "@types/node": "^20.11.30", diff --git a/packages/nfts/script/trailblazers-airdrop/Deploy.s.sol b/packages/nfts/script/trailblazers-airdrop/Deploy.s.sol index 663ef57e3df..b5667d4de35 100644 --- a/packages/nfts/script/trailblazers-airdrop/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-airdrop/Deploy.s.sol @@ -27,7 +27,7 @@ contract DeployScript is Script { uint256 constant CLAIM_AMOUNT = 10 ether; // hekla test root - bytes32 public merkleRoot = 0xea5b2299e76b4860965e9059388d021145269c96b816b07a808ff391cd80753e; + bytes32 public merkleRoot = 0xbe8ec647626f95185f551887b3eee43ea9e8965c7baf558a9f8cb22b020597f0; // rewards token ERC20Upgradeable public erc20; From 61781424f83d70b1ff516ab26e118188986ddd29 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Fri, 11 Oct 2024 01:06:43 +0200 Subject: [PATCH 33/79] tbz updated blacklist --- .../deployments/blacklist/hekla.json | 3 + .../deployments/blacklist/mainnet.json | 3 + packages/supplementary-contracts/package.json | 4 +- .../script/blacklist/Deploy.data.json | 155 +++++++++++++++++- .../script/blacklist/Deploy.sol | 72 ++++++-- 5 files changed, 222 insertions(+), 15 deletions(-) create mode 100644 packages/supplementary-contracts/deployments/blacklist/hekla.json create mode 100644 packages/supplementary-contracts/deployments/blacklist/mainnet.json diff --git a/packages/supplementary-contracts/deployments/blacklist/hekla.json b/packages/supplementary-contracts/deployments/blacklist/hekla.json new file mode 100644 index 00000000000..84a53c5c7c2 --- /dev/null +++ b/packages/supplementary-contracts/deployments/blacklist/hekla.json @@ -0,0 +1,3 @@ +{ + "Blacklist": "0xD10a2c799F61A89B8f6D8C695c48A4F38684ab30" +} diff --git a/packages/supplementary-contracts/deployments/blacklist/mainnet.json b/packages/supplementary-contracts/deployments/blacklist/mainnet.json new file mode 100644 index 00000000000..bcadc7ecfea --- /dev/null +++ b/packages/supplementary-contracts/deployments/blacklist/mainnet.json @@ -0,0 +1,3 @@ +{ + "Blacklist": "0x5e3052424E51a62c4FDFf4F1dD42300F59c9C57A" +} diff --git a/packages/supplementary-contracts/package.json b/packages/supplementary-contracts/package.json index db4335fa5e0..ba6c6f93d6e 100644 --- a/packages/supplementary-contracts/package.json +++ b/packages/supplementary-contracts/package.json @@ -9,7 +9,9 @@ "layout": "./deployments/gen-layouts.sh", "fmt:sol": "forge fmt", "lint:sol": "forge fmt && pnpm solhint 'contracts/**/*.sol'", - "test": "forge test -vvv --match-path test/*.t.sol" + "test": "forge test -vvv --match-path test/*.t.sol", + "deploy:blacklist:hekla": "forge script script/blacklist/Deploy.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", + "deploy:blacklist:mainnet": "forge script script/blacklist/Deploy.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --gas-estimate-multiplier 100" }, "devDependencies": { "@types/node": "^20.11.30", diff --git a/packages/supplementary-contracts/script/blacklist/Deploy.data.json b/packages/supplementary-contracts/script/blacklist/Deploy.data.json index 415c666f0a7..f0f0137813c 100644 --- a/packages/supplementary-contracts/script/blacklist/Deploy.data.json +++ b/packages/supplementary-contracts/script/blacklist/Deploy.data.json @@ -1,6 +1,6 @@ { - "admin": "0xf8ff2AF0DC1D5BA4811f22aCb02936A1529fd2Be", - "updater": "0xf8ff2AF0DC1D5BA4811f22aCb02936A1529fd2Be", + "admin": "0x7d70236E2517f5B95247AF1d806A9E3C328a7860", + "updater": "0x7d70236E2517f5B95247AF1d806A9E3C328a7860", "blacklist": [ "0x098B716B8Aaf21512996dC57EB0615e2383E2f96", "0xa0e1c89Ef1a489c9C7dE96311eD5Ce5D32c20E4B", @@ -155,6 +155,155 @@ "0x175d44451403Edf28469dF03A9280c1197ADb92c", "0x21B8d56BDA776bbE68655A16895afd96F5534feD", "0xE950DC316b836e4EeFb8308bf32Bf7C72a1358FF", - "0x19F8f2B0915Daa12a3f5C9CF01dF9E24D53794F7" + "0x19F8f2B0915Daa12a3f5C9CF01dF9E24D53794F7", + "0xB9C144ee9Db3850BB5c1598f9b1B03CD68812e30", + "0x683279542eD04d7C60DC56E4EA230fe621eDD4Ca", + "0x29E866A8471DA4f89b4AFF3FD41c801d8027058b", + "0xa2C13a6913D1DF18ff4f5de2bc342023Cd683C38", + "0x5c913285DD9421EDc9d8f1000A35D9bbDF0DCb62", + "0x4ee49B318B785BC358f947BfdCec46dFA12b1Ac1", + "0x6d9999D1aC0027F1E3Dc1e3F154e3366726743b7", + "0x4342F35851fa88873496A49F55ECF79671042bF9", + "0xb226eFF9Be0F679CfB703626C911113513B63bd4", + "0x93ff385916cfcDDA8EB0858276B0074e061E98F4", + "0x29aC5D7972C8B672bF2Ae60eFbc1bEFf48F1F038", + "0xA241038Cb362BDAbd55fDa08233de6f75c764C63", + "0x3d96638B127463e136dAaD12d9bfEAeaFA5437De", + "0x60E9c48A50828c4DC4e36D28fc7EF1b25124e002", + "0xB4c9105B0bF3785C30676D13D210D698Dde84F11", + "0xa4426fA0F0e53Cd06dc41d4fEcF4Bf8783dC5a27", + "0x509BBc835912dF27Fb19837b604b92664A5B8FF1", + "0x08103076D7b1219c7135D89fC0a1c90D26FB307F", + "0x2Cfd96Fb65a990F1b5193992a47e0b6D918Df0Dc", + "0xB33e272E9B62409a53dA0171Eaf88eFef8eE4692", + "0x64FF010064656dF2FC55a3b7D99420Bc4A07c56A", + "0xcDc7306b3c9E0F2947a7B62A137eF90806901f37", + "0xAF5c672f943cd547B7938158A46D08b584c492E8", + "0xAd5e1B0Ed51b625519f81D43117b479DE7e9AbDC", + "0xF8f5811d342DdC2a6320C205856977CfE3289f29", + "0xdd8BD6CEDE3D9eD2D453216df394C5bC8b05046a", + "0x72a2B878e6A909192b0aD91AF976494Ba5143855", + "0xBa5613D19214eD93844AabD24F1102040aceae4f", + "0xaf00a8b4e83A005921D0f878d20006DE0cDA044C", + "0x1a903fe2f732F96bAa7292A05f4121766dD7e07a", + "0xB84F419FD6DC9C30cCAA6ecbF5d194Af065A33ff", + "0xb787c56Bd3c21FB6C18Ceb9a3E49637ab7cD4Dd9", + "0xE2189aa87c1Ad7654bE7Ee258f348d6484F68165", + "0xbdaD5D2d23c0d5D6B17E402a79658f787328ee08", + "0xA189b646c8983253De9eE06C815c51171F265f81", + "0x660888f021BB7da1004869C6a51059Ed97d9e7c0", + "0x1dCFB0dB0D1A774Da525F1200E2c549Bf8A9DC70", + "0x4BA67EC73A7aBF9E015eeFC1979053CE0E56B369", + "0xF46dC57a0d8B614a0e8571217316d24B840ED9BC", + "0x3099cE94b9dDB6715B1169F61Aa0e16ad818Ce89", + "0x24317cAB3C632E0B1eD0d21De1E0a009359B1296", + "0xb692c229A8622Ad1dB19b18065E69B2b6116b9ef", + "0xC478e784b91b19665470CeAaCfa39Ba17D0f6183", + "0xEF8F0d7684D4405B5c51AEF023675946D5992b29", + "0xE9F41a0090fcc7eaf626037003AAD44B17098E7C", + "0x57B7F15C80461E83Ee56daE6a813A57f41E9b61d", + "0x05431cD62F011Cb44Ec803Fe4AC96FAC651CA494", + "0xcaFd650401708ca4f65a22340D07f78E18f8C332", + "0xbB7Cc747f5279Fde28b0878C928D92Eb6c90deBd", + "0x0f883a80a11Ba4057c265ad3a4C0c4e3869ac4c3", + "0xab2ECcf82a5b66396419da7a6e9fbF6630Bb7521", + "0xEc1C61c1c5cfEaA49141C24fB88815052D2fa6B1", + "0x7282aB49b58C7c493F49F2d5D1a723BdEd47C420", + "0x688c0a468ad7BE8Dc2e1cB92cc1b9b6fdca84d5A", + "0x5065d72003878656670f8C67498924704108C00C", + "0x8B59C939bE050814e56D69A68B7c8E485f79f9c3", + "0x38c104275141eaaE188dE0017eFf125FEb87F218", + "0xEe74356635A216A1fC89D4921495124c1533b0C8", + "0x394702830B44476C919389Cb7bA3726a1A885F3A", + "0xBA7770994a63d874127bC6eF8a0c78CCd5174E13", + "0x4edb34De5A54B42cDb88D7E535EC767AcdCa9Ce1", + "0x9c6F685403491272E6CF6258c32ccaA8E9A1ed21", + "0xdd7B2F2b821Ff20ee52A8787b3D9614b91A2b8B1", + "0xE86d78381c4cd7B4a67278e1194cA7bABc363Af9", + "0x873415F6633A0C42b8717bC898354638F52b13f3", + "0xB439b0844D0D9aF237FF37dc2379f07B6CD06171", + "0x796e3F689D8d475Dc82ce801440B184A76e68175", + "0xCe5CDb2Da5A7F30163126388Dd22a1e8084a9ad1", + "0x85204a5E932b69455822033F33E378DFF4Bb8960", + "0x588137e7c1Fce64a78e092611609B259bb524DaE", + "0x6De556d0d262BCC52fc5594abCcBc3b78524Ae17", + "0x52539Ea869f7162BC18f9c3C2dB595f2Cd69f63b", + "0xA706009f64b8eeDE2005546d18d2cbB87DDd95dF", + "0xD1799f7B0Bb7F48b0e997358eEEac349bA776c49", + "0x8fe67f559f6D6dED602E954d45897ebEE5F7FFec", + "0x464E1e588Bb3f49D039Ab8C4D5E33bB47fF8915C", + "0x9905d5753a005cd3e13D71bD030f0B6654703B81", + "0x4d7bF7e16fA37867b4Efcf7c05BD3d889ACB6ac9", + "0x026649F79905E4c5Fa26DafFbD905B3522d37e10", + "0x160EE9Bc0a0Fa051C6fEE189e9107669ed07DB0a", + "0x84a6b0C091c57313E3350B1C9d59472517f60D41", + "0x6d9807d18374F33213DE86917937544A7095e39e", + "0x9c9a2d9826b7c7e95D686e5714Fb0eF948EbC6B8", + "0x6aca843DD19AE4bfA43b6C53fC2e0c3a0bF6a002", + "0x381a0241a2A6e0217376A44C113707D5F9993e1b", + "0xC12B1050553c11993ed3A6aaB6818de7EC4DE4E2", + "0xc3F6b750Ab8b42D0455Cc90cac0E7B1F6bb6953a", + "0x07C35EF7A4AC953F5B8bBC79E6D497d114c38e6E", + "0x0395c16F061E8D2d79DFadF957fFcb97F2D765D3", + "0x6FFE37F348CCB189aC63BfB69ba6B4Aa0beDC3FB", + "0x7C22a14E676657Ebd573B7BE96AcFb21f09171dc", + "0xEC5568Bb595a311D2060506437D0f16Da8B8562D", + "0xea3D4D7f3484a683c39494D0b2A62C83cD52E8d4", + "0xDbd300Eba0F755Bb06DA769A4E1A84E4330068AF", + "0xE7eeb97861761e0AEE35F3e5dE42e1501C283495", + "0x0DC74caBcfB00ab5Fdeef60088685A71fef97003", + "0x45d993393f7B3Fe781935e1155118C7f830d4415", + "0x96BCa503a3ae8bEb794DaD2602202BB5ECD4AAE6", + "0x3Ad16031c0b29A2a6B7A3FBB5996649e39f4127b", + "0x8Cc38ceC2535DE89f2D573F6a50E74a717B45829", + "0x9fE7EDeDcd7DCF206cBe7F00bD23A6e70b398d74", + "0xa58b94936C196d5263b54232EB7D6C2B99A745b4", + "0xd8C860D789Ec1c6aE9631B680E6555F25Bc28331", + "0x6AEF558e7ebE574D692c2acd4C47232fd54e62b6", + "0xea99b1e741779a99646B7F9D57aF0F8264d94020", + "0x924eC99107E0F6fF59Ab33460ae6be9E8A6f5017", + "0x9a80ba749a649B2604d796e01D8A64Cc7B58ff78", + "0x904F40730023CC632c9dF65606dA0809D00D3B9a", + "0x9ECEc759D9F899Db97C6decDe38731f0A9DB449d", + "0xD6AFE7BA2E3c42C6A2729b861F33B54F8b2E6f2F", + "0xDE367Ba53E9EDC9381Ce00cDBba3DB01497E7974", + "0x37C4334EB5d24DCcCCfEBCC54680C433313EB040", + "0x87cCe15D359633EB901889E1B7CBa95c21053C19", + "0xE0B61B1EE0aa4Cb23d8667fda8F720F9f707c4B1", + "0x697F9Ab686b2834ACd86750B8A9Fd9f26b1f640e", + "0x6873a48E3A67E240D62E6Ec510900C0b9480cF8C", + "0x855980B2B60d8E3b60CFCf92413e3E3aF04AA101", + "0x435f6Fef6f7c1CadcD77CCB4ef1AD66C27FcFe79", + "0x735026cA2D9a0Cd24Da088eD3E1853EDe083Fc97", + "0x41ad8DD494057E87cE16dAeb20A06649E8ca2B50", + "0x87dFedBFD4FBBFDb8153fec55c82A983c299e5ad", + "0xEaA132575a13F88B715738562C7c1A545EC24300", + "0x3D3Aa68b54df9666CB6670A93aBE7A80CA01fbc3", + "0x7135603DAF6E50a76c3603582bdC2f33Fc558494", + "0x321186Ed48B0112Cc7Ed232e621d932c6EB84c61", + "0xc1B906579E383bE6Cb1B1Cc737DBA2e63CCEFa04", + "0x9471e8B1903Ef7f65f4002cFCE147b2646b6BB0f", + "0xc3fd682bdfb5ABab39Eb2c92E3411978e0b57E3f", + "0x477992B48247c889d50c9B0A87B2b2E34cbCA623", + "0x049dD5F736B851419cde65BB94DcE74d48324269", + "0xD9E6718b1C294CCe6EBC67eb6eBdbc02c343E489", + "0x830a02416Fc210C6F50A5afe65384F6c88132BE7", + "0x1b39f5ee1Fb4958F2E4049f69B53F78b75Bf1888", + "0x1742289017b61C48A5B4340666711AEd2Db72B4E", + "0x523c2937b6A1A0df143032033d6824dce499ddBF", + "0xB0a5eA798249fb30E9E1c81d475B051279962BB2", + "0xd2c7EeDBE8D68b045388A79b65915253dB582385", + "0xc1b44b014cD87d88BB04e176ba9324e086e9cd73", + "0x9D9854f6C9588bF5A56158a47090E0DFAC89d596", + "0x40eF5243c64BFa49301adF18b09A79A190CFa266", + "0xCF3c579061fB243aeFab480055B49e9038e6E488", + "0x0117Ce17Bc661d9bc331A328DC57C05d99B087D3", + "0xB2de33b99A59877d0780D4315690a600f47B5996", + "0xd50c9d01223F0EC1184A82eBEA3730Bdbc82238e", + "0x1F4a6756Da7592fc0f9a031D127d016ACc0BfcB2", + "0x63c9E4f81716dEBc57dB9Fbc60600106a44B9964", + "0xB7Cd2CEF367bf5536d7fdF6c491CE158D2651d97", + "0x1aa4a66Ef0cfA99cA9D39FdAD2B05489744C972a", + "0x3150BdCdA1b41E0F2A550955839F6b2C723aD0B7" ] } diff --git a/packages/supplementary-contracts/script/blacklist/Deploy.sol b/packages/supplementary-contracts/script/blacklist/Deploy.sol index f3ce0ced2c0..67ee1c65a2a 100644 --- a/packages/supplementary-contracts/script/blacklist/Deploy.sol +++ b/packages/supplementary-contracts/script/blacklist/Deploy.sol @@ -9,25 +9,75 @@ import "../../contracts/blacklist/Blacklist.sol"; contract DeployBlacklist is Script { using stdJson for string; - function setUp() public { } + uint256 public chainId; + + string public lowercaseNetworkKey; + string public uppercaseNetworkKey; + string public jsonLocation; + + uint256 public deployerPrivateKey; + address public deployerAddress; + + function getPrivateKey() public view returns (uint256) { + string memory lookupKey = string.concat(uppercaseNetworkKey, "_PRIVATE_KEY"); + return vm.envUint(lookupKey); + } + + function getContractJsonLocation() public view returns (string memory) { + string memory root = vm.projectRoot(); + return string.concat(root, "/deployments/blacklist/", lowercaseNetworkKey, ".json"); + } + + function setUp() public { + // load all network configs + chainId = block.chainid; + + if (chainId == 31_337) { + lowercaseNetworkKey = "localhost"; + uppercaseNetworkKey = "LOCALHOST"; + } else if (chainId == 17_000) { + lowercaseNetworkKey = "holesky"; + uppercaseNetworkKey = "HOLESKY"; + } else if (chainId == 167_001) { + lowercaseNetworkKey = "devnet"; + uppercaseNetworkKey = "DEVNET"; + } else if (chainId == 11_155_111) { + lowercaseNetworkKey = "sepolia"; + uppercaseNetworkKey = "SEPOLIA"; + } else if (chainId == 167_008) { + lowercaseNetworkKey = "katla"; + uppercaseNetworkKey = "KATLA"; + } else if (chainId == 167_000) { + lowercaseNetworkKey = "mainnet"; + uppercaseNetworkKey = "MAINNET"; + } else if (chainId == 167_009) { + lowercaseNetworkKey = "hekla"; + uppercaseNetworkKey = "HEKLA"; + } else { + revert("Unsupported chainId"); + } + + deployerPrivateKey = getPrivateKey(); + deployerAddress = vm.addr(deployerPrivateKey); + jsonLocation = getContractJsonLocation(); + } function run() external { string memory path = "/script/blacklist/Deploy.data.json"; string memory json = vm.readFile(string.concat(vm.projectRoot(), path)); - // get admin address - bytes memory rawPortion = json.parseRaw(".admin"); - address admin = abi.decode(rawPortion, (address)); - // get updater address - rawPortion = json.parseRaw(".updater"); - address updater = abi.decode(rawPortion, (address)); // get initial blacklist - rawPortion = json.parseRaw(".blacklist"); + bytes memory rawPortion = json.parseRaw(".blacklist"); address[] memory blacklist = abi.decode(rawPortion, (address[])); - vm.startBroadcast(); + vm.startBroadcast(deployerPrivateKey); + + Blacklist target = new Blacklist(deployerAddress, deployerAddress, blacklist); + console2.log("Blacklist deployed to ", address(target)); + + string memory finalJson = vm.serializeAddress("", "Blacklist", address(target)); + vm.writeJson(finalJson, jsonLocation); - Blacklist target = new Blacklist(admin, updater, blacklist); - console2.log("Deployed!\n", address(target)); + vm.stopBroadcast(); } } From ec62b64d377308de9940da5d50186abc1c930470 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Wed, 16 Oct 2024 16:32:42 +0200 Subject: [PATCH 34/79] approvals, start, tampers fully tested on front --- .../TrailblazersBadges.sol | 19 --------- .../TrailblazersBadgesV3.sol | 2 +- .../TrailblazersBadgesS2.sol | 24 +++++++---- .../TrailblazersS1BadgesV4.sol | 41 +++++++++++++++++++ .../trailblazers-season-2/hekla.json | 4 +- .../script/trailblazers-season-2/Deploy.s.sol | 17 ++------ .../TraiblazersBadgesS2.t.sol | 4 +- .../test/util/TrailblazerBadgesS1MintTo.sol | 9 ++-- 8 files changed, 72 insertions(+), 48 deletions(-) create mode 100644 packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadges.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadges.sol index c0997ac36bd..7b55195d412 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadges.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadges.sol @@ -221,23 +221,4 @@ contract TrailblazersBadges is ERC721EnumerableUpgradeable, ECDSAWhitelist { return balances; } - - /// @notice V3 - - address public season2BadgeContract; - - error INVALID_S2_CONTRACT(); - - function setSeason2BadgeContract(address _season2BadgeContract) public onlyOwner { - season2BadgeContract = _season2BadgeContract; - } - - modifier onlySeason2BadgeContract() { - if (msg.sender != season2BadgeContract) revert INVALID_S2_CONTRACT(); - _; - } - - function burn(uint256 _tokenId) public onlySeason2BadgeContract { - _burn(_tokenId); - } } diff --git a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesV3.sol b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesV3.sol index 3d6c0e511ba..cae60cd6468 100644 --- a/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesV3.sol +++ b/packages/nfts/contracts/trailblazers-badges/TrailblazersBadgesV3.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.24; import "./TrailblazersBadges.sol"; contract TrailblazersBadgesV3 is TrailblazersBadges { - function version() external pure returns (string memory) { + function version() external pure virtual returns (string memory) { return "V3"; } diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol index 4a50a565a4e..5024af1ddb2 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol @@ -20,7 +20,7 @@ import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol" import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; -import "../trailblazers-badges/TrailblazersBadges.sol"; +import "./TrailblazersS1BadgesV4.sol"; import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; contract TrailblazersBadgesS2 is @@ -32,9 +32,9 @@ contract TrailblazersBadgesS2 is ERC721HolderUpgradeable { /// @notice Time between start and end of a migration - uint256 public constant COOLDOWN_MIGRATION = 6 hours; + uint256 public constant COOLDOWN_MIGRATION = 10 minutes; //6 hours; /// @notice Time between tamper attempts - uint256 public constant COOLDOWN_TAMPER = 1 hours; + uint256 public constant COOLDOWN_TAMPER = 1 minutes; // 1 hours; /// @notice Weight of tamper attempts, in % uint256 public constant TAMPER_WEIGHT_PERCENT = 5; /// @notice Maximum tamper attempts, per color @@ -74,7 +74,7 @@ contract TrailblazersBadgesS2 is /// @notice Migration-enabled badge IDs per cycle mapping(uint256 _cycle => mapping(uint256 _s1BadgeId => bool _enabled)) public enabledBadgeIds; /// @notice S1 Badge contract - TrailblazersBadges public badges; + TrailblazersBadgesV4 public badges; /// @notice Address authorized to sign the random seeds address public randomSigner; /// @notice Current migration cycle @@ -106,7 +106,12 @@ contract TrailblazersBadgesS2 is event MigrationStarted( address _user, uint256 _s1BadgeId, uint256 _s1TokenId, uint256 _cooldownExpiration ); - event MigrationTampered(address _user, bool _pinkOrPurple, uint256 _cooldownExpiration); + event MigrationTampered( + address indexed _user, + uint256 indexed _s1TokenId, + bool _pinkOrPurple, + uint256 _cooldownExpiration + ); event MigrationEnded(address _user, uint256 _s2BadgeId, uint256 _s2TokenId); /// @notice Modifiers @@ -150,7 +155,7 @@ contract TrailblazersBadgesS2 is _transferOwnership(_msgSender()); __Context_init(); _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); - badges = TrailblazersBadges(_badges); + badges = TrailblazersBadgesV4(_badges); randomSigner = _randomSigner; } @@ -200,7 +205,12 @@ contract TrailblazersBadgesS2 is migrationTampers[_msgSender()][_pinkOrPurple]++; tamperCooldowns[_msgSender()] = block.timestamp + COOLDOWN_TAMPER; - emit MigrationTampered(_msgSender(), _pinkOrPurple, tamperCooldowns[_msgSender()]); + emit MigrationTampered( + _msgSender(), + migrationS1TokenIds[_msgSender()], + _pinkOrPurple, + tamperCooldowns[_msgSender()] + ); } /// @notice Reset the tamper counts diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol new file mode 100644 index 00000000000..089d545a1d9 --- /dev/null +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import "../trailblazers-badges/TrailblazersBadgesV3.sol"; + +contract TrailblazersBadgesV4 is TrailblazersBadgesV3 { + function version() external pure virtual override returns (string memory) { + return "V4"; + } + + // disable blacklist block + function _update( + address to, + uint256 tokenId, + address auth + ) + internal + virtual + override + returns (address) + { + return super._update(to, tokenId, auth); + } + + address public season2BadgeContract; + + error INVALID_S2_CONTRACT(); + + function setSeason2BadgeContract(address _season2BadgeContract) public onlyOwner { + season2BadgeContract = _season2BadgeContract; + } + + modifier onlySeason2BadgeContract() { + if (msg.sender != season2BadgeContract) revert INVALID_S2_CONTRACT(); + _; + } + + function burn(uint256 _tokenId) public onlySeason2BadgeContract { + _burn(_tokenId); + } +} diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index afcda6fc072..4f78cfa3240 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,5 +1,5 @@ { "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x291ac81710b10BC9920De6aab3dEFDAbB1a852e6", - "TrailblazersBadgesS2": "0x230a20a477043A93067FF92B8909e0E4561Dd121" + "TrailblazersBadges": "0xc67eAc342a49D49b4D804966CF02e6653bC32826", + "TrailblazersBadgesS2": "0x57B7B94D05fB86001788CcFc4AC7211B4c8bf40E" } diff --git a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol index 1400d7e3ea9..13c5d8889a1 100644 --- a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol @@ -28,7 +28,8 @@ contract DeployS2Script is Script { "https://taikonfts.4everland.link/ipfs/bafybeiebmvj6roz4iuoinackb5c6eeshvppctkydrckqrnxexdnzh6odq4"; IMinimalBlacklist blacklist = IMinimalBlacklist(0xe61E9034b5633977eC98E302b33e321e8140F105); - address mintSigner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; + address claimMintSigner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; + address migrationSigner = 0x3cda4F2EaC3fc2FdE78B3DFFe1A1A1Eff88c68c5; // Hardhat Testnet Values // address owner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; @@ -72,7 +73,7 @@ contract DeployS2Script is Script { new ERC1967Proxy( impl, abi.encodeCall( - TrailblazersBadges.initialize, (owner, baseURI, mintSigner, blacklist) + TrailblazersBadges.initialize, (owner, baseURI, claimMintSigner, blacklist) ) ) ); @@ -85,7 +86,7 @@ contract DeployS2Script is Script { proxy = address( new ERC1967Proxy( impl, - abi.encodeCall(TrailblazersBadgesS2.initialize, (address(s1Token), mintSigner)) + abi.encodeCall(TrailblazersBadgesS2.initialize, (address(s1Token), migrationSigner)) ) ); @@ -101,16 +102,6 @@ contract DeployS2Script is Script { string memory finalJson = vm.serializeAddress(jsonRoot, "Owner", s2Token.owner()); vm.writeJson(finalJson, jsonLocation); - // open up migrations for all badges on hekla - if (block.chainid != 167_000) { - uint256[] memory tokenIds = new uint256[](8); - for (uint256 i = 0; i < tokenIds.length; i++) { - tokenIds[i] = i; - } - s2Token.enableMigrations(tokenIds); - console.log("Enabled migrations for all badges"); - } - vm.stopBroadcast(); } } diff --git a/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol index f19a1e11c95..1e17e541e18 100644 --- a/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol +++ b/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol @@ -62,7 +62,7 @@ contract TrailblazersBadgesS2Test is Test { s1Badges.upgradeToAndCall( address(new TrailblazerBadgesS1MintTo()), - abi.encodeCall(TrailblazerBadgesS1MintTo.version, ()) + abi.encodeCall(TrailblazerBadgesS1MintTo.call, ()) ); s1BadgesMock = TrailblazerBadgesS1MintTo(address(s1Badges)); @@ -82,7 +82,7 @@ contract TrailblazersBadgesS2Test is Test { s2Badges = TrailblazersBadgesS2(proxy); MAX_TAMPERS = s2Badges.MAX_TAMPERS(); - s1Badges.setSeason2BadgeContract(address(s2Badges)); + // s1Badges.setSeason2BadgeContract(address(s2Badges)); // enable migration for BADGE_ID uint256[] memory enabledBadgeIds = new uint256[](1); diff --git a/packages/nfts/test/util/TrailblazerBadgesS1MintTo.sol b/packages/nfts/test/util/TrailblazerBadgesS1MintTo.sol index 0504fdb19e4..27f3697fd7c 100644 --- a/packages/nfts/test/util/TrailblazerBadgesS1MintTo.sol +++ b/packages/nfts/test/util/TrailblazerBadgesS1MintTo.sol @@ -3,9 +3,10 @@ pragma solidity 0.8.24; import { Test } from "forge-std/src/Test.sol"; -import { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; +import { TrailblazersBadgesV4 } from + "../../contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol"; -contract TrailblazerBadgesS1MintTo is TrailblazersBadges { +contract TrailblazerBadgesS1MintTo is TrailblazersBadgesV4 { function mintTo(address _minter, uint256 _badgeId) public onlyOwner { if (_badgeId > BADGE_SHINTO) revert INVALID_BADGE_ID(); @@ -17,7 +18,7 @@ contract TrailblazerBadgesS1MintTo is TrailblazersBadges { emit BadgeCreated(tokenId, _minter, _badgeId); } - function version() public pure returns (string memory) { - return "mock"; + function call() public view returns (bool) { + return true; } } From df62c0ec3930f41779b6e6de0b178e39b795c25a Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 17 Oct 2024 12:14:35 +0200 Subject: [PATCH 35/79] working code; needs cleanup --- .../TrailblazersBadgesS2.sol | 6 +- .../trailblazers-season-2/hekla.json | 4 +- .../script/trailblazers-season-2/Deploy.s.sol | 19 ++- .../TraiblazersBadgesS2.t.sol | 154 ++++++++++-------- 4 files changed, 103 insertions(+), 80 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol index 5024af1ddb2..485683068ab 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol @@ -32,7 +32,7 @@ contract TrailblazersBadgesS2 is ERC721HolderUpgradeable { /// @notice Time between start and end of a migration - uint256 public constant COOLDOWN_MIGRATION = 10 minutes; //6 hours; + uint256 public constant COOLDOWN_MIGRATION = 1 minutes; //6 hours; /// @notice Time between tamper attempts uint256 public constant COOLDOWN_TAMPER = 1 minutes; // 1 hours; /// @notice Weight of tamper attempts, in % @@ -430,8 +430,8 @@ contract TrailblazersBadgesS2 is /// @param _user The user address /// @param _exp The users experience points /// @return _hash The unique hash - function generateClaimHash(address _user, uint256 _exp) public view returns (bytes32) { - return keccak256(abi.encodePacked(_user, claimCooldowns[_user], _exp)); + function generateClaimHash(address _user, uint256 _exp) public pure returns (bytes32) { + return keccak256(abi.encodePacked(_user, _exp)); } /// @notice Generates a random number from a signature diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index 4f78cfa3240..32bdd225bef 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,5 +1,5 @@ { "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0xc67eAc342a49D49b4D804966CF02e6653bC32826", - "TrailblazersBadgesS2": "0x57B7B94D05fB86001788CcFc4AC7211B4c8bf40E" + "TrailblazersBadges": "0x85B951A284C8928c1B5cA7c149969CBFb3818819", + "TrailblazersBadgesS2": "0x2406036c19e7D3eF6f256060f56dc91f3F5a57a6" } diff --git a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol index 13c5d8889a1..3827509fdc7 100644 --- a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol @@ -9,6 +9,8 @@ import { TrailblazersBadges } from "../../contracts/trailblazers-badges/Trailbla import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; import { TrailblazersBadgesS2 } from "../../contracts/trailblazers-season-2/TrailblazersBadgesS2.sol"; +import { TrailblazersBadgesV4 } from + "../../contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol"; contract DeployS2Script is Script { UtilsScript public utils; @@ -57,14 +59,14 @@ contract DeployS2Script is Script { address impl; address proxy; - TrailblazersBadges s1Token; + TrailblazersBadgesV4 s1Token; TrailblazersBadgesS2 s2Token; vm.startBroadcast(deployerPrivateKey); if (block.chainid == 167_000) { // mainnet, use existing contract - s1Token = TrailblazersBadges(s1Contract); + s1Token = TrailblazersBadgesV4(s1Contract); } else { // hekla/localhost, deploy a s1 contract impl = address(new TrailblazersBadges()); @@ -78,7 +80,15 @@ contract DeployS2Script is Script { ) ); - s1Token = TrailblazersBadges(proxy); + TrailblazersBadges s1TokenV2 = TrailblazersBadges(proxy); + + // upgrade s1 contract to v4 + s1TokenV2.upgradeToAndCall( + address(new TrailblazersBadgesV4()), + abi.encodeCall(TrailblazersBadgesV4.version, ()) + ); + + s1Token = TrailblazersBadgesV4(address(s1TokenV2)); } // deploy s2 contract @@ -95,6 +105,9 @@ contract DeployS2Script is Script { console.log("Token Base URI:", baseURI); console.log("Deployed TrailblazersBadgesS2 to:", address(s2Token)); + // assign the s2 contract to the s1 contract + s1Token.setSeason2BadgeContract(address(s2Token)); + console.log("Assigned TrailblazersBadgesS2 to TrailblazersBadgesV4"); // Register deployment vm.serializeAddress(jsonRoot, "TrailblazersBadges", address(s1Token)); diff --git a/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol index 1e17e541e18..96735d2724e 100644 --- a/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol +++ b/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol @@ -12,11 +12,14 @@ import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import { TrailblazersBadgesS2 } from "../../contracts/trailblazers-season-2/TrailblazersBadgesS2.sol"; import { TrailblazerBadgesS1MintTo } from "../util/TrailblazerBadgesS1MintTo.sol"; +import { TrailblazersBadgesV4 } from + "../../contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol"; contract TrailblazersBadgesS2Test is Test { UtilsScript public utils; - TrailblazersBadges public s1Badges; + TrailblazersBadges public s1BadgesV2; + TrailblazersBadgesV4 public s1BadgesV4; TrailblazersBadgesS2 public s2Badges; TrailblazerBadgesS1MintTo public s1BadgesMock; @@ -56,18 +59,25 @@ contract TrailblazersBadgesS2Test is Test { ) ); - s1Badges = TrailblazersBadges(proxy); + s1BadgesV2 = TrailblazersBadges(proxy); // upgrade s1 badges contract to use the mock version - s1Badges.upgradeToAndCall( + s1BadgesV2.upgradeToAndCall( address(new TrailblazerBadgesS1MintTo()), abi.encodeCall(TrailblazerBadgesS1MintTo.call, ()) ); - s1BadgesMock = TrailblazerBadgesS1MintTo(address(s1Badges)); + s1BadgesMock = TrailblazerBadgesS1MintTo(address(s1BadgesV2)); - BADGE_ID = s1Badges.BADGE_RAVERS(); + BADGE_ID = s1BadgesV2.BADGE_RAVERS(); + + // upgrade s1 contract to v4 + s1BadgesV2.upgradeToAndCall( + address(new TrailblazersBadgesV4()), abi.encodeCall(TrailblazersBadgesV4.version, ()) + ); + + s1BadgesV4 = TrailblazersBadgesV4(address(s1BadgesV2)); // deploy the s2 contract @@ -75,14 +85,14 @@ contract TrailblazersBadgesS2Test is Test { proxy = address( new ERC1967Proxy( impl, - abi.encodeCall(TrailblazersBadgesS2.initialize, (address(s1Badges), mintSigner)) + abi.encodeCall(TrailblazersBadgesS2.initialize, (address(s1BadgesV2), mintSigner)) ) ); s2Badges = TrailblazersBadgesS2(proxy); MAX_TAMPERS = s2Badges.MAX_TAMPERS(); - // s1Badges.setSeason2BadgeContract(address(s2Badges)); + s1BadgesV4.setSeason2BadgeContract(address(s2Badges)); // enable migration for BADGE_ID uint256[] memory enabledBadgeIds = new uint256[](1); @@ -93,14 +103,14 @@ contract TrailblazersBadgesS2Test is Test { } function test_s1_metadata_badges() public view { - assertEq(s1Badges.BADGE_RAVERS(), 0); - assertEq(s1Badges.BADGE_ROBOTS(), 1); - assertEq(s1Badges.BADGE_BOUNCERS(), 2); - assertEq(s1Badges.BADGE_MASTERS(), 3); - assertEq(s1Badges.BADGE_MONKS(), 4); - assertEq(s1Badges.BADGE_DRUMMERS(), 5); - assertEq(s1Badges.BADGE_ANDROIDS(), 6); - assertEq(s1Badges.BADGE_SHINTO(), 7); + assertEq(s1BadgesV2.BADGE_RAVERS(), 0); + assertEq(s1BadgesV2.BADGE_ROBOTS(), 1); + assertEq(s1BadgesV2.BADGE_BOUNCERS(), 2); + assertEq(s1BadgesV2.BADGE_MASTERS(), 3); + assertEq(s1BadgesV2.BADGE_MONKS(), 4); + assertEq(s1BadgesV2.BADGE_DRUMMERS(), 5); + assertEq(s1BadgesV2.BADGE_ANDROIDS(), 6); + assertEq(s1BadgesV2.BADGE_SHINTO(), 7); } function test_s2_metadata_badges() public view { @@ -123,122 +133,122 @@ contract TrailblazersBadgesS2Test is Test { } function test_s1_s2_badgeId_conversion() public view { - (uint256 pinkId, uint256 purpleId) = s2Badges.getSeason2BadgeIds(s1Badges.BADGE_RAVERS()); + (uint256 pinkId, uint256 purpleId) = s2Badges.getSeason2BadgeIds(s1BadgesV2.BADGE_RAVERS()); assertEq(pinkId, s2Badges.RAVER_PINK_ID()); assertEq(purpleId, s2Badges.RAVER_PURPLE_ID()); - (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1Badges.BADGE_ROBOTS()); + (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1BadgesV2.BADGE_ROBOTS()); assertEq(pinkId, s2Badges.ROBOT_PINK_ID()); assertEq(purpleId, s2Badges.ROBOT_PURPLE_ID()); - (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1Badges.BADGE_BOUNCERS()); + (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1BadgesV2.BADGE_BOUNCERS()); assertEq(pinkId, s2Badges.BOUNCER_PINK_ID()); assertEq(purpleId, s2Badges.BOUNCER_PURPLE_ID()); - (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1Badges.BADGE_MASTERS()); + (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1BadgesV2.BADGE_MASTERS()); assertEq(pinkId, s2Badges.MASTER_PINK_ID()); assertEq(purpleId, s2Badges.MASTER_PURPLE_ID()); - (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1Badges.BADGE_MONKS()); + (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1BadgesV2.BADGE_MONKS()); assertEq(pinkId, s2Badges.MONK_PINK_ID()); assertEq(purpleId, s2Badges.MONK_PURPLE_ID()); - (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1Badges.BADGE_DRUMMERS()); + (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1BadgesV2.BADGE_DRUMMERS()); assertEq(pinkId, s2Badges.DRUMMER_PINK_ID()); assertEq(purpleId, s2Badges.DRUMMER_PURPLE_ID()); - (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1Badges.BADGE_ANDROIDS()); + (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1BadgesV2.BADGE_ANDROIDS()); assertEq(pinkId, s2Badges.ANDROID_PINK_ID()); assertEq(purpleId, s2Badges.ANDROID_PURPLE_ID()); - (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1Badges.BADGE_SHINTO()); + (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1BadgesV2.BADGE_SHINTO()); assertEq(pinkId, s2Badges.SHINTO_PINK_ID()); assertEq(purpleId, s2Badges.SHINTO_PURPLE_ID()); } function test_s2_s1_badgeId_conversion() public view { uint256 s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.RAVER_PINK_ID()); - assertEq(s1BadgeId, s1Badges.BADGE_RAVERS()); + assertEq(s1BadgeId, s1BadgesV2.BADGE_RAVERS()); s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.RAVER_PURPLE_ID()); - assertEq(s1BadgeId, s1Badges.BADGE_RAVERS()); + assertEq(s1BadgeId, s1BadgesV2.BADGE_RAVERS()); s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.ROBOT_PINK_ID()); - assertEq(s1BadgeId, s1Badges.BADGE_ROBOTS()); + assertEq(s1BadgeId, s1BadgesV2.BADGE_ROBOTS()); s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.ROBOT_PURPLE_ID()); - assertEq(s1BadgeId, s1Badges.BADGE_ROBOTS()); + assertEq(s1BadgeId, s1BadgesV2.BADGE_ROBOTS()); s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.BOUNCER_PINK_ID()); - assertEq(s1BadgeId, s1Badges.BADGE_BOUNCERS()); + assertEq(s1BadgeId, s1BadgesV2.BADGE_BOUNCERS()); s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.BOUNCER_PURPLE_ID()); - assertEq(s1BadgeId, s1Badges.BADGE_BOUNCERS()); + assertEq(s1BadgeId, s1BadgesV2.BADGE_BOUNCERS()); s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.MASTER_PINK_ID()); - assertEq(s1BadgeId, s1Badges.BADGE_MASTERS()); + assertEq(s1BadgeId, s1BadgesV2.BADGE_MASTERS()); s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.MASTER_PURPLE_ID()); - assertEq(s1BadgeId, s1Badges.BADGE_MASTERS()); + assertEq(s1BadgeId, s1BadgesV2.BADGE_MASTERS()); s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.MONK_PINK_ID()); - assertEq(s1BadgeId, s1Badges.BADGE_MONKS()); + assertEq(s1BadgeId, s1BadgesV2.BADGE_MONKS()); s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.MONK_PURPLE_ID()); - assertEq(s1BadgeId, s1Badges.BADGE_MONKS()); + assertEq(s1BadgeId, s1BadgesV2.BADGE_MONKS()); s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.DRUMMER_PINK_ID()); - assertEq(s1BadgeId, s1Badges.BADGE_DRUMMERS()); + assertEq(s1BadgeId, s1BadgesV2.BADGE_DRUMMERS()); s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.DRUMMER_PURPLE_ID()); - assertEq(s1BadgeId, s1Badges.BADGE_DRUMMERS()); + assertEq(s1BadgeId, s1BadgesV2.BADGE_DRUMMERS()); s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.ANDROID_PINK_ID()); - assertEq(s1BadgeId, s1Badges.BADGE_ANDROIDS()); + assertEq(s1BadgeId, s1BadgesV2.BADGE_ANDROIDS()); s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.ANDROID_PURPLE_ID()); - assertEq(s1BadgeId, s1Badges.BADGE_ANDROIDS()); + assertEq(s1BadgeId, s1BadgesV2.BADGE_ANDROIDS()); s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.SHINTO_PINK_ID()); - assertEq(s1BadgeId, s1Badges.BADGE_SHINTO()); + assertEq(s1BadgeId, s1BadgesV2.BADGE_SHINTO()); s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.SHINTO_PURPLE_ID()); - assertEq(s1BadgeId, s1Badges.BADGE_SHINTO()); + assertEq(s1BadgeId, s1BadgesV2.BADGE_SHINTO()); } function mint_s1(address minter, uint256 badgeId) public { - bytes32 _hash = s1Badges.getHash(minter, badgeId); + bytes32 _hash = s1BadgesV2.getHash(minter, badgeId); (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); - bool canMint = s1Badges.canMint(abi.encodePacked(r, s, v), minter, badgeId); + bool canMint = s1BadgesV2.canMint(abi.encodePacked(r, s, v), minter, badgeId); assertTrue(canMint); vm.startPrank(minter); - s1Badges.mint(abi.encodePacked(r, s, v), badgeId); + s1BadgesV2.mint(abi.encodePacked(r, s, v), badgeId); vm.stopPrank(); } function test_mint_s1() public { - mint_s1(minters[0], s1Badges.BADGE_RAVERS()); - mint_s1(minters[0], s1Badges.BADGE_ROBOTS()); - assertEq(s1Badges.balanceOf(minters[0]), 2); + mint_s1(minters[0], s1BadgesV2.BADGE_RAVERS()); + mint_s1(minters[0], s1BadgesV2.BADGE_ROBOTS()); + assertEq(s1BadgesV2.balanceOf(minters[0]), 2); - mint_s1(minters[1], s1Badges.BADGE_BOUNCERS()); - mint_s1(minters[1], s1Badges.BADGE_MASTERS()); - assertEq(s1Badges.balanceOf(minters[1]), 2); + mint_s1(minters[1], s1BadgesV2.BADGE_BOUNCERS()); + mint_s1(minters[1], s1BadgesV2.BADGE_MASTERS()); + assertEq(s1BadgesV2.balanceOf(minters[1]), 2); - mint_s1(minters[2], s1Badges.BADGE_MONKS()); - mint_s1(minters[2], s1Badges.BADGE_DRUMMERS()); - assertEq(s1Badges.balanceOf(minters[2]), 2); + mint_s1(minters[2], s1BadgesV2.BADGE_MONKS()); + mint_s1(minters[2], s1BadgesV2.BADGE_DRUMMERS()); + assertEq(s1BadgesV2.balanceOf(minters[2]), 2); } function test_startMigration() public { mint_s1(minters[0], BADGE_ID); - uint256 tokenId = s1Badges.tokenOfOwnerByIndex(minters[0], 0); + uint256 tokenId = s1BadgesV2.tokenOfOwnerByIndex(minters[0], 0); vm.startPrank(minters[0]); - s1Badges.approve(address(s2Badges), tokenId); + s1BadgesV2.approve(address(s2Badges), tokenId); s2Badges.startMigration(BADGE_ID); vm.stopPrank(); - assertEq(s1Badges.balanceOf(minters[0]), 0); - assertEq(s1Badges.balanceOf(address(s2Badges)), 1); + assertEq(s1BadgesV2.balanceOf(minters[0]), 0); + assertEq(s1BadgesV2.balanceOf(address(s2Badges)), 1); - assertEq(s1Badges.ownerOf(tokenId), address(s2Badges)); + assertEq(s1BadgesV2.ownerOf(tokenId), address(s2Badges)); assertEq(s2Badges.isMigrationActive(minters[0]), true); } @@ -331,8 +341,8 @@ contract TrailblazersBadgesS2Test is Test { vm.stopPrank(); // check for s1 burn - assertEq(s1Badges.balanceOf(minters[0]), 0); - assertEq(s1Badges.balanceOf(address(s2Badges)), 0); + assertEq(s1BadgesV2.balanceOf(minters[0]), 0); + assertEq(s1BadgesV2.balanceOf(address(s2Badges)), 0); // check for s2 state reset assertEq(s2Badges.isMigrationActive(minters[0]), false); @@ -377,20 +387,20 @@ contract TrailblazersBadgesS2Test is Test { } function test_revert_migrateDisabled() public { - uint256 badgeId = s1Badges.BADGE_ROBOTS(); + uint256 badgeId = s1BadgesV2.BADGE_ROBOTS(); mint_s1(minters[0], badgeId); - uint256 tokenId = s1Badges.tokenOfOwnerByIndex(minters[0], 0); + uint256 tokenId = s1BadgesV2.tokenOfOwnerByIndex(minters[0], 0); vm.startPrank(minters[0]); - s1Badges.approve(address(s2Badges), tokenId); + s1BadgesV2.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(s1BadgesV2.balanceOf(minters[0]), 1); + assertEq(s1BadgesV2.balanceOf(address(s2Badges)), 0); + assertEq(s1BadgesV2.ownerOf(tokenId), minters[0]); assertEq(s2Badges.isMigrationActive(minters[0]), false); } @@ -403,17 +413,17 @@ contract TrailblazersBadgesS2Test is Test { mint_s1(minters[0], BADGE_ID); - uint256 tokenId = s1Badges.tokenOfOwnerByIndex(minters[0], 0); + uint256 tokenId = s1BadgesV2.tokenOfOwnerByIndex(minters[0], 0); vm.startPrank(minters[0]); - s1Badges.approve(address(s2Badges), tokenId); + s1BadgesV2.approve(address(s2Badges), tokenId); vm.expectRevert(); s2Badges.startMigration(BADGE_ID); 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(s1BadgesV2.balanceOf(minters[0]), 1); + assertEq(s1BadgesV2.balanceOf(address(s2Badges)), 0); + assertEq(s1BadgesV2.ownerOf(tokenId), minters[0]); assertEq(s2Badges.isMigrationActive(minters[0]), false); } @@ -434,7 +444,7 @@ contract TrailblazersBadgesS2Test is Test { 28_417_844_340_632_250_945_870_465_294_567_768_196_388_504_060_802_704_441_612_911_129_119_444_309_664 ); } - + /* function test_migrateSameBadgeId_revert() public { // run a first migration test_endMigration(); @@ -445,9 +455,9 @@ contract TrailblazersBadgesS2Test is Test { // fail the second migration for that badge vm.startPrank(minters[0]); - s1Badges.approve(address(s2Badges), s1Badges.tokenOfOwnerByIndex(minters[0], 0)); + s1BadgesV2.approve(address(s2Badges), s1BadgesV2.tokenOfOwnerByIndex(minters[0], 0)); vm.expectRevert(); s2Badges.startMigration(BADGE_ID); vm.stopPrank(); - } + }*/ } From 7d536853acb8f5127807541e602d72d226bb195f Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 17 Oct 2024 12:16:30 +0200 Subject: [PATCH 36/79] safekeep commit before refactors --- .../trailblazers-season-2/BadgeMigration.sol | 0 .../TrailblazersBadgesS2.sol | 474 +----------------- .../trailblazers-season-2/original.sol | 473 +++++++++++++++++ 3 files changed, 474 insertions(+), 473 deletions(-) create mode 100644 packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol create mode 100644 packages/nfts/contracts/trailblazers-season-2/original.sol diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol index 485683068ab..34b80bc8467 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol @@ -1,473 +1 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.24; - -import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol"; -import "../trailblazers-badges/ECDSAWhitelist.sol"; -import "@taiko/blacklist/IMinimalBlacklist.sol"; -import "@openzeppelin/contracts/utils/Strings.sol"; -import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; -import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; -import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; -import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; -import "@openzeppelin/contracts/access/AccessControl.sol"; -import "@openzeppelin/contracts/utils/Strings.sol"; -import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; -import "./TrailblazersS1BadgesV4.sol"; -import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; - -contract TrailblazersBadgesS2 is - PausableUpgradeable, - UUPSUpgradeable, - Ownable2StepUpgradeable, - AccessControlUpgradeable, - ERC1155SupplyUpgradeable, - ERC721HolderUpgradeable -{ - /// @notice Time between start and end of a migration - uint256 public constant COOLDOWN_MIGRATION = 1 minutes; //6 hours; - /// @notice Time between tamper attempts - uint256 public constant COOLDOWN_TAMPER = 1 minutes; // 1 hours; - /// @notice Weight of tamper attempts, in % - uint256 public constant TAMPER_WEIGHT_PERCENT = 5; - /// @notice Maximum tamper attempts, per color - uint256 public constant MAX_TAMPERS = 3; - /// @notice S2 Badge IDs - uint256 public constant RAVER_PINK_ID = 0; - uint256 public constant RAVER_PURPLE_ID = 1; - uint256 public constant ROBOT_PINK_ID = 2; - uint256 public constant ROBOT_PURPLE_ID = 3; - uint256 public constant BOUNCER_PINK_ID = 4; - uint256 public constant BOUNCER_PURPLE_ID = 5; - uint256 public constant MASTER_PINK_ID = 6; - uint256 public constant MASTER_PURPLE_ID = 7; - uint256 public constant MONK_PINK_ID = 8; - uint256 public constant MONK_PURPLE_ID = 9; - uint256 public constant DRUMMER_PINK_ID = 10; - uint256 public constant DRUMMER_PURPLE_ID = 11; - uint256 public constant ANDROID_PINK_ID = 12; - uint256 public constant ANDROID_PURPLE_ID = 13; - uint256 public constant SHINTO_PINK_ID = 14; - uint256 public constant SHINTO_PURPLE_ID = 15; - /// @notice Total badge count - uint256 public constant BADGE_COUNT = 16; - - /// @notice Cooldown for migration - mapping(address _user => uint256 _cooldown) public claimCooldowns; - /// @notice Cooldown for tampering - mapping(address _user => uint256 _cooldown) public tamperCooldowns; - /// @notice Tamper count - mapping(address _user => mapping(bool pinkOrPurple => uint256 _tampers)) public migrationTampers; - /// @notice S1 Migration Badge ID mapping - mapping(address _user => uint256 _badgeId) private migrationS1BadgeIds; - /// @notice S1 Migration Token ID mapping - mapping(address _user => uint256 _tokenId) private migrationS1TokenIds; - /// @notice User to badge ID, token ID mapping - mapping(address _user => mapping(uint256 _badgeId => uint256 _tokenId)) public userBadges; - /// @notice Migration-enabled badge IDs per cycle - mapping(uint256 _cycle => mapping(uint256 _s1BadgeId => bool _enabled)) public enabledBadgeIds; - /// @notice S1 Badge contract - TrailblazersBadgesV4 public badges; - /// @notice Address authorized to sign the random seeds - address public randomSigner; - /// @notice Current migration cycle - uint256 public migrationCycle; - /// @notice Mapping of unique user-per-mint-per-cycle - mapping( - uint256 _migrationCycle - => mapping(address _minter => mapping(uint256 _s1BadgeId => bool _mintEnded)) - ) public migrationCycleUniqueMints; - /// @notice Gap for upgrade safety - uint256[43] private __gap; - - /// @notice Errors - error MAX_TAMPERS_REACHED(); - error MIGRATION_NOT_STARTED(); - error MIGRATION_ALREADY_STARTED(); - error TAMPER_IN_PROGRESS(); - error CONTRACT_PAUSED(); - error MIGRATION_NOT_READY(); - error TOKEN_NOT_MINTED(); - error MIGRATION_NOT_ENABLED(); - error TOKEN_NOT_OWNED(); - error NOT_RANDOM_SIGNER(); - error ALREADY_MIGRATED_IN_CYCLE(); - error HASH_MISMATCH(); - - /// @notice Events - event MigrationToggled(uint256 indexed _migrationCycleId, uint256 _s1BadgeId, bool _enabled); - event MigrationStarted( - address _user, uint256 _s1BadgeId, uint256 _s1TokenId, uint256 _cooldownExpiration - ); - event MigrationTampered( - address indexed _user, - uint256 indexed _s1TokenId, - bool _pinkOrPurple, - uint256 _cooldownExpiration - ); - event MigrationEnded(address _user, uint256 _s2BadgeId, uint256 _s2TokenId); - - /// @notice Modifiers - modifier isMigrating() { - if (claimCooldowns[_msgSender()] == 0) { - revert MIGRATION_NOT_STARTED(); - } - _; - } - - /// @notice Reverts if sender is already migrating - modifier isNotMigrating() { - if (claimCooldowns[_msgSender()] != 0) { - revert MIGRATION_ALREADY_STARTED(); - } - _; - } - - /// @notice Reverts if migrations aren't enabled for that badge - modifier migrationOpen(uint256 _s1BadgeId) { - if (!enabledBadgeIds[migrationCycle][_s1BadgeId]) { - revert MIGRATION_NOT_ENABLED(); - } - _; - } - - /// @notice Limits migrations to one per user, badge and cycle - modifier hasntMigratedInCycle(uint256 _s1BadgeId, address _minter) { - // check that the minter hasn't used the migration within this cycle - if (migrationCycleUniqueMints[migrationCycle][_minter][_s1BadgeId]) { - revert ALREADY_MIGRATED_IN_CYCLE(); - } - _; - } - - /// @notice Contract initializer - /// @param _badges The address of the S1 badges contract - function initialize(address _badges, address _randomSigner) external initializer { - __ERC1155_init(""); - __ERC1155Supply_init(); - _transferOwnership(_msgSender()); - __Context_init(); - _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); - badges = TrailblazersBadgesV4(_badges); - randomSigner = _randomSigner; - } - - /// @notice Start a migration for a badge - /// @param _s1BadgeId The badge ID (s1) - /// @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 - migrationOpen(_s1BadgeId) - isNotMigrating - hasntMigratedInCycle(_s1BadgeId, _msgSender()) - { - uint256 s1TokenId = badges.getTokenId(_msgSender(), _s1BadgeId); - - if (badges.ownerOf(s1TokenId) != _msgSender()) { - revert TOKEN_NOT_OWNED(); - } - - // set off the claim cooldown - claimCooldowns[_msgSender()] = block.timestamp + COOLDOWN_MIGRATION; - migrationTampers[_msgSender()][true] = 0; - migrationTampers[_msgSender()][false] = 0; - migrationS1BadgeIds[_msgSender()] = _s1BadgeId; - migrationS1TokenIds[_msgSender()] = s1TokenId; - tamperCooldowns[_msgSender()] = 0; - // transfer the badge tokens to the migration contract - badges.transferFrom(_msgSender(), address(this), s1TokenId); - - emit MigrationStarted(_msgSender(), _s1BadgeId, s1TokenId, claimCooldowns[_msgSender()]); - } - - /// @notice Tamper (alter) the chances during a migration - /// @param _pinkOrPurple true for pink, false for purple - /// @dev Can be called only during an active migration - /// @dev Implements a cooldown before allowing to re-tamper - /// @dev The max tamper amount is determined by Pass Tier - function tamperMigration(bool _pinkOrPurple) external isMigrating { - if (migrationTampers[_msgSender()][_pinkOrPurple] >= MAX_TAMPERS) { - revert MAX_TAMPERS_REACHED(); - } - - if (tamperCooldowns[_msgSender()] > block.timestamp) { - revert TAMPER_IN_PROGRESS(); - } - - migrationTampers[_msgSender()][_pinkOrPurple]++; - tamperCooldowns[_msgSender()] = block.timestamp + COOLDOWN_TAMPER; - emit MigrationTampered( - _msgSender(), - migrationS1TokenIds[_msgSender()], - _pinkOrPurple, - tamperCooldowns[_msgSender()] - ); - } - - /// @notice Reset the tamper counts - /// @dev Can be called only during an active migration - function resetTampers() external isMigrating { - migrationTampers[_msgSender()][true] = 0; - migrationTampers[_msgSender()][false] = 0; - tamperCooldowns[_msgSender()] = 0; - } - - /// @notice End a migration - /// @param _hash The hash to sign - /// @param v signature V field - /// @param r signature R field - /// @param s signature S field - /// @param exp The user's experience points - /// @dev Can be called only during an active migration, after the cooldown is over - /// @dev The final color is determined randomly, and affected by the tamper amounts - function endMigration( - bytes32 _hash, - uint8 v, - bytes32 r, - bytes32 s, - uint256 exp - ) - external - isMigrating - { - if (tamperCooldowns[_msgSender()] > block.timestamp) { - revert TAMPER_IN_PROGRESS(); - } - // check if the cooldown is over - if (claimCooldowns[_msgSender()] > block.timestamp) { - revert MIGRATION_NOT_READY(); - } - - // ensure the hash corresponds to the start time - bytes32 calculatedHash = generateClaimHash(_msgSender(), exp); - - if (calculatedHash != _hash) { - revert HASH_MISMATCH(); - } - - // get the tamper amounts - uint256 pinkTampers = migrationTampers[_msgSender()][true]; - uint256 purpleTampers = migrationTampers[_msgSender()][false]; - - uint256 randomSeed = randomFromSignature(_hash, v, r, s); - bool isPinkOrPurple; - // Calculate the difference in tampers and adjust chances - if (pinkTampers > purpleTampers) { - uint256 extraChance = (pinkTampers - purpleTampers) * TAMPER_WEIGHT_PERCENT; - uint256 chance = 50 + extraChance; // Base 50% + extra chance - isPinkOrPurple = (randomSeed % 100) < chance; // True for pink - } else if (purpleTampers > pinkTampers) { - uint256 extraChance = (purpleTampers - pinkTampers) * TAMPER_WEIGHT_PERCENT; - uint256 chance = 50 + extraChance; // Base 50% + extra chance - isPinkOrPurple = (randomSeed % 100) >= chance; // False for purple - } else { - // Equal number of pink and purple tampers, 50/50 chance - isPinkOrPurple = (randomSeed % 100) < 50; - } - - uint256 s1BadgeId = migrationS1BadgeIds[_msgSender()]; - (uint256 pinkBadgeId, uint256 purpleBadgeId) = getSeason2BadgeIds(s1BadgeId); - uint256 s2BadgeId = isPinkOrPurple ? pinkBadgeId : purpleBadgeId; - - // burn the s1 badge - uint256 s1TokenId = migrationS1TokenIds[_msgSender()]; - badges.burn(s1TokenId); - - uint256 s2TokenId = totalSupply() + 1; - // mint the badge - _mint(_msgSender(), s2TokenId, 1, ""); - - // reset the cooldowns - claimCooldowns[_msgSender()] = 0; - migrationTampers[_msgSender()][true] = 0; - migrationTampers[_msgSender()][false] = 0; - tamperCooldowns[_msgSender()] = 0; - migrationS1BadgeIds[_msgSender()] = 0; - migrationS1TokenIds[_msgSender()] = 0; - userBadges[_msgSender()][s2BadgeId] = s2TokenId; - migrationCycleUniqueMints[migrationCycle][_msgSender()][s1BadgeId] = true; - emit MigrationEnded(_msgSender(), s2BadgeId, s2TokenId); - } - - /// @notice Enable migrations for a set of badges - /// @param _s1BadgeIds The badge IDs to enable - /// @dev Can be called only by the contract owner/admin - function enableMigrations(uint256[] calldata _s1BadgeIds) - external - onlyRole(DEFAULT_ADMIN_ROLE) - { - migrationCycle++; - for (uint256 i = 0; i < _s1BadgeIds.length; i++) { - enabledBadgeIds[migrationCycle][_s1BadgeIds[i]] = true; - emit MigrationToggled(migrationCycle, _s1BadgeIds[i], true); - } - } - - /// @notice Check if the migrations for a badge are enabled - /// @param _s1Badge The badge ID to check - /// @return Whether the badge is enabled for migration - function canMigrate(uint256 _s1Badge) public view returns (bool) { - for (uint256 i = 0; i < 8; i++) { - if (enabledBadgeIds[migrationCycle][i] && i == _s1Badge) { - return true; - } - } - return false; - } - - /// @notice Pause the contract - /// @dev Can be called only by the contract owner/admin - function pause() public onlyRole(DEFAULT_ADMIN_ROLE) { - _disableMigrations(); - _pause(); - } - - /// @notice S1 --> S2 badge ID mapping - /// @param _s1BadgeId The S1 badge ID - /// @return _pinkBadgeId The S2 pink badge ID - /// @return _purpleBadgeId The S2 purple badge ID - function getSeason2BadgeIds(uint256 _s1BadgeId) - public - pure - returns (uint256 _pinkBadgeId, uint256 _purpleBadgeId) - { - return (_s1BadgeId * 2, _s1BadgeId * 2 + 1); - } - - /// @notice S2 --> S1 badge ID mapping - /// @param _s2BadgeId The S2 badge ID - /// @return _s1BadgeId The S1 badge ID - function getSeason1BadgeId(uint256 _s2BadgeId) public pure returns (uint256 _s1BadgeId) { - return _s2BadgeId / 2; - } - - /// @notice Check if a migration is active for a user - /// @param _user The user address - /// @return Whether the user has an active migration - function isMigrationActive(address _user) public view returns (bool) { - return claimCooldowns[_user] != 0; - } - - /// @notice Check if a tamper is active for a user - /// @param _user The user address - /// @return Whether the user has an active tamper - function isTamperActive(address _user) public view returns (bool) { - return tamperCooldowns[_user] > block.timestamp; - } - - /// @notice Get the migration tamper counts for a user - /// @param _user The user address - /// @return _pinkTampers The pink tamper count - /// @return _purpleTampers The purple tamper count - function getMigrationTampers(address _user) - public - view - returns (uint256 _pinkTampers, uint256 _purpleTampers) - { - if (!isMigrationActive(_user)) { - revert MIGRATION_NOT_STARTED(); - } - return (migrationTampers[_user][true], migrationTampers[_user][false]); - } - - /// @notice Retrieve a token ID given their owner and S2 Badge ID - /// @param _user The address of the badge owner - /// @param _s2BadgeId The S2 badge ID - /// @return _tokenId The token ID - function getTokenId(address _user, uint256 _s2BadgeId) public view returns (uint256 _tokenId) { - return userBadges[_user][_s2BadgeId]; - } - - /// @notice Retrieve boolean balance for each badge - /// @param _owner The addresses to check - /// @return _balances The badges atomic balances - function badgeBalances(address _owner) public view returns (bool[16] memory _balances) { - for (uint256 i = 0; i < BADGE_COUNT; i++) { - uint256 tokenId = getTokenId(_owner, i); - _balances[i] = tokenId > 0; - } - - return _balances; - } - - /// @notice Retrieve the total S2 unique badge balance of an address - /// @param _owner The address to check - /// @return _balance The total badge balance (count) - function badgeBalanceOf(address _owner) public view returns (uint256 _balance) { - bool[16] memory balances = badgeBalances(_owner); - - for (uint256 i = 0; i < balances.length; i++) { - if (balances[i]) { - _balance++; - } - } - - return _balance; - } - - /// @notice Disable all new migrations - /// @dev Doesn't allow for new migration attempts, but tampers and active migrations still run - function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) { - for (uint256 i = 0; i < 8; i++) { - if (enabledBadgeIds[migrationCycle][i]) { - emit MigrationToggled(migrationCycle, i, false); - } - - enabledBadgeIds[migrationCycle][i] = false; - } - } - - /// @notice Generate a unique hash for each migration uniquely - /// @param _user The user address - /// @param _exp The users experience points - /// @return _hash The unique hash - function generateClaimHash(address _user, uint256 _exp) public pure returns (bytes32) { - return keccak256(abi.encodePacked(_user, _exp)); - } - - /// @notice Generates a random number from a signature - /// @param _hash The hash to sign (keccak256(startMigrationBlockHash, _msgSender())) - /// @param v signature V field - /// @param r signature R field - /// @param s signature S field - /// @return _random The pseudo-random number - function randomFromSignature( - bytes32 _hash, - uint8 v, - bytes32 r, - bytes32 s - ) - public - view - returns (uint256 _random) - { - (address _recovered,,) = ECDSA.tryRecover(_hash, v, r, s); - if (_recovered != randomSigner) revert NOT_RANDOM_SIGNER(); - // Hash the signature parts to get a deterministic pseudo-random number - return uint256(keccak256(abi.encodePacked(r, s, v))); - } - - /// @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 { } -} +// code for the erc1155 token diff --git a/packages/nfts/contracts/trailblazers-season-2/original.sol b/packages/nfts/contracts/trailblazers-season-2/original.sol new file mode 100644 index 00000000000..485683068ab --- /dev/null +++ b/packages/nfts/contracts/trailblazers-season-2/original.sol @@ -0,0 +1,473 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol"; +import "../trailblazers-badges/ECDSAWhitelist.sol"; +import "@taiko/blacklist/IMinimalBlacklist.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; +import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; +import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; +import "@openzeppelin/contracts/access/AccessControl.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; +import "./TrailblazersS1BadgesV4.sol"; +import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; + +contract TrailblazersBadgesS2 is + PausableUpgradeable, + UUPSUpgradeable, + Ownable2StepUpgradeable, + AccessControlUpgradeable, + ERC1155SupplyUpgradeable, + ERC721HolderUpgradeable +{ + /// @notice Time between start and end of a migration + uint256 public constant COOLDOWN_MIGRATION = 1 minutes; //6 hours; + /// @notice Time between tamper attempts + uint256 public constant COOLDOWN_TAMPER = 1 minutes; // 1 hours; + /// @notice Weight of tamper attempts, in % + uint256 public constant TAMPER_WEIGHT_PERCENT = 5; + /// @notice Maximum tamper attempts, per color + uint256 public constant MAX_TAMPERS = 3; + /// @notice S2 Badge IDs + uint256 public constant RAVER_PINK_ID = 0; + uint256 public constant RAVER_PURPLE_ID = 1; + uint256 public constant ROBOT_PINK_ID = 2; + uint256 public constant ROBOT_PURPLE_ID = 3; + uint256 public constant BOUNCER_PINK_ID = 4; + uint256 public constant BOUNCER_PURPLE_ID = 5; + uint256 public constant MASTER_PINK_ID = 6; + uint256 public constant MASTER_PURPLE_ID = 7; + uint256 public constant MONK_PINK_ID = 8; + uint256 public constant MONK_PURPLE_ID = 9; + uint256 public constant DRUMMER_PINK_ID = 10; + uint256 public constant DRUMMER_PURPLE_ID = 11; + uint256 public constant ANDROID_PINK_ID = 12; + uint256 public constant ANDROID_PURPLE_ID = 13; + uint256 public constant SHINTO_PINK_ID = 14; + uint256 public constant SHINTO_PURPLE_ID = 15; + /// @notice Total badge count + uint256 public constant BADGE_COUNT = 16; + + /// @notice Cooldown for migration + mapping(address _user => uint256 _cooldown) public claimCooldowns; + /// @notice Cooldown for tampering + mapping(address _user => uint256 _cooldown) public tamperCooldowns; + /// @notice Tamper count + mapping(address _user => mapping(bool pinkOrPurple => uint256 _tampers)) public migrationTampers; + /// @notice S1 Migration Badge ID mapping + mapping(address _user => uint256 _badgeId) private migrationS1BadgeIds; + /// @notice S1 Migration Token ID mapping + mapping(address _user => uint256 _tokenId) private migrationS1TokenIds; + /// @notice User to badge ID, token ID mapping + mapping(address _user => mapping(uint256 _badgeId => uint256 _tokenId)) public userBadges; + /// @notice Migration-enabled badge IDs per cycle + mapping(uint256 _cycle => mapping(uint256 _s1BadgeId => bool _enabled)) public enabledBadgeIds; + /// @notice S1 Badge contract + TrailblazersBadgesV4 public badges; + /// @notice Address authorized to sign the random seeds + address public randomSigner; + /// @notice Current migration cycle + uint256 public migrationCycle; + /// @notice Mapping of unique user-per-mint-per-cycle + mapping( + uint256 _migrationCycle + => mapping(address _minter => mapping(uint256 _s1BadgeId => bool _mintEnded)) + ) public migrationCycleUniqueMints; + /// @notice Gap for upgrade safety + uint256[43] private __gap; + + /// @notice Errors + error MAX_TAMPERS_REACHED(); + error MIGRATION_NOT_STARTED(); + error MIGRATION_ALREADY_STARTED(); + error TAMPER_IN_PROGRESS(); + error CONTRACT_PAUSED(); + error MIGRATION_NOT_READY(); + error TOKEN_NOT_MINTED(); + error MIGRATION_NOT_ENABLED(); + error TOKEN_NOT_OWNED(); + error NOT_RANDOM_SIGNER(); + error ALREADY_MIGRATED_IN_CYCLE(); + error HASH_MISMATCH(); + + /// @notice Events + event MigrationToggled(uint256 indexed _migrationCycleId, uint256 _s1BadgeId, bool _enabled); + event MigrationStarted( + address _user, uint256 _s1BadgeId, uint256 _s1TokenId, uint256 _cooldownExpiration + ); + event MigrationTampered( + address indexed _user, + uint256 indexed _s1TokenId, + bool _pinkOrPurple, + uint256 _cooldownExpiration + ); + event MigrationEnded(address _user, uint256 _s2BadgeId, uint256 _s2TokenId); + + /// @notice Modifiers + modifier isMigrating() { + if (claimCooldowns[_msgSender()] == 0) { + revert MIGRATION_NOT_STARTED(); + } + _; + } + + /// @notice Reverts if sender is already migrating + modifier isNotMigrating() { + if (claimCooldowns[_msgSender()] != 0) { + revert MIGRATION_ALREADY_STARTED(); + } + _; + } + + /// @notice Reverts if migrations aren't enabled for that badge + modifier migrationOpen(uint256 _s1BadgeId) { + if (!enabledBadgeIds[migrationCycle][_s1BadgeId]) { + revert MIGRATION_NOT_ENABLED(); + } + _; + } + + /// @notice Limits migrations to one per user, badge and cycle + modifier hasntMigratedInCycle(uint256 _s1BadgeId, address _minter) { + // check that the minter hasn't used the migration within this cycle + if (migrationCycleUniqueMints[migrationCycle][_minter][_s1BadgeId]) { + revert ALREADY_MIGRATED_IN_CYCLE(); + } + _; + } + + /// @notice Contract initializer + /// @param _badges The address of the S1 badges contract + function initialize(address _badges, address _randomSigner) external initializer { + __ERC1155_init(""); + __ERC1155Supply_init(); + _transferOwnership(_msgSender()); + __Context_init(); + _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); + badges = TrailblazersBadgesV4(_badges); + randomSigner = _randomSigner; + } + + /// @notice Start a migration for a badge + /// @param _s1BadgeId The badge ID (s1) + /// @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 + migrationOpen(_s1BadgeId) + isNotMigrating + hasntMigratedInCycle(_s1BadgeId, _msgSender()) + { + uint256 s1TokenId = badges.getTokenId(_msgSender(), _s1BadgeId); + + if (badges.ownerOf(s1TokenId) != _msgSender()) { + revert TOKEN_NOT_OWNED(); + } + + // set off the claim cooldown + claimCooldowns[_msgSender()] = block.timestamp + COOLDOWN_MIGRATION; + migrationTampers[_msgSender()][true] = 0; + migrationTampers[_msgSender()][false] = 0; + migrationS1BadgeIds[_msgSender()] = _s1BadgeId; + migrationS1TokenIds[_msgSender()] = s1TokenId; + tamperCooldowns[_msgSender()] = 0; + // transfer the badge tokens to the migration contract + badges.transferFrom(_msgSender(), address(this), s1TokenId); + + emit MigrationStarted(_msgSender(), _s1BadgeId, s1TokenId, claimCooldowns[_msgSender()]); + } + + /// @notice Tamper (alter) the chances during a migration + /// @param _pinkOrPurple true for pink, false for purple + /// @dev Can be called only during an active migration + /// @dev Implements a cooldown before allowing to re-tamper + /// @dev The max tamper amount is determined by Pass Tier + function tamperMigration(bool _pinkOrPurple) external isMigrating { + if (migrationTampers[_msgSender()][_pinkOrPurple] >= MAX_TAMPERS) { + revert MAX_TAMPERS_REACHED(); + } + + if (tamperCooldowns[_msgSender()] > block.timestamp) { + revert TAMPER_IN_PROGRESS(); + } + + migrationTampers[_msgSender()][_pinkOrPurple]++; + tamperCooldowns[_msgSender()] = block.timestamp + COOLDOWN_TAMPER; + emit MigrationTampered( + _msgSender(), + migrationS1TokenIds[_msgSender()], + _pinkOrPurple, + tamperCooldowns[_msgSender()] + ); + } + + /// @notice Reset the tamper counts + /// @dev Can be called only during an active migration + function resetTampers() external isMigrating { + migrationTampers[_msgSender()][true] = 0; + migrationTampers[_msgSender()][false] = 0; + tamperCooldowns[_msgSender()] = 0; + } + + /// @notice End a migration + /// @param _hash The hash to sign + /// @param v signature V field + /// @param r signature R field + /// @param s signature S field + /// @param exp The user's experience points + /// @dev Can be called only during an active migration, after the cooldown is over + /// @dev The final color is determined randomly, and affected by the tamper amounts + function endMigration( + bytes32 _hash, + uint8 v, + bytes32 r, + bytes32 s, + uint256 exp + ) + external + isMigrating + { + if (tamperCooldowns[_msgSender()] > block.timestamp) { + revert TAMPER_IN_PROGRESS(); + } + // check if the cooldown is over + if (claimCooldowns[_msgSender()] > block.timestamp) { + revert MIGRATION_NOT_READY(); + } + + // ensure the hash corresponds to the start time + bytes32 calculatedHash = generateClaimHash(_msgSender(), exp); + + if (calculatedHash != _hash) { + revert HASH_MISMATCH(); + } + + // get the tamper amounts + uint256 pinkTampers = migrationTampers[_msgSender()][true]; + uint256 purpleTampers = migrationTampers[_msgSender()][false]; + + uint256 randomSeed = randomFromSignature(_hash, v, r, s); + bool isPinkOrPurple; + // Calculate the difference in tampers and adjust chances + if (pinkTampers > purpleTampers) { + uint256 extraChance = (pinkTampers - purpleTampers) * TAMPER_WEIGHT_PERCENT; + uint256 chance = 50 + extraChance; // Base 50% + extra chance + isPinkOrPurple = (randomSeed % 100) < chance; // True for pink + } else if (purpleTampers > pinkTampers) { + uint256 extraChance = (purpleTampers - pinkTampers) * TAMPER_WEIGHT_PERCENT; + uint256 chance = 50 + extraChance; // Base 50% + extra chance + isPinkOrPurple = (randomSeed % 100) >= chance; // False for purple + } else { + // Equal number of pink and purple tampers, 50/50 chance + isPinkOrPurple = (randomSeed % 100) < 50; + } + + uint256 s1BadgeId = migrationS1BadgeIds[_msgSender()]; + (uint256 pinkBadgeId, uint256 purpleBadgeId) = getSeason2BadgeIds(s1BadgeId); + uint256 s2BadgeId = isPinkOrPurple ? pinkBadgeId : purpleBadgeId; + + // burn the s1 badge + uint256 s1TokenId = migrationS1TokenIds[_msgSender()]; + badges.burn(s1TokenId); + + uint256 s2TokenId = totalSupply() + 1; + // mint the badge + _mint(_msgSender(), s2TokenId, 1, ""); + + // reset the cooldowns + claimCooldowns[_msgSender()] = 0; + migrationTampers[_msgSender()][true] = 0; + migrationTampers[_msgSender()][false] = 0; + tamperCooldowns[_msgSender()] = 0; + migrationS1BadgeIds[_msgSender()] = 0; + migrationS1TokenIds[_msgSender()] = 0; + userBadges[_msgSender()][s2BadgeId] = s2TokenId; + migrationCycleUniqueMints[migrationCycle][_msgSender()][s1BadgeId] = true; + emit MigrationEnded(_msgSender(), s2BadgeId, s2TokenId); + } + + /// @notice Enable migrations for a set of badges + /// @param _s1BadgeIds The badge IDs to enable + /// @dev Can be called only by the contract owner/admin + function enableMigrations(uint256[] calldata _s1BadgeIds) + external + onlyRole(DEFAULT_ADMIN_ROLE) + { + migrationCycle++; + for (uint256 i = 0; i < _s1BadgeIds.length; i++) { + enabledBadgeIds[migrationCycle][_s1BadgeIds[i]] = true; + emit MigrationToggled(migrationCycle, _s1BadgeIds[i], true); + } + } + + /// @notice Check if the migrations for a badge are enabled + /// @param _s1Badge The badge ID to check + /// @return Whether the badge is enabled for migration + function canMigrate(uint256 _s1Badge) public view returns (bool) { + for (uint256 i = 0; i < 8; i++) { + if (enabledBadgeIds[migrationCycle][i] && i == _s1Badge) { + return true; + } + } + return false; + } + + /// @notice Pause the contract + /// @dev Can be called only by the contract owner/admin + function pause() public onlyRole(DEFAULT_ADMIN_ROLE) { + _disableMigrations(); + _pause(); + } + + /// @notice S1 --> S2 badge ID mapping + /// @param _s1BadgeId The S1 badge ID + /// @return _pinkBadgeId The S2 pink badge ID + /// @return _purpleBadgeId The S2 purple badge ID + function getSeason2BadgeIds(uint256 _s1BadgeId) + public + pure + returns (uint256 _pinkBadgeId, uint256 _purpleBadgeId) + { + return (_s1BadgeId * 2, _s1BadgeId * 2 + 1); + } + + /// @notice S2 --> S1 badge ID mapping + /// @param _s2BadgeId The S2 badge ID + /// @return _s1BadgeId The S1 badge ID + function getSeason1BadgeId(uint256 _s2BadgeId) public pure returns (uint256 _s1BadgeId) { + return _s2BadgeId / 2; + } + + /// @notice Check if a migration is active for a user + /// @param _user The user address + /// @return Whether the user has an active migration + function isMigrationActive(address _user) public view returns (bool) { + return claimCooldowns[_user] != 0; + } + + /// @notice Check if a tamper is active for a user + /// @param _user The user address + /// @return Whether the user has an active tamper + function isTamperActive(address _user) public view returns (bool) { + return tamperCooldowns[_user] > block.timestamp; + } + + /// @notice Get the migration tamper counts for a user + /// @param _user The user address + /// @return _pinkTampers The pink tamper count + /// @return _purpleTampers The purple tamper count + function getMigrationTampers(address _user) + public + view + returns (uint256 _pinkTampers, uint256 _purpleTampers) + { + if (!isMigrationActive(_user)) { + revert MIGRATION_NOT_STARTED(); + } + return (migrationTampers[_user][true], migrationTampers[_user][false]); + } + + /// @notice Retrieve a token ID given their owner and S2 Badge ID + /// @param _user The address of the badge owner + /// @param _s2BadgeId The S2 badge ID + /// @return _tokenId The token ID + function getTokenId(address _user, uint256 _s2BadgeId) public view returns (uint256 _tokenId) { + return userBadges[_user][_s2BadgeId]; + } + + /// @notice Retrieve boolean balance for each badge + /// @param _owner The addresses to check + /// @return _balances The badges atomic balances + function badgeBalances(address _owner) public view returns (bool[16] memory _balances) { + for (uint256 i = 0; i < BADGE_COUNT; i++) { + uint256 tokenId = getTokenId(_owner, i); + _balances[i] = tokenId > 0; + } + + return _balances; + } + + /// @notice Retrieve the total S2 unique badge balance of an address + /// @param _owner The address to check + /// @return _balance The total badge balance (count) + function badgeBalanceOf(address _owner) public view returns (uint256 _balance) { + bool[16] memory balances = badgeBalances(_owner); + + for (uint256 i = 0; i < balances.length; i++) { + if (balances[i]) { + _balance++; + } + } + + return _balance; + } + + /// @notice Disable all new migrations + /// @dev Doesn't allow for new migration attempts, but tampers and active migrations still run + function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) { + for (uint256 i = 0; i < 8; i++) { + if (enabledBadgeIds[migrationCycle][i]) { + emit MigrationToggled(migrationCycle, i, false); + } + + enabledBadgeIds[migrationCycle][i] = false; + } + } + + /// @notice Generate a unique hash for each migration uniquely + /// @param _user The user address + /// @param _exp The users experience points + /// @return _hash The unique hash + function generateClaimHash(address _user, uint256 _exp) public pure returns (bytes32) { + return keccak256(abi.encodePacked(_user, _exp)); + } + + /// @notice Generates a random number from a signature + /// @param _hash The hash to sign (keccak256(startMigrationBlockHash, _msgSender())) + /// @param v signature V field + /// @param r signature R field + /// @param s signature S field + /// @return _random The pseudo-random number + function randomFromSignature( + bytes32 _hash, + uint8 v, + bytes32 r, + bytes32 s + ) + public + view + returns (uint256 _random) + { + (address _recovered,,) = ECDSA.tryRecover(_hash, v, r, s); + if (_recovered != randomSigner) revert NOT_RANDOM_SIGNER(); + // Hash the signature parts to get a deterministic pseudo-random number + return uint256(keccak256(abi.encodePacked(r, s, v))); + } + + /// @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 { } +} From 18b71c22c23537cd88c93df1fe9c5e044c0ef6cc Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 17 Oct 2024 12:53:39 +0200 Subject: [PATCH 37/79] refactored erc1155 aside --- .../trailblazers-season-2/BadgeMigration.sol | 2 + .../TrailblazersBadgesS2.sol | 150 +++++++++++++++++- .../script/trailblazers-season-2/Deploy.s.sol | 7 +- .../TrailblazersBadgesS2.t.sol | 61 +++++++ ...TraiblazersBadgesS2.t.sol => original.sol} | 31 +--- 5 files changed, 219 insertions(+), 32 deletions(-) create mode 100644 packages/nfts/test/trailblazers-season-2/TrailblazersBadgesS2.t.sol rename packages/nfts/test/trailblazers-season-2/{TraiblazersBadgesS2.t.sol => original.sol} (95%) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index e69de29bb2d..72f41ee08c4 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -0,0 +1,2 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol index 34b80bc8467..4e19d75dc2c 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol @@ -1 +1,149 @@ -// code for the erc1155 token +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol"; +import "../trailblazers-badges/ECDSAWhitelist.sol"; +import "@taiko/blacklist/IMinimalBlacklist.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; +import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; +import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; +import "@openzeppelin/contracts/access/AccessControl.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; +import "./TrailblazersS1BadgesV4.sol"; + +contract TrailblazersBadgesS2 is + ContextUpgradeable, + UUPSUpgradeable, + Ownable2StepUpgradeable, + ERC1155SupplyUpgradeable +{ + enum BadgeType { + Ravers, // s1 id: 0 + Robots, // s1 id: 1 + Bouncers, // s1 id: 2 + Masters, // s1 id: 3 + Monks, // s1 id: 4 + Drummers, // s1 id: 5 + Androids, // s1 id: 6 + Shinto // s1 id: 7 + + } + + enum MovementType { + Dev, // s1 neutral + Minnow, // s1 based/pink + Whale // s1 boosted/purple + + } + + struct Badge { + uint256 tokenId; + BadgeType badgeType; + MovementType movementType; + } + + mapping(uint256 tokenId => Badge badge) public badges; + + string public uriTemplate; + + address public minter; + + /// @notice Gap for upgrade safety + uint256[43] private __gap; + + /// @notice Errors + error NOT_MINTER(); + + modifier onlyMinter() { + if (minter != _msgSender()) { + revert NOT_MINTER(); + } + _; + } + + function initialize( + address _minter, + string calldata _uriTemplate + ) + external + virtual + initializer + { + __ERC1155_init(""); + __ERC1155Supply_init(); + _transferOwnership(_msgSender()); + __Context_init(); + + minter = _minter; + uriTemplate = _uriTemplate; + } + + function updateMinter(address _minter) external virtual onlyOwner { + minter = _minter; + } + + function mint( + address _to, + BadgeType _badgeType, + MovementType _movementType + ) + external + virtual + onlyMinter + { + uint256 tokenId = totalSupply() + 1; + Badge memory badge = Badge(tokenId, _badgeType, _movementType); + _mint(_to, tokenId, 1, ""); + badges[tokenId] = badge; + } + + function _uri( + BadgeType _badgeType, + MovementType _movementType + ) + internal + view + virtual + returns (string memory) + { + return string(abi.encodePacked(uriTemplate, _badgeType, "/", _movementType, ".json")); + } + + function uri( + BadgeType _badgeType, + MovementType _movementType + ) + external + view + virtual + returns (string memory) + { + return _uri(_badgeType, _movementType); + } + + function uri(uint256 tokenId) public view virtual override returns (string memory) { + Badge memory badge = badges[tokenId]; + return _uri(badge.badgeType, badge.movementType); + } + + /// @notice supportsInterface implementation + /// @param interfaceId The interface ID + /// @return Whether the interface is supported + function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { + return super.supportsInterface(interfaceId); + } + + /// @notice Internal method to authorize an upgrade + function _authorizeUpgrade(address) internal virtual override onlyOwner { } +} diff --git a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol index 3827509fdc7..f3ee9438755 100644 --- a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol @@ -53,6 +53,7 @@ contract DeployS2Script is Script { } function run() public { + /* string memory jsonRoot = "root"; address owner = deployerAddress; require(owner != address(0), "Owner must be specified"); @@ -75,7 +76,7 @@ contract DeployS2Script is Script { new ERC1967Proxy( impl, abi.encodeCall( - TrailblazersBadges.initialize, (owner, baseURI, claimMintSigner, blacklist) + TrailblazersBadges.initialize, (owner, baseURI, claimMintSigner, blacklist) ) ) ); @@ -96,7 +97,7 @@ contract DeployS2Script is Script { proxy = address( new ERC1967Proxy( impl, - abi.encodeCall(TrailblazersBadgesS2.initialize, (address(s1Token), migrationSigner)) + abi.encodeCall(TrailblazersBadgesS2.initialize, (address(s1Token), migrationSigner)) ) ); @@ -115,6 +116,6 @@ contract DeployS2Script is Script { string memory finalJson = vm.serializeAddress(jsonRoot, "Owner", s2Token.owner()); vm.writeJson(finalJson, jsonLocation); - vm.stopBroadcast(); + vm.stopBroadcast();*/ } } diff --git a/packages/nfts/test/trailblazers-season-2/TrailblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-season-2/TrailblazersBadgesS2.t.sol new file mode 100644 index 00000000000..3ea0927f5af --- /dev/null +++ b/packages/nfts/test/trailblazers-season-2/TrailblazersBadgesS2.t.sol @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import { Test } from "forge-std/src/Test.sol"; + +import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; +import { UtilsScript } from "../../script/taikoon/sol/Utils.s.sol"; +import { TrailblazersBadgesS2 } from + "../../contracts/trailblazers-season-2/TrailblazersBadgesS2.sol"; + +contract TrailblazersBadgesS2Test is Test { + UtilsScript public utils; + + address public owner = vm.addr(0x5); + address public authorizedMinter = vm.addr(0x6); + address[3] public minters = [vm.addr(0x1), vm.addr(0x2), vm.addr(0x3)]; + + string public uriTemplate = "ipfs://hash/"; + + TrailblazersBadgesS2 public nft; + + function setUp() public { + utils = new UtilsScript(); + utils.setUp(); + // create whitelist merkle tree + vm.startBroadcast(owner); + + address impl = address(new TrailblazersBadgesS2()); + address proxy = address( + new ERC1967Proxy( + impl, + abi.encodeCall(TrailblazersBadgesS2.initialize, (authorizedMinter, uriTemplate)) + ) + ); + + nft = TrailblazersBadgesS2(proxy); + + vm.stopBroadcast(); + } + + function test_mint() public { + vm.prank(authorizedMinter); + nft.mint( + minters[0], + TrailblazersBadgesS2.BadgeType.Ravers, + TrailblazersBadgesS2.MovementType.Minnow + ); + + assertEq(nft.balanceOf(minters[0], 1), 1); + } + + function test_mint_revert__notAuthorizedMinter() public { + vm.prank(minters[1]); + vm.expectRevert(); + nft.mint( + minters[1], + TrailblazersBadgesS2.BadgeType.Ravers, + TrailblazersBadgesS2.MovementType.Minnow + ); + } +} diff --git a/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-season-2/original.sol similarity index 95% rename from packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol rename to packages/nfts/test/trailblazers-season-2/original.sol index 96735d2724e..e06e0ac36ee 100644 --- a/packages/nfts/test/trailblazers-season-2/TraiblazersBadgesS2.t.sol +++ b/packages/nfts/test/trailblazers-season-2/original.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.24; - +/* import { Test } from "forge-std/src/Test.sol"; import { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; @@ -307,18 +307,7 @@ contract TrailblazersBadgesS2Test is Test { assertEq(purpleTampers, 0); } - /* - function test_revert_early_endMigration() public { - test_tamperMigration(); - vm.startPrank(minters[0]); - vm.expectRevert(); - - s2Badges.endMigration(); - vm.stopPrank(); - } - - */ function test_endMigration() public { test_tamperMigration(); @@ -441,23 +430,9 @@ contract TrailblazersBadgesS2Test is Test { assertEq( random, - 28_417_844_340_632_250_945_870_465_294_567_768_196_388_504_060_802_704_441_612_911_129_119_444_309_664 +28_417_844_340_632_250_945_870_465_294_567_768_196_388_504_060_802_704_441_612_911_129_119_444_309_664 ); } - /* - function test_migrateSameBadgeId_revert() public { - // run a first migration - test_endMigration(); - - // mint a second badge to the user - vm.prank(owner); - s1BadgesMock.mintTo(minters[0], BADGE_ID); - // fail the second migration for that badge - vm.startPrank(minters[0]); - s1BadgesV2.approve(address(s2Badges), s1BadgesV2.tokenOfOwnerByIndex(minters[0], 0)); - vm.expectRevert(); - s2Badges.startMigration(BADGE_ID); - vm.stopPrank(); - }*/ } +*/ From 3f37702ecb1af89c1dd0249c170e7f284df6217c Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 17 Oct 2024 13:27:35 +0200 Subject: [PATCH 38/79] extended erc1155 tests --- .../TrailblazersBadgesS2.sol | 20 ++++++++++++-- .../TrailblazersBadgesS2.t.sol | 27 ++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol index 4e19d75dc2c..be2d5960ed9 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol @@ -21,6 +21,7 @@ import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; import "./TrailblazersS1BadgesV4.sol"; +import { Strings } from "@openzeppelin/contracts/utils/Strings.sol"; contract TrailblazersBadgesS2 is ContextUpgradeable, @@ -53,7 +54,7 @@ contract TrailblazersBadgesS2 is MovementType movementType; } - mapping(uint256 tokenId => Badge badge) public badges; + mapping(uint256 tokenId => Badge badge) private badges; string public uriTemplate; @@ -64,6 +65,8 @@ contract TrailblazersBadgesS2 is /// @notice Errors error NOT_MINTER(); + error TOKEN_NOT_MINTED(); + /// @notice Modifiers modifier onlyMinter() { if (minter != _msgSender()) { @@ -117,7 +120,10 @@ contract TrailblazersBadgesS2 is virtual returns (string memory) { - return string(abi.encodePacked(uriTemplate, _badgeType, "/", _movementType, ".json")); + string memory badgeType = Strings.toString(uint256(_badgeType)); + string memory movementType = Strings.toString(uint256(_movementType)); + + return string(abi.encodePacked(uriTemplate, badgeType, "/", movementType, ".json")); } function uri( @@ -133,10 +139,20 @@ contract TrailblazersBadgesS2 is } function uri(uint256 tokenId) public view virtual override returns (string memory) { + if (tokenId > totalSupply()) { + revert TOKEN_NOT_MINTED(); + } Badge memory badge = badges[tokenId]; return _uri(badge.badgeType, badge.movementType); } + function getBadge(uint256 tokenId) external view virtual returns (Badge memory) { + if (tokenId < totalSupply()) { + revert TOKEN_NOT_MINTED(); + } + return badges[tokenId]; + } + /// @notice supportsInterface implementation /// @param interfaceId The interface ID /// @return Whether the interface is supported diff --git a/packages/nfts/test/trailblazers-season-2/TrailblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-season-2/TrailblazersBadgesS2.t.sol index 3ea0927f5af..838c4b9e78a 100644 --- a/packages/nfts/test/trailblazers-season-2/TrailblazersBadgesS2.t.sol +++ b/packages/nfts/test/trailblazers-season-2/TrailblazersBadgesS2.t.sol @@ -19,6 +19,8 @@ contract TrailblazersBadgesS2Test is Test { TrailblazersBadgesS2 public nft; + uint256 public TOKEN_ID = 1; + function setUp() public { utils = new UtilsScript(); utils.setUp(); @@ -46,7 +48,30 @@ contract TrailblazersBadgesS2Test is Test { TrailblazersBadgesS2.MovementType.Minnow ); - assertEq(nft.balanceOf(minters[0], 1), 1); + assertEq(nft.balanceOf(minters[0], TOKEN_ID), 1); + + TrailblazersBadgesS2.Badge memory badge = nft.getBadge(TOKEN_ID); + assertEq(badge.tokenId, TOKEN_ID); + assertEq(uint8(badge.badgeType), uint8(TrailblazersBadgesS2.BadgeType.Ravers)); + assertEq(uint8(badge.movementType), uint8(TrailblazersBadgesS2.MovementType.Minnow)); + } + + function test_uri_byTokenId() public { + test_mint(); + assertEq(nft.uri(TOKEN_ID), "ipfs://hash/0/1.json"); + } + + function test_uri_byTypeAndMovement() public { + test_mint(); + assertEq( + nft.uri(TrailblazersBadgesS2.BadgeType.Ravers, TrailblazersBadgesS2.MovementType.Minnow), + "ipfs://hash/0/1.json" + ); + } + + function test_uri_revert__tokenNotMinted() public { + vm.expectRevert(); + nft.uri(TOKEN_ID); } function test_mint_revert__notAuthorizedMinter() public { From e338efd4b2a73cff777740ef2f62bbac97e45799 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 17 Oct 2024 14:10:14 +0200 Subject: [PATCH 39/79] refactored out migrations; passing tests; needs cleanup --- .../trailblazers-season-2/BadgeMigration.sol | 425 ++++++++++++++++++ .../TrailblazersBadgesS2.sol | 15 +- .../TrailblazersS1BadgesV4.sol | 12 +- .../BadgeMigration.t.sol | 345 ++++++++++++++ 4 files changed, 790 insertions(+), 7 deletions(-) create mode 100644 packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index 72f41ee08c4..40af8ba0e28 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -1,2 +1,427 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.24; + +import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol"; +import "../trailblazers-badges/ECDSAWhitelist.sol"; +import "@taiko/blacklist/IMinimalBlacklist.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; +import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; +import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; +import "@openzeppelin/contracts/access/AccessControl.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; +import "./TrailblazersS1BadgesV4.sol"; +import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import "./TrailblazersBadgesS2.sol"; + +contract BadgeMigration is + PausableUpgradeable, + UUPSUpgradeable, + Ownable2StepUpgradeable, + AccessControlUpgradeable, + ERC721HolderUpgradeable +{ + TrailblazersBadgesV4 public s1Badges; + TrailblazersBadgesS2 public s2Badges; + address public randomSigner; + + /// @notice Time between start and end of a migration + uint256 public constant COOLDOWN_MIGRATION = 1 minutes; //6 hours; + /// @notice Time between tamper attempts + uint256 public constant COOLDOWN_TAMPER = 1 minutes; // 1 hours; + /// @notice Weight of tamper attempts, in % + uint256 public constant TAMPER_WEIGHT_PERCENT = 5; + /// @notice Maximum tamper attempts, per color + uint256 public constant MAX_TAMPERS = 3; + + /// @notice Cooldown for migration + + mapping(address _user => uint256 _cooldown) public claimCooldowns; + + /// @notice Migration-enabled badge IDs per cycle + mapping(uint256 _cycle => mapping(uint256 _s1BadgeId => bool _enabled)) public enabledBadgeIds; + + /// @notice Current migration cycle + uint256 public migrationCycle; + /// @notice Mapping of unique user-per-mint-per-cycle + mapping( + uint256 _migrationCycle + => mapping(address _minter => mapping(uint256 _s1BadgeId => bool _mintEnded)) + ) public migrationCycleUniqueMints; + + /// @notice Tamper count + mapping(address _user => mapping(bool pinkOrPurple => uint256 _tampers)) public migrationTampers; + /// @notice S1 Migration Badge ID mapping + mapping(address _user => uint256 _badgeId) private migrationS1BadgeIds; + /// @notice S1 Migration Token ID mapping + mapping(address _user => uint256 _tokenId) private migrationS1TokenIds; + /// @notice Cooldown for tampering + mapping(address _user => uint256 _cooldown) public tamperCooldowns; + /// @notice User to badge ID, token ID mapping + mapping(address _user => mapping(uint256 _badgeId => uint256 _tokenId)) public userBadges; + + /// @notice Errors + error MAX_TAMPERS_REACHED(); + error MIGRATION_NOT_STARTED(); + error MIGRATION_ALREADY_STARTED(); + error TAMPER_IN_PROGRESS(); + error CONTRACT_PAUSED(); + error MIGRATION_NOT_READY(); + error TOKEN_NOT_MINTED(); + error MIGRATION_NOT_ENABLED(); + error TOKEN_NOT_OWNED(); + error NOT_RANDOM_SIGNER(); + error ALREADY_MIGRATED_IN_CYCLE(); + error HASH_MISMATCH(); + + /// @notice Events + event MigrationToggled(uint256 indexed _migrationCycleId, uint256 _s1BadgeId, bool _enabled); + event MigrationStarted( + address _user, uint256 _s1BadgeId, uint256 _s1TokenId, uint256 _cooldownExpiration + ); + event MigrationTampered( + address indexed _user, + uint256 indexed _s1TokenId, + bool _pinkOrPurple, + uint256 _cooldownExpiration + ); + event MigrationEnded( + address _user, uint256 _s2BadgeId, uint256 _s2MovementId, uint256 _s2TokenId + ); + + /// @notice Modifiers + modifier isMigrating() { + if (claimCooldowns[_msgSender()] == 0) { + revert MIGRATION_NOT_STARTED(); + } + _; + } + + /// @notice Reverts if sender is already migrating + modifier isNotMigrating() { + if (claimCooldowns[_msgSender()] != 0) { + revert MIGRATION_ALREADY_STARTED(); + } + _; + } + + /// @notice Reverts if migrations aren't enabled for that badge + modifier migrationOpen(uint256 _s1BadgeId) { + if (!enabledBadgeIds[migrationCycle][_s1BadgeId]) { + revert MIGRATION_NOT_ENABLED(); + } + _; + } + + /// @notice Limits migrations to one per user, badge and cycle + modifier hasntMigratedInCycle(uint256 _s1BadgeId, address _minter) { + // check that the minter hasn't used the migration within this cycle + if (migrationCycleUniqueMints[migrationCycle][_minter][_s1BadgeId]) { + revert ALREADY_MIGRATED_IN_CYCLE(); + } + _; + } + + /// @notice Contract initializer + function initialize( + address _s1Badges, + address _s2Badges, + address _randomSigner + ) + external + initializer + { + _transferOwnership(_msgSender()); + __Context_init(); + _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); + s1Badges = TrailblazersBadgesV4(_s1Badges); + s2Badges = TrailblazersBadgesS2(_s2Badges); + randomSigner = _randomSigner; + } + + /// @notice Disable all new migrations + /// @dev Doesn't allow for new migration attempts, but tampers and active migrations still run + function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) { + for (uint256 i = 0; i < 8; i++) { + if (enabledBadgeIds[migrationCycle][i]) { + emit MigrationToggled(migrationCycle, i, false); + } + + enabledBadgeIds[migrationCycle][i] = false; + } + } + + /// @notice Enable migrations for a set of badges + /// @param _s1BadgeIds The badge IDs to enable + /// @dev Can be called only by the contract owner/admin + function enableMigrations(uint256[] calldata _s1BadgeIds) + external + onlyRole(DEFAULT_ADMIN_ROLE) + { + migrationCycle++; + for (uint256 i = 0; i < _s1BadgeIds.length; i++) { + enabledBadgeIds[migrationCycle][_s1BadgeIds[i]] = true; + emit MigrationToggled(migrationCycle, _s1BadgeIds[i], true); + } + } + + /// @notice Pause the contract + /// @dev Can be called only by the contract owner/admin + function pause() public onlyRole(DEFAULT_ADMIN_ROLE) { + _disableMigrations(); + _pause(); + } + + /// @notice Start a migration for a badge + /// @param _s1BadgeId The badge ID (s1) + /// @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 + migrationOpen(_s1BadgeId) + isNotMigrating + hasntMigratedInCycle(_s1BadgeId, _msgSender()) + { + uint256 s1TokenId = s1Badges.getTokenId(_msgSender(), _s1BadgeId); + + if (s1Badges.ownerOf(s1TokenId) != _msgSender()) { + revert TOKEN_NOT_OWNED(); + } + + // set off the claim cooldown + claimCooldowns[_msgSender()] = block.timestamp + COOLDOWN_MIGRATION; + migrationTampers[_msgSender()][true] = 0; + migrationTampers[_msgSender()][false] = 0; + migrationS1BadgeIds[_msgSender()] = _s1BadgeId; + migrationS1TokenIds[_msgSender()] = s1TokenId; + tamperCooldowns[_msgSender()] = 0; + // transfer the badge tokens to the migration contract + s1Badges.transferFrom(_msgSender(), address(this), s1TokenId); + + emit MigrationStarted(_msgSender(), _s1BadgeId, s1TokenId, claimCooldowns[_msgSender()]); + } + + /// @notice Tamper (alter) the chances during a migration + /// @param _pinkOrPurple true for pink, false for purple + /// @dev Can be called only during an active migration + /// @dev Implements a cooldown before allowing to re-tamper + /// @dev The max tamper amount is determined by Pass Tier + function tamperMigration(bool _pinkOrPurple) external isMigrating { + if (migrationTampers[_msgSender()][_pinkOrPurple] >= MAX_TAMPERS) { + revert MAX_TAMPERS_REACHED(); + } + + if (tamperCooldowns[_msgSender()] > block.timestamp) { + revert TAMPER_IN_PROGRESS(); + } + + migrationTampers[_msgSender()][_pinkOrPurple]++; + tamperCooldowns[_msgSender()] = block.timestamp + COOLDOWN_TAMPER; + emit MigrationTampered( + _msgSender(), + migrationS1TokenIds[_msgSender()], + _pinkOrPurple, + tamperCooldowns[_msgSender()] + ); + } + + /// @notice Reset the tamper counts + /// @dev Can be called only during an active migration + function resetTampers() external isMigrating { + migrationTampers[_msgSender()][true] = 0; + migrationTampers[_msgSender()][false] = 0; + tamperCooldowns[_msgSender()] = 0; + } + + /// @notice End a migration + /// @param _hash The hash to sign + /// @param v signature V field + /// @param r signature R field + /// @param s signature S field + /// @param exp The user's experience points + /// @dev Can be called only during an active migration, after the cooldown is over + /// @dev The final color is determined randomly, and affected by the tamper amounts + function endMigration( + bytes32 _hash, + uint8 v, + bytes32 r, + bytes32 s, + uint256 exp + ) + external + isMigrating + { + if (tamperCooldowns[_msgSender()] > block.timestamp) { + revert TAMPER_IN_PROGRESS(); + } + // check if the cooldown is over + if (claimCooldowns[_msgSender()] > block.timestamp) { + revert MIGRATION_NOT_READY(); + } + + // ensure the hash corresponds to the start time + bytes32 calculatedHash = generateClaimHash(_msgSender(), exp); + + if (calculatedHash != _hash) { + revert HASH_MISMATCH(); + } + + // get the tamper amounts + uint256 pinkTampers = migrationTampers[_msgSender()][true]; + uint256 purpleTampers = migrationTampers[_msgSender()][false]; + + uint256 randomSeed = randomFromSignature(_hash, v, r, s); + bool isPinkOrPurple; + // Calculate the difference in tampers and adjust chances + if (pinkTampers > purpleTampers) { + uint256 extraChance = (pinkTampers - purpleTampers) * TAMPER_WEIGHT_PERCENT; + uint256 chance = 50 + extraChance; // Base 50% + extra chance + isPinkOrPurple = (randomSeed % 100) < chance; // True for pink + } else if (purpleTampers > pinkTampers) { + uint256 extraChance = (purpleTampers - pinkTampers) * TAMPER_WEIGHT_PERCENT; + uint256 chance = 50 + extraChance; // Base 50% + extra chance + isPinkOrPurple = (randomSeed % 100) >= chance; // False for purple + } else { + // Equal number of pink and purple tampers, 50/50 chance + isPinkOrPurple = (randomSeed % 100) < 50; + } + + uint256 s1BadgeId = migrationS1BadgeIds[_msgSender()]; + // (uint256 pinkBadgeId, uint256 purpleBadgeId) = getSeason2BadgeIds(s1BadgeId); + // uint256 s2BadgeId = isPinkOrPurple ? pinkBadgeId : purpleBadgeId; + + // burn the s1 badge + uint256 s1TokenId = migrationS1TokenIds[_msgSender()]; + s1Badges.burn(s1TokenId); + + // mint the badge + s2Badges.mint( + _msgSender(), + TrailblazersBadgesS2.BadgeType(s1BadgeId), + isPinkOrPurple + ? TrailblazersBadgesS2.MovementType.Minnow + : TrailblazersBadgesS2.MovementType.Whale + ); + uint256 s2TokenId = s2Badges.totalSupply(); + + // reset the cooldowns + claimCooldowns[_msgSender()] = 0; + migrationTampers[_msgSender()][true] = 0; + migrationTampers[_msgSender()][false] = 0; + tamperCooldowns[_msgSender()] = 0; + migrationS1BadgeIds[_msgSender()] = 0; + migrationS1TokenIds[_msgSender()] = 0; + // userBadges[_msgSender()][s2BadgeId] = s2TokenId; + migrationCycleUniqueMints[migrationCycle][_msgSender()][s1BadgeId] = true; + emit MigrationEnded( + _msgSender(), + s1BadgeId, + uint256( + isPinkOrPurple + ? TrailblazersBadgesS2.MovementType.Minnow + : TrailblazersBadgesS2.MovementType.Whale + ), + s2TokenId + ); + } + + /// @notice S1 --> S2 badge ID mapping + /// @param _s1BadgeId The S1 badge ID + /// @return _pinkBadgeId The S2 pink badge ID + /// @return _purpleBadgeId The S2 purple badge ID + function getSeason2BadgeIds(uint256 _s1BadgeId) + public + pure + returns (uint256 _pinkBadgeId, uint256 _purpleBadgeId) + { + return (_s1BadgeId * 2, _s1BadgeId * 2 + 1); + } + + /// @notice Generate a unique hash for each migration uniquely + /// @param _user The user address + /// @param _exp The users experience points + /// @return _hash The unique hash + function generateClaimHash(address _user, uint256 _exp) public pure returns (bytes32) { + return keccak256(abi.encodePacked(_user, _exp)); + } + + /// @notice Check if a migration is active for a user + /// @param _user The user address + /// @return Whether the user has an active migration + function isMigrationActive(address _user) public view returns (bool) { + return claimCooldowns[_user] != 0; + } + + /// @notice Generates a random number from a signature + /// @param _hash The hash to sign (keccak256(startMigrationBlockHash, _msgSender())) + /// @param v signature V field + /// @param r signature R field + /// @param s signature S field + /// @return _random The pseudo-random number + function randomFromSignature( + bytes32 _hash, + uint8 v, + bytes32 r, + bytes32 s + ) + public + view + returns (uint256 _random) + { + (address _recovered,,) = ECDSA.tryRecover(_hash, v, r, s); + if (_recovered != randomSigner) revert NOT_RANDOM_SIGNER(); + // Hash the signature parts to get a deterministic pseudo-random number + return uint256(keccak256(abi.encodePacked(r, s, v))); + } + + /// @notice Check if a tamper is active for a user + /// @param _user The user address + /// @return Whether the user has an active tamper + function isTamperActive(address _user) public view returns (bool) { + return tamperCooldowns[_user] > block.timestamp; + } + + /// @notice Get the migration tamper counts for a user + /// @param _user The user address + /// @return _pinkTampers The pink tamper count + /// @return _purpleTampers The purple tamper count + function getMigrationTampers(address _user) + public + view + returns (uint256 _pinkTampers, uint256 _purpleTampers) + { + if (!isMigrationActive(_user)) { + revert MIGRATION_NOT_STARTED(); + } + return (migrationTampers[_user][true], migrationTampers[_user][false]); + } + + /// @notice Retrieve a token ID given their owner and S2 Badge ID + /// @param _user The address of the badge owner + /// @param _s2BadgeId The S2 badge ID + /// @return _tokenId The token ID + function getTokenId(address _user, uint256 _s2BadgeId) public view returns (uint256 _tokenId) { + return userBadges[_user][_s2BadgeId]; + } + + /// @notice supportsInterface implementation + /// @param interfaceId The interface ID + /// @return Whether the interface is supported + function supportsInterface(bytes4 interfaceId) public view override returns (bool) { + return super.supportsInterface(interfaceId); + } + + /// @notice Internal method to authorize an upgrade + function _authorizeUpgrade(address) internal virtual override onlyOwner { } +} diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol index be2d5960ed9..b16d5341740 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol @@ -92,7 +92,7 @@ contract TrailblazersBadgesS2 is uriTemplate = _uriTemplate; } - function updateMinter(address _minter) external virtual onlyOwner { + function setMinter(address _minter) external virtual onlyOwner { minter = _minter; } @@ -153,6 +153,19 @@ contract TrailblazersBadgesS2 is return badges[tokenId]; } + /// @notice Retrieve boolean balance for each badge + /// @param _owner The addresses to check + /// @return _balances The badges atomic balances + function badgeBalances(address _owner) public view returns (bool[16] memory _balances) { + /* + for (uint256 i = 0; i < BADGE_COUNT; i++) { + uint256 tokenId = getTokenId(_owner, i); + _balances[i] = tokenId > 0; + } + + return _balances;*/ + } + /// @notice supportsInterface implementation /// @param interfaceId The interface ID /// @return Whether the interface is supported diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol index 089d545a1d9..55ec0836a1e 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol @@ -22,20 +22,20 @@ contract TrailblazersBadgesV4 is TrailblazersBadgesV3 { return super._update(to, tokenId, auth); } - address public season2BadgeContract; + address public migrationContract; error INVALID_S2_CONTRACT(); - function setSeason2BadgeContract(address _season2BadgeContract) public onlyOwner { - season2BadgeContract = _season2BadgeContract; + function setMigrationContract(address _migrationContract) public onlyOwner { + migrationContract = _migrationContract; } - modifier onlySeason2BadgeContract() { - if (msg.sender != season2BadgeContract) revert INVALID_S2_CONTRACT(); + modifier onlyMigrationContract() { + if (msg.sender != migrationContract) revert INVALID_S2_CONTRACT(); _; } - function burn(uint256 _tokenId) public onlySeason2BadgeContract { + function burn(uint256 _tokenId) public onlyMigrationContract { _burn(_tokenId); } } diff --git a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol new file mode 100644 index 00000000000..9020d4c46b9 --- /dev/null +++ b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol @@ -0,0 +1,345 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.24; + +import { Test } from "forge-std/src/Test.sol"; + +import { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; +import { Merkle } from "murky/Merkle.sol"; +import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; +import { UtilsScript } from "../../script/taikoon/sol/Utils.s.sol"; +import { MockBlacklist } from "../util/Blacklist.sol"; +import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import { TrailblazersBadgesS2 } from + "../../contracts/trailblazers-season-2/TrailblazersBadgesS2.sol"; +import { TrailblazerBadgesS1MintTo } from "../util/TrailblazerBadgesS1MintTo.sol"; +import { TrailblazersBadgesV4 } from + "../../contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol"; +import { BadgeMigration } from "../../contracts/trailblazers-season-2/BadgeMigration.sol"; + +contract TrailblazersBadgesS2Test is Test { + UtilsScript public utils; + + TrailblazersBadgesV4 public s1BadgesV4; + TrailblazersBadgesS2 public s2Badges; + + address public owner = vm.addr(0x5); + + address[3] public minters = [vm.addr(0x1), vm.addr(0x2), vm.addr(0x3)]; + + uint256 public BADGE_ID; + + MockBlacklist public blacklist; + + address mintSigner; + uint256 mintSignerPk; + + bool constant PINK_TAMPER = true; + bool constant PURPLE_TAMPER = false; + + uint256 public MAX_TAMPERS; + + BadgeMigration public migration; + + function setUp() public { + utils = new UtilsScript(); + utils.setUp(); + blacklist = new MockBlacklist(); + // create whitelist merkle tree + vm.startBroadcast(owner); + + (mintSigner, mintSignerPk) = makeAddrAndKey("mintSigner"); + + // deploy token with empty root + address impl = address(new TrailblazersBadges()); + address proxy = address( + new ERC1967Proxy( + impl, + abi.encodeCall( + TrailblazersBadges.initialize, (owner, "ipfs://", mintSigner, blacklist) + ) + ) + ); + + TrailblazersBadges s1BadgesV2 = TrailblazersBadges(proxy); + + // upgrade s1 badges contract to use the mock version + + s1BadgesV2.upgradeToAndCall( + address(new TrailblazerBadgesS1MintTo()), + abi.encodeCall(TrailblazerBadgesS1MintTo.call, ()) + ); + + TrailblazerBadgesS1MintTo s1BadgesMock = TrailblazerBadgesS1MintTo(address(s1BadgesV2)); + + BADGE_ID = s1BadgesV2.BADGE_RAVERS(); + + // upgrade s1 contract to v4 + s1BadgesV2.upgradeToAndCall( + address(new TrailblazersBadgesV4()), abi.encodeCall(TrailblazersBadgesV4.version, ()) + ); + + s1BadgesV4 = TrailblazersBadgesV4(address(s1BadgesV2)); + + // deploy the s2 erc1155 token contract + + impl = address(new TrailblazersBadgesS2()); + proxy = address( + new ERC1967Proxy( + impl, + abi.encodeCall(TrailblazersBadgesS2.initialize, (address(migration), "ipfs://")) + ) + ); + s2Badges = TrailblazersBadgesS2(proxy); + + // deploy the migration contract + + impl = address(new BadgeMigration()); + proxy = address( + new ERC1967Proxy( + impl, + abi.encodeCall( + BadgeMigration.initialize, (address(s1BadgesV2), address(s2Badges), mintSigner) + ) + ) + ); + migration = BadgeMigration(proxy); + MAX_TAMPERS = migration.MAX_TAMPERS(); + + s1BadgesV4.setMigrationContract(address(migration)); + s2Badges.setMinter(address(migration)); + // enable migration for BADGE_ID + uint256[] memory enabledBadgeIds = new uint256[](1); + enabledBadgeIds[0] = BADGE_ID; + migration.enableMigrations(enabledBadgeIds); + + vm.stopBroadcast(); + } + + function mint_s1(address minter, uint256 badgeId) public { + bytes32 _hash = s1BadgesV4.getHash(minter, badgeId); + + (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); + + bool canMint = s1BadgesV4.canMint(abi.encodePacked(r, s, v), minter, badgeId); + assertTrue(canMint); + + vm.startPrank(minter); + s1BadgesV4.mint(abi.encodePacked(r, s, v), badgeId); + vm.stopPrank(); + } + + function test_mint_s1() public { + mint_s1(minters[0], s1BadgesV4.BADGE_RAVERS()); + mint_s1(minters[0], s1BadgesV4.BADGE_ROBOTS()); + assertEq(s1BadgesV4.balanceOf(minters[0]), 2); + + mint_s1(minters[1], s1BadgesV4.BADGE_BOUNCERS()); + mint_s1(minters[1], s1BadgesV4.BADGE_MASTERS()); + assertEq(s1BadgesV4.balanceOf(minters[1]), 2); + + mint_s1(minters[2], s1BadgesV4.BADGE_MONKS()); + mint_s1(minters[2], s1BadgesV4.BADGE_DRUMMERS()); + assertEq(s1BadgesV4.balanceOf(minters[2]), 2); + } + + function test_startMigration() public { + mint_s1(minters[0], BADGE_ID); + + uint256 tokenId = s1BadgesV4.tokenOfOwnerByIndex(minters[0], 0); + + vm.startPrank(minters[0]); + s1BadgesV4.approve(address(migration), tokenId); + migration.startMigration(BADGE_ID); + vm.stopPrank(); + /* + assertEq(s1BadgesV2.balanceOf(minters[0]), 0); + assertEq(s1BadgesV2.balanceOf(address(s2Badges)), 1); + + assertEq(s1BadgesV2.ownerOf(tokenId), address(s2Badges)); + + assertEq(migration.isMigrationActive(minters[0]), true);*/ + } + + function wait(uint256 time) public { + vm.warp(block.timestamp + time); + } + + // happy-path, make 3 pink tampers, and 2 purple ones + function test_tamperMigration() public { + test_startMigration(); + + vm.startPrank(minters[0]); + for (uint256 i = 0; i < MAX_TAMPERS; i++) { + wait(migration.COOLDOWN_TAMPER()); + migration.tamperMigration(PINK_TAMPER); + } + + wait(migration.COOLDOWN_TAMPER()); + migration.tamperMigration(PURPLE_TAMPER); + wait(migration.COOLDOWN_TAMPER()); + migration.tamperMigration(PURPLE_TAMPER); + + vm.stopPrank(); + + assertEq(migration.isTamperActive(minters[0]), true); + assertEq(migration.isMigrationActive(minters[0]), true); + + (uint256 pinkTampers, uint256 purpleTampers) = migration.getMigrationTampers(minters[0]); + assertEq(pinkTampers, MAX_TAMPERS); + assertEq(purpleTampers, 2); + } + + function test_revert_tooManyTampers() public { + test_tamperMigration(); + vm.startPrank(minters[0]); + vm.expectRevert(); + migration.tamperMigration(PINK_TAMPER); + + vm.stopPrank(); + } + + function test_resetTampers() public { + test_tamperMigration(); + assertEq(migration.isTamperActive(minters[0]), true); + (uint256 pinkTampers, uint256 purpleTampers) = migration.getMigrationTampers(minters[0]); + assertEq(pinkTampers, MAX_TAMPERS); + assertEq(purpleTampers, 2); + + vm.prank(minters[0]); + migration.resetTampers(); + + assertEq(migration.isTamperActive(minters[0]), false); + (pinkTampers, purpleTampers) = migration.getMigrationTampers(minters[0]); + assertEq(pinkTampers, 0); + assertEq(purpleTampers, 0); + } + + function test_endMigration() public { + test_tamperMigration(); + + wait(migration.COOLDOWN_TAMPER()); + wait(migration.COOLDOWN_MIGRATION()); + + // generate the claim hash for the current migration + bytes32 claimHash = migration.generateClaimHash( + minters[0], + 0 // experience points + ); + + // simulate the backend signing the hash + (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, claimHash); + + // exercise the randomFromSignature function + + vm.startPrank(minters[0]); + migration.endMigration(claimHash, v, r, s, 0); + vm.stopPrank(); + + /* + // check for s1 burn + assertEq(s1BadgesV2.balanceOf(minters[0]), 0); + assertEq(s1BadgesV2.balanceOf(address(s2Badges)), 0); + + // check for s2 state reset + assertEq(migration.isMigrationActive(minters[0]), false); + assertEq(migration.isTamperActive(minters[0]), false); + + // check for s2 mint + (uint256 pinkBadgeId, uint256 purpleBadgeId) = migration.getSeason2BadgeIds(BADGE_ID); + uint256 s2TokenId = migration.getTokenId(minters[0], pinkBadgeId) > 0 + ? migration.getTokenId(minters[0], pinkBadgeId) + : migration.getTokenId(minters[0], purpleBadgeId); + assertEq(s2Badges.balanceOf(minters[0], s2TokenId), 1); + + */ + + // check for s2 badge balances + // bool[16] memory badgeBalances = s2Badges.badgeBalances(minters[0]); + /* + assertTrue( + badgeBalances[s2Badges.RAVER_PINK_ID()] || badgeBalances[s2Badges.RAVER_PURPLE_ID()] + ); + + assertFalse(badgeBalances[s2Badges.ROBOT_PINK_ID()]); + assertFalse(badgeBalances[s2Badges.ROBOT_PURPLE_ID()]); + assertFalse(badgeBalances[s2Badges.BOUNCER_PINK_ID()]); + assertFalse(badgeBalances[s2Badges.BOUNCER_PURPLE_ID()]); + assertFalse(badgeBalances[s2Badges.MASTER_PINK_ID()]); + assertFalse(badgeBalances[s2Badges.MASTER_PURPLE_ID()]); + assertFalse(badgeBalances[s2Badges.MONK_PINK_ID()]); + assertFalse(badgeBalances[s2Badges.MONK_PURPLE_ID()]); + assertFalse(badgeBalances[s2Badges.DRUMMER_PINK_ID()]); + assertFalse(badgeBalances[s2Badges.DRUMMER_PURPLE_ID()]); + assertFalse(badgeBalances[s2Badges.ANDROID_PINK_ID()]); + assertFalse(badgeBalances[s2Badges.ANDROID_PURPLE_ID()]); + assertFalse(badgeBalances[s2Badges.SHINTO_PINK_ID()]); + assertFalse(badgeBalances[s2Badges.SHINTO_PURPLE_ID()]);*/ + } + + function test_revert_startMigrationTwice() public { + test_startMigration(); + vm.startPrank(minters[0]); + vm.expectRevert(); + migration.startMigration(BADGE_ID); + vm.stopPrank(); + } + + function test_revert_migrateDisabled() public { + uint256 badgeId = s1BadgesV4.BADGE_ROBOTS(); + mint_s1(minters[0], badgeId); + + uint256 tokenId = s1BadgesV4.tokenOfOwnerByIndex(minters[0], 0); + + vm.startPrank(minters[0]); + s1BadgesV4.approve(address(migration), tokenId); + vm.expectRevert(); + migration.startMigration(badgeId); + vm.stopPrank(); + // ensure no values got changed/updated + assertEq(s1BadgesV4.balanceOf(minters[0]), 1); + assertEq(s1BadgesV4.balanceOf(address(s2Badges)), 0); + assertEq(s1BadgesV4.ownerOf(tokenId), minters[0]); + assertEq(migration.isMigrationActive(minters[0]), false); + } + + function test_revert_pausedContract() public { + // have the admin pause the contract + // ensure no badges are mintable afterwards + vm.startPrank(owner); + migration.pause(); + vm.stopPrank(); + + mint_s1(minters[0], BADGE_ID); + + uint256 tokenId = s1BadgesV4.tokenOfOwnerByIndex(minters[0], 0); + + vm.startPrank(minters[0]); + s1BadgesV4.approve(address(migration), tokenId); + vm.expectRevert(); + migration.startMigration(BADGE_ID); + vm.stopPrank(); + // ensure no values got changed/updated + assertEq(s1BadgesV4.balanceOf(minters[0]), 1); + assertEq(s1BadgesV4.balanceOf(address(s2Badges)), 0); + assertEq(s1BadgesV4.ownerOf(tokenId), minters[0]); + assertEq(migration.isMigrationActive(minters[0]), false); + } + + function test_randomFromSignature() public view { + bytes32 signatureHash = keccak256( + abi.encodePacked( + keccak256("1234567890"), // should use the block's hash + minters[0] + ) + ); + + (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, signatureHash); + + uint256 random = migration.randomFromSignature(signatureHash, v, r, s); + + assertEq( + random, + 28_417_844_340_632_250_945_870_465_294_567_768_196_388_504_060_802_704_441_612_911_129_119_444_309_664 + ); + } +} From f09204a27912a87d4aa53ed23d287bcf03d0a64a Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 17 Oct 2024 14:47:54 +0200 Subject: [PATCH 40/79] refactored migration using structs --- .../trailblazers-season-2/BadgeMigration.sol | 159 ++++++++++-------- 1 file changed, 93 insertions(+), 66 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index 40af8ba0e28..fd863d49c2d 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -44,10 +44,6 @@ contract BadgeMigration is /// @notice Maximum tamper attempts, per color uint256 public constant MAX_TAMPERS = 3; - /// @notice Cooldown for migration - - mapping(address _user => uint256 _cooldown) public claimCooldowns; - /// @notice Migration-enabled badge IDs per cycle mapping(uint256 _cycle => mapping(uint256 _s1BadgeId => bool _enabled)) public enabledBadgeIds; @@ -59,16 +55,19 @@ contract BadgeMigration is => mapping(address _minter => mapping(uint256 _s1BadgeId => bool _mintEnded)) ) public migrationCycleUniqueMints; - /// @notice Tamper count - mapping(address _user => mapping(bool pinkOrPurple => uint256 _tampers)) public migrationTampers; - /// @notice S1 Migration Badge ID mapping - mapping(address _user => uint256 _badgeId) private migrationS1BadgeIds; - /// @notice S1 Migration Token ID mapping - mapping(address _user => uint256 _tokenId) private migrationS1TokenIds; - /// @notice Cooldown for tampering - mapping(address _user => uint256 _cooldown) public tamperCooldowns; - /// @notice User to badge ID, token ID mapping - mapping(address _user => mapping(uint256 _badgeId => uint256 _tokenId)) public userBadges; + struct Migration { + uint256 migrationCycle; + address user; + uint256 s1BadgeId; + uint256 s1TokenId; + uint256 s2TokenId; + uint256 cooldownExpiration; + uint256 tamperExpiration; + uint256 pinkTampers; + uint256 purpleTampers; + } + + mapping(address _user => Migration[] _migration) public migrations; /// @notice Errors error MAX_TAMPERS_REACHED(); @@ -99,9 +98,12 @@ contract BadgeMigration is address _user, uint256 _s2BadgeId, uint256 _s2MovementId, uint256 _s2TokenId ); + event MigrationTamperReset(address _user); + /// @notice Modifiers modifier isMigrating() { - if (claimCooldowns[_msgSender()] == 0) { + Migration memory _migration = getActiveMigrationFor(_msgSender()); + if (_migration.cooldownExpiration == 0) { revert MIGRATION_NOT_STARTED(); } _; @@ -109,7 +111,10 @@ contract BadgeMigration is /// @notice Reverts if sender is already migrating modifier isNotMigrating() { - if (claimCooldowns[_msgSender()] != 0) { + if ( + migrations[_msgSender()].length > 0 + && migrations[_msgSender()][migrations[_msgSender()].length - 1].cooldownExpiration == 0 + ) { revert MIGRATION_ALREADY_STARTED(); } _; @@ -187,11 +192,8 @@ contract BadgeMigration 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 - migrationOpen(_s1BadgeId) - isNotMigrating - hasntMigratedInCycle(_s1BadgeId, _msgSender()) + function startMigration(uint256 _s1BadgeId) external migrationOpen(_s1BadgeId) isNotMigrating + // hasntMigratedInCycle(_s1BadgeId, _msgSender()) { uint256 s1TokenId = s1Badges.getTokenId(_msgSender(), _s1BadgeId); @@ -199,17 +201,35 @@ contract BadgeMigration is revert TOKEN_NOT_OWNED(); } - // set off the claim cooldown - claimCooldowns[_msgSender()] = block.timestamp + COOLDOWN_MIGRATION; - migrationTampers[_msgSender()][true] = 0; - migrationTampers[_msgSender()][false] = 0; - migrationS1BadgeIds[_msgSender()] = _s1BadgeId; - migrationS1TokenIds[_msgSender()] = s1TokenId; - tamperCooldowns[_msgSender()] = 0; + Migration memory _migration = Migration( + migrationCycle, // migrationCycle + _msgSender(), // user + _s1BadgeId, + s1TokenId, + 0, // s2TokenId, unset + block.timestamp + COOLDOWN_MIGRATION, // cooldownExpiration + 0, // tamperExpiration, unset + 0, // pinkTampers + 0 // purpleTampers + ); + + migrations[_msgSender()].push(_migration); + // transfer the badge tokens to the migration contract s1Badges.transferFrom(_msgSender(), address(this), s1TokenId); - emit MigrationStarted(_msgSender(), _s1BadgeId, s1TokenId, claimCooldowns[_msgSender()]); + emit MigrationStarted(_msgSender(), _s1BadgeId, s1TokenId, _migration.cooldownExpiration); + } + + function getActiveMigrationFor(address _user) public view returns (Migration memory) { + if (migrations[_user].length == 0) { + revert MIGRATION_NOT_STARTED(); + } + return migrations[_user][migrations[_user].length - 1]; + } + + function _updateMigration(Migration memory _migration) internal virtual { + migrations[_migration.user][migrations[_migration.user].length - 1] = _migration; } /// @notice Tamper (alter) the chances during a migration @@ -218,30 +238,42 @@ contract BadgeMigration is /// @dev Implements a cooldown before allowing to re-tamper /// @dev The max tamper amount is determined by Pass Tier function tamperMigration(bool _pinkOrPurple) external isMigrating { - if (migrationTampers[_msgSender()][_pinkOrPurple] >= MAX_TAMPERS) { + Migration memory _migration = getActiveMigrationFor(_msgSender()); + + if ((_migration.pinkTampers + _migration.purpleTampers) > MAX_TAMPERS * 2) { revert MAX_TAMPERS_REACHED(); } - if (tamperCooldowns[_msgSender()] > block.timestamp) { + if (_migration.tamperExpiration > block.timestamp) { revert TAMPER_IN_PROGRESS(); } - migrationTampers[_msgSender()][_pinkOrPurple]++; - tamperCooldowns[_msgSender()] = block.timestamp + COOLDOWN_TAMPER; + if (_pinkOrPurple) { + _migration.pinkTampers++; + } else { + _migration.purpleTampers++; + } + + _migration.tamperExpiration = block.timestamp + COOLDOWN_TAMPER; + + // update migration + _updateMigration(_migration); emit MigrationTampered( - _msgSender(), - migrationS1TokenIds[_msgSender()], - _pinkOrPurple, - tamperCooldowns[_msgSender()] + _msgSender(), _migration.s1TokenId, _pinkOrPurple, _migration.tamperExpiration ); } /// @notice Reset the tamper counts /// @dev Can be called only during an active migration function resetTampers() external isMigrating { - migrationTampers[_msgSender()][true] = 0; - migrationTampers[_msgSender()][false] = 0; - tamperCooldowns[_msgSender()] = 0; + Migration memory _migration = getActiveMigrationFor(_msgSender()); + _migration.pinkTampers = 0; + _migration.purpleTampers = 0; + _migration.tamperExpiration = 0; + + _updateMigration(_migration); + + emit MigrationTamperReset(_msgSender()); } /// @notice End a migration @@ -262,11 +294,13 @@ contract BadgeMigration is external isMigrating { - if (tamperCooldowns[_msgSender()] > block.timestamp) { + Migration memory _migration = getActiveMigrationFor(_msgSender()); + + if (_migration.tamperExpiration > block.timestamp) { revert TAMPER_IN_PROGRESS(); } // check if the cooldown is over - if (claimCooldowns[_msgSender()] > block.timestamp) { + if (_migration.cooldownExpiration > block.timestamp) { revert MIGRATION_NOT_READY(); } @@ -278,8 +312,8 @@ contract BadgeMigration is } // get the tamper amounts - uint256 pinkTampers = migrationTampers[_msgSender()][true]; - uint256 purpleTampers = migrationTampers[_msgSender()][false]; + uint256 pinkTampers = _migration.pinkTampers; + uint256 purpleTampers = _migration.purpleTampers; uint256 randomSeed = randomFromSignature(_hash, v, r, s); bool isPinkOrPurple; @@ -297,12 +331,12 @@ contract BadgeMigration is isPinkOrPurple = (randomSeed % 100) < 50; } - uint256 s1BadgeId = migrationS1BadgeIds[_msgSender()]; + uint256 s1BadgeId = _migration.s1BadgeId; // (uint256 pinkBadgeId, uint256 purpleBadgeId) = getSeason2BadgeIds(s1BadgeId); // uint256 s2BadgeId = isPinkOrPurple ? pinkBadgeId : purpleBadgeId; // burn the s1 badge - uint256 s1TokenId = migrationS1TokenIds[_msgSender()]; + uint256 s1TokenId = _migration.s1TokenId; s1Badges.burn(s1TokenId); // mint the badge @@ -315,15 +349,10 @@ contract BadgeMigration is ); uint256 s2TokenId = s2Badges.totalSupply(); - // reset the cooldowns - claimCooldowns[_msgSender()] = 0; - migrationTampers[_msgSender()][true] = 0; - migrationTampers[_msgSender()][false] = 0; - tamperCooldowns[_msgSender()] = 0; - migrationS1BadgeIds[_msgSender()] = 0; - migrationS1TokenIds[_msgSender()] = 0; - // userBadges[_msgSender()][s2BadgeId] = s2TokenId; - migrationCycleUniqueMints[migrationCycle][_msgSender()][s1BadgeId] = true; + _migration.s2TokenId = s2TokenId; + _migration.cooldownExpiration = 0; + _migration.tamperExpiration = 0; + emit MigrationEnded( _msgSender(), s1BadgeId, @@ -360,7 +389,11 @@ contract BadgeMigration is /// @param _user The user address /// @return Whether the user has an active migration function isMigrationActive(address _user) public view returns (bool) { - return claimCooldowns[_user] != 0; + if (migrations[_user].length == 0) { + return false; + } + Migration memory _migration = getActiveMigrationFor(_user); + return _migration.cooldownExpiration != 0; } /// @notice Generates a random number from a signature @@ -389,7 +422,8 @@ contract BadgeMigration is /// @param _user The user address /// @return Whether the user has an active tamper function isTamperActive(address _user) public view returns (bool) { - return tamperCooldowns[_user] > block.timestamp; + Migration memory _migration = getActiveMigrationFor(_user); + return _migration.tamperExpiration > block.timestamp; } /// @notice Get the migration tamper counts for a user @@ -404,15 +438,8 @@ contract BadgeMigration is if (!isMigrationActive(_user)) { revert MIGRATION_NOT_STARTED(); } - return (migrationTampers[_user][true], migrationTampers[_user][false]); - } - - /// @notice Retrieve a token ID given their owner and S2 Badge ID - /// @param _user The address of the badge owner - /// @param _s2BadgeId The S2 badge ID - /// @return _tokenId The token ID - function getTokenId(address _user, uint256 _s2BadgeId) public view returns (uint256 _tokenId) { - return userBadges[_user][_s2BadgeId]; + Migration memory _migration = getActiveMigrationFor(_user); + return (_migration.pinkTampers, _migration.purpleTampers); } /// @notice supportsInterface implementation From 60ec90af398d77b850dbdaaba766e02e327d4349 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 17 Oct 2024 14:56:07 +0200 Subject: [PATCH 41/79] refactored config --- .../trailblazers-season-2/BadgeMigration.sol | 31 ++++++++++++++----- .../BadgeMigration.t.sol | 24 ++++++++------ 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index fd863d49c2d..15b4f633f30 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -34,7 +34,7 @@ contract BadgeMigration is TrailblazersBadgesV4 public s1Badges; TrailblazersBadgesS2 public s2Badges; address public randomSigner; - + /* /// @notice Time between start and end of a migration uint256 public constant COOLDOWN_MIGRATION = 1 minutes; //6 hours; /// @notice Time between tamper attempts @@ -44,6 +44,8 @@ contract BadgeMigration is /// @notice Maximum tamper attempts, per color uint256 public constant MAX_TAMPERS = 3; + */ + /// @notice Migration-enabled badge IDs per cycle mapping(uint256 _cycle => mapping(uint256 _s1BadgeId => bool _enabled)) public enabledBadgeIds; @@ -55,6 +57,15 @@ contract BadgeMigration is => mapping(address _minter => mapping(uint256 _s1BadgeId => bool _mintEnded)) ) public migrationCycleUniqueMints; + struct Config { + uint256 cooldownMigration; + uint256 cooldownTamper; + uint256 tamperWeightPercent; + uint256 maxTampers; + } + + Config public config; + struct Migration { uint256 migrationCycle; address user; @@ -141,7 +152,8 @@ contract BadgeMigration is function initialize( address _s1Badges, address _s2Badges, - address _randomSigner + address _randomSigner, + Config memory _config ) external initializer @@ -152,6 +164,11 @@ contract BadgeMigration is s1Badges = TrailblazersBadgesV4(_s1Badges); s2Badges = TrailblazersBadgesS2(_s2Badges); randomSigner = _randomSigner; + config = _config; + } + + function setConfig(Config memory _config) external onlyRole(DEFAULT_ADMIN_ROLE) { + config = _config; } /// @notice Disable all new migrations @@ -207,7 +224,7 @@ contract BadgeMigration is _s1BadgeId, s1TokenId, 0, // s2TokenId, unset - block.timestamp + COOLDOWN_MIGRATION, // cooldownExpiration + block.timestamp + config.cooldownMigration, // cooldownExpiration 0, // tamperExpiration, unset 0, // pinkTampers 0 // purpleTampers @@ -240,7 +257,7 @@ contract BadgeMigration is function tamperMigration(bool _pinkOrPurple) external isMigrating { Migration memory _migration = getActiveMigrationFor(_msgSender()); - if ((_migration.pinkTampers + _migration.purpleTampers) > MAX_TAMPERS * 2) { + if ((_migration.pinkTampers + _migration.purpleTampers) > config.maxTampers * 2) { revert MAX_TAMPERS_REACHED(); } @@ -254,7 +271,7 @@ contract BadgeMigration is _migration.purpleTampers++; } - _migration.tamperExpiration = block.timestamp + COOLDOWN_TAMPER; + _migration.tamperExpiration = block.timestamp + config.cooldownTamper; // update migration _updateMigration(_migration); @@ -319,11 +336,11 @@ contract BadgeMigration is bool isPinkOrPurple; // Calculate the difference in tampers and adjust chances if (pinkTampers > purpleTampers) { - uint256 extraChance = (pinkTampers - purpleTampers) * TAMPER_WEIGHT_PERCENT; + uint256 extraChance = (pinkTampers - purpleTampers) * config.tamperWeightPercent; uint256 chance = 50 + extraChance; // Base 50% + extra chance isPinkOrPurple = (randomSeed % 100) < chance; // True for pink } else if (purpleTampers > pinkTampers) { - uint256 extraChance = (purpleTampers - pinkTampers) * TAMPER_WEIGHT_PERCENT; + uint256 extraChance = (purpleTampers - pinkTampers) * config.tamperWeightPercent; uint256 chance = 50 + extraChance; // Base 50% + extra chance isPinkOrPurple = (randomSeed % 100) >= chance; // False for purple } else { diff --git a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol index 9020d4c46b9..4a042630172 100644 --- a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol +++ b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol @@ -36,7 +36,10 @@ contract TrailblazersBadgesS2Test is Test { bool constant PINK_TAMPER = true; bool constant PURPLE_TAMPER = false; - uint256 public MAX_TAMPERS; + uint256 public MAX_TAMPERS = 3; + uint256 public COOLDOWN_MIGRATION = 1 hours; + uint256 public COOLDOWN_TAMPER = 5 minutes; + uint256 public TAMPER_WEIGHT_PERCENT = 5; BadgeMigration public migration; @@ -93,18 +96,21 @@ contract TrailblazersBadgesS2Test is Test { // deploy the migration contract + BadgeMigration.Config memory config = BadgeMigration.Config( + COOLDOWN_MIGRATION, COOLDOWN_TAMPER, TAMPER_WEIGHT_PERCENT, MAX_TAMPERS + ); + impl = address(new BadgeMigration()); proxy = address( new ERC1967Proxy( impl, abi.encodeCall( - BadgeMigration.initialize, (address(s1BadgesV2), address(s2Badges), mintSigner) + BadgeMigration.initialize, + (address(s1BadgesV2), address(s2Badges), mintSigner, config) ) ) ); migration = BadgeMigration(proxy); - MAX_TAMPERS = migration.MAX_TAMPERS(); - s1BadgesV4.setMigrationContract(address(migration)); s2Badges.setMinter(address(migration)); // enable migration for BADGE_ID @@ -170,13 +176,13 @@ contract TrailblazersBadgesS2Test is Test { vm.startPrank(minters[0]); for (uint256 i = 0; i < MAX_TAMPERS; i++) { - wait(migration.COOLDOWN_TAMPER()); + wait(COOLDOWN_TAMPER); migration.tamperMigration(PINK_TAMPER); } - wait(migration.COOLDOWN_TAMPER()); + wait(COOLDOWN_TAMPER); migration.tamperMigration(PURPLE_TAMPER); - wait(migration.COOLDOWN_TAMPER()); + wait(COOLDOWN_TAMPER); migration.tamperMigration(PURPLE_TAMPER); vm.stopPrank(); @@ -217,8 +223,8 @@ contract TrailblazersBadgesS2Test is Test { function test_endMigration() public { test_tamperMigration(); - wait(migration.COOLDOWN_TAMPER()); - wait(migration.COOLDOWN_MIGRATION()); + wait(COOLDOWN_TAMPER); + wait(COOLDOWN_MIGRATION); // generate the claim hash for the current migration bytes32 claimHash = migration.generateClaimHash( From 257e12d647e24c229d845235f2ca71d30976e3b1 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 17 Oct 2024 14:59:02 +0200 Subject: [PATCH 42/79] tests for config refactor --- .../trailblazers-season-2/BadgeMigration.sol | 6 ++++- .../BadgeMigration.t.sol | 22 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index 15b4f633f30..553d048a911 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -64,7 +64,7 @@ contract BadgeMigration is uint256 maxTampers; } - Config public config; + Config private config; struct Migration { uint256 migrationCycle; @@ -171,6 +171,10 @@ contract BadgeMigration is config = _config; } + function getConfig() external view returns (Config memory) { + return config; + } + /// @notice Disable all new migrations /// @dev Doesn't allow for new migration attempts, but tampers and active migrations still run function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) { diff --git a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol index 4a042630172..d6618e94ec5 100644 --- a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol +++ b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol @@ -348,4 +348,26 @@ contract TrailblazersBadgesS2Test is Test { 28_417_844_340_632_250_945_870_465_294_567_768_196_388_504_060_802_704_441_612_911_129_119_444_309_664 ); } + + function test_setConfig() public { + BadgeMigration.Config memory config = BadgeMigration.Config(1 hours, 5 minutes, 5, 3); + vm.prank(owner); + migration.setConfig(config); + + BadgeMigration.Config memory newConfig = migration.getConfig(); + + assertEq(newConfig.cooldownMigration, 1 hours); + assertEq(newConfig.cooldownTamper, 5 minutes); + assertEq(newConfig.tamperWeightPercent, 5); + assertEq(newConfig.maxTampers, 3); + } + + function test_setConfig_revert__notOwner() public { + BadgeMigration.Config memory config = BadgeMigration.Config(1 hours, 5 minutes, 5, 3); + + vm.startPrank(minters[0]); + vm.expectRevert(); + migration.setConfig(config); + vm.stopPrank(); + } } From 84ceaeed4b711bb99ec164507913c3d3a5b898be Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 17 Oct 2024 15:10:15 +0200 Subject: [PATCH 43/79] post-mint reading states simplified --- .../trailblazers-season-2/BadgeMigration.sol | 40 ++++--------------- .../BadgeMigration.t.sol | 35 ++-------------- 2 files changed, 11 insertions(+), 64 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index 553d048a911..b3c8d5e2779 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -353,49 +353,25 @@ contract BadgeMigration is } uint256 s1BadgeId = _migration.s1BadgeId; - // (uint256 pinkBadgeId, uint256 purpleBadgeId) = getSeason2BadgeIds(s1BadgeId); - // uint256 s2BadgeId = isPinkOrPurple ? pinkBadgeId : purpleBadgeId; - - // burn the s1 badge uint256 s1TokenId = _migration.s1TokenId; s1Badges.burn(s1TokenId); + TrailblazersBadgesS2.MovementType pinkOrPurple = isPinkOrPurple + ? TrailblazersBadgesS2.MovementType.Minnow + : TrailblazersBadgesS2.MovementType.Whale; + // mint the badge - s2Badges.mint( - _msgSender(), - TrailblazersBadgesS2.BadgeType(s1BadgeId), - isPinkOrPurple - ? TrailblazersBadgesS2.MovementType.Minnow - : TrailblazersBadgesS2.MovementType.Whale - ); + s2Badges.mint(_msgSender(), TrailblazersBadgesS2.BadgeType(s1BadgeId), pinkOrPurple); + uint256 s2TokenId = s2Badges.totalSupply(); _migration.s2TokenId = s2TokenId; _migration.cooldownExpiration = 0; _migration.tamperExpiration = 0; - emit MigrationEnded( - _msgSender(), - s1BadgeId, - uint256( - isPinkOrPurple - ? TrailblazersBadgesS2.MovementType.Minnow - : TrailblazersBadgesS2.MovementType.Whale - ), - s2TokenId - ); - } + _updateMigration(_migration); - /// @notice S1 --> S2 badge ID mapping - /// @param _s1BadgeId The S1 badge ID - /// @return _pinkBadgeId The S2 pink badge ID - /// @return _purpleBadgeId The S2 purple badge ID - function getSeason2BadgeIds(uint256 _s1BadgeId) - public - pure - returns (uint256 _pinkBadgeId, uint256 _purpleBadgeId) - { - return (_s1BadgeId * 2, _s1BadgeId * 2 + 1); + emit MigrationEnded(_msgSender(), s1BadgeId, uint256(pinkOrPurple), s2TokenId); } /// @notice Generate a unique hash for each migration uniquely diff --git a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol index d6618e94ec5..5c25bbea93d 100644 --- a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol +++ b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol @@ -241,45 +241,16 @@ contract TrailblazersBadgesS2Test is Test { migration.endMigration(claimHash, v, r, s, 0); vm.stopPrank(); - /* // check for s1 burn - assertEq(s1BadgesV2.balanceOf(minters[0]), 0); - assertEq(s1BadgesV2.balanceOf(address(s2Badges)), 0); + assertEq(s1BadgesV4.balanceOf(minters[0]), 0); + assertEq(s1BadgesV4.balanceOf(address(s2Badges)), 0); // check for s2 state reset assertEq(migration.isMigrationActive(minters[0]), false); assertEq(migration.isTamperActive(minters[0]), false); // check for s2 mint - (uint256 pinkBadgeId, uint256 purpleBadgeId) = migration.getSeason2BadgeIds(BADGE_ID); - uint256 s2TokenId = migration.getTokenId(minters[0], pinkBadgeId) > 0 - ? migration.getTokenId(minters[0], pinkBadgeId) - : migration.getTokenId(minters[0], purpleBadgeId); - assertEq(s2Badges.balanceOf(minters[0], s2TokenId), 1); - - */ - - // check for s2 badge balances - // bool[16] memory badgeBalances = s2Badges.badgeBalances(minters[0]); - /* - assertTrue( - badgeBalances[s2Badges.RAVER_PINK_ID()] || badgeBalances[s2Badges.RAVER_PURPLE_ID()] - ); - - assertFalse(badgeBalances[s2Badges.ROBOT_PINK_ID()]); - assertFalse(badgeBalances[s2Badges.ROBOT_PURPLE_ID()]); - assertFalse(badgeBalances[s2Badges.BOUNCER_PINK_ID()]); - assertFalse(badgeBalances[s2Badges.BOUNCER_PURPLE_ID()]); - assertFalse(badgeBalances[s2Badges.MASTER_PINK_ID()]); - assertFalse(badgeBalances[s2Badges.MASTER_PURPLE_ID()]); - assertFalse(badgeBalances[s2Badges.MONK_PINK_ID()]); - assertFalse(badgeBalances[s2Badges.MONK_PURPLE_ID()]); - assertFalse(badgeBalances[s2Badges.DRUMMER_PINK_ID()]); - assertFalse(badgeBalances[s2Badges.DRUMMER_PURPLE_ID()]); - assertFalse(badgeBalances[s2Badges.ANDROID_PINK_ID()]); - assertFalse(badgeBalances[s2Badges.ANDROID_PURPLE_ID()]); - assertFalse(badgeBalances[s2Badges.SHINTO_PINK_ID()]); - assertFalse(badgeBalances[s2Badges.SHINTO_PURPLE_ID()]);*/ + assertEq(s2Badges.balanceOf(minters[0], 1), 1); } function test_revert_startMigrationTwice() public { From c752fb4aaaf75c89620218adc2d892559b79792a Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 17 Oct 2024 15:20:49 +0200 Subject: [PATCH 44/79] cycle tests --- .../trailblazers-season-2/BadgeMigration.sol | 24 +++++++++++-------- .../BadgeMigration.t.sol | 17 +++++++++++++ 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index b3c8d5e2779..584c6754db9 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -50,7 +50,7 @@ contract BadgeMigration is mapping(uint256 _cycle => mapping(uint256 _s1BadgeId => bool _enabled)) public enabledBadgeIds; /// @notice Current migration cycle - uint256 public migrationCycle; + uint256 private _migrationCycle; /// @notice Mapping of unique user-per-mint-per-cycle mapping( uint256 _migrationCycle @@ -133,7 +133,7 @@ contract BadgeMigration is /// @notice Reverts if migrations aren't enabled for that badge modifier migrationOpen(uint256 _s1BadgeId) { - if (!enabledBadgeIds[migrationCycle][_s1BadgeId]) { + if (!enabledBadgeIds[_migrationCycle][_s1BadgeId]) { revert MIGRATION_NOT_ENABLED(); } _; @@ -142,7 +142,7 @@ contract BadgeMigration is /// @notice Limits migrations to one per user, badge and cycle modifier hasntMigratedInCycle(uint256 _s1BadgeId, address _minter) { // check that the minter hasn't used the migration within this cycle - if (migrationCycleUniqueMints[migrationCycle][_minter][_s1BadgeId]) { + if (migrationCycleUniqueMints[_migrationCycle][_minter][_s1BadgeId]) { revert ALREADY_MIGRATED_IN_CYCLE(); } _; @@ -179,11 +179,11 @@ contract BadgeMigration is /// @dev Doesn't allow for new migration attempts, but tampers and active migrations still run function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) { for (uint256 i = 0; i < 8; i++) { - if (enabledBadgeIds[migrationCycle][i]) { - emit MigrationToggled(migrationCycle, i, false); + if (enabledBadgeIds[_migrationCycle][i]) { + emit MigrationToggled(_migrationCycle, i, false); } - enabledBadgeIds[migrationCycle][i] = false; + enabledBadgeIds[_migrationCycle][i] = false; } } @@ -194,13 +194,17 @@ contract BadgeMigration is external onlyRole(DEFAULT_ADMIN_ROLE) { - migrationCycle++; + _migrationCycle++; for (uint256 i = 0; i < _s1BadgeIds.length; i++) { - enabledBadgeIds[migrationCycle][_s1BadgeIds[i]] = true; - emit MigrationToggled(migrationCycle, _s1BadgeIds[i], true); + enabledBadgeIds[_migrationCycle][_s1BadgeIds[i]] = true; + emit MigrationToggled(_migrationCycle, _s1BadgeIds[i], true); } } + function migrationCycle() external view returns (uint256) { + return _migrationCycle; + } + /// @notice Pause the contract /// @dev Can be called only by the contract owner/admin function pause() public onlyRole(DEFAULT_ADMIN_ROLE) { @@ -223,7 +227,7 @@ contract BadgeMigration is } Migration memory _migration = Migration( - migrationCycle, // migrationCycle + _migrationCycle, // migrationCycle _msgSender(), // user _s1BadgeId, s1TokenId, diff --git a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol index 5c25bbea93d..958b728eb19 100644 --- a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol +++ b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol @@ -341,4 +341,21 @@ contract TrailblazersBadgesS2Test is Test { migration.setConfig(config); vm.stopPrank(); } + + function test_rollCycle() public { + assertEq(migration.migrationCycle(), 1); + + test_endMigration(); + + // close the current cycle + vm.startPrank(owner); + migration.pause(); + // launch the next cycle + uint256[] memory enabledBadgeIds = new uint256[](1); + enabledBadgeIds[0] = BADGE_ID; + migration.enableMigrations(enabledBadgeIds); + + // check cycle id + assertEq(migration.migrationCycle(), 2); + } } From eceb798a292cef4f295fc137753ad41df7e7bde6 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 17 Oct 2024 15:48:45 +0200 Subject: [PATCH 45/79] refactored events for simplicity --- .../trailblazers-season-2/BadgeMigration.sol | 74 ++++++++++--------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index 584c6754db9..849b30a8a01 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -34,17 +34,6 @@ contract BadgeMigration is TrailblazersBadgesV4 public s1Badges; TrailblazersBadgesS2 public s2Badges; address public randomSigner; - /* - /// @notice Time between start and end of a migration - uint256 public constant COOLDOWN_MIGRATION = 1 minutes; //6 hours; - /// @notice Time between tamper attempts - uint256 public constant COOLDOWN_TAMPER = 1 minutes; // 1 hours; - /// @notice Weight of tamper attempts, in % - uint256 public constant TAMPER_WEIGHT_PERCENT = 5; - /// @notice Maximum tamper attempts, per color - uint256 public constant MAX_TAMPERS = 3; - - */ /// @notice Migration-enabled badge IDs per cycle mapping(uint256 _cycle => mapping(uint256 _s1BadgeId => bool _enabled)) public enabledBadgeIds; @@ -85,9 +74,7 @@ contract BadgeMigration is error MIGRATION_NOT_STARTED(); error MIGRATION_ALREADY_STARTED(); error TAMPER_IN_PROGRESS(); - error CONTRACT_PAUSED(); error MIGRATION_NOT_READY(); - error TOKEN_NOT_MINTED(); error MIGRATION_NOT_ENABLED(); error TOKEN_NOT_OWNED(); error NOT_RANDOM_SIGNER(); @@ -95,21 +82,21 @@ contract BadgeMigration is error HASH_MISMATCH(); /// @notice Events - event MigrationToggled(uint256 indexed _migrationCycleId, uint256 _s1BadgeId, bool _enabled); - event MigrationStarted( - address _user, uint256 _s1BadgeId, uint256 _s1TokenId, uint256 _cooldownExpiration - ); - event MigrationTampered( - address indexed _user, - uint256 indexed _s1TokenId, - bool _pinkOrPurple, - uint256 _cooldownExpiration - ); - event MigrationEnded( - address _user, uint256 _s2BadgeId, uint256 _s2MovementId, uint256 _s2TokenId + event MigrationCycleToggled( + uint256 indexed _migrationCycleId, uint256 _s1BadgeId, bool _enabled ); - event MigrationTamperReset(address _user); + event MigrationUpdated( + uint256 indexed migrationCycle, + address indexed user, + uint256 s1BadgeId, + uint256 s1TokenId, + uint256 s2TokenId, + uint256 cooldownExpiration, + uint256 tamperExpiration, + uint256 pinkTampers, + uint256 purpleTampers + ); /// @notice Modifiers modifier isMigrating() { @@ -180,7 +167,7 @@ contract BadgeMigration is function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) { for (uint256 i = 0; i < 8; i++) { if (enabledBadgeIds[_migrationCycle][i]) { - emit MigrationToggled(_migrationCycle, i, false); + emit MigrationCycleToggled(_migrationCycle, i, false); } enabledBadgeIds[_migrationCycle][i] = false; @@ -197,7 +184,7 @@ contract BadgeMigration is _migrationCycle++; for (uint256 i = 0; i < _s1BadgeIds.length; i++) { enabledBadgeIds[_migrationCycle][_s1BadgeIds[i]] = true; - emit MigrationToggled(_migrationCycle, _s1BadgeIds[i], true); + emit MigrationCycleToggled(_migrationCycle, _s1BadgeIds[i], true); } } @@ -243,7 +230,17 @@ contract BadgeMigration is // transfer the badge tokens to the migration contract s1Badges.transferFrom(_msgSender(), address(this), s1TokenId); - emit MigrationStarted(_msgSender(), _s1BadgeId, s1TokenId, _migration.cooldownExpiration); + emit MigrationUpdated( + _migration.migrationCycle, + _migration.user, + _migration.s1BadgeId, + _migration.s1TokenId, + _migration.s2TokenId, + _migration.cooldownExpiration, + _migration.tamperExpiration, + _migration.pinkTampers, + _migration.purpleTampers + ); } function getActiveMigrationFor(address _user) public view returns (Migration memory) { @@ -255,6 +252,18 @@ contract BadgeMigration is function _updateMigration(Migration memory _migration) internal virtual { migrations[_migration.user][migrations[_migration.user].length - 1] = _migration; + + emit MigrationUpdated( + _migration.migrationCycle, + _migration.user, + _migration.s1BadgeId, + _migration.s1TokenId, + _migration.s2TokenId, + _migration.cooldownExpiration, + _migration.tamperExpiration, + _migration.pinkTampers, + _migration.purpleTampers + ); } /// @notice Tamper (alter) the chances during a migration @@ -283,9 +292,6 @@ contract BadgeMigration is // update migration _updateMigration(_migration); - emit MigrationTampered( - _msgSender(), _migration.s1TokenId, _pinkOrPurple, _migration.tamperExpiration - ); } /// @notice Reset the tamper counts @@ -297,8 +303,6 @@ contract BadgeMigration is _migration.tamperExpiration = 0; _updateMigration(_migration); - - emit MigrationTamperReset(_msgSender()); } /// @notice End a migration @@ -374,8 +378,6 @@ contract BadgeMigration is _migration.tamperExpiration = 0; _updateMigration(_migration); - - emit MigrationEnded(_msgSender(), s1BadgeId, uint256(pinkOrPurple), s2TokenId); } /// @notice Generate a unique hash for each migration uniquely From 5f55660937d93b7ac6b3af12a98444b0d3707241 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 17 Oct 2024 16:04:39 +0200 Subject: [PATCH 46/79] refactored max tampers to be exp-bound --- .../trailblazers-season-2/BadgeMigration.sol | 28 +- .../BadgeMigration.t.sol | 22 +- .../test/trailblazers-season-2/original.sol | 438 ------------------ 3 files changed, 42 insertions(+), 446 deletions(-) delete mode 100644 packages/nfts/test/trailblazers-season-2/original.sol diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index 849b30a8a01..2c363068875 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -50,7 +50,7 @@ contract BadgeMigration is uint256 cooldownMigration; uint256 cooldownTamper; uint256 tamperWeightPercent; - uint256 maxTampers; + uint256 baseMaxTampers; } Config private config; @@ -266,15 +266,37 @@ contract BadgeMigration is ); } + function maxTampers(uint256 exp) internal view virtual returns (uint256 value) { + // start at 3 tampers + // add +1 tamper for every 100 exp + value = exp / 100; + value += 2 * config.baseMaxTampers; + return value; + } + /// @notice Tamper (alter) the chances during a migration /// @param _pinkOrPurple true for pink, false for purple /// @dev Can be called only during an active migration /// @dev Implements a cooldown before allowing to re-tamper /// @dev The max tamper amount is determined by Pass Tier - function tamperMigration(bool _pinkOrPurple) external isMigrating { + function tamperMigration( + bytes32 _hash, + uint8 v, + bytes32 r, + bytes32 s, + uint256 exp, + bool _pinkOrPurple + ) + external + isMigrating + { + (address _recovered,,) = ECDSA.tryRecover(_hash, v, r, s); + if (_recovered != randomSigner) revert NOT_RANDOM_SIGNER(); + // Hash the signature parts to get a deterministic pseudo-random number + Migration memory _migration = getActiveMigrationFor(_msgSender()); - if ((_migration.pinkTampers + _migration.purpleTampers) > config.maxTampers * 2) { + if ((_migration.pinkTampers + _migration.purpleTampers) > maxTampers(exp)) { revert MAX_TAMPERS_REACHED(); } diff --git a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol index 958b728eb19..91b4edc1bf6 100644 --- a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol +++ b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol @@ -175,15 +175,22 @@ contract TrailblazersBadgesS2Test is Test { test_startMigration(); vm.startPrank(minters[0]); + + uint256 points = 0; + bytes32 _hash = migration.generateClaimHash(minters[0], points); + + (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); + for (uint256 i = 0; i < MAX_TAMPERS; i++) { wait(COOLDOWN_TAMPER); - migration.tamperMigration(PINK_TAMPER); + migration.tamperMigration(_hash, v, r, s, points, PINK_TAMPER); } wait(COOLDOWN_TAMPER); - migration.tamperMigration(PURPLE_TAMPER); + migration.tamperMigration(_hash, v, r, s, points, PURPLE_TAMPER); wait(COOLDOWN_TAMPER); - migration.tamperMigration(PURPLE_TAMPER); + + migration.tamperMigration(_hash, v, r, s, points, PURPLE_TAMPER); vm.stopPrank(); @@ -196,10 +203,15 @@ contract TrailblazersBadgesS2Test is Test { } function test_revert_tooManyTampers() public { + uint256 points = 0; + bytes32 _hash = migration.generateClaimHash(minters[0], points); + + (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); + test_tamperMigration(); vm.startPrank(minters[0]); vm.expectRevert(); - migration.tamperMigration(PINK_TAMPER); + migration.tamperMigration(_hash, v, r, s, points, PINK_TAMPER); vm.stopPrank(); } @@ -330,7 +342,7 @@ contract TrailblazersBadgesS2Test is Test { assertEq(newConfig.cooldownMigration, 1 hours); assertEq(newConfig.cooldownTamper, 5 minutes); assertEq(newConfig.tamperWeightPercent, 5); - assertEq(newConfig.maxTampers, 3); + assertEq(newConfig.baseMaxTampers, 3); } function test_setConfig_revert__notOwner() public { diff --git a/packages/nfts/test/trailblazers-season-2/original.sol b/packages/nfts/test/trailblazers-season-2/original.sol deleted file mode 100644 index e06e0ac36ee..00000000000 --- a/packages/nfts/test/trailblazers-season-2/original.sol +++ /dev/null @@ -1,438 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.24; -/* -import { Test } from "forge-std/src/Test.sol"; - -import { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; -import { Merkle } from "murky/Merkle.sol"; -import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; -import { UtilsScript } from "../../script/taikoon/sol/Utils.s.sol"; -import { MockBlacklist } from "../util/Blacklist.sol"; -import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -import { TrailblazersBadgesS2 } from - "../../contracts/trailblazers-season-2/TrailblazersBadgesS2.sol"; -import { TrailblazerBadgesS1MintTo } from "../util/TrailblazerBadgesS1MintTo.sol"; -import { TrailblazersBadgesV4 } from - "../../contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol"; - -contract TrailblazersBadgesS2Test is Test { - UtilsScript public utils; - - TrailblazersBadges public s1BadgesV2; - TrailblazersBadgesV4 public s1BadgesV4; - TrailblazersBadgesS2 public s2Badges; - TrailblazerBadgesS1MintTo public s1BadgesMock; - - address public owner = vm.addr(0x5); - - address[3] public minters = [vm.addr(0x1), vm.addr(0x2), vm.addr(0x3)]; - - uint256 public BADGE_ID; - - MockBlacklist public blacklist; - - address mintSigner; - uint256 mintSignerPk; - - bool constant PINK_TAMPER = true; - bool constant PURPLE_TAMPER = false; - - uint256 public MAX_TAMPERS; - - function setUp() public { - utils = new UtilsScript(); - utils.setUp(); - blacklist = new MockBlacklist(); - // create whitelist merkle tree - vm.startBroadcast(owner); - - (mintSigner, mintSignerPk) = makeAddrAndKey("mintSigner"); - - // deploy token with empty root - address impl = address(new TrailblazersBadges()); - address proxy = address( - new ERC1967Proxy( - impl, - abi.encodeCall( - TrailblazersBadges.initialize, (owner, "ipfs://", mintSigner, blacklist) - ) - ) - ); - - s1BadgesV2 = TrailblazersBadges(proxy); - - // upgrade s1 badges contract to use the mock version - - s1BadgesV2.upgradeToAndCall( - address(new TrailblazerBadgesS1MintTo()), - abi.encodeCall(TrailblazerBadgesS1MintTo.call, ()) - ); - - s1BadgesMock = TrailblazerBadgesS1MintTo(address(s1BadgesV2)); - - BADGE_ID = s1BadgesV2.BADGE_RAVERS(); - - // upgrade s1 contract to v4 - s1BadgesV2.upgradeToAndCall( - address(new TrailblazersBadgesV4()), abi.encodeCall(TrailblazersBadgesV4.version, ()) - ); - - s1BadgesV4 = TrailblazersBadgesV4(address(s1BadgesV2)); - - // deploy the s2 contract - - impl = address(new TrailblazersBadgesS2()); - proxy = address( - new ERC1967Proxy( - impl, - abi.encodeCall(TrailblazersBadgesS2.initialize, (address(s1BadgesV2), mintSigner)) - ) - ); - - s2Badges = TrailblazersBadgesS2(proxy); - MAX_TAMPERS = s2Badges.MAX_TAMPERS(); - - s1BadgesV4.setSeason2BadgeContract(address(s2Badges)); - - // enable migration for BADGE_ID - uint256[] memory enabledBadgeIds = new uint256[](1); - enabledBadgeIds[0] = BADGE_ID; - s2Badges.enableMigrations(enabledBadgeIds); - - vm.stopBroadcast(); - } - - function test_s1_metadata_badges() public view { - assertEq(s1BadgesV2.BADGE_RAVERS(), 0); - assertEq(s1BadgesV2.BADGE_ROBOTS(), 1); - assertEq(s1BadgesV2.BADGE_BOUNCERS(), 2); - assertEq(s1BadgesV2.BADGE_MASTERS(), 3); - assertEq(s1BadgesV2.BADGE_MONKS(), 4); - assertEq(s1BadgesV2.BADGE_DRUMMERS(), 5); - assertEq(s1BadgesV2.BADGE_ANDROIDS(), 6); - assertEq(s1BadgesV2.BADGE_SHINTO(), 7); - } - - function test_s2_metadata_badges() public view { - assertEq(s2Badges.RAVER_PINK_ID(), 0); - assertEq(s2Badges.RAVER_PURPLE_ID(), 1); - assertEq(s2Badges.ROBOT_PINK_ID(), 2); - assertEq(s2Badges.ROBOT_PURPLE_ID(), 3); - assertEq(s2Badges.BOUNCER_PINK_ID(), 4); - assertEq(s2Badges.BOUNCER_PURPLE_ID(), 5); - assertEq(s2Badges.MASTER_PINK_ID(), 6); - assertEq(s2Badges.MASTER_PURPLE_ID(), 7); - assertEq(s2Badges.MONK_PINK_ID(), 8); - assertEq(s2Badges.MONK_PURPLE_ID(), 9); - assertEq(s2Badges.DRUMMER_PINK_ID(), 10); - assertEq(s2Badges.DRUMMER_PURPLE_ID(), 11); - assertEq(s2Badges.ANDROID_PINK_ID(), 12); - assertEq(s2Badges.ANDROID_PURPLE_ID(), 13); - assertEq(s2Badges.SHINTO_PINK_ID(), 14); - assertEq(s2Badges.SHINTO_PURPLE_ID(), 15); - } - - function test_s1_s2_badgeId_conversion() public view { - (uint256 pinkId, uint256 purpleId) = s2Badges.getSeason2BadgeIds(s1BadgesV2.BADGE_RAVERS()); - assertEq(pinkId, s2Badges.RAVER_PINK_ID()); - assertEq(purpleId, s2Badges.RAVER_PURPLE_ID()); - - (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1BadgesV2.BADGE_ROBOTS()); - assertEq(pinkId, s2Badges.ROBOT_PINK_ID()); - assertEq(purpleId, s2Badges.ROBOT_PURPLE_ID()); - - (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1BadgesV2.BADGE_BOUNCERS()); - assertEq(pinkId, s2Badges.BOUNCER_PINK_ID()); - assertEq(purpleId, s2Badges.BOUNCER_PURPLE_ID()); - - (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1BadgesV2.BADGE_MASTERS()); - assertEq(pinkId, s2Badges.MASTER_PINK_ID()); - assertEq(purpleId, s2Badges.MASTER_PURPLE_ID()); - - (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1BadgesV2.BADGE_MONKS()); - assertEq(pinkId, s2Badges.MONK_PINK_ID()); - assertEq(purpleId, s2Badges.MONK_PURPLE_ID()); - - (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1BadgesV2.BADGE_DRUMMERS()); - assertEq(pinkId, s2Badges.DRUMMER_PINK_ID()); - assertEq(purpleId, s2Badges.DRUMMER_PURPLE_ID()); - - (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1BadgesV2.BADGE_ANDROIDS()); - assertEq(pinkId, s2Badges.ANDROID_PINK_ID()); - assertEq(purpleId, s2Badges.ANDROID_PURPLE_ID()); - - (pinkId, purpleId) = s2Badges.getSeason2BadgeIds(s1BadgesV2.BADGE_SHINTO()); - assertEq(pinkId, s2Badges.SHINTO_PINK_ID()); - assertEq(purpleId, s2Badges.SHINTO_PURPLE_ID()); - } - - function test_s2_s1_badgeId_conversion() public view { - uint256 s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.RAVER_PINK_ID()); - assertEq(s1BadgeId, s1BadgesV2.BADGE_RAVERS()); - s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.RAVER_PURPLE_ID()); - assertEq(s1BadgeId, s1BadgesV2.BADGE_RAVERS()); - - s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.ROBOT_PINK_ID()); - assertEq(s1BadgeId, s1BadgesV2.BADGE_ROBOTS()); - s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.ROBOT_PURPLE_ID()); - assertEq(s1BadgeId, s1BadgesV2.BADGE_ROBOTS()); - - s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.BOUNCER_PINK_ID()); - assertEq(s1BadgeId, s1BadgesV2.BADGE_BOUNCERS()); - s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.BOUNCER_PURPLE_ID()); - assertEq(s1BadgeId, s1BadgesV2.BADGE_BOUNCERS()); - - s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.MASTER_PINK_ID()); - assertEq(s1BadgeId, s1BadgesV2.BADGE_MASTERS()); - s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.MASTER_PURPLE_ID()); - assertEq(s1BadgeId, s1BadgesV2.BADGE_MASTERS()); - - s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.MONK_PINK_ID()); - assertEq(s1BadgeId, s1BadgesV2.BADGE_MONKS()); - s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.MONK_PURPLE_ID()); - assertEq(s1BadgeId, s1BadgesV2.BADGE_MONKS()); - - s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.DRUMMER_PINK_ID()); - assertEq(s1BadgeId, s1BadgesV2.BADGE_DRUMMERS()); - s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.DRUMMER_PURPLE_ID()); - assertEq(s1BadgeId, s1BadgesV2.BADGE_DRUMMERS()); - - s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.ANDROID_PINK_ID()); - assertEq(s1BadgeId, s1BadgesV2.BADGE_ANDROIDS()); - s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.ANDROID_PURPLE_ID()); - assertEq(s1BadgeId, s1BadgesV2.BADGE_ANDROIDS()); - - s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.SHINTO_PINK_ID()); - assertEq(s1BadgeId, s1BadgesV2.BADGE_SHINTO()); - s1BadgeId = s2Badges.getSeason1BadgeId(s2Badges.SHINTO_PURPLE_ID()); - assertEq(s1BadgeId, s1BadgesV2.BADGE_SHINTO()); - } - - function mint_s1(address minter, uint256 badgeId) public { - bytes32 _hash = s1BadgesV2.getHash(minter, badgeId); - - (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); - - bool canMint = s1BadgesV2.canMint(abi.encodePacked(r, s, v), minter, badgeId); - assertTrue(canMint); - - vm.startPrank(minter); - s1BadgesV2.mint(abi.encodePacked(r, s, v), badgeId); - vm.stopPrank(); - } - - function test_mint_s1() public { - mint_s1(minters[0], s1BadgesV2.BADGE_RAVERS()); - mint_s1(minters[0], s1BadgesV2.BADGE_ROBOTS()); - assertEq(s1BadgesV2.balanceOf(minters[0]), 2); - - mint_s1(minters[1], s1BadgesV2.BADGE_BOUNCERS()); - mint_s1(minters[1], s1BadgesV2.BADGE_MASTERS()); - assertEq(s1BadgesV2.balanceOf(minters[1]), 2); - - mint_s1(minters[2], s1BadgesV2.BADGE_MONKS()); - mint_s1(minters[2], s1BadgesV2.BADGE_DRUMMERS()); - assertEq(s1BadgesV2.balanceOf(minters[2]), 2); - } - - function test_startMigration() public { - mint_s1(minters[0], BADGE_ID); - - uint256 tokenId = s1BadgesV2.tokenOfOwnerByIndex(minters[0], 0); - - vm.startPrank(minters[0]); - s1BadgesV2.approve(address(s2Badges), tokenId); - s2Badges.startMigration(BADGE_ID); - vm.stopPrank(); - - assertEq(s1BadgesV2.balanceOf(minters[0]), 0); - assertEq(s1BadgesV2.balanceOf(address(s2Badges)), 1); - - assertEq(s1BadgesV2.ownerOf(tokenId), address(s2Badges)); - - assertEq(s2Badges.isMigrationActive(minters[0]), true); - } - - function wait(uint256 time) public { - vm.warp(block.timestamp + time); - } - - // happy-path, make 3 pink tampers, and 2 purple ones - function test_tamperMigration() public { - test_startMigration(); - - vm.startPrank(minters[0]); - for (uint256 i = 0; i < MAX_TAMPERS; i++) { - wait(s2Badges.COOLDOWN_TAMPER()); - s2Badges.tamperMigration(PINK_TAMPER); - } - - wait(s2Badges.COOLDOWN_TAMPER()); - s2Badges.tamperMigration(PURPLE_TAMPER); - wait(s2Badges.COOLDOWN_TAMPER()); - s2Badges.tamperMigration(PURPLE_TAMPER); - - vm.stopPrank(); - - assertEq(s2Badges.isTamperActive(minters[0]), true); - assertEq(s2Badges.isMigrationActive(minters[0]), true); - - (uint256 pinkTampers, uint256 purpleTampers) = s2Badges.getMigrationTampers(minters[0]); - assertEq(pinkTampers, MAX_TAMPERS); - assertEq(purpleTampers, 2); - } - - function test_revert_tooManyTampers() public { - test_tamperMigration(); - vm.startPrank(minters[0]); - vm.expectRevert(); - s2Badges.tamperMigration(PINK_TAMPER); - - vm.stopPrank(); - } - - function test_resetTampers() public { - test_tamperMigration(); - assertEq(s2Badges.isTamperActive(minters[0]), true); - (uint256 pinkTampers, uint256 purpleTampers) = s2Badges.getMigrationTampers(minters[0]); - assertEq(pinkTampers, MAX_TAMPERS); - assertEq(purpleTampers, 2); - - vm.prank(minters[0]); - s2Badges.resetTampers(); - - assertEq(s2Badges.isTamperActive(minters[0]), false); - (pinkTampers, purpleTampers) = s2Badges.getMigrationTampers(minters[0]); - assertEq(pinkTampers, 0); - assertEq(purpleTampers, 0); - } - - - function test_endMigration() public { - test_tamperMigration(); - - wait(s2Badges.COOLDOWN_TAMPER()); - wait(s2Badges.COOLDOWN_MIGRATION()); - - // generate the claim hash for the current migration - bytes32 claimHash = s2Badges.generateClaimHash( - minters[0], - 0 // experience points - ); - - // simulate the backend signing the hash - (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, claimHash); - - // exercise the randomFromSignature function - - vm.startPrank(minters[0]); - s2Badges.endMigration(claimHash, v, r, s, 0); - vm.stopPrank(); - - // check for s1 burn - assertEq(s1BadgesV2.balanceOf(minters[0]), 0); - assertEq(s1BadgesV2.balanceOf(address(s2Badges)), 0); - - // check for s2 state reset - assertEq(s2Badges.isMigrationActive(minters[0]), false); - assertEq(s2Badges.isTamperActive(minters[0]), false); - - // check for s2 mint - (uint256 pinkBadgeId, uint256 purpleBadgeId) = s2Badges.getSeason2BadgeIds(BADGE_ID); - uint256 s2TokenId = s2Badges.getTokenId(minters[0], pinkBadgeId) > 0 - ? s2Badges.getTokenId(minters[0], pinkBadgeId) - : s2Badges.getTokenId(minters[0], purpleBadgeId); - assertEq(s2Badges.balanceOf(minters[0], s2TokenId), 1); - - // check for s2 badge balances - bool[16] memory badgeBalances = s2Badges.badgeBalances(minters[0]); - - assertTrue( - badgeBalances[s2Badges.RAVER_PINK_ID()] || badgeBalances[s2Badges.RAVER_PURPLE_ID()] - ); - - assertFalse(badgeBalances[s2Badges.ROBOT_PINK_ID()]); - assertFalse(badgeBalances[s2Badges.ROBOT_PURPLE_ID()]); - assertFalse(badgeBalances[s2Badges.BOUNCER_PINK_ID()]); - assertFalse(badgeBalances[s2Badges.BOUNCER_PURPLE_ID()]); - assertFalse(badgeBalances[s2Badges.MASTER_PINK_ID()]); - assertFalse(badgeBalances[s2Badges.MASTER_PURPLE_ID()]); - assertFalse(badgeBalances[s2Badges.MONK_PINK_ID()]); - assertFalse(badgeBalances[s2Badges.MONK_PURPLE_ID()]); - assertFalse(badgeBalances[s2Badges.DRUMMER_PINK_ID()]); - assertFalse(badgeBalances[s2Badges.DRUMMER_PURPLE_ID()]); - assertFalse(badgeBalances[s2Badges.ANDROID_PINK_ID()]); - assertFalse(badgeBalances[s2Badges.ANDROID_PURPLE_ID()]); - assertFalse(badgeBalances[s2Badges.SHINTO_PINK_ID()]); - assertFalse(badgeBalances[s2Badges.SHINTO_PURPLE_ID()]); - } - - function test_revert_startMigrationTwice() public { - test_startMigration(); - vm.startPrank(minters[0]); - vm.expectRevert(); - s2Badges.startMigration(BADGE_ID); - vm.stopPrank(); - } - - function test_revert_migrateDisabled() public { - uint256 badgeId = s1BadgesV2.BADGE_ROBOTS(); - mint_s1(minters[0], badgeId); - - uint256 tokenId = s1BadgesV2.tokenOfOwnerByIndex(minters[0], 0); - - vm.startPrank(minters[0]); - s1BadgesV2.approve(address(s2Badges), tokenId); - vm.expectRevert(); - s2Badges.startMigration(badgeId); - vm.stopPrank(); - // ensure no values got changed/updated - assertEq(s1BadgesV2.balanceOf(minters[0]), 1); - assertEq(s1BadgesV2.balanceOf(address(s2Badges)), 0); - assertEq(s1BadgesV2.ownerOf(tokenId), minters[0]); - assertEq(s2Badges.isMigrationActive(minters[0]), false); - } - - function test_revert_pausedContract() public { - // have the admin pause the contract - // ensure no badges are mintable afterwards - vm.startPrank(owner); - s2Badges.pause(); - vm.stopPrank(); - - mint_s1(minters[0], BADGE_ID); - - uint256 tokenId = s1BadgesV2.tokenOfOwnerByIndex(minters[0], 0); - - vm.startPrank(minters[0]); - s1BadgesV2.approve(address(s2Badges), tokenId); - vm.expectRevert(); - s2Badges.startMigration(BADGE_ID); - vm.stopPrank(); - // ensure no values got changed/updated - assertEq(s1BadgesV2.balanceOf(minters[0]), 1); - assertEq(s1BadgesV2.balanceOf(address(s2Badges)), 0); - assertEq(s1BadgesV2.ownerOf(tokenId), minters[0]); - assertEq(s2Badges.isMigrationActive(minters[0]), false); - } - - function test_randomFromSignature() public view { - bytes32 signatureHash = keccak256( - abi.encodePacked( - keccak256("1234567890"), // should use the block's hash - minters[0] - ) - ); - - (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, signatureHash); - - uint256 random = s2Badges.randomFromSignature(signatureHash, v, r, s); - - assertEq( - random, -28_417_844_340_632_250_945_870_465_294_567_768_196_388_504_060_802_704_441_612_911_129_119_444_309_664 - ); - } - -} -*/ From 98c374b81829e51152f2ba6008ee9c41ffa57c56 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 17 Oct 2024 16:21:08 +0200 Subject: [PATCH 47/79] natspec comment, cleanup --- .../trailblazers-season-2/BadgeMigration.sol | 230 +++++---- .../TrailblazersBadgesS2.sol | 84 ++-- .../trailblazers-season-2/original.sol | 473 ------------------ .../BadgeMigration.t.sol | 4 +- 4 files changed, 178 insertions(+), 613 deletions(-) delete mode 100644 packages/nfts/contracts/trailblazers-season-2/original.sol diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index 2c363068875..40ce3884da7 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -31,20 +31,22 @@ contract BadgeMigration is AccessControlUpgradeable, ERC721HolderUpgradeable { + /// @notice Season 1 Badges ERC721 contract TrailblazersBadgesV4 public s1Badges; + /// @notice Season 2 Badges ERC1155 contract TrailblazersBadgesS2 public s2Badges; + /// @notice Wallet authorized to sign as a source of randomness address public randomSigner; - /// @notice Migration-enabled badge IDs per cycle - mapping(uint256 _cycle => mapping(uint256 _s1BadgeId => bool _enabled)) public enabledBadgeIds; - + mapping(uint256 cycle => mapping(uint256 s1BadgeId => bool enabled)) public enabledBadgeIds; /// @notice Current migration cycle - uint256 private _migrationCycle; + uint256 private migrationCycle; /// @notice Mapping of unique user-per-mint-per-cycle mapping( - uint256 _migrationCycle - => mapping(address _minter => mapping(uint256 _s1BadgeId => bool _mintEnded)) + uint256 migrationCycle + => mapping(address minter => mapping(uint256 s1BadgeId => bool mintEnded)) ) public migrationCycleUniqueMints; + /// @notice Configuration struct struct Config { uint256 cooldownMigration; @@ -52,8 +54,10 @@ contract BadgeMigration is uint256 tamperWeightPercent; uint256 baseMaxTampers; } + /// @notice Current config Config private config; + /// @notice Migration struct struct Migration { uint256 migrationCycle; @@ -66,10 +70,13 @@ contract BadgeMigration is uint256 pinkTampers; uint256 purpleTampers; } + /// @notice Migrations per user mapping(address _user => Migration[] _migration) public migrations; - + /// @notice Gap for upgrade safety + uint256[43] private __gap; /// @notice Errors + error MAX_TAMPERS_REACHED(); error MIGRATION_NOT_STARTED(); error MIGRATION_ALREADY_STARTED(); @@ -82,9 +89,7 @@ contract BadgeMigration is error HASH_MISMATCH(); /// @notice Events - event MigrationCycleToggled( - uint256 indexed _migrationCycleId, uint256 _s1BadgeId, bool _enabled - ); + event MigrationCycleToggled(uint256 indexed migrationCycleId, uint256 s1BadgeId, bool enabled); event MigrationUpdated( uint256 indexed migrationCycle, @@ -98,10 +103,10 @@ contract BadgeMigration is uint256 purpleTampers ); - /// @notice Modifiers + /// @notice Check if the message sender has an active migration modifier isMigrating() { - Migration memory _migration = getActiveMigrationFor(_msgSender()); - if (_migration.cooldownExpiration == 0) { + Migration memory migration_ = getActiveMigrationFor(_msgSender()); + if (migration_.cooldownExpiration == 0) { revert MIGRATION_NOT_STARTED(); } _; @@ -119,23 +124,30 @@ contract BadgeMigration is } /// @notice Reverts if migrations aren't enabled for that badge + /// @param _s1BadgeId The badge ID modifier migrationOpen(uint256 _s1BadgeId) { - if (!enabledBadgeIds[_migrationCycle][_s1BadgeId]) { + if (!enabledBadgeIds[migrationCycle][_s1BadgeId]) { revert MIGRATION_NOT_ENABLED(); } _; } /// @notice Limits migrations to one per user, badge and cycle + /// @param _s1BadgeId The badge ID + /// @param _minter The minter address modifier hasntMigratedInCycle(uint256 _s1BadgeId, address _minter) { // check that the minter hasn't used the migration within this cycle - if (migrationCycleUniqueMints[_migrationCycle][_minter][_s1BadgeId]) { + if (migrationCycleUniqueMints[migrationCycle][_minter][_s1BadgeId]) { revert ALREADY_MIGRATED_IN_CYCLE(); } _; } /// @notice Contract initializer + /// @param _s1Badges The Season 1 Badges contract address + /// @param _s2Badges The Season 2 Badges contract address + /// @param _randomSigner The random signer address + /// @param _config The initial configuration function initialize( address _s1Badges, address _s2Badges, @@ -154,10 +166,14 @@ contract BadgeMigration is config = _config; } + /// @notice Upgrade configuration + /// @param _config The new configuration function setConfig(Config memory _config) external onlyRole(DEFAULT_ADMIN_ROLE) { config = _config; } + /// @notice Get the current configuration + /// @return The current configuration function getConfig() external view returns (Config memory) { return config; } @@ -166,11 +182,11 @@ contract BadgeMigration is /// @dev Doesn't allow for new migration attempts, but tampers and active migrations still run function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) { for (uint256 i = 0; i < 8; i++) { - if (enabledBadgeIds[_migrationCycle][i]) { - emit MigrationCycleToggled(_migrationCycle, i, false); + if (enabledBadgeIds[migrationCycle][i]) { + emit MigrationCycleToggled(migrationCycle, i, false); } - enabledBadgeIds[_migrationCycle][i] = false; + enabledBadgeIds[migrationCycle][i] = false; } } @@ -181,15 +197,17 @@ contract BadgeMigration is external onlyRole(DEFAULT_ADMIN_ROLE) { - _migrationCycle++; + migrationCycle++; for (uint256 i = 0; i < _s1BadgeIds.length; i++) { - enabledBadgeIds[_migrationCycle][_s1BadgeIds[i]] = true; - emit MigrationCycleToggled(_migrationCycle, _s1BadgeIds[i], true); + enabledBadgeIds[migrationCycle][_s1BadgeIds[i]] = true; + emit MigrationCycleToggled(migrationCycle, _s1BadgeIds[i], true); } } - function migrationCycle() external view returns (uint256) { - return _migrationCycle; + /// @notice Get the current migration cycle + /// @return The current migration cycle + function getMigrationCycle() external view returns (uint256) { + return migrationCycle; } /// @notice Pause the contract @@ -204,8 +222,11 @@ contract BadgeMigration 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 migrationOpen(_s1BadgeId) isNotMigrating - // hasntMigratedInCycle(_s1BadgeId, _msgSender()) + function startMigration(uint256 _s1BadgeId) + external + migrationOpen(_s1BadgeId) + isNotMigrating + hasntMigratedInCycle(_s1BadgeId, _msgSender()) { uint256 s1TokenId = s1Badges.getTokenId(_msgSender(), _s1BadgeId); @@ -214,7 +235,7 @@ contract BadgeMigration is } Migration memory _migration = Migration( - _migrationCycle, // migrationCycle + migrationCycle, // migrationCycle _msgSender(), // user _s1BadgeId, s1TokenId, @@ -243,6 +264,9 @@ contract BadgeMigration is ); } + /// @notice Get the active migration for a user + /// @param _user The user address + /// @return The active migration function getActiveMigrationFor(address _user) public view returns (Migration memory) { if (migrations[_user].length == 0) { revert MIGRATION_NOT_STARTED(); @@ -250,6 +274,8 @@ contract BadgeMigration is return migrations[_user][migrations[_user].length - 1]; } + /// @notice Update a migration + /// @param _migration The updated migration function _updateMigration(Migration memory _migration) internal virtual { migrations[_migration.user][migrations[_migration.user].length - 1] = _migration; @@ -266,15 +292,19 @@ contract BadgeMigration is ); } - function maxTampers(uint256 exp) internal view virtual returns (uint256 value) { - // start at 3 tampers - // add +1 tamper for every 100 exp - value = exp / 100; + /// @notice Get the maximum number of tampers for a given experience + /// @param _exp The user's experience points + function maxTampers(uint256 _exp) public view virtual returns (uint256 value) { + value = _exp / 100; value += 2 * config.baseMaxTampers; return value; } /// @notice Tamper (alter) the chances during a migration + /// @param _hash The hash to sign + /// @param v signature V field + /// @param r signature R field + /// @param s signature S field /// @param _pinkOrPurple true for pink, false for purple /// @dev Can be called only during an active migration /// @dev Implements a cooldown before allowing to re-tamper @@ -290,116 +320,111 @@ contract BadgeMigration is external isMigrating { - (address _recovered,,) = ECDSA.tryRecover(_hash, v, r, s); - if (_recovered != randomSigner) revert NOT_RANDOM_SIGNER(); - // Hash the signature parts to get a deterministic pseudo-random number - - Migration memory _migration = getActiveMigrationFor(_msgSender()); + (address recovered_,,) = ECDSA.tryRecover(_hash, v, r, s); + if (recovered_ != randomSigner) revert NOT_RANDOM_SIGNER(); + Migration memory migration_ = getActiveMigrationFor(_msgSender()); - if ((_migration.pinkTampers + _migration.purpleTampers) > maxTampers(exp)) { + if ((migration_.pinkTampers + migration_.purpleTampers) > maxTampers(exp)) { revert MAX_TAMPERS_REACHED(); } - if (_migration.tamperExpiration > block.timestamp) { + if (migration_.tamperExpiration > block.timestamp) { revert TAMPER_IN_PROGRESS(); } if (_pinkOrPurple) { - _migration.pinkTampers++; + migration_.pinkTampers++; } else { - _migration.purpleTampers++; + migration_.purpleTampers++; } - _migration.tamperExpiration = block.timestamp + config.cooldownTamper; + migration_.tamperExpiration = block.timestamp + config.cooldownTamper; - // update migration - _updateMigration(_migration); + _updateMigration(migration_); } /// @notice Reset the tamper counts /// @dev Can be called only during an active migration function resetTampers() external isMigrating { - Migration memory _migration = getActiveMigrationFor(_msgSender()); - _migration.pinkTampers = 0; - _migration.purpleTampers = 0; - _migration.tamperExpiration = 0; + Migration memory migration_ = getActiveMigrationFor(_msgSender()); + migration_.pinkTampers = 0; + migration_.purpleTampers = 0; + migration_.tamperExpiration = 0; - _updateMigration(_migration); + _updateMigration(migration_); } /// @notice End a migration /// @param _hash The hash to sign - /// @param v signature V field - /// @param r signature R field - /// @param s signature S field - /// @param exp The user's experience points + /// @param _v signature V field + /// @param _r signature R field + /// @param _s signature S field + /// @param _exp The user's experience points /// @dev Can be called only during an active migration, after the cooldown is over /// @dev The final color is determined randomly, and affected by the tamper amounts function endMigration( bytes32 _hash, - uint8 v, - bytes32 r, - bytes32 s, - uint256 exp + uint8 _v, + bytes32 _r, + bytes32 _s, + uint256 _exp ) external isMigrating { - Migration memory _migration = getActiveMigrationFor(_msgSender()); + Migration memory migration_ = getActiveMigrationFor(_msgSender()); - if (_migration.tamperExpiration > block.timestamp) { + if (migration_.tamperExpiration > block.timestamp) { revert TAMPER_IN_PROGRESS(); } // check if the cooldown is over - if (_migration.cooldownExpiration > block.timestamp) { + if (migration_.cooldownExpiration > block.timestamp) { revert MIGRATION_NOT_READY(); } - // ensure the hash corresponds to the start time - bytes32 calculatedHash = generateClaimHash(_msgSender(), exp); + bytes32 calculatedHash_ = generateClaimHash(_msgSender(), _exp); - if (calculatedHash != _hash) { + if (calculatedHash_ != _hash) { revert HASH_MISMATCH(); } // get the tamper amounts - uint256 pinkTampers = _migration.pinkTampers; - uint256 purpleTampers = _migration.purpleTampers; + uint256 pinkTampers_ = migration_.pinkTampers; + uint256 purpleTampers_ = migration_.purpleTampers; - uint256 randomSeed = randomFromSignature(_hash, v, r, s); - bool isPinkOrPurple; + uint256 randomSeed_ = randomFromSignature(_hash, _v, _r, _s); + bool isPinkOrPurple_; // Calculate the difference in tampers and adjust chances - if (pinkTampers > purpleTampers) { - uint256 extraChance = (pinkTampers - purpleTampers) * config.tamperWeightPercent; + if (pinkTampers_ > purpleTampers_) { + uint256 extraChance = (pinkTampers_ - purpleTampers_) * config.tamperWeightPercent; uint256 chance = 50 + extraChance; // Base 50% + extra chance - isPinkOrPurple = (randomSeed % 100) < chance; // True for pink - } else if (purpleTampers > pinkTampers) { - uint256 extraChance = (purpleTampers - pinkTampers) * config.tamperWeightPercent; + isPinkOrPurple_ = (randomSeed_ % 100) < chance; // True for pink + } else if (purpleTampers_ > pinkTampers_) { + uint256 extraChance = (purpleTampers_ - pinkTampers_) * config.tamperWeightPercent; uint256 chance = 50 + extraChance; // Base 50% + extra chance - isPinkOrPurple = (randomSeed % 100) >= chance; // False for purple + isPinkOrPurple_ = (randomSeed_ % 100) >= chance; // False for purple } else { // Equal number of pink and purple tampers, 50/50 chance - isPinkOrPurple = (randomSeed % 100) < 50; + isPinkOrPurple_ = (randomSeed_ % 100) < 50; } - uint256 s1BadgeId = _migration.s1BadgeId; - uint256 s1TokenId = _migration.s1TokenId; - s1Badges.burn(s1TokenId); + uint256 s1BadgeId_ = migration_.s1BadgeId; + uint256 s1TokenId_ = migration_.s1TokenId; + s1Badges.burn(s1TokenId_); - TrailblazersBadgesS2.MovementType pinkOrPurple = isPinkOrPurple + TrailblazersBadgesS2.MovementType pinkOrPurple = isPinkOrPurple_ ? TrailblazersBadgesS2.MovementType.Minnow : TrailblazersBadgesS2.MovementType.Whale; // mint the badge - s2Badges.mint(_msgSender(), TrailblazersBadgesS2.BadgeType(s1BadgeId), pinkOrPurple); - - uint256 s2TokenId = s2Badges.totalSupply(); + s2Badges.mint(_msgSender(), TrailblazersBadgesS2.BadgeType(s1BadgeId_), pinkOrPurple); + uint256 s2TokenId_ = s2Badges.totalSupply(); - _migration.s2TokenId = s2TokenId; - _migration.cooldownExpiration = 0; - _migration.tamperExpiration = 0; + migration_.s2TokenId = s2TokenId_; + migration_.cooldownExpiration = 0; + migration_.tamperExpiration = 0; - _updateMigration(_migration); + _updateMigration(migration_); } /// @notice Generate a unique hash for each migration uniquely @@ -417,38 +442,37 @@ contract BadgeMigration is if (migrations[_user].length == 0) { return false; } - Migration memory _migration = getActiveMigrationFor(_user); - return _migration.cooldownExpiration != 0; + Migration memory migration_ = getActiveMigrationFor(_user); + return migration_.cooldownExpiration != 0; } /// @notice Generates a random number from a signature - /// @param _hash The hash to sign (keccak256(startMigrationBlockHash, _msgSender())) - /// @param v signature V field - /// @param r signature R field - /// @param s signature S field + /// @param _hash The hash to sign + /// @param _v signature V field + /// @param _r signature R field + /// @param _s signature S field /// @return _random The pseudo-random number function randomFromSignature( bytes32 _hash, - uint8 v, - bytes32 r, - bytes32 s + uint8 _v, + bytes32 _r, + bytes32 _s ) public view returns (uint256 _random) { - (address _recovered,,) = ECDSA.tryRecover(_hash, v, r, s); - if (_recovered != randomSigner) revert NOT_RANDOM_SIGNER(); - // Hash the signature parts to get a deterministic pseudo-random number - return uint256(keccak256(abi.encodePacked(r, s, v))); + (address recovered_,,) = ECDSA.tryRecover(_hash, _v, _r, _s); + if (recovered_ != randomSigner) revert NOT_RANDOM_SIGNER(); + return uint256(keccak256(abi.encodePacked(_r, _s, _v))); } /// @notice Check if a tamper is active for a user /// @param _user The user address /// @return Whether the user has an active tamper function isTamperActive(address _user) public view returns (bool) { - Migration memory _migration = getActiveMigrationFor(_user); - return _migration.tamperExpiration > block.timestamp; + Migration memory migration_ = getActiveMigrationFor(_user); + return migration_.tamperExpiration > block.timestamp; } /// @notice Get the migration tamper counts for a user @@ -463,15 +487,15 @@ contract BadgeMigration is if (!isMigrationActive(_user)) { revert MIGRATION_NOT_STARTED(); } - Migration memory _migration = getActiveMigrationFor(_user); - return (_migration.pinkTampers, _migration.purpleTampers); + Migration memory migration_ = getActiveMigrationFor(_user); + return (migration_.pinkTampers, migration_.purpleTampers); } /// @notice supportsInterface implementation - /// @param interfaceId The interface ID + /// @param _interfaceId The interface ID /// @return Whether the interface is supported - function supportsInterface(bytes4 interfaceId) public view override returns (bool) { - return super.supportsInterface(interfaceId); + function supportsInterface(bytes4 _interfaceId) public view override returns (bool) { + return super.supportsInterface(_interfaceId); } /// @notice Internal method to authorize an upgrade diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol index b16d5341740..3e405655239 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol @@ -29,6 +29,7 @@ contract TrailblazersBadgesS2 is Ownable2StepUpgradeable, ERC1155SupplyUpgradeable { + /// @notice Badge types enum BadgeType { Ravers, // s1 id: 0 Robots, // s1 id: 1 @@ -40,34 +41,35 @@ contract TrailblazersBadgesS2 is Shinto // s1 id: 7 } - + /// @notice Movement types enum MovementType { Dev, // s1 neutral Minnow, // s1 based/pink Whale // s1 boosted/purple } + /// @notice Badge struct struct Badge { uint256 tokenId; BadgeType badgeType; MovementType movementType; } + /// @notice Badge mapping mapping(uint256 tokenId => Badge badge) private badges; - + /// @notice Badge URI template string public uriTemplate; - + /// @notice Minter address; BadgeMigration contract address public minter; - /// @notice Gap for upgrade safety uint256[43] private __gap; /// @notice Errors error NOT_MINTER(); error TOKEN_NOT_MINTED(); - /// @notice Modifiers + /// @notice Allow only the minter to call the function modifier onlyMinter() { if (minter != _msgSender()) { revert NOT_MINTER(); @@ -75,6 +77,9 @@ contract TrailblazersBadgesS2 is _; } + /// @notice Initialize the contract + /// @param _minter The minter address + /// @param _uriTemplate The badge URI template function initialize( address _minter, string calldata _uriTemplate @@ -92,10 +97,18 @@ contract TrailblazersBadgesS2 is uriTemplate = _uriTemplate; } + /// @notice Set the minter address + /// @param _minter The minter address + /// @dev Only the owner can call this function function setMinter(address _minter) external virtual onlyOwner { minter = _minter; } + /// @notice Mint a badge + /// @param _to The address to mint the badge to + /// @param _badgeType The badge type + /// @param _movementType The movement type + /// @dev Only the minter can call this function function mint( address _to, BadgeType _badgeType, @@ -105,12 +118,16 @@ contract TrailblazersBadgesS2 is virtual onlyMinter { - uint256 tokenId = totalSupply() + 1; - Badge memory badge = Badge(tokenId, _badgeType, _movementType); - _mint(_to, tokenId, 1, ""); - badges[tokenId] = badge; + uint256 tokenId_ = totalSupply() + 1; + Badge memory badge_ = Badge(tokenId_, _badgeType, _movementType); + _mint(_to, tokenId_, 1, ""); + badges[tokenId_] = badge_; } + /// @notice Internal method to assemble URIs + /// @param _badgeType The badge type + /// @param _movementType The movement type + /// @return The URI function _uri( BadgeType _badgeType, MovementType _movementType @@ -120,12 +137,16 @@ contract TrailblazersBadgesS2 is virtual returns (string memory) { - string memory badgeType = Strings.toString(uint256(_badgeType)); - string memory movementType = Strings.toString(uint256(_movementType)); + string memory badgeType_ = Strings.toString(uint256(_badgeType)); + string memory movementType_ = Strings.toString(uint256(_movementType)); - return string(abi.encodePacked(uriTemplate, badgeType, "/", movementType, ".json")); + return string(abi.encodePacked(uriTemplate, badgeType_, "/", movementType_, ".json")); } + /// @notice Retrieve the URI for a badge given the type & movement + /// @param _badgeType The badge type + /// @param _movementType The movement type + /// @return The URI function uri( BadgeType _badgeType, MovementType _movementType @@ -138,39 +159,32 @@ contract TrailblazersBadgesS2 is return _uri(_badgeType, _movementType); } - function uri(uint256 tokenId) public view virtual override returns (string memory) { - if (tokenId > totalSupply()) { + /// @notice Retrieve the URI for a badge given the token ID + /// @param _tokenId The token ID + /// @return The URI + function uri(uint256 _tokenId) public view virtual override returns (string memory) { + if (_tokenId > totalSupply()) { revert TOKEN_NOT_MINTED(); } - Badge memory badge = badges[tokenId]; - return _uri(badge.badgeType, badge.movementType); + Badge memory badge_ = badges[_tokenId]; + return _uri(badge_.badgeType, badge_.movementType); } - function getBadge(uint256 tokenId) external view virtual returns (Badge memory) { - if (tokenId < totalSupply()) { + /// @notice Retrieve a badge + /// @param _tokenId The token ID + /// @return The badge + function getBadge(uint256 _tokenId) external view virtual returns (Badge memory) { + if (_tokenId < totalSupply()) { revert TOKEN_NOT_MINTED(); } - return badges[tokenId]; - } - - /// @notice Retrieve boolean balance for each badge - /// @param _owner The addresses to check - /// @return _balances The badges atomic balances - function badgeBalances(address _owner) public view returns (bool[16] memory _balances) { - /* - for (uint256 i = 0; i < BADGE_COUNT; i++) { - uint256 tokenId = getTokenId(_owner, i); - _balances[i] = tokenId > 0; - } - - return _balances;*/ + return badges[_tokenId]; } /// @notice supportsInterface implementation - /// @param interfaceId The interface ID + /// @param _interfaceId The interface ID /// @return Whether the interface is supported - function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { - return super.supportsInterface(interfaceId); + function supportsInterface(bytes4 _interfaceId) public view virtual override returns (bool) { + return super.supportsInterface(_interfaceId); } /// @notice Internal method to authorize an upgrade diff --git a/packages/nfts/contracts/trailblazers-season-2/original.sol b/packages/nfts/contracts/trailblazers-season-2/original.sol deleted file mode 100644 index 485683068ab..00000000000 --- a/packages/nfts/contracts/trailblazers-season-2/original.sol +++ /dev/null @@ -1,473 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.24; - -import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol"; -import "../trailblazers-badges/ECDSAWhitelist.sol"; -import "@taiko/blacklist/IMinimalBlacklist.sol"; -import "@openzeppelin/contracts/utils/Strings.sol"; -import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; -import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; -import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; -import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; -import "@openzeppelin/contracts/access/AccessControl.sol"; -import "@openzeppelin/contracts/utils/Strings.sol"; -import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol"; -import "./TrailblazersS1BadgesV4.sol"; -import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; - -contract TrailblazersBadgesS2 is - PausableUpgradeable, - UUPSUpgradeable, - Ownable2StepUpgradeable, - AccessControlUpgradeable, - ERC1155SupplyUpgradeable, - ERC721HolderUpgradeable -{ - /// @notice Time between start and end of a migration - uint256 public constant COOLDOWN_MIGRATION = 1 minutes; //6 hours; - /// @notice Time between tamper attempts - uint256 public constant COOLDOWN_TAMPER = 1 minutes; // 1 hours; - /// @notice Weight of tamper attempts, in % - uint256 public constant TAMPER_WEIGHT_PERCENT = 5; - /// @notice Maximum tamper attempts, per color - uint256 public constant MAX_TAMPERS = 3; - /// @notice S2 Badge IDs - uint256 public constant RAVER_PINK_ID = 0; - uint256 public constant RAVER_PURPLE_ID = 1; - uint256 public constant ROBOT_PINK_ID = 2; - uint256 public constant ROBOT_PURPLE_ID = 3; - uint256 public constant BOUNCER_PINK_ID = 4; - uint256 public constant BOUNCER_PURPLE_ID = 5; - uint256 public constant MASTER_PINK_ID = 6; - uint256 public constant MASTER_PURPLE_ID = 7; - uint256 public constant MONK_PINK_ID = 8; - uint256 public constant MONK_PURPLE_ID = 9; - uint256 public constant DRUMMER_PINK_ID = 10; - uint256 public constant DRUMMER_PURPLE_ID = 11; - uint256 public constant ANDROID_PINK_ID = 12; - uint256 public constant ANDROID_PURPLE_ID = 13; - uint256 public constant SHINTO_PINK_ID = 14; - uint256 public constant SHINTO_PURPLE_ID = 15; - /// @notice Total badge count - uint256 public constant BADGE_COUNT = 16; - - /// @notice Cooldown for migration - mapping(address _user => uint256 _cooldown) public claimCooldowns; - /// @notice Cooldown for tampering - mapping(address _user => uint256 _cooldown) public tamperCooldowns; - /// @notice Tamper count - mapping(address _user => mapping(bool pinkOrPurple => uint256 _tampers)) public migrationTampers; - /// @notice S1 Migration Badge ID mapping - mapping(address _user => uint256 _badgeId) private migrationS1BadgeIds; - /// @notice S1 Migration Token ID mapping - mapping(address _user => uint256 _tokenId) private migrationS1TokenIds; - /// @notice User to badge ID, token ID mapping - mapping(address _user => mapping(uint256 _badgeId => uint256 _tokenId)) public userBadges; - /// @notice Migration-enabled badge IDs per cycle - mapping(uint256 _cycle => mapping(uint256 _s1BadgeId => bool _enabled)) public enabledBadgeIds; - /// @notice S1 Badge contract - TrailblazersBadgesV4 public badges; - /// @notice Address authorized to sign the random seeds - address public randomSigner; - /// @notice Current migration cycle - uint256 public migrationCycle; - /// @notice Mapping of unique user-per-mint-per-cycle - mapping( - uint256 _migrationCycle - => mapping(address _minter => mapping(uint256 _s1BadgeId => bool _mintEnded)) - ) public migrationCycleUniqueMints; - /// @notice Gap for upgrade safety - uint256[43] private __gap; - - /// @notice Errors - error MAX_TAMPERS_REACHED(); - error MIGRATION_NOT_STARTED(); - error MIGRATION_ALREADY_STARTED(); - error TAMPER_IN_PROGRESS(); - error CONTRACT_PAUSED(); - error MIGRATION_NOT_READY(); - error TOKEN_NOT_MINTED(); - error MIGRATION_NOT_ENABLED(); - error TOKEN_NOT_OWNED(); - error NOT_RANDOM_SIGNER(); - error ALREADY_MIGRATED_IN_CYCLE(); - error HASH_MISMATCH(); - - /// @notice Events - event MigrationToggled(uint256 indexed _migrationCycleId, uint256 _s1BadgeId, bool _enabled); - event MigrationStarted( - address _user, uint256 _s1BadgeId, uint256 _s1TokenId, uint256 _cooldownExpiration - ); - event MigrationTampered( - address indexed _user, - uint256 indexed _s1TokenId, - bool _pinkOrPurple, - uint256 _cooldownExpiration - ); - event MigrationEnded(address _user, uint256 _s2BadgeId, uint256 _s2TokenId); - - /// @notice Modifiers - modifier isMigrating() { - if (claimCooldowns[_msgSender()] == 0) { - revert MIGRATION_NOT_STARTED(); - } - _; - } - - /// @notice Reverts if sender is already migrating - modifier isNotMigrating() { - if (claimCooldowns[_msgSender()] != 0) { - revert MIGRATION_ALREADY_STARTED(); - } - _; - } - - /// @notice Reverts if migrations aren't enabled for that badge - modifier migrationOpen(uint256 _s1BadgeId) { - if (!enabledBadgeIds[migrationCycle][_s1BadgeId]) { - revert MIGRATION_NOT_ENABLED(); - } - _; - } - - /// @notice Limits migrations to one per user, badge and cycle - modifier hasntMigratedInCycle(uint256 _s1BadgeId, address _minter) { - // check that the minter hasn't used the migration within this cycle - if (migrationCycleUniqueMints[migrationCycle][_minter][_s1BadgeId]) { - revert ALREADY_MIGRATED_IN_CYCLE(); - } - _; - } - - /// @notice Contract initializer - /// @param _badges The address of the S1 badges contract - function initialize(address _badges, address _randomSigner) external initializer { - __ERC1155_init(""); - __ERC1155Supply_init(); - _transferOwnership(_msgSender()); - __Context_init(); - _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); - badges = TrailblazersBadgesV4(_badges); - randomSigner = _randomSigner; - } - - /// @notice Start a migration for a badge - /// @param _s1BadgeId The badge ID (s1) - /// @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 - migrationOpen(_s1BadgeId) - isNotMigrating - hasntMigratedInCycle(_s1BadgeId, _msgSender()) - { - uint256 s1TokenId = badges.getTokenId(_msgSender(), _s1BadgeId); - - if (badges.ownerOf(s1TokenId) != _msgSender()) { - revert TOKEN_NOT_OWNED(); - } - - // set off the claim cooldown - claimCooldowns[_msgSender()] = block.timestamp + COOLDOWN_MIGRATION; - migrationTampers[_msgSender()][true] = 0; - migrationTampers[_msgSender()][false] = 0; - migrationS1BadgeIds[_msgSender()] = _s1BadgeId; - migrationS1TokenIds[_msgSender()] = s1TokenId; - tamperCooldowns[_msgSender()] = 0; - // transfer the badge tokens to the migration contract - badges.transferFrom(_msgSender(), address(this), s1TokenId); - - emit MigrationStarted(_msgSender(), _s1BadgeId, s1TokenId, claimCooldowns[_msgSender()]); - } - - /// @notice Tamper (alter) the chances during a migration - /// @param _pinkOrPurple true for pink, false for purple - /// @dev Can be called only during an active migration - /// @dev Implements a cooldown before allowing to re-tamper - /// @dev The max tamper amount is determined by Pass Tier - function tamperMigration(bool _pinkOrPurple) external isMigrating { - if (migrationTampers[_msgSender()][_pinkOrPurple] >= MAX_TAMPERS) { - revert MAX_TAMPERS_REACHED(); - } - - if (tamperCooldowns[_msgSender()] > block.timestamp) { - revert TAMPER_IN_PROGRESS(); - } - - migrationTampers[_msgSender()][_pinkOrPurple]++; - tamperCooldowns[_msgSender()] = block.timestamp + COOLDOWN_TAMPER; - emit MigrationTampered( - _msgSender(), - migrationS1TokenIds[_msgSender()], - _pinkOrPurple, - tamperCooldowns[_msgSender()] - ); - } - - /// @notice Reset the tamper counts - /// @dev Can be called only during an active migration - function resetTampers() external isMigrating { - migrationTampers[_msgSender()][true] = 0; - migrationTampers[_msgSender()][false] = 0; - tamperCooldowns[_msgSender()] = 0; - } - - /// @notice End a migration - /// @param _hash The hash to sign - /// @param v signature V field - /// @param r signature R field - /// @param s signature S field - /// @param exp The user's experience points - /// @dev Can be called only during an active migration, after the cooldown is over - /// @dev The final color is determined randomly, and affected by the tamper amounts - function endMigration( - bytes32 _hash, - uint8 v, - bytes32 r, - bytes32 s, - uint256 exp - ) - external - isMigrating - { - if (tamperCooldowns[_msgSender()] > block.timestamp) { - revert TAMPER_IN_PROGRESS(); - } - // check if the cooldown is over - if (claimCooldowns[_msgSender()] > block.timestamp) { - revert MIGRATION_NOT_READY(); - } - - // ensure the hash corresponds to the start time - bytes32 calculatedHash = generateClaimHash(_msgSender(), exp); - - if (calculatedHash != _hash) { - revert HASH_MISMATCH(); - } - - // get the tamper amounts - uint256 pinkTampers = migrationTampers[_msgSender()][true]; - uint256 purpleTampers = migrationTampers[_msgSender()][false]; - - uint256 randomSeed = randomFromSignature(_hash, v, r, s); - bool isPinkOrPurple; - // Calculate the difference in tampers and adjust chances - if (pinkTampers > purpleTampers) { - uint256 extraChance = (pinkTampers - purpleTampers) * TAMPER_WEIGHT_PERCENT; - uint256 chance = 50 + extraChance; // Base 50% + extra chance - isPinkOrPurple = (randomSeed % 100) < chance; // True for pink - } else if (purpleTampers > pinkTampers) { - uint256 extraChance = (purpleTampers - pinkTampers) * TAMPER_WEIGHT_PERCENT; - uint256 chance = 50 + extraChance; // Base 50% + extra chance - isPinkOrPurple = (randomSeed % 100) >= chance; // False for purple - } else { - // Equal number of pink and purple tampers, 50/50 chance - isPinkOrPurple = (randomSeed % 100) < 50; - } - - uint256 s1BadgeId = migrationS1BadgeIds[_msgSender()]; - (uint256 pinkBadgeId, uint256 purpleBadgeId) = getSeason2BadgeIds(s1BadgeId); - uint256 s2BadgeId = isPinkOrPurple ? pinkBadgeId : purpleBadgeId; - - // burn the s1 badge - uint256 s1TokenId = migrationS1TokenIds[_msgSender()]; - badges.burn(s1TokenId); - - uint256 s2TokenId = totalSupply() + 1; - // mint the badge - _mint(_msgSender(), s2TokenId, 1, ""); - - // reset the cooldowns - claimCooldowns[_msgSender()] = 0; - migrationTampers[_msgSender()][true] = 0; - migrationTampers[_msgSender()][false] = 0; - tamperCooldowns[_msgSender()] = 0; - migrationS1BadgeIds[_msgSender()] = 0; - migrationS1TokenIds[_msgSender()] = 0; - userBadges[_msgSender()][s2BadgeId] = s2TokenId; - migrationCycleUniqueMints[migrationCycle][_msgSender()][s1BadgeId] = true; - emit MigrationEnded(_msgSender(), s2BadgeId, s2TokenId); - } - - /// @notice Enable migrations for a set of badges - /// @param _s1BadgeIds The badge IDs to enable - /// @dev Can be called only by the contract owner/admin - function enableMigrations(uint256[] calldata _s1BadgeIds) - external - onlyRole(DEFAULT_ADMIN_ROLE) - { - migrationCycle++; - for (uint256 i = 0; i < _s1BadgeIds.length; i++) { - enabledBadgeIds[migrationCycle][_s1BadgeIds[i]] = true; - emit MigrationToggled(migrationCycle, _s1BadgeIds[i], true); - } - } - - /// @notice Check if the migrations for a badge are enabled - /// @param _s1Badge The badge ID to check - /// @return Whether the badge is enabled for migration - function canMigrate(uint256 _s1Badge) public view returns (bool) { - for (uint256 i = 0; i < 8; i++) { - if (enabledBadgeIds[migrationCycle][i] && i == _s1Badge) { - return true; - } - } - return false; - } - - /// @notice Pause the contract - /// @dev Can be called only by the contract owner/admin - function pause() public onlyRole(DEFAULT_ADMIN_ROLE) { - _disableMigrations(); - _pause(); - } - - /// @notice S1 --> S2 badge ID mapping - /// @param _s1BadgeId The S1 badge ID - /// @return _pinkBadgeId The S2 pink badge ID - /// @return _purpleBadgeId The S2 purple badge ID - function getSeason2BadgeIds(uint256 _s1BadgeId) - public - pure - returns (uint256 _pinkBadgeId, uint256 _purpleBadgeId) - { - return (_s1BadgeId * 2, _s1BadgeId * 2 + 1); - } - - /// @notice S2 --> S1 badge ID mapping - /// @param _s2BadgeId The S2 badge ID - /// @return _s1BadgeId The S1 badge ID - function getSeason1BadgeId(uint256 _s2BadgeId) public pure returns (uint256 _s1BadgeId) { - return _s2BadgeId / 2; - } - - /// @notice Check if a migration is active for a user - /// @param _user The user address - /// @return Whether the user has an active migration - function isMigrationActive(address _user) public view returns (bool) { - return claimCooldowns[_user] != 0; - } - - /// @notice Check if a tamper is active for a user - /// @param _user The user address - /// @return Whether the user has an active tamper - function isTamperActive(address _user) public view returns (bool) { - return tamperCooldowns[_user] > block.timestamp; - } - - /// @notice Get the migration tamper counts for a user - /// @param _user The user address - /// @return _pinkTampers The pink tamper count - /// @return _purpleTampers The purple tamper count - function getMigrationTampers(address _user) - public - view - returns (uint256 _pinkTampers, uint256 _purpleTampers) - { - if (!isMigrationActive(_user)) { - revert MIGRATION_NOT_STARTED(); - } - return (migrationTampers[_user][true], migrationTampers[_user][false]); - } - - /// @notice Retrieve a token ID given their owner and S2 Badge ID - /// @param _user The address of the badge owner - /// @param _s2BadgeId The S2 badge ID - /// @return _tokenId The token ID - function getTokenId(address _user, uint256 _s2BadgeId) public view returns (uint256 _tokenId) { - return userBadges[_user][_s2BadgeId]; - } - - /// @notice Retrieve boolean balance for each badge - /// @param _owner The addresses to check - /// @return _balances The badges atomic balances - function badgeBalances(address _owner) public view returns (bool[16] memory _balances) { - for (uint256 i = 0; i < BADGE_COUNT; i++) { - uint256 tokenId = getTokenId(_owner, i); - _balances[i] = tokenId > 0; - } - - return _balances; - } - - /// @notice Retrieve the total S2 unique badge balance of an address - /// @param _owner The address to check - /// @return _balance The total badge balance (count) - function badgeBalanceOf(address _owner) public view returns (uint256 _balance) { - bool[16] memory balances = badgeBalances(_owner); - - for (uint256 i = 0; i < balances.length; i++) { - if (balances[i]) { - _balance++; - } - } - - return _balance; - } - - /// @notice Disable all new migrations - /// @dev Doesn't allow for new migration attempts, but tampers and active migrations still run - function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) { - for (uint256 i = 0; i < 8; i++) { - if (enabledBadgeIds[migrationCycle][i]) { - emit MigrationToggled(migrationCycle, i, false); - } - - enabledBadgeIds[migrationCycle][i] = false; - } - } - - /// @notice Generate a unique hash for each migration uniquely - /// @param _user The user address - /// @param _exp The users experience points - /// @return _hash The unique hash - function generateClaimHash(address _user, uint256 _exp) public pure returns (bytes32) { - return keccak256(abi.encodePacked(_user, _exp)); - } - - /// @notice Generates a random number from a signature - /// @param _hash The hash to sign (keccak256(startMigrationBlockHash, _msgSender())) - /// @param v signature V field - /// @param r signature R field - /// @param s signature S field - /// @return _random The pseudo-random number - function randomFromSignature( - bytes32 _hash, - uint8 v, - bytes32 r, - bytes32 s - ) - public - view - returns (uint256 _random) - { - (address _recovered,,) = ECDSA.tryRecover(_hash, v, r, s); - if (_recovered != randomSigner) revert NOT_RANDOM_SIGNER(); - // Hash the signature parts to get a deterministic pseudo-random number - return uint256(keccak256(abi.encodePacked(r, s, v))); - } - - /// @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 { } -} diff --git a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol index 91b4edc1bf6..0b4253a8f57 100644 --- a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol +++ b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol @@ -355,7 +355,7 @@ contract TrailblazersBadgesS2Test is Test { } function test_rollCycle() public { - assertEq(migration.migrationCycle(), 1); + assertEq(migration.getMigrationCycle(), 1); test_endMigration(); @@ -368,6 +368,6 @@ contract TrailblazersBadgesS2Test is Test { migration.enableMigrations(enabledBadgeIds); // check cycle id - assertEq(migration.migrationCycle(), 2); + assertEq(migration.getMigrationCycle(), 2); } } From 7473c5b8549a7b3fcfbc48e6a7066106ea3e84d2 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 17 Oct 2024 16:30:22 +0200 Subject: [PATCH 48/79] hekla deployment script --- packages/nfts/deployments/taikoon/hekla.json | 2 +- .../trailblazers-season-2/hekla.json | 4 +- .../script/trailblazers-season-2/Deploy.s.sol | 43 ++++++++++++++++--- .../BadgeMigration.t.sol | 2 - 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/packages/nfts/deployments/taikoon/hekla.json b/packages/nfts/deployments/taikoon/hekla.json index 6d54379cbe2..ad7f9270ff8 100644 --- a/packages/nfts/deployments/taikoon/hekla.json +++ b/packages/nfts/deployments/taikoon/hekla.json @@ -1,5 +1,5 @@ { "MerkleRoot": "0x1c3b504b4d5640d26ad1aa3b57a9df9ec034f19239768e734b849c306d10b110", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TaikoonToken": "0xf3FBa6f1E6C1998195239e7DD794c1EcEA8Da66B" + "TaikoonToken": "0xF917fE66b590f7A09fE654FD5397da461f816FD0" } diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index 32bdd225bef..1b55d24c4cf 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,5 +1,5 @@ { "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x85B951A284C8928c1B5cA7c149969CBFb3818819", - "TrailblazersBadgesS2": "0x2406036c19e7D3eF6f256060f56dc91f3F5a57a6" + "TrailblazersBadges": "0xF7Eb53D3947f0Bc22c423f357d2D5173E0Ccdb8A", + "TrailblazersBadgesS2": "0x039813b48975Ed2b0c1160Ff259702407427691B" } diff --git a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol index f3ee9438755..40440408c2c 100644 --- a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol @@ -11,6 +11,7 @@ import { TrailblazersBadgesS2 } from "../../contracts/trailblazers-season-2/TrailblazersBadgesS2.sol"; import { TrailblazersBadgesV4 } from "../../contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol"; +import { BadgeMigration } from "../../contracts/trailblazers-season-2/BadgeMigration.sol"; contract DeployS2Script is Script { UtilsScript public utils; @@ -18,6 +19,16 @@ contract DeployS2Script is Script { uint256 public deployerPrivateKey; address public deployerAddress; + BadgeMigration migration; + + bool constant PINK_TAMPER = true; + bool constant PURPLE_TAMPER = false; + + uint256 public MAX_TAMPERS = 3; + uint256 public COOLDOWN_MIGRATION = 1 hours; + uint256 public COOLDOWN_TAMPER = 5 minutes; + uint256 public TAMPER_WEIGHT_PERCENT = 5; + // Taiko Mainnet Values //address owner = 0xf8ff2AF0DC1D5BA4811f22aCb02936A1529fd2Be; //bytes32 root = 0xa7e510d5aed347e65609cf6f0e0738cdd752ffdf5980749057c634489fd09fc3; @@ -53,7 +64,6 @@ contract DeployS2Script is Script { } function run() public { - /* string memory jsonRoot = "root"; address owner = deployerAddress; require(owner != address(0), "Owner must be specified"); @@ -76,7 +86,7 @@ contract DeployS2Script is Script { new ERC1967Proxy( impl, abi.encodeCall( - TrailblazersBadges.initialize, (owner, baseURI, claimMintSigner, blacklist) + TrailblazersBadges.initialize, (owner, baseURI, claimMintSigner, blacklist) ) ) ); @@ -96,18 +106,39 @@ contract DeployS2Script is Script { impl = address(new TrailblazersBadgesS2()); proxy = address( new ERC1967Proxy( - impl, - abi.encodeCall(TrailblazersBadgesS2.initialize, (address(s1Token), migrationSigner)) + impl, abi.encodeCall(TrailblazersBadgesS2.initialize, (address(owner), "ipfs://")) ) ); s2Token = TrailblazersBadgesS2(proxy); + // deploy the migration contract + + BadgeMigration.Config memory config = BadgeMigration.Config( + COOLDOWN_MIGRATION, COOLDOWN_TAMPER, TAMPER_WEIGHT_PERCENT, MAX_TAMPERS + ); + + impl = address(new BadgeMigration()); + proxy = address( + new ERC1967Proxy( + impl, + abi.encodeCall( + BadgeMigration.initialize, + (address(s1Token), address(s2Token), migrationSigner, config) + ) + ) + ); + migration = BadgeMigration(proxy); + + // assign relations + s1Token.setMigrationContract(address(migration)); + s2Token.setMinter(address(migration)); + console.log("Token Base URI:", baseURI); console.log("Deployed TrailblazersBadgesS2 to:", address(s2Token)); // assign the s2 contract to the s1 contract - s1Token.setSeason2BadgeContract(address(s2Token)); + s1Token.setMigrationContract(address(s2Token)); console.log("Assigned TrailblazersBadgesS2 to TrailblazersBadgesV4"); // Register deployment @@ -116,6 +147,6 @@ contract DeployS2Script is Script { string memory finalJson = vm.serializeAddress(jsonRoot, "Owner", s2Token.owner()); vm.writeJson(finalJson, jsonLocation); - vm.stopBroadcast();*/ + vm.stopBroadcast(); } } diff --git a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol index 0b4253a8f57..ba64f2f17cb 100644 --- a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol +++ b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol @@ -72,8 +72,6 @@ contract TrailblazersBadgesS2Test is Test { abi.encodeCall(TrailblazerBadgesS1MintTo.call, ()) ); - TrailblazerBadgesS1MintTo s1BadgesMock = TrailblazerBadgesS1MintTo(address(s1BadgesV2)); - BADGE_ID = s1BadgesV2.BADGE_RAVERS(); // upgrade s1 contract to v4 From f86e6322e059e4fa579f7ba2cde76be966e74d08 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 17 Oct 2024 17:31:56 +0200 Subject: [PATCH 49/79] pre-merge commit --- packages/nfts/deployments/trailblazers-season-2/hekla.json | 5 +++-- packages/nfts/script/trailblazers-season-2/Deploy.s.sol | 5 +---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index 1b55d24c4cf..3139cd24e60 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,5 +1,6 @@ { + "BadgeMigration": "0x05BCdDcA8B696c6f2E0a8c7F5e19Cd02E1fD6b57", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0xF7Eb53D3947f0Bc22c423f357d2D5173E0Ccdb8A", - "TrailblazersBadgesS2": "0x039813b48975Ed2b0c1160Ff259702407427691B" + "TrailblazersBadges": "0x49C157dD9Bc9e7A083eB2721f4e3fd97Ba1FDE66", + "TrailblazersBadgesS2": "0x39148d4eF6803d1E46496E2e461Dc3738B8Bd783" } diff --git a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol index 40440408c2c..b345624a8d8 100644 --- a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol @@ -137,13 +137,10 @@ contract DeployS2Script is Script { console.log("Token Base URI:", baseURI); console.log("Deployed TrailblazersBadgesS2 to:", address(s2Token)); - // assign the s2 contract to the s1 contract - s1Token.setMigrationContract(address(s2Token)); - console.log("Assigned TrailblazersBadgesS2 to TrailblazersBadgesV4"); // Register deployment - vm.serializeAddress(jsonRoot, "TrailblazersBadges", address(s1Token)); vm.serializeAddress(jsonRoot, "TrailblazersBadgesS2", address(s2Token)); + vm.serializeAddress(jsonRoot, "BadgeMigration", address(migration)); string memory finalJson = vm.serializeAddress(jsonRoot, "Owner", s2Token.owner()); vm.writeJson(finalJson, jsonLocation); From 65e812701b0ed0b6453e3c90a4575ba4c5b8970a Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 17 Oct 2024 17:35:41 +0200 Subject: [PATCH 50/79] reverted unwanted changes From dcd0d06e92a1838c049b5965ace2aea1c56c62a8 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 21 Oct 2024 12:46:41 +0200 Subject: [PATCH 51/79] refactored s1 badges being frozen for a year, rather than burnt --- .../trailblazers-season-2/BadgeMigration.sol | 39 ++++++++------ .../TrailblazersS1BadgesV4.sol | 51 +++++++++++++++---- .../trailblazers-airdrop/hekla.json | 3 +- .../trailblazers-airdrop/mainnet.json | 3 +- .../trailblazers-season-2/hekla.json | 6 +-- .../script/trailblazers-season-2/Deploy.s.sol | 5 +- .../BadgeMigration.t.sol | 42 +++++++-------- 7 files changed, 95 insertions(+), 54 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index 40ce3884da7..ca7f56234a6 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -87,6 +87,7 @@ contract BadgeMigration is error NOT_RANDOM_SIGNER(); error ALREADY_MIGRATED_IN_CYCLE(); error HASH_MISMATCH(); + error NOT_S1_CONTRACT(); /// @notice Events event MigrationCycleToggled(uint256 indexed migrationCycleId, uint256 s1BadgeId, bool enabled); @@ -113,10 +114,10 @@ contract BadgeMigration is } /// @notice Reverts if sender is already migrating - modifier isNotMigrating() { + modifier isNotMigrating(address _user) { if ( - migrations[_msgSender()].length > 0 - && migrations[_msgSender()][migrations[_msgSender()].length - 1].cooldownExpiration == 0 + migrations[_user].length > 0 + && migrations[_user][migrations[_user].length - 1].cooldownExpiration == 0 ) { revert MIGRATION_ALREADY_STARTED(); } @@ -143,6 +144,13 @@ contract BadgeMigration is _; } + modifier onlyS1Contract() { + if (_msgSender() != address(s1Badges)) { + revert NOT_S1_CONTRACT(); + } + _; + } + /// @notice Contract initializer /// @param _s1Badges The Season 1 Badges contract address /// @param _s2Badges The Season 2 Badges contract address @@ -222,21 +230,26 @@ contract BadgeMigration 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) + /// @dev Must be called from the s1 badges contract + function startMigration( + address _user, + uint256 _s1BadgeId + ) external + onlyS1Contract migrationOpen(_s1BadgeId) - isNotMigrating - hasntMigratedInCycle(_s1BadgeId, _msgSender()) + isNotMigrating(_user) + hasntMigratedInCycle(_s1BadgeId, _user) { - uint256 s1TokenId = s1Badges.getTokenId(_msgSender(), _s1BadgeId); + uint256 s1TokenId = s1Badges.getTokenId(_user, _s1BadgeId); - if (s1Badges.ownerOf(s1TokenId) != _msgSender()) { + if (s1Badges.ownerOf(s1TokenId) != _user) { revert TOKEN_NOT_OWNED(); } Migration memory _migration = Migration( migrationCycle, // migrationCycle - _msgSender(), // user + _user, // user _s1BadgeId, s1TokenId, 0, // s2TokenId, unset @@ -246,10 +259,8 @@ contract BadgeMigration is 0 // purpleTampers ); - migrations[_msgSender()].push(_migration); - - // transfer the badge tokens to the migration contract - s1Badges.transferFrom(_msgSender(), address(this), s1TokenId); + migrations[_user].push(_migration); + migrationCycleUniqueMints[migrationCycle][_user][_s1BadgeId] = true; emit MigrationUpdated( _migration.migrationCycle, @@ -409,8 +420,6 @@ contract BadgeMigration is } uint256 s1BadgeId_ = migration_.s1BadgeId; - uint256 s1TokenId_ = migration_.s1TokenId; - s1Badges.burn(s1TokenId_); TrailblazersBadgesS2.MovementType pinkOrPurple = isPinkOrPurple_ ? TrailblazersBadgesS2.MovementType.Minnow diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol index 55ec0836a1e..0d78a382915 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol @@ -2,13 +2,31 @@ pragma solidity 0.8.24; import "../trailblazers-badges/TrailblazersBadgesV3.sol"; +import "./BadgeMigration.sol"; contract TrailblazersBadgesV4 is TrailblazersBadgesV3 { + /// @notice Duration for which a s1 badge is locked after migration is started + uint256 public migrationLockDuration; + /// @notice BadgeMigration contract + BadgeMigration public migrationContract; + /// @notice Mapping of badge token id to unlock timestamp + mapping(uint256 tokenId => uint256 unlockTimestamp) public unlockTimestamps; + + /// @notice Errors + error BADGE_LOCKED(); + error MIGRATION_LOCK_DURATION_NOT_SET(); + + /// @notice Updated version function + /// @return Version string function version() external pure virtual override returns (string memory) { return "V4"; } - // disable blacklist block + /// @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, @@ -19,23 +37,34 @@ contract TrailblazersBadgesV4 is TrailblazersBadgesV3 { override returns (address) { + if (unlockTimestamps[tokenId] > block.timestamp) { + revert BADGE_LOCKED(); + } return super._update(to, tokenId, auth); } - address public migrationContract; - - error INVALID_S2_CONTRACT(); - + /// @notice Set migration contract + /// @param _migrationContract Address of the migration contract + /// @dev Only owner function setMigrationContract(address _migrationContract) public onlyOwner { - migrationContract = _migrationContract; + migrationContract = BadgeMigration(_migrationContract); } - modifier onlyMigrationContract() { - if (msg.sender != migrationContract) revert INVALID_S2_CONTRACT(); - _; + /// @notice Set migration lock duration + /// @param _duration Duration in seconds + /// @dev Only owner + function setMigrationLockDuration(uint256 _duration) public onlyOwner { + migrationLockDuration = _duration; } - function burn(uint256 _tokenId) public onlyMigrationContract { - _burn(_tokenId); + /// @notice Start migration for a badge + /// @param _badgeId Badge id + function startMigration(uint256 _badgeId) public { + if (migrationLockDuration == 0) { + revert MIGRATION_LOCK_DURATION_NOT_SET(); + } + uint256 tokenId = getTokenId(_msgSender(), _badgeId); + unlockTimestamps[tokenId] = block.timestamp + migrationLockDuration; + migrationContract.startMigration(_msgSender(), _badgeId); } } diff --git a/packages/nfts/deployments/trailblazers-airdrop/hekla.json b/packages/nfts/deployments/trailblazers-airdrop/hekla.json index 5c8dd9aabf2..10960be94d8 100644 --- a/packages/nfts/deployments/trailblazers-airdrop/hekla.json +++ b/packages/nfts/deployments/trailblazers-airdrop/hekla.json @@ -1,4 +1,5 @@ { "ERC20Airdrop": "0xdeC2662Dff4eAB8b94B5257D637204d18D95cb74", - "MerkleRoot": "0xbe8ec647626f95185f551887b3eee43ea9e8965c7baf558a9f8cb22b020597f0" + "MerkleRoot": "0xbe8ec647626f95185f551887b3eee43ea9e8965c7baf558a9f8cb22b020597f0", + "ERC20Token": "0xa9d23408b9ba935c230493c40c73824df71a0975" } diff --git a/packages/nfts/deployments/trailblazers-airdrop/mainnet.json b/packages/nfts/deployments/trailblazers-airdrop/mainnet.json index 289f920f46b..d0f2601ab76 100644 --- a/packages/nfts/deployments/trailblazers-airdrop/mainnet.json +++ b/packages/nfts/deployments/trailblazers-airdrop/mainnet.json @@ -1,4 +1,5 @@ { "ERC20Airdrop": "0x290265ACd21816EE414E64eEC77dd490d8dd9f51", - "MerkleRoot": "0xc7f7e6bb3d1bb31b0ef5e2e34383c12ec9ef8a301ffde9771bd9de7554c70b1d" + "MerkleRoot": "0xc7f7e6bb3d1bb31b0ef5e2e34383c12ec9ef8a301ffde9771bd9de7554c70b1d", + "ERC20Token": "0xa9d23408b9ba935c230493c40c73824df71a0975" } diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index 3139cd24e60..404dae3c48f 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,6 +1,6 @@ { - "BadgeMigration": "0x05BCdDcA8B696c6f2E0a8c7F5e19Cd02E1fD6b57", + "BadgeMigration": "0x73F9a4A5c3D6902c2Cbf865c2C5F2F347dbF334e", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x49C157dD9Bc9e7A083eB2721f4e3fd97Ba1FDE66", - "TrailblazersBadgesS2": "0x39148d4eF6803d1E46496E2e461Dc3738B8Bd783" + "TrailblazersBadges": "0x07aA4990C1c1F94f1A6ADF0E6c67884E1e37011c", + "TrailblazersBadgesS2": "0xFEaD2a6bF11305D5df8Ff47037EEB5bdE23C07A2" } diff --git a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol index b345624a8d8..8fb6fb42bd0 100644 --- a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol @@ -25,8 +25,8 @@ contract DeployS2Script is Script { bool constant PURPLE_TAMPER = false; uint256 public MAX_TAMPERS = 3; - uint256 public COOLDOWN_MIGRATION = 1 hours; - uint256 public COOLDOWN_TAMPER = 5 minutes; + uint256 public COOLDOWN_MIGRATION = 1 minutes; + uint256 public COOLDOWN_TAMPER = 1 minutes; uint256 public TAMPER_WEIGHT_PERCENT = 5; // Taiko Mainnet Values @@ -136,6 +136,7 @@ contract DeployS2Script is Script { console.log("Token Base URI:", baseURI); console.log("Deployed TrailblazersBadgesS2 to:", address(s2Token)); + console.log("Deployed BadgeMigration to:", address(migration)); // Register deployment vm.serializeAddress(jsonRoot, "TrailblazersBadges", address(s1Token)); diff --git a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol index ba64f2f17cb..8ca000c9053 100644 --- a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol +++ b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol @@ -81,6 +81,9 @@ contract TrailblazersBadgesS2Test is Test { s1BadgesV4 = TrailblazersBadgesV4(address(s1BadgesV2)); + // set cooldown migration + s1BadgesV4.setMigrationLockDuration(365 days); + // deploy the s2 erc1155 token contract impl = address(new TrailblazersBadgesS2()); @@ -149,19 +152,13 @@ contract TrailblazersBadgesS2Test is Test { function test_startMigration() public { mint_s1(minters[0], BADGE_ID); - uint256 tokenId = s1BadgesV4.tokenOfOwnerByIndex(minters[0], 0); - - vm.startPrank(minters[0]); - s1BadgesV4.approve(address(migration), tokenId); - migration.startMigration(BADGE_ID); - vm.stopPrank(); - /* - assertEq(s1BadgesV2.balanceOf(minters[0]), 0); - assertEq(s1BadgesV2.balanceOf(address(s2Badges)), 1); - - assertEq(s1BadgesV2.ownerOf(tokenId), address(s2Badges)); + vm.prank(minters[0]); + s1BadgesV4.startMigration(BADGE_ID); - assertEq(migration.isMigrationActive(minters[0]), true);*/ + uint256 tokenId = s1BadgesV4.getTokenId(minters[0], BADGE_ID); + assertEq(s1BadgesV4.balanceOf(minters[0]), 1); + assertEq(migration.isMigrationActive(minters[0]), true); + assertEq(s1BadgesV4.unlockTimestamps(tokenId), block.timestamp + 365 days); } function wait(uint256 time) public { @@ -251,10 +248,6 @@ contract TrailblazersBadgesS2Test is Test { migration.endMigration(claimHash, v, r, s, 0); vm.stopPrank(); - // check for s1 burn - assertEq(s1BadgesV4.balanceOf(minters[0]), 0); - assertEq(s1BadgesV4.balanceOf(address(s2Badges)), 0); - // check for s2 state reset assertEq(migration.isMigrationActive(minters[0]), false); assertEq(migration.isTamperActive(minters[0]), false); @@ -267,7 +260,7 @@ contract TrailblazersBadgesS2Test is Test { test_startMigration(); vm.startPrank(minters[0]); vm.expectRevert(); - migration.startMigration(BADGE_ID); + s1BadgesV4.startMigration(BADGE_ID); vm.stopPrank(); } @@ -278,9 +271,8 @@ contract TrailblazersBadgesS2Test is Test { uint256 tokenId = s1BadgesV4.tokenOfOwnerByIndex(minters[0], 0); vm.startPrank(minters[0]); - s1BadgesV4.approve(address(migration), tokenId); vm.expectRevert(); - migration.startMigration(badgeId); + s1BadgesV4.startMigration(badgeId); vm.stopPrank(); // ensure no values got changed/updated assertEq(s1BadgesV4.balanceOf(minters[0]), 1); @@ -301,9 +293,8 @@ contract TrailblazersBadgesS2Test is Test { uint256 tokenId = s1BadgesV4.tokenOfOwnerByIndex(minters[0], 0); vm.startPrank(minters[0]); - s1BadgesV4.approve(address(migration), tokenId); vm.expectRevert(); - migration.startMigration(BADGE_ID); + s1BadgesV4.startMigration(BADGE_ID); vm.stopPrank(); // ensure no values got changed/updated assertEq(s1BadgesV4.balanceOf(minters[0]), 1); @@ -368,4 +359,13 @@ contract TrailblazersBadgesS2Test is Test { // check cycle id assertEq(migration.getMigrationCycle(), 2); } + + function test_revertTransferAfterMigrationStarts() public { + test_startMigration(); + assertEq(s1BadgesV4.balanceOf(minters[0]), 1); + uint256 tokenId = s1BadgesV4.getTokenId(minters[0], BADGE_ID); + vm.prank(minters[0]); + vm.expectRevert(); + s1BadgesV4.transferFrom(minters[0], minters[1], tokenId); + } } From b2d7258a96001c0c6492a82744f5e3aa0b6e89a3 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Tue, 22 Oct 2024 10:37:58 +0200 Subject: [PATCH 52/79] added dev as s2 badge --- .../trailblazers-season-2/BadgeMigration.sol | 73 +++++++++++-------- .../TrailblazersBadgesS2.sol | 9 ++- .../BadgeMigration.t.sol | 34 +++++---- .../TrailblazersBadgesS2.t.sol | 4 +- 4 files changed, 69 insertions(+), 51 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index ca7f56234a6..4960b56a36c 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -46,8 +46,15 @@ contract BadgeMigration is uint256 migrationCycle => mapping(address minter => mapping(uint256 s1BadgeId => bool mintEnded)) ) public migrationCycleUniqueMints; - /// @notice Configuration struct + enum TamperColor { + Dev, // neutral + Whale, // based, pink + Minnow // boosted, purple + + } + + /// @notice Configuration struct struct Config { uint256 cooldownMigration; uint256 cooldownTamper; @@ -67,8 +74,9 @@ contract BadgeMigration is uint256 s2TokenId; uint256 cooldownExpiration; uint256 tamperExpiration; - uint256 pinkTampers; - uint256 purpleTampers; + uint256 devTampers; + uint256 whaleTampers; + uint256 minnowTampers; } /// @notice Migrations per user @@ -100,8 +108,9 @@ contract BadgeMigration is uint256 s2TokenId, uint256 cooldownExpiration, uint256 tamperExpiration, - uint256 pinkTampers, - uint256 purpleTampers + uint256 devTampers, + uint256 whaleTampers, + uint256 minnowTampers ); /// @notice Check if the message sender has an active migration @@ -255,8 +264,9 @@ contract BadgeMigration is 0, // s2TokenId, unset block.timestamp + config.cooldownMigration, // cooldownExpiration 0, // tamperExpiration, unset - 0, // pinkTampers - 0 // purpleTampers + 0, // dev tampers + 0, // whaleTampers + 0 // minnowTampers ); migrations[_user].push(_migration); @@ -270,8 +280,9 @@ contract BadgeMigration is _migration.s2TokenId, _migration.cooldownExpiration, _migration.tamperExpiration, - _migration.pinkTampers, - _migration.purpleTampers + _migration.devTampers, + _migration.whaleTampers, + _migration.minnowTampers ); } @@ -298,8 +309,9 @@ contract BadgeMigration is _migration.s2TokenId, _migration.cooldownExpiration, _migration.tamperExpiration, - _migration.pinkTampers, - _migration.purpleTampers + _migration.devTampers, + _migration.whaleTampers, + _migration.minnowTampers ); } @@ -316,7 +328,7 @@ contract BadgeMigration is /// @param v signature V field /// @param r signature R field /// @param s signature S field - /// @param _pinkOrPurple true for pink, false for purple + /// @param _tamperColor the tamper's color /// @dev Can be called only during an active migration /// @dev Implements a cooldown before allowing to re-tamper /// @dev The max tamper amount is determined by Pass Tier @@ -326,7 +338,7 @@ contract BadgeMigration is bytes32 r, bytes32 s, uint256 exp, - bool _pinkOrPurple + TamperColor _tamperColor ) external isMigrating @@ -335,7 +347,7 @@ contract BadgeMigration is if (recovered_ != randomSigner) revert NOT_RANDOM_SIGNER(); Migration memory migration_ = getActiveMigrationFor(_msgSender()); - if ((migration_.pinkTampers + migration_.purpleTampers) > maxTampers(exp)) { + if ((migration_.whaleTampers + migration_.minnowTampers) > maxTampers(exp)) { revert MAX_TAMPERS_REACHED(); } @@ -343,10 +355,12 @@ contract BadgeMigration is revert TAMPER_IN_PROGRESS(); } - if (_pinkOrPurple) { - migration_.pinkTampers++; + if (_tamperColor == TamperColor.Dev) { + migration_.devTampers++; + } else if (_tamperColor == TamperColor.Whale) { + migration_.whaleTampers++; } else { - migration_.purpleTampers++; + migration_.minnowTampers++; } migration_.tamperExpiration = block.timestamp + config.cooldownTamper; @@ -358,8 +372,8 @@ contract BadgeMigration is /// @dev Can be called only during an active migration function resetTampers() external isMigrating { Migration memory migration_ = getActiveMigrationFor(_msgSender()); - migration_.pinkTampers = 0; - migration_.purpleTampers = 0; + migration_.whaleTampers = 0; + migration_.minnowTampers = 0; migration_.tamperExpiration = 0; _updateMigration(migration_); @@ -400,18 +414,18 @@ contract BadgeMigration is } // get the tamper amounts - uint256 pinkTampers_ = migration_.pinkTampers; - uint256 purpleTampers_ = migration_.purpleTampers; + uint256 whaleTampers_ = migration_.whaleTampers; + uint256 minnowTampers_ = migration_.minnowTampers; uint256 randomSeed_ = randomFromSignature(_hash, _v, _r, _s); bool isPinkOrPurple_; // Calculate the difference in tampers and adjust chances - if (pinkTampers_ > purpleTampers_) { - uint256 extraChance = (pinkTampers_ - purpleTampers_) * config.tamperWeightPercent; + if (whaleTampers_ > minnowTampers_) { + uint256 extraChance = (whaleTampers_ - minnowTampers_) * config.tamperWeightPercent; uint256 chance = 50 + extraChance; // Base 50% + extra chance isPinkOrPurple_ = (randomSeed_ % 100) < chance; // True for pink - } else if (purpleTampers_ > pinkTampers_) { - uint256 extraChance = (purpleTampers_ - pinkTampers_) * config.tamperWeightPercent; + } else if (minnowTampers_ > whaleTampers_) { + uint256 extraChance = (minnowTampers_ - whaleTampers_) * config.tamperWeightPercent; uint256 chance = 50 + extraChance; // Base 50% + extra chance isPinkOrPurple_ = (randomSeed_ % 100) >= chance; // False for purple } else { @@ -486,18 +500,19 @@ contract BadgeMigration is /// @notice Get the migration tamper counts for a user /// @param _user The user address - /// @return _pinkTampers The pink tamper count - /// @return _purpleTampers The purple tamper count + /// @return _devTampers The Dev tamper count + /// @return _whaleTampers The Whale tamper count + /// @return _minnowTampers The Minnow tamper count function getMigrationTampers(address _user) public view - returns (uint256 _pinkTampers, uint256 _purpleTampers) + returns (uint256 _devTampers, uint256 _whaleTampers, uint256 _minnowTampers) { if (!isMigrationActive(_user)) { revert MIGRATION_NOT_STARTED(); } Migration memory migration_ = getActiveMigrationFor(_user); - return (migration_.pinkTampers, migration_.purpleTampers); + return (migration_.devTampers, migration_.whaleTampers, migration_.minnowTampers); } /// @notice supportsInterface implementation diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol index 3e405655239..80f87bb0298 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol @@ -41,22 +41,23 @@ contract TrailblazersBadgesS2 is Shinto // s1 id: 7 } + /// @notice Movement types enum MovementType { Dev, // s1 neutral - Minnow, // s1 based/pink - Whale // s1 boosted/purple + Whale, // s1 based/pink + Minnow // s1 boosted/purple } - /// @notice Badge struct + /// @notice Badge struct struct Badge { uint256 tokenId; BadgeType badgeType; MovementType movementType; } - /// @notice Badge mapping + /// @notice Badge mapping mapping(uint256 tokenId => Badge badge) private badges; /// @notice Badge URI template string public uriTemplate; diff --git a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol index 8ca000c9053..0d1922c260f 100644 --- a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol +++ b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol @@ -33,9 +33,6 @@ contract TrailblazersBadgesS2Test is Test { address mintSigner; uint256 mintSignerPk; - bool constant PINK_TAMPER = true; - bool constant PURPLE_TAMPER = false; - uint256 public MAX_TAMPERS = 3; uint256 public COOLDOWN_MIGRATION = 1 hours; uint256 public COOLDOWN_TAMPER = 5 minutes; @@ -178,23 +175,25 @@ contract TrailblazersBadgesS2Test is Test { for (uint256 i = 0; i < MAX_TAMPERS; i++) { wait(COOLDOWN_TAMPER); - migration.tamperMigration(_hash, v, r, s, points, PINK_TAMPER); + migration.tamperMigration(_hash, v, r, s, points, BadgeMigration.TamperColor.Whale); } wait(COOLDOWN_TAMPER); - migration.tamperMigration(_hash, v, r, s, points, PURPLE_TAMPER); + migration.tamperMigration(_hash, v, r, s, points, BadgeMigration.TamperColor.Minnow); wait(COOLDOWN_TAMPER); - migration.tamperMigration(_hash, v, r, s, points, PURPLE_TAMPER); + migration.tamperMigration(_hash, v, r, s, points, BadgeMigration.TamperColor.Minnow); vm.stopPrank(); assertEq(migration.isTamperActive(minters[0]), true); assertEq(migration.isMigrationActive(minters[0]), true); - (uint256 pinkTampers, uint256 purpleTampers) = migration.getMigrationTampers(minters[0]); - assertEq(pinkTampers, MAX_TAMPERS); - assertEq(purpleTampers, 2); + (uint256 devTampers, uint256 whaleTampers, uint256 minnowTampers) = + migration.getMigrationTampers(minters[0]); + assertEq(devTampers, 0); + assertEq(whaleTampers, MAX_TAMPERS); + assertEq(minnowTampers, 2); } function test_revert_tooManyTampers() public { @@ -206,7 +205,7 @@ contract TrailblazersBadgesS2Test is Test { test_tamperMigration(); vm.startPrank(minters[0]); vm.expectRevert(); - migration.tamperMigration(_hash, v, r, s, points, PINK_TAMPER); + migration.tamperMigration(_hash, v, r, s, points, BadgeMigration.TamperColor.Whale); vm.stopPrank(); } @@ -214,17 +213,20 @@ contract TrailblazersBadgesS2Test is Test { function test_resetTampers() public { test_tamperMigration(); assertEq(migration.isTamperActive(minters[0]), true); - (uint256 pinkTampers, uint256 purpleTampers) = migration.getMigrationTampers(minters[0]); - assertEq(pinkTampers, MAX_TAMPERS); - assertEq(purpleTampers, 2); + (uint256 devTampers, uint256 whaleTampers, uint256 minnowTampers) = + migration.getMigrationTampers(minters[0]); + assertEq(devTampers, 0); + assertEq(whaleTampers, MAX_TAMPERS); + assertEq(minnowTampers, 2); vm.prank(minters[0]); migration.resetTampers(); assertEq(migration.isTamperActive(minters[0]), false); - (pinkTampers, purpleTampers) = migration.getMigrationTampers(minters[0]); - assertEq(pinkTampers, 0); - assertEq(purpleTampers, 0); + (devTampers, whaleTampers, minnowTampers) = migration.getMigrationTampers(minters[0]); + assertEq(devTampers, 0); + assertEq(whaleTampers, 0); + assertEq(minnowTampers, 0); } function test_endMigration() public { diff --git a/packages/nfts/test/trailblazers-season-2/TrailblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-season-2/TrailblazersBadgesS2.t.sol index 838c4b9e78a..5c3345f54bb 100644 --- a/packages/nfts/test/trailblazers-season-2/TrailblazersBadgesS2.t.sol +++ b/packages/nfts/test/trailblazers-season-2/TrailblazersBadgesS2.t.sol @@ -58,14 +58,14 @@ contract TrailblazersBadgesS2Test is Test { function test_uri_byTokenId() public { test_mint(); - assertEq(nft.uri(TOKEN_ID), "ipfs://hash/0/1.json"); + assertEq(nft.uri(TOKEN_ID), "ipfs://hash/0/2.json"); } function test_uri_byTypeAndMovement() public { test_mint(); assertEq( nft.uri(TrailblazersBadgesS2.BadgeType.Ravers, TrailblazersBadgesS2.MovementType.Minnow), - "ipfs://hash/0/1.json" + "ipfs://hash/0/2.json" ); } From 1ab2afd6261718d80f71919a7fa2746f110bc243 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Tue, 22 Oct 2024 11:49:12 +0200 Subject: [PATCH 53/79] added exp-driven badge claims --- .../trailblazers-season-2/BadgeMigration.sol | 110 ++++++++++++++---- .../script/trailblazers-season-2/Deploy.s.sol | 7 +- .../BadgeMigration.t.sol | 52 ++++++++- 3 files changed, 144 insertions(+), 25 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index 4960b56a36c..f7e762488ff 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -39,6 +39,7 @@ contract BadgeMigration is address public randomSigner; /// @notice Migration-enabled badge IDs per cycle mapping(uint256 cycle => mapping(uint256 s1BadgeId => bool enabled)) public enabledBadgeIds; + uint256[] public currentCycleEnabledMigrationIds; /// @notice Current migration cycle uint256 private migrationCycle; /// @notice Mapping of unique user-per-mint-per-cycle @@ -46,6 +47,9 @@ contract BadgeMigration is uint256 migrationCycle => mapping(address minter => mapping(uint256 s1BadgeId => bool mintEnded)) ) public migrationCycleUniqueMints; + /// @notice User experience points + mapping(address user => uint256 experience) public userExperience; + /// @notice Tamper colors available enum TamperColor { Dev, // neutral @@ -60,6 +64,7 @@ contract BadgeMigration is uint256 cooldownTamper; uint256 tamperWeightPercent; uint256 baseMaxTampers; + uint256 pointsClaimMultiplicationFactor; } /// @notice Current config @@ -96,8 +101,9 @@ contract BadgeMigration is error ALREADY_MIGRATED_IN_CYCLE(); error HASH_MISMATCH(); error NOT_S1_CONTRACT(); - + error EXP_TOO_LOW(); /// @notice Events + event MigrationCycleToggled(uint256 indexed migrationCycleId, uint256 s1BadgeId, bool enabled); event MigrationUpdated( @@ -205,6 +211,7 @@ contract BadgeMigration is enabledBadgeIds[migrationCycle][i] = false; } + currentCycleEnabledMigrationIds = new uint256[](0); } /// @notice Enable migrations for a set of badges @@ -219,6 +226,7 @@ contract BadgeMigration is enabledBadgeIds[migrationCycle][_s1BadgeIds[i]] = true; emit MigrationCycleToggled(migrationCycle, _s1BadgeIds[i], true); } + currentCycleEnabledMigrationIds = _s1BadgeIds; } /// @notice Get the current migration cycle @@ -234,33 +242,23 @@ contract BadgeMigration is _pause(); } - /// @notice Start a migration for a badge - /// @param _s1BadgeId The badge ID (s1) - /// @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 - /// @dev Must be called from the s1 badges contract - function startMigration( + /// @notice Internal logic to start a migration + /// @param _user The user address + /// @param _s1BadgeId The badge ID + /// @param _s1TokenId The badge token ID + function _startMigration( address _user, - uint256 _s1BadgeId + uint256 _s1BadgeId, + uint256 _s1TokenId ) - external - onlyS1Contract - migrationOpen(_s1BadgeId) - isNotMigrating(_user) - hasntMigratedInCycle(_s1BadgeId, _user) + internal + virtual { - uint256 s1TokenId = s1Badges.getTokenId(_user, _s1BadgeId); - - if (s1Badges.ownerOf(s1TokenId) != _user) { - revert TOKEN_NOT_OWNED(); - } - Migration memory _migration = Migration( migrationCycle, // migrationCycle _user, // user _s1BadgeId, - s1TokenId, + _s1TokenId, 0, // s2TokenId, unset block.timestamp + config.cooldownMigration, // cooldownExpiration 0, // tamperExpiration, unset @@ -286,6 +284,76 @@ contract BadgeMigration is ); } + /// @notice Start a migration for a badge using the user's experience points + /// @param _hash The hash to sign of the signature + /// @param _v The signature V field + /// @param _r The signature R field + /// @param _s The signature S field + /// @param _exp The user's experience points + function startMigration( + bytes32 _hash, + uint8 _v, + bytes32 _r, + bytes32 _s, + uint256 _exp + ) + external + virtual + isNotMigrating(_msgSender()) + { + bytes32 calculatedHash_ = generateClaimHash(_msgSender(), _exp); + + if (calculatedHash_ != _hash) { + revert HASH_MISMATCH(); + } + + (address recovered_,,) = ECDSA.tryRecover(_hash, _v, _r, _s); + if (recovered_ != randomSigner) { + revert NOT_RANDOM_SIGNER(); + } + + if (_exp < userExperience[_msgSender()]) { + revert EXP_TOO_LOW(); + } + + userExperience[_msgSender()] = _exp; + + uint256 randomSeed_ = randomFromSignature(_hash, _v, _r, _s); + uint256 s1BadgeId_ = + currentCycleEnabledMigrationIds[randomSeed_ % currentCycleEnabledMigrationIds.length]; + + if (migrationCycleUniqueMints[migrationCycle][_msgSender()][s1BadgeId_]) { + revert ALREADY_MIGRATED_IN_CYCLE(); + } + + _startMigration(_msgSender(), (randomSeed_ % 8), 0); + } + + /// @notice Start a migration for a badge + /// @param _s1BadgeId The badge ID (s1) + /// @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 + /// @dev Must be called from the s1 badges contract + function startMigration( + address _user, + uint256 _s1BadgeId + ) + external + virtual + onlyS1Contract + migrationOpen(_s1BadgeId) + isNotMigrating(_user) + hasntMigratedInCycle(_s1BadgeId, _user) + { + uint256 s1TokenId_ = s1Badges.getTokenId(_user, _s1BadgeId); + + if (s1Badges.ownerOf(s1TokenId_) != _user) { + revert TOKEN_NOT_OWNED(); + } + _startMigration(_user, _s1BadgeId, s1TokenId_); + } + /// @notice Get the active migration for a user /// @param _user The user address /// @return The active migration diff --git a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol index 8fb6fb42bd0..8b76ffe70ab 100644 --- a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol @@ -28,6 +28,7 @@ contract DeployS2Script is Script { uint256 public COOLDOWN_MIGRATION = 1 minutes; uint256 public COOLDOWN_TAMPER = 1 minutes; uint256 public TAMPER_WEIGHT_PERCENT = 5; + uint256 public POINTS_CLAIM_MULTIPLICATION_FACTOR = 10; // 10% // Taiko Mainnet Values //address owner = 0xf8ff2AF0DC1D5BA4811f22aCb02936A1529fd2Be; @@ -115,7 +116,11 @@ contract DeployS2Script is Script { // deploy the migration contract BadgeMigration.Config memory config = BadgeMigration.Config( - COOLDOWN_MIGRATION, COOLDOWN_TAMPER, TAMPER_WEIGHT_PERCENT, MAX_TAMPERS + COOLDOWN_MIGRATION, + COOLDOWN_TAMPER, + TAMPER_WEIGHT_PERCENT, + MAX_TAMPERS, + POINTS_CLAIM_MULTIPLICATION_FACTOR ); impl = address(new BadgeMigration()); diff --git a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol index 0d1922c260f..9943f189d61 100644 --- a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol +++ b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol @@ -37,6 +37,7 @@ contract TrailblazersBadgesS2Test is Test { uint256 public COOLDOWN_MIGRATION = 1 hours; uint256 public COOLDOWN_TAMPER = 5 minutes; uint256 public TAMPER_WEIGHT_PERCENT = 5; + uint256 public POINTS_CLAIM_MULTIPLICATION_FACTOR = 10; // 10% BadgeMigration public migration; @@ -95,7 +96,11 @@ contract TrailblazersBadgesS2Test is Test { // deploy the migration contract BadgeMigration.Config memory config = BadgeMigration.Config( - COOLDOWN_MIGRATION, COOLDOWN_TAMPER, TAMPER_WEIGHT_PERCENT, MAX_TAMPERS + COOLDOWN_MIGRATION, + COOLDOWN_TAMPER, + TAMPER_WEIGHT_PERCENT, + MAX_TAMPERS, + POINTS_CLAIM_MULTIPLICATION_FACTOR ); impl = address(new BadgeMigration()); @@ -324,7 +329,7 @@ contract TrailblazersBadgesS2Test is Test { } function test_setConfig() public { - BadgeMigration.Config memory config = BadgeMigration.Config(1 hours, 5 minutes, 5, 3); + BadgeMigration.Config memory config = BadgeMigration.Config(1 hours, 5 minutes, 5, 3, 1); vm.prank(owner); migration.setConfig(config); @@ -337,7 +342,7 @@ contract TrailblazersBadgesS2Test is Test { } function test_setConfig_revert__notOwner() public { - BadgeMigration.Config memory config = BadgeMigration.Config(1 hours, 5 minutes, 5, 3); + BadgeMigration.Config memory config = BadgeMigration.Config(1 hours, 5 minutes, 5, 3, 1); vm.startPrank(minters[0]); vm.expectRevert(); @@ -370,4 +375,45 @@ contract TrailblazersBadgesS2Test is Test { vm.expectRevert(); s1BadgesV4.transferFrom(minters[0], minters[1], tokenId); } + + function test_startMigration_expBased() public { + mint_s1(minters[0], BADGE_ID); + + uint256 points = 100; + bytes32 _hash = migration.generateClaimHash(minters[0], points); + + (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); + + vm.prank(minters[0]); + migration.startMigration(_hash, v, r, s, points); + + assertEq(s1BadgesV4.balanceOf(minters[0]), 1); + assertEq(migration.isMigrationActive(minters[0]), true); + } + + function test_startMigration_expBased_revert_hashMissmatch() public { + mint_s1(minters[0], BADGE_ID); + + uint256 points = 100; + bytes32 _hash = migration.generateClaimHash(minters[0], points); + + (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); + + vm.prank(minters[0]); + vm.expectRevert(BadgeMigration.HASH_MISMATCH.selector); + migration.startMigration(_hash, v, s, r, points + 1); + } + + function test_startMigration_expBased_revert_notRandomSigner() public { + mint_s1(minters[0], BADGE_ID); + + uint256 points = 100; + bytes32 _hash = migration.generateClaimHash(minters[0], points); + (, uint256 badSignerPk) = makeAddrAndKey("badSigner"); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(badSignerPk, _hash); + + vm.prank(minters[0]); + vm.expectRevert(BadgeMigration.NOT_RANDOM_SIGNER.selector); + migration.startMigration(_hash, v, r, s, points); + } } From 13e740144fa07626867d01f8db2ba1331eb5d2e5 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Tue, 22 Oct 2024 11:51:25 +0200 Subject: [PATCH 54/79] restored unwanted changes --- packages/taiko-client/integration_test/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/taiko-client/integration_test/README.md b/packages/taiko-client/integration_test/README.md index 9a5242cc5f3..2e3d99cb137 100644 --- a/packages/taiko-client/integration_test/README.md +++ b/packages/taiko-client/integration_test/README.md @@ -1,7 +1,5 @@ # How to debug test cases? - - set up config - ``` export L2_NODE=l2_geth ``` From 74b4a54620036968c7dbf183834ffbf6d784c15a Mon Sep 17 00:00:00 2001 From: bearni95 Date: Tue, 22 Oct 2024 11:53:34 +0200 Subject: [PATCH 55/79] typo fix --- packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol index 9943f189d61..c24977d9348 100644 --- a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol +++ b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol @@ -391,7 +391,7 @@ contract TrailblazersBadgesS2Test is Test { assertEq(migration.isMigrationActive(minters[0]), true); } - function test_startMigration_expBased_revert_hashMissmatch() public { + function test_startMigration_expBased_revert_hashMismatch() public { mint_s1(minters[0], BADGE_ID); uint256 points = 100; From 2094baf27c4caa7ff5215429ebd80d016fdbf290 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Wed, 23 Oct 2024 00:33:04 +0200 Subject: [PATCH 56/79] updated endMigration function; emit migrationComplete event --- .../trailblazers-season-2/BadgeMigration.sol | 55 +++++++++++-------- .../trailblazers-season-2/hekla.json | 6 +- .../script/trailblazers-season-2/Deploy.s.sol | 9 ++- 3 files changed, 42 insertions(+), 28 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index f7e762488ff..e640cf356d1 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -119,6 +119,14 @@ contract BadgeMigration is uint256 minnowTampers ); + event MigrationComplete( + uint256 indexed migrationCycle, + address indexed user, + uint256 s1TokenId, + uint256 s2TokenId, + uint256 finalColor + ); + /// @notice Check if the message sender has an active migration modifier isMigrating() { Migration memory migration_ = getActiveMigrationFor(_msgSender()); @@ -132,7 +140,7 @@ contract BadgeMigration is modifier isNotMigrating(address _user) { if ( migrations[_user].length > 0 - && migrations[_user][migrations[_user].length - 1].cooldownExpiration == 0 + && migrations[_user][migrations[_user].length - 1].cooldownExpiration > block.timestamp ) { revert MIGRATION_ALREADY_STARTED(); } @@ -481,34 +489,29 @@ contract BadgeMigration is revert HASH_MISMATCH(); } - // get the tamper amounts - uint256 whaleTampers_ = migration_.whaleTampers; - uint256 minnowTampers_ = migration_.minnowTampers; - uint256 randomSeed_ = randomFromSignature(_hash, _v, _r, _s); - bool isPinkOrPurple_; - // Calculate the difference in tampers and adjust chances - if (whaleTampers_ > minnowTampers_) { - uint256 extraChance = (whaleTampers_ - minnowTampers_) * config.tamperWeightPercent; - uint256 chance = 50 + extraChance; // Base 50% + extra chance - isPinkOrPurple_ = (randomSeed_ % 100) < chance; // True for pink - } else if (minnowTampers_ > whaleTampers_) { - uint256 extraChance = (minnowTampers_ - whaleTampers_) * config.tamperWeightPercent; - uint256 chance = 50 + extraChance; // Base 50% + extra chance - isPinkOrPurple_ = (randomSeed_ % 100) >= chance; // False for purple + + uint256 devWeight_ = migration_.devTampers * config.tamperWeightPercent; + uint256 whaleWeight_ = migration_.whaleTampers * config.tamperWeightPercent; + uint256 minnowWeight_ = migration_.minnowTampers * config.tamperWeightPercent; + + uint256 totalWeight_ = devWeight_ + whaleWeight_ + minnowWeight_; + + uint256 randomValue = randomSeed_ % totalWeight_; + + TrailblazersBadgesS2.MovementType finalColor_; + if (randomValue < devWeight_) { + finalColor_ = TrailblazersBadgesS2.MovementType.Dev; + } else if (randomValue < devWeight_ + whaleWeight_) { + finalColor_ = TrailblazersBadgesS2.MovementType.Whale; } else { - // Equal number of pink and purple tampers, 50/50 chance - isPinkOrPurple_ = (randomSeed_ % 100) < 50; + finalColor_ = TrailblazersBadgesS2.MovementType.Minnow; } uint256 s1BadgeId_ = migration_.s1BadgeId; - TrailblazersBadgesS2.MovementType pinkOrPurple = isPinkOrPurple_ - ? TrailblazersBadgesS2.MovementType.Minnow - : TrailblazersBadgesS2.MovementType.Whale; - // mint the badge - s2Badges.mint(_msgSender(), TrailblazersBadgesS2.BadgeType(s1BadgeId_), pinkOrPurple); + s2Badges.mint(_msgSender(), TrailblazersBadgesS2.BadgeType(s1BadgeId_), finalColor_); uint256 s2TokenId_ = s2Badges.totalSupply(); migration_.s2TokenId = s2TokenId_; @@ -516,6 +519,14 @@ contract BadgeMigration is migration_.tamperExpiration = 0; _updateMigration(migration_); + + emit MigrationComplete( + migration_.migrationCycle, + migration_.user, + migration_.s1TokenId, + migration_.s2TokenId, + uint256(finalColor_) + ); } /// @notice Generate a unique hash for each migration uniquely diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index 404dae3c48f..e34880c849f 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,6 +1,6 @@ { - "BadgeMigration": "0x73F9a4A5c3D6902c2Cbf865c2C5F2F347dbF334e", + "BadgeMigration": "0x223996199E2f8Ea0afB3e5B4F794f3Ffd1f5Fea8", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x07aA4990C1c1F94f1A6ADF0E6c67884E1e37011c", - "TrailblazersBadgesS2": "0xFEaD2a6bF11305D5df8Ff47037EEB5bdE23C07A2" + "TrailblazersBadges": "0x5519767F99eAc7A1B07F321847E90Cc1E084d038", + "TrailblazersBadgesS2": "0xC2C95F57eE2A0853D5B04E266B1bC86281B08ebE" } diff --git a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol index 8b76ffe70ab..921cdd5e6cd 100644 --- a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol @@ -25,11 +25,11 @@ contract DeployS2Script is Script { bool constant PURPLE_TAMPER = false; uint256 public MAX_TAMPERS = 3; - uint256 public COOLDOWN_MIGRATION = 1 minutes; - uint256 public COOLDOWN_TAMPER = 1 minutes; + uint256 public COOLDOWN_MIGRATION = 10 minutes; + uint256 public COOLDOWN_TAMPER = 2 minutes; uint256 public TAMPER_WEIGHT_PERCENT = 5; uint256 public POINTS_CLAIM_MULTIPLICATION_FACTOR = 10; // 10% - + uint256 public S1_LOCK_DURATION = 365 days; // Taiko Mainnet Values //address owner = 0xf8ff2AF0DC1D5BA4811f22aCb02936A1529fd2Be; //bytes32 root = 0xa7e510d5aed347e65609cf6f0e0738cdd752ffdf5980749057c634489fd09fc3; @@ -139,6 +139,9 @@ contract DeployS2Script is Script { s1Token.setMigrationContract(address(migration)); s2Token.setMinter(address(migration)); + // set the lock duration + s1Token.setMigrationLockDuration(S1_LOCK_DURATION); + console.log("Token Base URI:", baseURI); console.log("Deployed TrailblazersBadgesS2 to:", address(s2Token)); console.log("Deployed BadgeMigration to:", address(migration)); From 17b1220d0921b7587318db3d3e2ccccfb445385b Mon Sep 17 00:00:00 2001 From: bearni95 Date: Wed, 23 Oct 2024 01:57:07 +0200 Subject: [PATCH 57/79] updated deployment --- packages/nfts/deployments/trailblazers-season-2/hekla.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index e34880c849f..c6358801491 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,6 +1,6 @@ { - "BadgeMigration": "0x223996199E2f8Ea0afB3e5B4F794f3Ffd1f5Fea8", + "BadgeMigration": "0x9bEC2F8afb818D7326F13FfbFBAc371116aFD142", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x5519767F99eAc7A1B07F321847E90Cc1E084d038", - "TrailblazersBadgesS2": "0xC2C95F57eE2A0853D5B04E266B1bC86281B08ebE" + "TrailblazersBadges": "0xaC6aEbDcbdCfdCfe682D645b996eD10A13434d64", + "TrailblazersBadgesS2": "0x4bD44deba83B91282101997B99BC9f8168501edf" } From 4737123dd1959b76b158427ae75f7e2705fbc82c Mon Sep 17 00:00:00 2001 From: bearni95 Date: Wed, 23 Oct 2024 01:58:32 +0200 Subject: [PATCH 58/79] updated migration --- .../nfts/contracts/trailblazers-season-2/BadgeMigration.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index e640cf356d1..53fb20a21eb 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -491,9 +491,9 @@ contract BadgeMigration is uint256 randomSeed_ = randomFromSignature(_hash, _v, _r, _s); - uint256 devWeight_ = migration_.devTampers * config.tamperWeightPercent; - uint256 whaleWeight_ = migration_.whaleTampers * config.tamperWeightPercent; - uint256 minnowWeight_ = migration_.minnowTampers * config.tamperWeightPercent; + uint256 devWeight_ = 1 + migration_.devTampers * config.tamperWeightPercent; + uint256 whaleWeight_ = 1 + migration_.whaleTampers * config.tamperWeightPercent; + uint256 minnowWeight_ = 1 + migration_.minnowTampers * config.tamperWeightPercent; uint256 totalWeight_ = devWeight_ + whaleWeight_ + minnowWeight_; From 01dcb14ee860d6aeaf585a71743dc1980929171b Mon Sep 17 00:00:00 2001 From: bearni95 Date: Wed, 23 Oct 2024 02:07:22 +0200 Subject: [PATCH 59/79] qa deployment --- packages/nfts/deployments/trailblazers-season-2/hekla.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index c6358801491..040d97704b2 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,6 +1,6 @@ { - "BadgeMigration": "0x9bEC2F8afb818D7326F13FfbFBAc371116aFD142", + "BadgeMigration": "0xC6035575431b4552cB80B275db4c4B0B54462c2c", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0xaC6aEbDcbdCfdCfe682D645b996eD10A13434d64", - "TrailblazersBadgesS2": "0x4bD44deba83B91282101997B99BC9f8168501edf" + "TrailblazersBadges": "0xfF7926adDCc4bD8bD9236DE07DE3CBd2aB98033C", + "TrailblazersBadgesS2": "0xbf7E21fc9999D337F5f42Eed60cbe9efF53F264B" } From db244bcdd81d990325fdf3a44c0c227139ede4ac Mon Sep 17 00:00:00 2001 From: bearni95 Date: Wed, 23 Oct 2024 16:23:25 +0200 Subject: [PATCH 60/79] updated hekla deployment --- .../nfts/contracts/trailblazers-season-2/BadgeMigration.sol | 6 +++--- packages/nfts/deployments/trailblazers-season-2/hekla.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index 53fb20a21eb..dd4354d452e 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -491,9 +491,9 @@ contract BadgeMigration is uint256 randomSeed_ = randomFromSignature(_hash, _v, _r, _s); - uint256 devWeight_ = 1 + migration_.devTampers * config.tamperWeightPercent; - uint256 whaleWeight_ = 1 + migration_.whaleTampers * config.tamperWeightPercent; - uint256 minnowWeight_ = 1 + migration_.minnowTampers * config.tamperWeightPercent; + uint256 devWeight_ = 33 + migration_.devTampers * config.tamperWeightPercent; + uint256 whaleWeight_ = 33 + migration_.whaleTampers * config.tamperWeightPercent; + uint256 minnowWeight_ = 33 + migration_.minnowTampers * config.tamperWeightPercent; uint256 totalWeight_ = devWeight_ + whaleWeight_ + minnowWeight_; diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index 040d97704b2..cc69c7c0c78 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,6 +1,6 @@ { - "BadgeMigration": "0xC6035575431b4552cB80B275db4c4B0B54462c2c", + "BadgeMigration": "0xE4a5230800D083A04B8Ee796e07951EDC7F873Fa", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0xfF7926adDCc4bD8bD9236DE07DE3CBd2aB98033C", - "TrailblazersBadgesS2": "0xbf7E21fc9999D337F5f42Eed60cbe9efF53F264B" + "TrailblazersBadges": "0x8314Caf6AC85BD72d74d81b0055025230F13B5b5", + "TrailblazersBadgesS2": "0xE91cb3D73F116a1F25af2802F79f08FA7894e426" } From dd231aa3a065436b68054d89c141ba44059af5db Mon Sep 17 00:00:00 2001 From: bearni95 Date: Fri, 25 Oct 2024 11:13:10 +0200 Subject: [PATCH 61/79] addressed review comments --- .../trailblazers-season-2/BadgeMigration.sol | 12 +++---- .../TrailblazersBadgesS2.sol | 32 ++++++++++++------- packages/nfts/deployments/gen-layouts.sh | 2 ++ .../trailblazers-season-2/hekla.json | 6 ++-- .../BadgeMigration.t.sol | 3 +- 5 files changed, 30 insertions(+), 25 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index dd4354d452e..93d0a831294 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -33,6 +33,8 @@ contract BadgeMigration is { /// @notice Season 1 Badges ERC721 contract TrailblazersBadgesV4 public s1Badges; + /// @notice badges role key + bytes32 public constant S1_BADGES_ROLE = keccak256("S1_BADGES_ROLE"); /// @notice Season 2 Badges ERC1155 contract TrailblazersBadgesS2 public s2Badges; /// @notice Wallet authorized to sign as a source of randomness @@ -167,13 +169,6 @@ contract BadgeMigration is _; } - modifier onlyS1Contract() { - if (_msgSender() != address(s1Badges)) { - revert NOT_S1_CONTRACT(); - } - _; - } - /// @notice Contract initializer /// @param _s1Badges The Season 1 Badges contract address /// @param _s2Badges The Season 2 Badges contract address @@ -192,6 +187,7 @@ contract BadgeMigration is __Context_init(); _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); s1Badges = TrailblazersBadgesV4(_s1Badges); + _grantRole(S1_BADGES_ROLE, _s1Badges); s2Badges = TrailblazersBadgesS2(_s2Badges); randomSigner = _randomSigner; config = _config; @@ -349,7 +345,7 @@ contract BadgeMigration is ) external virtual - onlyS1Contract + onlyRole(S1_BADGES_ROLE) migrationOpen(_s1BadgeId) isNotMigrating(_user) hasntMigratedInCycle(_s1BadgeId, _user) diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol index 80f87bb0298..d7fd3861a88 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol @@ -27,6 +27,7 @@ contract TrailblazersBadgesS2 is ContextUpgradeable, UUPSUpgradeable, Ownable2StepUpgradeable, + AccessControlUpgradeable, ERC1155SupplyUpgradeable { /// @notice Badge types @@ -59,10 +60,17 @@ contract TrailblazersBadgesS2 is /// @notice Badge mapping mapping(uint256 tokenId => Badge badge) private badges; + /// @notice User, Badge, and Movement relation to tokenId + mapping( + address user + => mapping(BadgeType badgeType => mapping(MovementType movementType => uint256 tokenId)) + ) private userBadges; /// @notice Badge URI template string public uriTemplate; /// @notice Minter address; BadgeMigration contract address public minter; + /// @notice Minter role + bytes32 public constant MINTER = keccak256("MINTER"); /// @notice Gap for upgrade safety uint256[43] private __gap; @@ -70,14 +78,6 @@ contract TrailblazersBadgesS2 is error NOT_MINTER(); error TOKEN_NOT_MINTED(); - /// @notice Allow only the minter to call the function - modifier onlyMinter() { - if (minter != _msgSender()) { - revert NOT_MINTER(); - } - _; - } - /// @notice Initialize the contract /// @param _minter The minter address /// @param _uriTemplate The badge URI template @@ -93,7 +93,8 @@ contract TrailblazersBadgesS2 is __ERC1155Supply_init(); _transferOwnership(_msgSender()); __Context_init(); - + _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); + _grantRole(MINTER, _minter); minter = _minter; uriTemplate = _uriTemplate; } @@ -101,8 +102,9 @@ contract TrailblazersBadgesS2 is /// @notice Set the minter address /// @param _minter The minter address /// @dev Only the owner can call this function - function setMinter(address _minter) external virtual onlyOwner { + function setMinter(address _minter) external virtual onlyRole(DEFAULT_ADMIN_ROLE) { minter = _minter; + _grantRole(MINTER, _minter); } /// @notice Mint a badge @@ -117,7 +119,7 @@ contract TrailblazersBadgesS2 is ) external virtual - onlyMinter + onlyRole(MINTER) { uint256 tokenId_ = totalSupply() + 1; Badge memory badge_ = Badge(tokenId_, _badgeType, _movementType); @@ -184,7 +186,13 @@ contract TrailblazersBadgesS2 is /// @notice supportsInterface implementation /// @param _interfaceId The interface ID /// @return Whether the interface is supported - function supportsInterface(bytes4 _interfaceId) public view virtual override returns (bool) { + function supportsInterface(bytes4 _interfaceId) + public + view + virtual + override(AccessControlUpgradeable, ERC1155Upgradeable) + returns (bool) + { return super.supportsInterface(_interfaceId); } diff --git a/packages/nfts/deployments/gen-layouts.sh b/packages/nfts/deployments/gen-layouts.sh index 2d0fbb034b4..6f647cfb56c 100755 --- a/packages/nfts/deployments/gen-layouts.sh +++ b/packages/nfts/deployments/gen-layouts.sh @@ -7,6 +7,8 @@ contracts=( "SnaefellToken" "ECDSAWhitelist" "TrailblazersBadges" + "TrailblazersBadgesV2" + "BadgeMigration" ) # Empty the output file initially diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index cc69c7c0c78..a9d6ab012fb 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,6 +1,6 @@ { - "BadgeMigration": "0xE4a5230800D083A04B8Ee796e07951EDC7F873Fa", + "BadgeMigration": "0x8e358947C36D52a9bB1F2F7542B5aB01590cb459", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x8314Caf6AC85BD72d74d81b0055025230F13B5b5", - "TrailblazersBadgesS2": "0xE91cb3D73F116a1F25af2802F79f08FA7894e426" + "TrailblazersBadges": "0x9D2be10FDd3cDe11301A7f7c08f150f5863d8Eff", + "TrailblazersBadgesS2": "0x0842187e0D2695264A31753A8E3128133902B142" } diff --git a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol index c24977d9348..77eb6918851 100644 --- a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol +++ b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol @@ -251,9 +251,8 @@ contract TrailblazersBadgesS2Test is Test { // exercise the randomFromSignature function - vm.startPrank(minters[0]); + vm.prank(minters[0]); migration.endMigration(claimHash, v, r, s, 0); - vm.stopPrank(); // check for s2 state reset assertEq(migration.isMigrationActive(minters[0]), false); From 4615fec5a6f2ca4b102a7c50848b877ee4252f06 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Fri, 25 Oct 2024 11:16:13 +0200 Subject: [PATCH 62/79] hekla deployment and taikoons contract replacement --- packages/nfts/deployments/taikoon/hekla.json | 2 +- packages/nfts/deployments/trailblazers-season-2/hekla.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/nfts/deployments/taikoon/hekla.json b/packages/nfts/deployments/taikoon/hekla.json index ad7f9270ff8..6d54379cbe2 100644 --- a/packages/nfts/deployments/taikoon/hekla.json +++ b/packages/nfts/deployments/taikoon/hekla.json @@ -1,5 +1,5 @@ { "MerkleRoot": "0x1c3b504b4d5640d26ad1aa3b57a9df9ec034f19239768e734b849c306d10b110", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TaikoonToken": "0xF917fE66b590f7A09fE654FD5397da461f816FD0" + "TaikoonToken": "0xf3FBa6f1E6C1998195239e7DD794c1EcEA8Da66B" } diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index a9d6ab012fb..2d1a887b4c1 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,6 +1,6 @@ { - "BadgeMigration": "0x8e358947C36D52a9bB1F2F7542B5aB01590cb459", + "BadgeMigration": "0xCcd65B3BBAf6a3058C11BEFce9E48cfab12BFe6b", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x9D2be10FDd3cDe11301A7f7c08f150f5863d8Eff", - "TrailblazersBadgesS2": "0x0842187e0D2695264A31753A8E3128133902B142" + "TrailblazersBadges": "0x3882909bED4Af7bd6e283f1202e0E661E2C67450", + "TrailblazersBadgesS2": "0x5B3D9dCBDEB160d4d5cD7579dfff7E8De8160bf1" } From c1b6c7f47ba3866ce888daaf0b0eacc3c91bd936 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 31 Oct 2024 18:12:58 +0100 Subject: [PATCH 63/79] removal of dev s2 badges --- .../trailblazers-season-2/BadgeMigration.sol | 36 ++++++++----------- .../TrailblazersBadgesS2.sol | 10 +++--- .../trailblazers-season-2/hekla.json | 6 ++-- .../BadgeMigration.t.sol | 13 +++---- 4 files changed, 27 insertions(+), 38 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol index 93d0a831294..588782ee57a 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol @@ -54,7 +54,7 @@ contract BadgeMigration is /// @notice Tamper colors available enum TamperColor { - Dev, // neutral + Undefined, // unused Whale, // based, pink Minnow // boosted, purple @@ -81,7 +81,6 @@ contract BadgeMigration is uint256 s2TokenId; uint256 cooldownExpiration; uint256 tamperExpiration; - uint256 devTampers; uint256 whaleTampers; uint256 minnowTampers; } @@ -104,6 +103,7 @@ contract BadgeMigration is error HASH_MISMATCH(); error NOT_S1_CONTRACT(); error EXP_TOO_LOW(); + error INVALID_TAMPER_COLOR(); /// @notice Events event MigrationCycleToggled(uint256 indexed migrationCycleId, uint256 s1BadgeId, bool enabled); @@ -116,7 +116,6 @@ contract BadgeMigration is uint256 s2TokenId, uint256 cooldownExpiration, uint256 tamperExpiration, - uint256 devTampers, uint256 whaleTampers, uint256 minnowTampers ); @@ -266,7 +265,6 @@ contract BadgeMigration is 0, // s2TokenId, unset block.timestamp + config.cooldownMigration, // cooldownExpiration 0, // tamperExpiration, unset - 0, // dev tampers 0, // whaleTampers 0 // minnowTampers ); @@ -282,7 +280,6 @@ contract BadgeMigration is _migration.s2TokenId, _migration.cooldownExpiration, _migration.tamperExpiration, - _migration.devTampers, _migration.whaleTampers, _migration.minnowTampers ); @@ -381,7 +378,6 @@ contract BadgeMigration is _migration.s2TokenId, _migration.cooldownExpiration, _migration.tamperExpiration, - _migration.devTampers, _migration.whaleTampers, _migration.minnowTampers ); @@ -427,12 +423,12 @@ contract BadgeMigration is revert TAMPER_IN_PROGRESS(); } - if (_tamperColor == TamperColor.Dev) { - migration_.devTampers++; - } else if (_tamperColor == TamperColor.Whale) { + if (_tamperColor == TamperColor.Whale) { migration_.whaleTampers++; - } else { + } else if (_tamperColor == TamperColor.Minnow) { migration_.minnowTampers++; + } else { + revert INVALID_TAMPER_COLOR(); } migration_.tamperExpiration = block.timestamp + config.cooldownTamper; @@ -487,21 +483,18 @@ contract BadgeMigration is uint256 randomSeed_ = randomFromSignature(_hash, _v, _r, _s); - uint256 devWeight_ = 33 + migration_.devTampers * config.tamperWeightPercent; - uint256 whaleWeight_ = 33 + migration_.whaleTampers * config.tamperWeightPercent; - uint256 minnowWeight_ = 33 + migration_.minnowTampers * config.tamperWeightPercent; + uint256 whaleWeight_ = 50 + migration_.whaleTampers * config.tamperWeightPercent; + uint256 minnowWeight_ = 50 + migration_.minnowTampers * config.tamperWeightPercent; - uint256 totalWeight_ = devWeight_ + whaleWeight_ + minnowWeight_; + uint256 totalWeight_ = whaleWeight_ + minnowWeight_; uint256 randomValue = randomSeed_ % totalWeight_; TrailblazersBadgesS2.MovementType finalColor_; - if (randomValue < devWeight_) { - finalColor_ = TrailblazersBadgesS2.MovementType.Dev; - } else if (randomValue < devWeight_ + whaleWeight_) { - finalColor_ = TrailblazersBadgesS2.MovementType.Whale; - } else { + if (randomValue < minnowWeight_) { finalColor_ = TrailblazersBadgesS2.MovementType.Minnow; + } else { + finalColor_ = TrailblazersBadgesS2.MovementType.Whale; } uint256 s1BadgeId_ = migration_.s1BadgeId; @@ -575,19 +568,18 @@ contract BadgeMigration is /// @notice Get the migration tamper counts for a user /// @param _user The user address - /// @return _devTampers The Dev tamper count /// @return _whaleTampers The Whale tamper count /// @return _minnowTampers The Minnow tamper count function getMigrationTampers(address _user) public view - returns (uint256 _devTampers, uint256 _whaleTampers, uint256 _minnowTampers) + returns (uint256 _whaleTampers, uint256 _minnowTampers) { if (!isMigrationActive(_user)) { revert MIGRATION_NOT_STARTED(); } Migration memory migration_ = getActiveMigrationFor(_user); - return (migration_.devTampers, migration_.whaleTampers, migration_.minnowTampers); + return (migration_.whaleTampers, migration_.minnowTampers); } /// @notice supportsInterface implementation diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol index d7fd3861a88..8d3e7705dc3 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol @@ -45,7 +45,7 @@ contract TrailblazersBadgesS2 is /// @notice Movement types enum MovementType { - Dev, // s1 neutral + Undefined, // unused Whale, // s1 based/pink Minnow // s1 boosted/purple @@ -70,7 +70,7 @@ contract TrailblazersBadgesS2 is /// @notice Minter address; BadgeMigration contract address public minter; /// @notice Minter role - bytes32 public constant MINTER = keccak256("MINTER"); + bytes32 public constant MINTER_ROLE = keccak256("MINTER"); /// @notice Gap for upgrade safety uint256[43] private __gap; @@ -94,7 +94,7 @@ contract TrailblazersBadgesS2 is _transferOwnership(_msgSender()); __Context_init(); _grantRole(DEFAULT_ADMIN_ROLE, _msgSender()); - _grantRole(MINTER, _minter); + _grantRole(MINTER_ROLE, _minter); minter = _minter; uriTemplate = _uriTemplate; } @@ -104,7 +104,7 @@ contract TrailblazersBadgesS2 is /// @dev Only the owner can call this function function setMinter(address _minter) external virtual onlyRole(DEFAULT_ADMIN_ROLE) { minter = _minter; - _grantRole(MINTER, _minter); + _grantRole(MINTER_ROLE, _minter); } /// @notice Mint a badge @@ -119,7 +119,7 @@ contract TrailblazersBadgesS2 is ) external virtual - onlyRole(MINTER) + onlyRole(MINTER_ROLE) { uint256 tokenId_ = totalSupply() + 1; Badge memory badge_ = Badge(tokenId_, _badgeType, _movementType); diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index 2d1a887b4c1..06e35bb4a53 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,6 +1,6 @@ { - "BadgeMigration": "0xCcd65B3BBAf6a3058C11BEFce9E48cfab12BFe6b", + "BadgeMigration": "0x68c3f04573619e05B295C5C553c7c9E091A866c0", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x3882909bED4Af7bd6e283f1202e0E661E2C67450", - "TrailblazersBadgesS2": "0x5B3D9dCBDEB160d4d5cD7579dfff7E8De8160bf1" + "TrailblazersBadges": "0x4042A3E28375e0B45BfDCCdE1fA750c052890700", + "TrailblazersBadgesS2": "0x064Ba388C9A9c051FE43F7786eA9e594C40189Cf" } diff --git a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol index 77eb6918851..d016af07493 100644 --- a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol +++ b/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol @@ -194,9 +194,8 @@ contract TrailblazersBadgesS2Test is Test { assertEq(migration.isTamperActive(minters[0]), true); assertEq(migration.isMigrationActive(minters[0]), true); - (uint256 devTampers, uint256 whaleTampers, uint256 minnowTampers) = - migration.getMigrationTampers(minters[0]); - assertEq(devTampers, 0); + (uint256 whaleTampers, uint256 minnowTampers) = migration.getMigrationTampers(minters[0]); + assertEq(whaleTampers, MAX_TAMPERS); assertEq(minnowTampers, 2); } @@ -218,9 +217,8 @@ contract TrailblazersBadgesS2Test is Test { function test_resetTampers() public { test_tamperMigration(); assertEq(migration.isTamperActive(minters[0]), true); - (uint256 devTampers, uint256 whaleTampers, uint256 minnowTampers) = - migration.getMigrationTampers(minters[0]); - assertEq(devTampers, 0); + (uint256 whaleTampers, uint256 minnowTampers) = migration.getMigrationTampers(minters[0]); + assertEq(whaleTampers, MAX_TAMPERS); assertEq(minnowTampers, 2); @@ -228,8 +226,7 @@ contract TrailblazersBadgesS2Test is Test { migration.resetTampers(); assertEq(migration.isTamperActive(minters[0]), false); - (devTampers, whaleTampers, minnowTampers) = migration.getMigrationTampers(minters[0]); - assertEq(devTampers, 0); + (whaleTampers, minnowTampers) = migration.getMigrationTampers(minters[0]); assertEq(whaleTampers, 0); assertEq(minnowTampers, 0); } From deffd9be4d5a11c86293430b89f0a075fa7fa09c Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 31 Oct 2024 19:17:45 +0100 Subject: [PATCH 64/79] cleanup --- packages/nfts/deployments/trailblazers-season-2/hekla.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index 06e35bb4a53..69abe88a0bd 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,6 +1,6 @@ { - "BadgeMigration": "0x68c3f04573619e05B295C5C553c7c9E091A866c0", + "BadgeMigration": "0x902b9D8A288b4D30741AC4314dd0AB9f5a835326", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x4042A3E28375e0B45BfDCCdE1fA750c052890700", - "TrailblazersBadgesS2": "0x064Ba388C9A9c051FE43F7786eA9e594C40189Cf" + "TrailblazersBadges": "0xB08DC15bcC81c413d40bb1c68e79DF240d7Bd8f6", + "TrailblazersBadgesS2": "0x7074dc99764Db1Afc39771F4D01aAd887cD5647e" } From f42edee9fd948e460c6cb753278144d6bcb59c17 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 4 Nov 2024 11:48:15 +0100 Subject: [PATCH 65/79] refactored naming --- ...adgeMigration.sol => BadgeRecruitment.sol} | 352 +++++++++--------- .../TrailblazersS1BadgesV4.sol | 34 +- .../trailblazers-season-2/hekla.json | 6 +- .../script/trailblazers-season-2/Deploy.s.sol | 28 +- ...Migration.t.sol => BadgeRecruitment.t.sol} | 176 ++++----- 5 files changed, 298 insertions(+), 298 deletions(-) rename packages/nfts/contracts/trailblazers-season-2/{BadgeMigration.sol => BadgeRecruitment.sol} (55%) rename packages/nfts/test/trailblazers-season-2/{BadgeMigration.t.sol => BadgeRecruitment.t.sol} (63%) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol similarity index 55% rename from packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol rename to packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol index 588782ee57a..bfb94c0216f 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeMigration.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol @@ -24,7 +24,7 @@ import "./TrailblazersS1BadgesV4.sol"; import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "./TrailblazersBadgesS2.sol"; -contract BadgeMigration is +contract BadgeRecruitment is PausableUpgradeable, UUPSUpgradeable, Ownable2StepUpgradeable, @@ -39,21 +39,21 @@ contract BadgeMigration is TrailblazersBadgesS2 public s2Badges; /// @notice Wallet authorized to sign as a source of randomness address public randomSigner; - /// @notice Migration-enabled badge IDs per cycle + /// @notice Recruitment-enabled badge IDs per cycle mapping(uint256 cycle => mapping(uint256 s1BadgeId => bool enabled)) public enabledBadgeIds; - uint256[] public currentCycleEnabledMigrationIds; - /// @notice Current migration cycle - uint256 private migrationCycle; + uint256[] public currentCycleEnabledRecruitmentIds; + /// @notice Current recruitment cycle + uint256 private recruitmentCycle; /// @notice Mapping of unique user-per-mint-per-cycle mapping( - uint256 migrationCycle + uint256 recruitmentCycle => mapping(address minter => mapping(uint256 s1BadgeId => bool mintEnded)) - ) public migrationCycleUniqueMints; + ) public recruitmentCycleUniqueMints; /// @notice User experience points mapping(address user => uint256 experience) public userExperience; - /// @notice Tamper colors available + /// @notice Influence colors available - enum TamperColor { + enum InfluenceColor { Undefined, // unused Whale, // based, pink Minnow // boosted, purple @@ -62,31 +62,31 @@ contract BadgeMigration is /// @notice Configuration struct struct Config { - uint256 cooldownMigration; - uint256 cooldownTamper; - uint256 tamperWeightPercent; - uint256 baseMaxTampers; + uint256 cooldownRecruitment; + uint256 cooldownInfluence; + uint256 influenceWeightPercent; + uint256 baseMaxInfluences; uint256 pointsClaimMultiplicationFactor; } /// @notice Current config Config private config; - /// @notice Migration struct + /// @notice Recruitment struct - struct Migration { - uint256 migrationCycle; + struct Recruitment { + uint256 recruitmentCycle; address user; uint256 s1BadgeId; uint256 s1TokenId; uint256 s2TokenId; uint256 cooldownExpiration; - uint256 tamperExpiration; - uint256 whaleTampers; - uint256 minnowTampers; + uint256 influenceExpiration; + uint256 whaleInfluences; + uint256 minnowInfluences; } - /// @notice Migrations per user + /// @notice Recruitments per user - mapping(address _user => Migration[] _migration) public migrations; + mapping(address _user => Recruitment[] _recruitment) public recruitments; /// @notice Gap for upgrade safety uint256[43] private __gap; /// @notice Errors @@ -106,32 +106,32 @@ contract BadgeMigration is error INVALID_TAMPER_COLOR(); /// @notice Events - event MigrationCycleToggled(uint256 indexed migrationCycleId, uint256 s1BadgeId, bool enabled); + event RecruitmentCycleToggled(uint256 indexed recruitmentCycleId, uint256 s1BadgeId, bool enabled); - event MigrationUpdated( - uint256 indexed migrationCycle, + event RecruitmentUpdated( + uint256 indexed recruitmentCycle, address indexed user, uint256 s1BadgeId, uint256 s1TokenId, uint256 s2TokenId, uint256 cooldownExpiration, - uint256 tamperExpiration, - uint256 whaleTampers, - uint256 minnowTampers + uint256 influenceExpiration, + uint256 whaleInfluences, + uint256 minnowInfluences ); - event MigrationComplete( - uint256 indexed migrationCycle, + event RecruitmentComplete( + uint256 indexed recruitmentCycle, address indexed user, uint256 s1TokenId, uint256 s2TokenId, uint256 finalColor ); - /// @notice Check if the message sender has an active migration + /// @notice Check if the message sender has an active recruitment modifier isMigrating() { - Migration memory migration_ = getActiveMigrationFor(_msgSender()); - if (migration_.cooldownExpiration == 0) { + Recruitment memory recruitment_ = getActiveRecruitmentFor(_msgSender()); + if (recruitment_.cooldownExpiration == 0) { revert MIGRATION_NOT_STARTED(); } _; @@ -140,29 +140,29 @@ contract BadgeMigration is /// @notice Reverts if sender is already migrating modifier isNotMigrating(address _user) { if ( - migrations[_user].length > 0 - && migrations[_user][migrations[_user].length - 1].cooldownExpiration > block.timestamp + recruitments[_user].length > 0 + && recruitments[_user][recruitments[_user].length - 1].cooldownExpiration > block.timestamp ) { revert MIGRATION_ALREADY_STARTED(); } _; } - /// @notice Reverts if migrations aren't enabled for that badge + /// @notice Reverts if recruitments aren't enabled for that badge /// @param _s1BadgeId The badge ID - modifier migrationOpen(uint256 _s1BadgeId) { - if (!enabledBadgeIds[migrationCycle][_s1BadgeId]) { + modifier recruitmentOpen(uint256 _s1BadgeId) { + if (!enabledBadgeIds[recruitmentCycle][_s1BadgeId]) { revert MIGRATION_NOT_ENABLED(); } _; } - /// @notice Limits migrations to one per user, badge and cycle + /// @notice Limits recruitments to one per user, badge and cycle /// @param _s1BadgeId The badge ID /// @param _minter The minter address modifier hasntMigratedInCycle(uint256 _s1BadgeId, address _minter) { - // check that the minter hasn't used the migration within this cycle - if (migrationCycleUniqueMints[migrationCycle][_minter][_s1BadgeId]) { + // check that the minter hasn't used the recruitment within this cycle + if (recruitmentCycleUniqueMints[recruitmentCycle][_minter][_s1BadgeId]) { revert ALREADY_MIGRATED_IN_CYCLE(); } _; @@ -204,52 +204,52 @@ contract BadgeMigration is return config; } - /// @notice Disable all new migrations - /// @dev Doesn't allow for new migration attempts, but tampers and active migrations still run - function _disableMigrations() internal onlyRole(DEFAULT_ADMIN_ROLE) { + /// @notice Disable all new recruitments + /// @dev Doesn't allow for new recruitment attempts, but influences and active recruitments still run + function _disableRecruitments() internal onlyRole(DEFAULT_ADMIN_ROLE) { for (uint256 i = 0; i < 8; i++) { - if (enabledBadgeIds[migrationCycle][i]) { - emit MigrationCycleToggled(migrationCycle, i, false); + if (enabledBadgeIds[recruitmentCycle][i]) { + emit RecruitmentCycleToggled(recruitmentCycle, i, false); } - enabledBadgeIds[migrationCycle][i] = false; + enabledBadgeIds[recruitmentCycle][i] = false; } - currentCycleEnabledMigrationIds = new uint256[](0); + currentCycleEnabledRecruitmentIds = new uint256[](0); } - /// @notice Enable migrations for a set of badges + /// @notice Enable recruitments for a set of badges /// @param _s1BadgeIds The badge IDs to enable /// @dev Can be called only by the contract owner/admin - function enableMigrations(uint256[] calldata _s1BadgeIds) + function enableRecruitments(uint256[] calldata _s1BadgeIds) external onlyRole(DEFAULT_ADMIN_ROLE) { - migrationCycle++; + recruitmentCycle++; for (uint256 i = 0; i < _s1BadgeIds.length; i++) { - enabledBadgeIds[migrationCycle][_s1BadgeIds[i]] = true; - emit MigrationCycleToggled(migrationCycle, _s1BadgeIds[i], true); + enabledBadgeIds[recruitmentCycle][_s1BadgeIds[i]] = true; + emit RecruitmentCycleToggled(recruitmentCycle, _s1BadgeIds[i], true); } - currentCycleEnabledMigrationIds = _s1BadgeIds; + currentCycleEnabledRecruitmentIds = _s1BadgeIds; } - /// @notice Get the current migration cycle - /// @return The current migration cycle - function getMigrationCycle() external view returns (uint256) { - return migrationCycle; + /// @notice Get the current recruitment cycle + /// @return The current recruitment cycle + function getRecruitmentCycle() external view returns (uint256) { + return recruitmentCycle; } /// @notice Pause the contract /// @dev Can be called only by the contract owner/admin function pause() public onlyRole(DEFAULT_ADMIN_ROLE) { - _disableMigrations(); + _disableRecruitments(); _pause(); } - /// @notice Internal logic to start a migration + /// @notice Internal logic to start a recruitment /// @param _user The user address /// @param _s1BadgeId The badge ID /// @param _s1TokenId The badge token ID - function _startMigration( + function _startRecruitment( address _user, uint256 _s1BadgeId, uint256 _s1TokenId @@ -257,41 +257,41 @@ contract BadgeMigration is internal virtual { - Migration memory _migration = Migration( - migrationCycle, // migrationCycle + Recruitment memory _recruitment = Recruitment( + recruitmentCycle, // recruitmentCycle _user, // user _s1BadgeId, _s1TokenId, 0, // s2TokenId, unset - block.timestamp + config.cooldownMigration, // cooldownExpiration - 0, // tamperExpiration, unset - 0, // whaleTampers - 0 // minnowTampers + block.timestamp + config.cooldownRecruitment, // cooldownExpiration + 0, // influenceExpiration, unset + 0, // whaleInfluences + 0 // minnowInfluences ); - migrations[_user].push(_migration); - migrationCycleUniqueMints[migrationCycle][_user][_s1BadgeId] = true; - - emit MigrationUpdated( - _migration.migrationCycle, - _migration.user, - _migration.s1BadgeId, - _migration.s1TokenId, - _migration.s2TokenId, - _migration.cooldownExpiration, - _migration.tamperExpiration, - _migration.whaleTampers, - _migration.minnowTampers + recruitments[_user].push(_recruitment); + recruitmentCycleUniqueMints[recruitmentCycle][_user][_s1BadgeId] = true; + + emit RecruitmentUpdated( + _recruitment.recruitmentCycle, + _recruitment.user, + _recruitment.s1BadgeId, + _recruitment.s1TokenId, + _recruitment.s2TokenId, + _recruitment.cooldownExpiration, + _recruitment.influenceExpiration, + _recruitment.whaleInfluences, + _recruitment.minnowInfluences ); } - /// @notice Start a migration for a badge using the user's experience points + /// @notice Start a recruitment for a badge using the user's experience points /// @param _hash The hash to sign of the signature /// @param _v The signature V field /// @param _r The signature R field /// @param _s The signature S field /// @param _exp The user's experience points - function startMigration( + function startRecruitment( bytes32 _hash, uint8 _v, bytes32 _r, @@ -321,29 +321,29 @@ contract BadgeMigration is uint256 randomSeed_ = randomFromSignature(_hash, _v, _r, _s); uint256 s1BadgeId_ = - currentCycleEnabledMigrationIds[randomSeed_ % currentCycleEnabledMigrationIds.length]; + currentCycleEnabledRecruitmentIds[randomSeed_ % currentCycleEnabledRecruitmentIds.length]; - if (migrationCycleUniqueMints[migrationCycle][_msgSender()][s1BadgeId_]) { + if (recruitmentCycleUniqueMints[recruitmentCycle][_msgSender()][s1BadgeId_]) { revert ALREADY_MIGRATED_IN_CYCLE(); } - _startMigration(_msgSender(), (randomSeed_ % 8), 0); + _startRecruitment(_msgSender(), (randomSeed_ % 8), 0); } - /// @notice Start a migration for a badge + /// @notice Start a recruitment for a badge /// @param _s1BadgeId The badge ID (s1) - /// @dev Not all badges are eligible for migration at the same time - /// @dev Defines a cooldown for the migration to be complete + /// @dev Not all badges are eligible for recruitment at the same time + /// @dev Defines a cooldown for the recruitment to be complete /// @dev the cooldown is lesser the higher the Pass Tier /// @dev Must be called from the s1 badges contract - function startMigration( + function startRecruitment( address _user, uint256 _s1BadgeId ) external virtual onlyRole(S1_BADGES_ROLE) - migrationOpen(_s1BadgeId) + recruitmentOpen(_s1BadgeId) isNotMigrating(_user) hasntMigratedInCycle(_s1BadgeId, _user) { @@ -352,110 +352,110 @@ contract BadgeMigration is if (s1Badges.ownerOf(s1TokenId_) != _user) { revert TOKEN_NOT_OWNED(); } - _startMigration(_user, _s1BadgeId, s1TokenId_); + _startRecruitment(_user, _s1BadgeId, s1TokenId_); } - /// @notice Get the active migration for a user + /// @notice Get the active recruitment for a user /// @param _user The user address - /// @return The active migration - function getActiveMigrationFor(address _user) public view returns (Migration memory) { - if (migrations[_user].length == 0) { + /// @return The active recruitment + function getActiveRecruitmentFor(address _user) public view returns (Recruitment memory) { + if (recruitments[_user].length == 0) { revert MIGRATION_NOT_STARTED(); } - return migrations[_user][migrations[_user].length - 1]; + return recruitments[_user][recruitments[_user].length - 1]; } - /// @notice Update a migration - /// @param _migration The updated migration - function _updateMigration(Migration memory _migration) internal virtual { - migrations[_migration.user][migrations[_migration.user].length - 1] = _migration; - - emit MigrationUpdated( - _migration.migrationCycle, - _migration.user, - _migration.s1BadgeId, - _migration.s1TokenId, - _migration.s2TokenId, - _migration.cooldownExpiration, - _migration.tamperExpiration, - _migration.whaleTampers, - _migration.minnowTampers + /// @notice Update a recruitment + /// @param _recruitment The updated recruitment + function _updateRecruitment(Recruitment memory _recruitment) internal virtual { + recruitments[_recruitment.user][recruitments[_recruitment.user].length - 1] = _recruitment; + + emit RecruitmentUpdated( + _recruitment.recruitmentCycle, + _recruitment.user, + _recruitment.s1BadgeId, + _recruitment.s1TokenId, + _recruitment.s2TokenId, + _recruitment.cooldownExpiration, + _recruitment.influenceExpiration, + _recruitment.whaleInfluences, + _recruitment.minnowInfluences ); } - /// @notice Get the maximum number of tampers for a given experience + /// @notice Get the maximum number of influences for a given experience /// @param _exp The user's experience points - function maxTampers(uint256 _exp) public view virtual returns (uint256 value) { + function maxInfluences(uint256 _exp) public view virtual returns (uint256 value) { value = _exp / 100; - value += 2 * config.baseMaxTampers; + value += 2 * config.baseMaxInfluences; return value; } - /// @notice Tamper (alter) the chances during a migration + /// @notice Influence (alter) the chances during a recruitment /// @param _hash The hash to sign /// @param v signature V field /// @param r signature R field /// @param s signature S field - /// @param _tamperColor the tamper's color - /// @dev Can be called only during an active migration - /// @dev Implements a cooldown before allowing to re-tamper - /// @dev The max tamper amount is determined by Pass Tier - function tamperMigration( + /// @param _influenceColor the influence's color + /// @dev Can be called only during an active recruitment + /// @dev Implements a cooldown before allowing to re-influence + /// @dev The max influence amount is determined by Pass Tier + function influenceRecruitment( bytes32 _hash, uint8 v, bytes32 r, bytes32 s, uint256 exp, - TamperColor _tamperColor + InfluenceColor _influenceColor ) external isMigrating { (address recovered_,,) = ECDSA.tryRecover(_hash, v, r, s); if (recovered_ != randomSigner) revert NOT_RANDOM_SIGNER(); - Migration memory migration_ = getActiveMigrationFor(_msgSender()); + Recruitment memory recruitment_ = getActiveRecruitmentFor(_msgSender()); - if ((migration_.whaleTampers + migration_.minnowTampers) > maxTampers(exp)) { + if ((recruitment_.whaleInfluences + recruitment_.minnowInfluences) > maxInfluences(exp)) { revert MAX_TAMPERS_REACHED(); } - if (migration_.tamperExpiration > block.timestamp) { + if (recruitment_.influenceExpiration > block.timestamp) { revert TAMPER_IN_PROGRESS(); } - if (_tamperColor == TamperColor.Whale) { - migration_.whaleTampers++; - } else if (_tamperColor == TamperColor.Minnow) { - migration_.minnowTampers++; + if (_influenceColor == InfluenceColor.Whale) { + recruitment_.whaleInfluences++; + } else if (_influenceColor == InfluenceColor.Minnow) { + recruitment_.minnowInfluences++; } else { revert INVALID_TAMPER_COLOR(); } - migration_.tamperExpiration = block.timestamp + config.cooldownTamper; + recruitment_.influenceExpiration = block.timestamp + config.cooldownInfluence; - _updateMigration(migration_); + _updateRecruitment(recruitment_); } - /// @notice Reset the tamper counts - /// @dev Can be called only during an active migration - function resetTampers() external isMigrating { - Migration memory migration_ = getActiveMigrationFor(_msgSender()); - migration_.whaleTampers = 0; - migration_.minnowTampers = 0; - migration_.tamperExpiration = 0; + /// @notice Reset the influence counts + /// @dev Can be called only during an active recruitment + function resetInfluences() external isMigrating { + Recruitment memory recruitment_ = getActiveRecruitmentFor(_msgSender()); + recruitment_.whaleInfluences = 0; + recruitment_.minnowInfluences = 0; + recruitment_.influenceExpiration = 0; - _updateMigration(migration_); + _updateRecruitment(recruitment_); } - /// @notice End a migration + /// @notice End a recruitment /// @param _hash The hash to sign /// @param _v signature V field /// @param _r signature R field /// @param _s signature S field /// @param _exp The user's experience points - /// @dev Can be called only during an active migration, after the cooldown is over - /// @dev The final color is determined randomly, and affected by the tamper amounts - function endMigration( + /// @dev Can be called only during an active recruitment, after the cooldown is over + /// @dev The final color is determined randomly, and affected by the influence amounts + function endRecruitment( bytes32 _hash, uint8 _v, bytes32 _r, @@ -465,13 +465,13 @@ contract BadgeMigration is external isMigrating { - Migration memory migration_ = getActiveMigrationFor(_msgSender()); + Recruitment memory recruitment_ = getActiveRecruitmentFor(_msgSender()); - if (migration_.tamperExpiration > block.timestamp) { + if (recruitment_.influenceExpiration > block.timestamp) { revert TAMPER_IN_PROGRESS(); } // check if the cooldown is over - if (migration_.cooldownExpiration > block.timestamp) { + if (recruitment_.cooldownExpiration > block.timestamp) { revert MIGRATION_NOT_READY(); } // ensure the hash corresponds to the start time @@ -483,8 +483,8 @@ contract BadgeMigration is uint256 randomSeed_ = randomFromSignature(_hash, _v, _r, _s); - uint256 whaleWeight_ = 50 + migration_.whaleTampers * config.tamperWeightPercent; - uint256 minnowWeight_ = 50 + migration_.minnowTampers * config.tamperWeightPercent; + uint256 whaleWeight_ = 50 + recruitment_.whaleInfluences * config.influenceWeightPercent; + uint256 minnowWeight_ = 50 + recruitment_.minnowInfluences * config.influenceWeightPercent; uint256 totalWeight_ = whaleWeight_ + minnowWeight_; @@ -497,28 +497,28 @@ contract BadgeMigration is finalColor_ = TrailblazersBadgesS2.MovementType.Whale; } - uint256 s1BadgeId_ = migration_.s1BadgeId; + uint256 s1BadgeId_ = recruitment_.s1BadgeId; // mint the badge s2Badges.mint(_msgSender(), TrailblazersBadgesS2.BadgeType(s1BadgeId_), finalColor_); uint256 s2TokenId_ = s2Badges.totalSupply(); - migration_.s2TokenId = s2TokenId_; - migration_.cooldownExpiration = 0; - migration_.tamperExpiration = 0; + recruitment_.s2TokenId = s2TokenId_; + recruitment_.cooldownExpiration = 0; + recruitment_.influenceExpiration = 0; - _updateMigration(migration_); + _updateRecruitment(recruitment_); - emit MigrationComplete( - migration_.migrationCycle, - migration_.user, - migration_.s1TokenId, - migration_.s2TokenId, + emit RecruitmentComplete( + recruitment_.recruitmentCycle, + recruitment_.user, + recruitment_.s1TokenId, + recruitment_.s2TokenId, uint256(finalColor_) ); } - /// @notice Generate a unique hash for each migration uniquely + /// @notice Generate a unique hash for each recruitment uniquely /// @param _user The user address /// @param _exp The users experience points /// @return _hash The unique hash @@ -526,15 +526,15 @@ contract BadgeMigration is return keccak256(abi.encodePacked(_user, _exp)); } - /// @notice Check if a migration is active for a user + /// @notice Check if a recruitment is active for a user /// @param _user The user address - /// @return Whether the user has an active migration - function isMigrationActive(address _user) public view returns (bool) { - if (migrations[_user].length == 0) { + /// @return Whether the user has an active recruitment + function isRecruitmentActive(address _user) public view returns (bool) { + if (recruitments[_user].length == 0) { return false; } - Migration memory migration_ = getActiveMigrationFor(_user); - return migration_.cooldownExpiration != 0; + Recruitment memory recruitment_ = getActiveRecruitmentFor(_user); + return recruitment_.cooldownExpiration != 0; } /// @notice Generates a random number from a signature @@ -558,28 +558,28 @@ contract BadgeMigration is return uint256(keccak256(abi.encodePacked(_r, _s, _v))); } - /// @notice Check if a tamper is active for a user + /// @notice Check if a influence is active for a user /// @param _user The user address - /// @return Whether the user has an active tamper - function isTamperActive(address _user) public view returns (bool) { - Migration memory migration_ = getActiveMigrationFor(_user); - return migration_.tamperExpiration > block.timestamp; + /// @return Whether the user has an active influence + function isInfluenceActive(address _user) public view returns (bool) { + Recruitment memory recruitment_ = getActiveRecruitmentFor(_user); + return recruitment_.influenceExpiration > block.timestamp; } - /// @notice Get the migration tamper counts for a user + /// @notice Get the recruitment influence counts for a user /// @param _user The user address - /// @return _whaleTampers The Whale tamper count - /// @return _minnowTampers The Minnow tamper count - function getMigrationTampers(address _user) + /// @return _whaleInfluences The Whale influence count + /// @return _minnowInfluences The Minnow influence count + function getRecruitmentInfluences(address _user) public view - returns (uint256 _whaleTampers, uint256 _minnowTampers) + returns (uint256 _whaleInfluences, uint256 _minnowInfluences) { - if (!isMigrationActive(_user)) { + if (!isRecruitmentActive(_user)) { revert MIGRATION_NOT_STARTED(); } - Migration memory migration_ = getActiveMigrationFor(_user); - return (migration_.whaleTampers, migration_.minnowTampers); + Recruitment memory recruitment_ = getActiveRecruitmentFor(_user); + return (recruitment_.whaleInfluences, recruitment_.minnowInfluences); } /// @notice supportsInterface implementation diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol index 0d78a382915..7103f110ba7 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol @@ -2,13 +2,13 @@ pragma solidity 0.8.24; import "../trailblazers-badges/TrailblazersBadgesV3.sol"; -import "./BadgeMigration.sol"; +import "./BadgeRecruitment.sol"; contract TrailblazersBadgesV4 is TrailblazersBadgesV3 { - /// @notice Duration for which a s1 badge is locked after migration is started - uint256 public migrationLockDuration; - /// @notice BadgeMigration contract - BadgeMigration public migrationContract; + /// @notice Duration for which a s1 badge is locked after recruitment is started + uint256 public recruitmentLockDuration; + /// @notice BadgeRecruitment contract + BadgeRecruitment public recruitmentContract; /// @notice Mapping of badge token id to unlock timestamp mapping(uint256 tokenId => uint256 unlockTimestamp) public unlockTimestamps; @@ -43,28 +43,28 @@ contract TrailblazersBadgesV4 is TrailblazersBadgesV3 { return super._update(to, tokenId, auth); } - /// @notice Set migration contract - /// @param _migrationContract Address of the migration contract + /// @notice Set recruitment contract + /// @param _recruitmentContract Address of the recruitment contract /// @dev Only owner - function setMigrationContract(address _migrationContract) public onlyOwner { - migrationContract = BadgeMigration(_migrationContract); + function setRecruitmentContract(address _recruitmentContract) public onlyOwner { + recruitmentContract = BadgeRecruitment(_recruitmentContract); } - /// @notice Set migration lock duration + /// @notice Set recruitment lock duration /// @param _duration Duration in seconds /// @dev Only owner - function setMigrationLockDuration(uint256 _duration) public onlyOwner { - migrationLockDuration = _duration; + function setRecruitmentLockDuration(uint256 _duration) public onlyOwner { + recruitmentLockDuration = _duration; } - /// @notice Start migration for a badge + /// @notice Start recruitment for a badge /// @param _badgeId Badge id - function startMigration(uint256 _badgeId) public { - if (migrationLockDuration == 0) { + function startRecruitment(uint256 _badgeId) public { + if (recruitmentLockDuration == 0) { revert MIGRATION_LOCK_DURATION_NOT_SET(); } uint256 tokenId = getTokenId(_msgSender(), _badgeId); - unlockTimestamps[tokenId] = block.timestamp + migrationLockDuration; - migrationContract.startMigration(_msgSender(), _badgeId); + unlockTimestamps[tokenId] = block.timestamp + recruitmentLockDuration; + recruitmentContract.startRecruitment(_msgSender(), _badgeId); } } diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index 69abe88a0bd..6b9fe476e90 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,6 +1,6 @@ { - "BadgeMigration": "0x902b9D8A288b4D30741AC4314dd0AB9f5a835326", + "BadgeRecruitment": "0x6cb02e9b2bDfb62fA766A5D6efF42BCDBC931E4B", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0xB08DC15bcC81c413d40bb1c68e79DF240d7Bd8f6", - "TrailblazersBadgesS2": "0x7074dc99764Db1Afc39771F4D01aAd887cD5647e" + "TrailblazersBadges": "0x5ebFC0Cb18C96f6Ff230F7F0E5b6887076570023", + "TrailblazersBadgesS2": "0x96Cb23f90632A8d767de8C79c2eA92b7F5251cd8" } diff --git a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol index 921cdd5e6cd..f39bc288d3d 100644 --- a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol @@ -11,7 +11,7 @@ import { TrailblazersBadgesS2 } from "../../contracts/trailblazers-season-2/TrailblazersBadgesS2.sol"; import { TrailblazersBadgesV4 } from "../../contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol"; -import { BadgeMigration } from "../../contracts/trailblazers-season-2/BadgeMigration.sol"; +import { BadgeRecruitment } from "../../contracts/trailblazers-season-2/BadgeRecruitment.sol"; contract DeployS2Script is Script { UtilsScript public utils; @@ -19,7 +19,7 @@ contract DeployS2Script is Script { uint256 public deployerPrivateKey; address public deployerAddress; - BadgeMigration migration; + BadgeRecruitment recruitment; bool constant PINK_TAMPER = true; bool constant PURPLE_TAMPER = false; @@ -43,7 +43,7 @@ contract DeployS2Script is Script { IMinimalBlacklist blacklist = IMinimalBlacklist(0xe61E9034b5633977eC98E302b33e321e8140F105); address claimMintSigner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; - address migrationSigner = 0x3cda4F2EaC3fc2FdE78B3DFFe1A1A1Eff88c68c5; + address recruitmentSigner = 0x3cda4F2EaC3fc2FdE78B3DFFe1A1A1Eff88c68c5; // Hardhat Testnet Values // address owner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; @@ -113,9 +113,9 @@ contract DeployS2Script is Script { s2Token = TrailblazersBadgesS2(proxy); - // deploy the migration contract + // deploy the recruitment contract - BadgeMigration.Config memory config = BadgeMigration.Config( + BadgeRecruitment.Config memory config = BadgeRecruitment.Config( COOLDOWN_MIGRATION, COOLDOWN_TAMPER, TAMPER_WEIGHT_PERCENT, @@ -123,33 +123,33 @@ contract DeployS2Script is Script { POINTS_CLAIM_MULTIPLICATION_FACTOR ); - impl = address(new BadgeMigration()); + impl = address(new BadgeRecruitment()); proxy = address( new ERC1967Proxy( impl, abi.encodeCall( - BadgeMigration.initialize, - (address(s1Token), address(s2Token), migrationSigner, config) + BadgeRecruitment.initialize, + (address(s1Token), address(s2Token), recruitmentSigner, config) ) ) ); - migration = BadgeMigration(proxy); + recruitment = BadgeRecruitment(proxy); // assign relations - s1Token.setMigrationContract(address(migration)); - s2Token.setMinter(address(migration)); + s1Token.setRecruitmentContract(address(recruitment)); + s2Token.setMinter(address(recruitment)); // set the lock duration - s1Token.setMigrationLockDuration(S1_LOCK_DURATION); + s1Token.setRecruitmentLockDuration(S1_LOCK_DURATION); console.log("Token Base URI:", baseURI); console.log("Deployed TrailblazersBadgesS2 to:", address(s2Token)); - console.log("Deployed BadgeMigration to:", address(migration)); + console.log("Deployed BadgeRecruitment to:", address(recruitment)); // Register deployment vm.serializeAddress(jsonRoot, "TrailblazersBadges", address(s1Token)); vm.serializeAddress(jsonRoot, "TrailblazersBadgesS2", address(s2Token)); - vm.serializeAddress(jsonRoot, "BadgeMigration", address(migration)); + vm.serializeAddress(jsonRoot, "BadgeRecruitment", address(recruitment)); string memory finalJson = vm.serializeAddress(jsonRoot, "Owner", s2Token.owner()); vm.writeJson(finalJson, jsonLocation); diff --git a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeRecruitment.t.sol similarity index 63% rename from packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol rename to packages/nfts/test/trailblazers-season-2/BadgeRecruitment.t.sol index d016af07493..c94c57e8ca2 100644 --- a/packages/nfts/test/trailblazers-season-2/BadgeMigration.t.sol +++ b/packages/nfts/test/trailblazers-season-2/BadgeRecruitment.t.sol @@ -14,7 +14,7 @@ import { TrailblazersBadgesS2 } from import { TrailblazerBadgesS1MintTo } from "../util/TrailblazerBadgesS1MintTo.sol"; import { TrailblazersBadgesV4 } from "../../contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol"; -import { BadgeMigration } from "../../contracts/trailblazers-season-2/BadgeMigration.sol"; +import { BadgeRecruitment } from "../../contracts/trailblazers-season-2/BadgeRecruitment.sol"; contract TrailblazersBadgesS2Test is Test { UtilsScript public utils; @@ -39,7 +39,7 @@ contract TrailblazersBadgesS2Test is Test { uint256 public TAMPER_WEIGHT_PERCENT = 5; uint256 public POINTS_CLAIM_MULTIPLICATION_FACTOR = 10; // 10% - BadgeMigration public migration; + BadgeRecruitment public recruitment; function setUp() public { utils = new UtilsScript(); @@ -79,8 +79,8 @@ contract TrailblazersBadgesS2Test is Test { s1BadgesV4 = TrailblazersBadgesV4(address(s1BadgesV2)); - // set cooldown migration - s1BadgesV4.setMigrationLockDuration(365 days); + // set cooldown recruitment + s1BadgesV4.setRecruitmentLockDuration(365 days); // deploy the s2 erc1155 token contract @@ -88,14 +88,14 @@ contract TrailblazersBadgesS2Test is Test { proxy = address( new ERC1967Proxy( impl, - abi.encodeCall(TrailblazersBadgesS2.initialize, (address(migration), "ipfs://")) + abi.encodeCall(TrailblazersBadgesS2.initialize, (address(recruitment), "ipfs://")) ) ); s2Badges = TrailblazersBadgesS2(proxy); - // deploy the migration contract + // deploy the recruitment contract - BadgeMigration.Config memory config = BadgeMigration.Config( + BadgeRecruitment.Config memory config = BadgeRecruitment.Config( COOLDOWN_MIGRATION, COOLDOWN_TAMPER, TAMPER_WEIGHT_PERCENT, @@ -103,23 +103,23 @@ contract TrailblazersBadgesS2Test is Test { POINTS_CLAIM_MULTIPLICATION_FACTOR ); - impl = address(new BadgeMigration()); + impl = address(new BadgeRecruitment()); proxy = address( new ERC1967Proxy( impl, abi.encodeCall( - BadgeMigration.initialize, + BadgeRecruitment.initialize, (address(s1BadgesV2), address(s2Badges), mintSigner, config) ) ) ); - migration = BadgeMigration(proxy); - s1BadgesV4.setMigrationContract(address(migration)); - s2Badges.setMinter(address(migration)); - // enable migration for BADGE_ID + recruitment = BadgeRecruitment(proxy); + s1BadgesV4.setRecruitmentContract(address(recruitment)); + s2Badges.setMinter(address(recruitment)); + // enable recruitment for BADGE_ID uint256[] memory enabledBadgeIds = new uint256[](1); enabledBadgeIds[0] = BADGE_ID; - migration.enableMigrations(enabledBadgeIds); + recruitment.enableRecruitments(enabledBadgeIds); vm.stopBroadcast(); } @@ -151,15 +151,15 @@ contract TrailblazersBadgesS2Test is Test { assertEq(s1BadgesV4.balanceOf(minters[2]), 2); } - function test_startMigration() public { + function test_startRecruitment() public { mint_s1(minters[0], BADGE_ID); vm.prank(minters[0]); - s1BadgesV4.startMigration(BADGE_ID); + s1BadgesV4.startRecruitment(BADGE_ID); uint256 tokenId = s1BadgesV4.getTokenId(minters[0], BADGE_ID); assertEq(s1BadgesV4.balanceOf(minters[0]), 1); - assertEq(migration.isMigrationActive(minters[0]), true); + assertEq(recruitment.isRecruitmentActive(minters[0]), true); assertEq(s1BadgesV4.unlockTimestamps(tokenId), block.timestamp + 365 days); } @@ -167,78 +167,78 @@ contract TrailblazersBadgesS2Test is Test { vm.warp(block.timestamp + time); } - // happy-path, make 3 pink tampers, and 2 purple ones - function test_tamperMigration() public { - test_startMigration(); + // happy-path, make 3 pink influences, and 2 purple ones + function test_influenceRecruitment() public { + test_startRecruitment(); vm.startPrank(minters[0]); uint256 points = 0; - bytes32 _hash = migration.generateClaimHash(minters[0], points); + bytes32 _hash = recruitment.generateClaimHash(minters[0], points); (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); for (uint256 i = 0; i < MAX_TAMPERS; i++) { wait(COOLDOWN_TAMPER); - migration.tamperMigration(_hash, v, r, s, points, BadgeMigration.TamperColor.Whale); + recruitment.influenceRecruitment(_hash, v, r, s, points, BadgeRecruitment.InfluenceColor.Whale); } wait(COOLDOWN_TAMPER); - migration.tamperMigration(_hash, v, r, s, points, BadgeMigration.TamperColor.Minnow); + recruitment.influenceRecruitment(_hash, v, r, s, points, BadgeRecruitment.InfluenceColor.Minnow); wait(COOLDOWN_TAMPER); - migration.tamperMigration(_hash, v, r, s, points, BadgeMigration.TamperColor.Minnow); + recruitment.influenceRecruitment(_hash, v, r, s, points, BadgeRecruitment.InfluenceColor.Minnow); vm.stopPrank(); - assertEq(migration.isTamperActive(minters[0]), true); - assertEq(migration.isMigrationActive(minters[0]), true); + assertEq(recruitment.isInfluenceActive(minters[0]), true); + assertEq(recruitment.isRecruitmentActive(minters[0]), true); - (uint256 whaleTampers, uint256 minnowTampers) = migration.getMigrationTampers(minters[0]); + (uint256 whaleInfluences, uint256 minnowInfluences) = recruitment.getRecruitmentInfluences(minters[0]); - assertEq(whaleTampers, MAX_TAMPERS); - assertEq(minnowTampers, 2); + assertEq(whaleInfluences, MAX_TAMPERS); + assertEq(minnowInfluences, 2); } - function test_revert_tooManyTampers() public { + function test_revert_tooManyInfluences() public { uint256 points = 0; - bytes32 _hash = migration.generateClaimHash(minters[0], points); + bytes32 _hash = recruitment.generateClaimHash(minters[0], points); (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); - test_tamperMigration(); + test_influenceRecruitment(); vm.startPrank(minters[0]); vm.expectRevert(); - migration.tamperMigration(_hash, v, r, s, points, BadgeMigration.TamperColor.Whale); + recruitment.influenceRecruitment(_hash, v, r, s, points, BadgeRecruitment.InfluenceColor.Whale); vm.stopPrank(); } - function test_resetTampers() public { - test_tamperMigration(); - assertEq(migration.isTamperActive(minters[0]), true); - (uint256 whaleTampers, uint256 minnowTampers) = migration.getMigrationTampers(minters[0]); + function test_resetInfluences() public { + test_influenceRecruitment(); + assertEq(recruitment.isInfluenceActive(minters[0]), true); + (uint256 whaleInfluences, uint256 minnowInfluences) = recruitment.getRecruitmentInfluences(minters[0]); - assertEq(whaleTampers, MAX_TAMPERS); - assertEq(minnowTampers, 2); + assertEq(whaleInfluences, MAX_TAMPERS); + assertEq(minnowInfluences, 2); vm.prank(minters[0]); - migration.resetTampers(); + recruitment.resetInfluences(); - assertEq(migration.isTamperActive(minters[0]), false); - (whaleTampers, minnowTampers) = migration.getMigrationTampers(minters[0]); - assertEq(whaleTampers, 0); - assertEq(minnowTampers, 0); + assertEq(recruitment.isInfluenceActive(minters[0]), false); + (whaleInfluences, minnowInfluences) = recruitment.getRecruitmentInfluences(minters[0]); + assertEq(whaleInfluences, 0); + assertEq(minnowInfluences, 0); } - function test_endMigration() public { - test_tamperMigration(); + function test_endRecruitment() public { + test_influenceRecruitment(); wait(COOLDOWN_TAMPER); wait(COOLDOWN_MIGRATION); - // generate the claim hash for the current migration - bytes32 claimHash = migration.generateClaimHash( + // generate the claim hash for the current recruitment + bytes32 claimHash = recruitment.generateClaimHash( minters[0], 0 // experience points ); @@ -249,21 +249,21 @@ contract TrailblazersBadgesS2Test is Test { // exercise the randomFromSignature function vm.prank(minters[0]); - migration.endMigration(claimHash, v, r, s, 0); + recruitment.endRecruitment(claimHash, v, r, s, 0); // check for s2 state reset - assertEq(migration.isMigrationActive(minters[0]), false); - assertEq(migration.isTamperActive(minters[0]), false); + assertEq(recruitment.isRecruitmentActive(minters[0]), false); + assertEq(recruitment.isInfluenceActive(minters[0]), false); // check for s2 mint assertEq(s2Badges.balanceOf(minters[0], 1), 1); } - function test_revert_startMigrationTwice() public { - test_startMigration(); + function test_revert_startRecruitmentTwice() public { + test_startRecruitment(); vm.startPrank(minters[0]); vm.expectRevert(); - s1BadgesV4.startMigration(BADGE_ID); + s1BadgesV4.startRecruitment(BADGE_ID); vm.stopPrank(); } @@ -275,20 +275,20 @@ contract TrailblazersBadgesS2Test is Test { vm.startPrank(minters[0]); vm.expectRevert(); - s1BadgesV4.startMigration(badgeId); + s1BadgesV4.startRecruitment(badgeId); vm.stopPrank(); // ensure no values got changed/updated assertEq(s1BadgesV4.balanceOf(minters[0]), 1); assertEq(s1BadgesV4.balanceOf(address(s2Badges)), 0); assertEq(s1BadgesV4.ownerOf(tokenId), minters[0]); - assertEq(migration.isMigrationActive(minters[0]), false); + assertEq(recruitment.isRecruitmentActive(minters[0]), false); } function test_revert_pausedContract() public { // have the admin pause the contract // ensure no badges are mintable afterwards vm.startPrank(owner); - migration.pause(); + recruitment.pause(); vm.stopPrank(); mint_s1(minters[0], BADGE_ID); @@ -297,13 +297,13 @@ contract TrailblazersBadgesS2Test is Test { vm.startPrank(minters[0]); vm.expectRevert(); - s1BadgesV4.startMigration(BADGE_ID); + s1BadgesV4.startRecruitment(BADGE_ID); vm.stopPrank(); // ensure no values got changed/updated assertEq(s1BadgesV4.balanceOf(minters[0]), 1); assertEq(s1BadgesV4.balanceOf(address(s2Badges)), 0); assertEq(s1BadgesV4.ownerOf(tokenId), minters[0]); - assertEq(migration.isMigrationActive(minters[0]), false); + assertEq(recruitment.isRecruitmentActive(minters[0]), false); } function test_randomFromSignature() public view { @@ -316,7 +316,7 @@ contract TrailblazersBadgesS2Test is Test { (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, signatureHash); - uint256 random = migration.randomFromSignature(signatureHash, v, r, s); + uint256 random = recruitment.randomFromSignature(signatureHash, v, r, s); assertEq( random, @@ -325,46 +325,46 @@ contract TrailblazersBadgesS2Test is Test { } function test_setConfig() public { - BadgeMigration.Config memory config = BadgeMigration.Config(1 hours, 5 minutes, 5, 3, 1); + BadgeRecruitment.Config memory config = BadgeRecruitment.Config(1 hours, 5 minutes, 5, 3, 1); vm.prank(owner); - migration.setConfig(config); + recruitment.setConfig(config); - BadgeMigration.Config memory newConfig = migration.getConfig(); + BadgeRecruitment.Config memory newConfig = recruitment.getConfig(); - assertEq(newConfig.cooldownMigration, 1 hours); - assertEq(newConfig.cooldownTamper, 5 minutes); - assertEq(newConfig.tamperWeightPercent, 5); - assertEq(newConfig.baseMaxTampers, 3); + assertEq(newConfig.cooldownRecruitment, 1 hours); + assertEq(newConfig.cooldownInfluence, 5 minutes); + assertEq(newConfig.influenceWeightPercent, 5); + assertEq(newConfig.baseMaxInfluences, 3); } function test_setConfig_revert__notOwner() public { - BadgeMigration.Config memory config = BadgeMigration.Config(1 hours, 5 minutes, 5, 3, 1); + BadgeRecruitment.Config memory config = BadgeRecruitment.Config(1 hours, 5 minutes, 5, 3, 1); vm.startPrank(minters[0]); vm.expectRevert(); - migration.setConfig(config); + recruitment.setConfig(config); vm.stopPrank(); } function test_rollCycle() public { - assertEq(migration.getMigrationCycle(), 1); + assertEq(recruitment.getRecruitmentCycle(), 1); - test_endMigration(); + test_endRecruitment(); // close the current cycle vm.startPrank(owner); - migration.pause(); + recruitment.pause(); // launch the next cycle uint256[] memory enabledBadgeIds = new uint256[](1); enabledBadgeIds[0] = BADGE_ID; - migration.enableMigrations(enabledBadgeIds); + recruitment.enableRecruitments(enabledBadgeIds); // check cycle id - assertEq(migration.getMigrationCycle(), 2); + assertEq(recruitment.getRecruitmentCycle(), 2); } - function test_revertTransferAfterMigrationStarts() public { - test_startMigration(); + function test_revertTransferAfterRecruitmentStarts() public { + test_startRecruitment(); assertEq(s1BadgesV4.balanceOf(minters[0]), 1); uint256 tokenId = s1BadgesV4.getTokenId(minters[0], BADGE_ID); vm.prank(minters[0]); @@ -372,44 +372,44 @@ contract TrailblazersBadgesS2Test is Test { s1BadgesV4.transferFrom(minters[0], minters[1], tokenId); } - function test_startMigration_expBased() public { + function test_startRecruitment_expBased() public { mint_s1(minters[0], BADGE_ID); uint256 points = 100; - bytes32 _hash = migration.generateClaimHash(minters[0], points); + bytes32 _hash = recruitment.generateClaimHash(minters[0], points); (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); vm.prank(minters[0]); - migration.startMigration(_hash, v, r, s, points); + recruitment.startRecruitment(_hash, v, r, s, points); assertEq(s1BadgesV4.balanceOf(minters[0]), 1); - assertEq(migration.isMigrationActive(minters[0]), true); + assertEq(recruitment.isRecruitmentActive(minters[0]), true); } - function test_startMigration_expBased_revert_hashMismatch() public { + function test_startRecruitment_expBased_revert_hashMismatch() public { mint_s1(minters[0], BADGE_ID); uint256 points = 100; - bytes32 _hash = migration.generateClaimHash(minters[0], points); + bytes32 _hash = recruitment.generateClaimHash(minters[0], points); (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); vm.prank(minters[0]); - vm.expectRevert(BadgeMigration.HASH_MISMATCH.selector); - migration.startMigration(_hash, v, s, r, points + 1); + vm.expectRevert(BadgeRecruitment.HASH_MISMATCH.selector); + recruitment.startRecruitment(_hash, v, s, r, points + 1); } - function test_startMigration_expBased_revert_notRandomSigner() public { + function test_startRecruitment_expBased_revert_notRandomSigner() public { mint_s1(minters[0], BADGE_ID); uint256 points = 100; - bytes32 _hash = migration.generateClaimHash(minters[0], points); + bytes32 _hash = recruitment.generateClaimHash(minters[0], points); (, uint256 badSignerPk) = makeAddrAndKey("badSigner"); (uint8 v, bytes32 r, bytes32 s) = vm.sign(badSignerPk, _hash); vm.prank(minters[0]); - vm.expectRevert(BadgeMigration.NOT_RANDOM_SIGNER.selector); - migration.startMigration(_hash, v, r, s, points); + vm.expectRevert(BadgeRecruitment.NOT_RANDOM_SIGNER.selector); + recruitment.startRecruitment(_hash, v, r, s, points); } } From bb1f34adf5f0f67dac11ada935461c12d99fa6d7 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 4 Nov 2024 13:13:58 +0100 Subject: [PATCH 66/79] cleanup --- .../BadgeRecruitment.sol | 66 +++++++-------- .../TrailblazersS1BadgesV4.sol | 4 +- .../trailblazers-season-2/hekla.json | 6 +- .../script/trailblazers-season-2/Deploy.s.sol | 26 +++--- .../BadgeRecruitment.t.sol | 81 +++++++++---------- 5 files changed, 87 insertions(+), 96 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol index bfb94c0216f..529291979f9 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol @@ -66,7 +66,7 @@ contract BadgeRecruitment is uint256 cooldownInfluence; uint256 influenceWeightPercent; uint256 baseMaxInfluences; - uint256 pointsClaimMultiplicationFactor; + uint256 maxInfluencesDivider; } /// @notice Current config @@ -91,22 +91,24 @@ contract BadgeRecruitment is uint256[43] private __gap; /// @notice Errors - error MAX_TAMPERS_REACHED(); - error MIGRATION_NOT_STARTED(); - error MIGRATION_ALREADY_STARTED(); - error TAMPER_IN_PROGRESS(); - error MIGRATION_NOT_READY(); - error MIGRATION_NOT_ENABLED(); + error MAX_INFLUENCES_REACHED(); + error RECRUITMENT_NOT_STARTED(); + error RECRUITMENT_ALREADY_STARTED(); + error INFLUENCE_IN_PROGRESS(); + error RECRUITMENT_NOT_READY(); + error RECRUITMENT_NOT_ENABLED(); error TOKEN_NOT_OWNED(); error NOT_RANDOM_SIGNER(); error ALREADY_MIGRATED_IN_CYCLE(); error HASH_MISMATCH(); error NOT_S1_CONTRACT(); error EXP_TOO_LOW(); - error INVALID_TAMPER_COLOR(); + error INVALID_INFLUENCE_COLOR(); /// @notice Events - event RecruitmentCycleToggled(uint256 indexed recruitmentCycleId, uint256 s1BadgeId, bool enabled); + event RecruitmentCycleToggled( + uint256 indexed recruitmentCycleId, uint256 s1BadgeId, bool enabled + ); event RecruitmentUpdated( uint256 indexed recruitmentCycle, @@ -132,7 +134,7 @@ contract BadgeRecruitment is modifier isMigrating() { Recruitment memory recruitment_ = getActiveRecruitmentFor(_msgSender()); if (recruitment_.cooldownExpiration == 0) { - revert MIGRATION_NOT_STARTED(); + revert RECRUITMENT_NOT_STARTED(); } _; } @@ -141,9 +143,10 @@ contract BadgeRecruitment is modifier isNotMigrating(address _user) { if ( recruitments[_user].length > 0 - && recruitments[_user][recruitments[_user].length - 1].cooldownExpiration > block.timestamp + && recruitments[_user][recruitments[_user].length - 1].cooldownExpiration + > block.timestamp ) { - revert MIGRATION_ALREADY_STARTED(); + revert RECRUITMENT_ALREADY_STARTED(); } _; } @@ -152,7 +155,7 @@ contract BadgeRecruitment is /// @param _s1BadgeId The badge ID modifier recruitmentOpen(uint256 _s1BadgeId) { if (!enabledBadgeIds[recruitmentCycle][_s1BadgeId]) { - revert MIGRATION_NOT_ENABLED(); + revert RECRUITMENT_NOT_ENABLED(); } _; } @@ -205,7 +208,8 @@ contract BadgeRecruitment is } /// @notice Disable all new recruitments - /// @dev Doesn't allow for new recruitment attempts, but influences and active recruitments still run + /// @dev Doesn't allow for new recruitment attempts, but influences and active recruitments + /// still run function _disableRecruitments() internal onlyRole(DEFAULT_ADMIN_ROLE) { for (uint256 i = 0; i < 8; i++) { if (enabledBadgeIds[recruitmentCycle][i]) { @@ -320,8 +324,8 @@ contract BadgeRecruitment is userExperience[_msgSender()] = _exp; uint256 randomSeed_ = randomFromSignature(_hash, _v, _r, _s); - uint256 s1BadgeId_ = - currentCycleEnabledRecruitmentIds[randomSeed_ % currentCycleEnabledRecruitmentIds.length]; + uint256 s1BadgeId_ = currentCycleEnabledRecruitmentIds[randomSeed_ + % currentCycleEnabledRecruitmentIds.length]; if (recruitmentCycleUniqueMints[recruitmentCycle][_msgSender()][s1BadgeId_]) { revert ALREADY_MIGRATED_IN_CYCLE(); @@ -360,7 +364,7 @@ contract BadgeRecruitment is /// @return The active recruitment function getActiveRecruitmentFor(address _user) public view returns (Recruitment memory) { if (recruitments[_user].length == 0) { - revert MIGRATION_NOT_STARTED(); + revert RECRUITMENT_NOT_STARTED(); } return recruitments[_user][recruitments[_user].length - 1]; } @@ -386,7 +390,7 @@ contract BadgeRecruitment is /// @notice Get the maximum number of influences for a given experience /// @param _exp The user's experience points function maxInfluences(uint256 _exp) public view virtual returns (uint256 value) { - value = _exp / 100; + value = _exp / config.maxInfluencesDivider; value += 2 * config.baseMaxInfluences; return value; } @@ -416,19 +420,22 @@ contract BadgeRecruitment is Recruitment memory recruitment_ = getActiveRecruitmentFor(_msgSender()); if ((recruitment_.whaleInfluences + recruitment_.minnowInfluences) > maxInfluences(exp)) { - revert MAX_TAMPERS_REACHED(); + revert MAX_INFLUENCES_REACHED(); } if (recruitment_.influenceExpiration > block.timestamp) { - revert TAMPER_IN_PROGRESS(); + revert INFLUENCE_IN_PROGRESS(); } + // apply the influence, and reset the other if (_influenceColor == InfluenceColor.Whale) { recruitment_.whaleInfluences++; + recruitment_.minnowInfluences = 0; } else if (_influenceColor == InfluenceColor.Minnow) { recruitment_.minnowInfluences++; + recruitment_.whaleInfluences = 0; } else { - revert INVALID_TAMPER_COLOR(); + revert INVALID_INFLUENCE_COLOR(); } recruitment_.influenceExpiration = block.timestamp + config.cooldownInfluence; @@ -436,17 +443,6 @@ contract BadgeRecruitment is _updateRecruitment(recruitment_); } - /// @notice Reset the influence counts - /// @dev Can be called only during an active recruitment - function resetInfluences() external isMigrating { - Recruitment memory recruitment_ = getActiveRecruitmentFor(_msgSender()); - recruitment_.whaleInfluences = 0; - recruitment_.minnowInfluences = 0; - recruitment_.influenceExpiration = 0; - - _updateRecruitment(recruitment_); - } - /// @notice End a recruitment /// @param _hash The hash to sign /// @param _v signature V field @@ -468,11 +464,11 @@ contract BadgeRecruitment is Recruitment memory recruitment_ = getActiveRecruitmentFor(_msgSender()); if (recruitment_.influenceExpiration > block.timestamp) { - revert TAMPER_IN_PROGRESS(); + revert INFLUENCE_IN_PROGRESS(); } // check if the cooldown is over if (recruitment_.cooldownExpiration > block.timestamp) { - revert MIGRATION_NOT_READY(); + revert RECRUITMENT_NOT_READY(); } // ensure the hash corresponds to the start time bytes32 calculatedHash_ = generateClaimHash(_msgSender(), _exp); @@ -576,7 +572,7 @@ contract BadgeRecruitment is returns (uint256 _whaleInfluences, uint256 _minnowInfluences) { if (!isRecruitmentActive(_user)) { - revert MIGRATION_NOT_STARTED(); + revert RECRUITMENT_NOT_STARTED(); } Recruitment memory recruitment_ = getActiveRecruitmentFor(_user); return (recruitment_.whaleInfluences, recruitment_.minnowInfluences); diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol index 7103f110ba7..c272a552667 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol @@ -14,7 +14,7 @@ contract TrailblazersBadgesV4 is TrailblazersBadgesV3 { /// @notice Errors error BADGE_LOCKED(); - error MIGRATION_LOCK_DURATION_NOT_SET(); + error RECRUITMENT_LOCK_DURATION_NOT_SET(); /// @notice Updated version function /// @return Version string @@ -61,7 +61,7 @@ contract TrailblazersBadgesV4 is TrailblazersBadgesV3 { /// @param _badgeId Badge id function startRecruitment(uint256 _badgeId) public { if (recruitmentLockDuration == 0) { - revert MIGRATION_LOCK_DURATION_NOT_SET(); + revert RECRUITMENT_LOCK_DURATION_NOT_SET(); } uint256 tokenId = getTokenId(_msgSender(), _badgeId); unlockTimestamps[tokenId] = block.timestamp + recruitmentLockDuration; diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index 6b9fe476e90..512c5036c44 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,6 +1,6 @@ { - "BadgeRecruitment": "0x6cb02e9b2bDfb62fA766A5D6efF42BCDBC931E4B", + "BadgeRecruitment": "0x1BE5a1C0Ba277D5e3485f51a1107aBcaCC96B086", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x5ebFC0Cb18C96f6Ff230F7F0E5b6887076570023", - "TrailblazersBadgesS2": "0x96Cb23f90632A8d767de8C79c2eA92b7F5251cd8" + "TrailblazersBadges": "0xC249C4c54DD42a3d22d38426d69cD3ba41e9549F", + "TrailblazersBadgesS2": "0x9519173A3E718C61e93C587ae7136455CC6FD69e" } diff --git a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol index f39bc288d3d..e6db2b59eec 100644 --- a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol @@ -21,14 +21,14 @@ contract DeployS2Script is Script { BadgeRecruitment recruitment; - bool constant PINK_TAMPER = true; - bool constant PURPLE_TAMPER = false; - - uint256 public MAX_TAMPERS = 3; - uint256 public COOLDOWN_MIGRATION = 10 minutes; - uint256 public COOLDOWN_TAMPER = 2 minutes; - uint256 public TAMPER_WEIGHT_PERCENT = 5; - uint256 public POINTS_CLAIM_MULTIPLICATION_FACTOR = 10; // 10% + bool constant PINK_INFLUENCE = true; + bool constant PURPLE_INFLUENCE = false; + + uint256 public MAX_INFLUENCES = 3; + uint256 public COOLDOWN_RECRUITMENT = 10 minutes; + uint256 public COOLDOWN_INFLUENCE = 2 minutes; + uint256 public INFLUENCE_WEIGHT_PERCENT = 5; + uint256 public MAX_INFLUENCES_DIVIDER = 100; uint256 public S1_LOCK_DURATION = 365 days; // Taiko Mainnet Values //address owner = 0xf8ff2AF0DC1D5BA4811f22aCb02936A1529fd2Be; @@ -116,11 +116,11 @@ contract DeployS2Script is Script { // deploy the recruitment contract BadgeRecruitment.Config memory config = BadgeRecruitment.Config( - COOLDOWN_MIGRATION, - COOLDOWN_TAMPER, - TAMPER_WEIGHT_PERCENT, - MAX_TAMPERS, - POINTS_CLAIM_MULTIPLICATION_FACTOR + COOLDOWN_RECRUITMENT, + COOLDOWN_INFLUENCE, + INFLUENCE_WEIGHT_PERCENT, + MAX_INFLUENCES, + MAX_INFLUENCES_DIVIDER ); impl = address(new BadgeRecruitment()); diff --git a/packages/nfts/test/trailblazers-season-2/BadgeRecruitment.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeRecruitment.t.sol index c94c57e8ca2..9e4b38f624b 100644 --- a/packages/nfts/test/trailblazers-season-2/BadgeRecruitment.t.sol +++ b/packages/nfts/test/trailblazers-season-2/BadgeRecruitment.t.sol @@ -33,11 +33,11 @@ contract TrailblazersBadgesS2Test is Test { address mintSigner; uint256 mintSignerPk; - uint256 public MAX_TAMPERS = 3; - uint256 public COOLDOWN_MIGRATION = 1 hours; - uint256 public COOLDOWN_TAMPER = 5 minutes; - uint256 public TAMPER_WEIGHT_PERCENT = 5; - uint256 public POINTS_CLAIM_MULTIPLICATION_FACTOR = 10; // 10% + uint256 public MAX_INFLUENCES = 3; + uint256 public COOLDOWN_RECRUITMENT = 1 hours; + uint256 public COOLDOWN_INFLUENCE = 5 minutes; + uint256 public INFLUENCE_WEIGHT_PERCENT = 5; + uint256 public MAX_INFLUENCES_DIVIDER = 100; BadgeRecruitment public recruitment; @@ -96,11 +96,11 @@ contract TrailblazersBadgesS2Test is Test { // deploy the recruitment contract BadgeRecruitment.Config memory config = BadgeRecruitment.Config( - COOLDOWN_MIGRATION, - COOLDOWN_TAMPER, - TAMPER_WEIGHT_PERCENT, - MAX_TAMPERS, - POINTS_CLAIM_MULTIPLICATION_FACTOR + COOLDOWN_RECRUITMENT, + COOLDOWN_INFLUENCE, + INFLUENCE_WEIGHT_PERCENT, + MAX_INFLUENCES, + MAX_INFLUENCES_DIVIDER ); impl = address(new BadgeRecruitment()); @@ -178,26 +178,34 @@ contract TrailblazersBadgesS2Test is Test { (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); - for (uint256 i = 0; i < MAX_TAMPERS; i++) { - wait(COOLDOWN_TAMPER); - recruitment.influenceRecruitment(_hash, v, r, s, points, BadgeRecruitment.InfluenceColor.Whale); - } + wait(COOLDOWN_INFLUENCE); - wait(COOLDOWN_TAMPER); - recruitment.influenceRecruitment(_hash, v, r, s, points, BadgeRecruitment.InfluenceColor.Minnow); - wait(COOLDOWN_TAMPER); + recruitment.influenceRecruitment( + _hash, v, r, s, points, BadgeRecruitment.InfluenceColor.Minnow + ); + wait(COOLDOWN_INFLUENCE); - recruitment.influenceRecruitment(_hash, v, r, s, points, BadgeRecruitment.InfluenceColor.Minnow); + recruitment.influenceRecruitment( + _hash, v, r, s, points, BadgeRecruitment.InfluenceColor.Minnow + ); + + for (uint256 i = 0; i < MAX_INFLUENCES; i++) { + wait(COOLDOWN_INFLUENCE); + recruitment.influenceRecruitment( + _hash, v, r, s, points, BadgeRecruitment.InfluenceColor.Whale + ); + } vm.stopPrank(); assertEq(recruitment.isInfluenceActive(minters[0]), true); assertEq(recruitment.isRecruitmentActive(minters[0]), true); - (uint256 whaleInfluences, uint256 minnowInfluences) = recruitment.getRecruitmentInfluences(minters[0]); + (uint256 whaleInfluences, uint256 minnowInfluences) = + recruitment.getRecruitmentInfluences(minters[0]); - assertEq(whaleInfluences, MAX_TAMPERS); - assertEq(minnowInfluences, 2); + assertEq(whaleInfluences, MAX_INFLUENCES); + assertEq(minnowInfluences, 0); } function test_revert_tooManyInfluences() public { @@ -209,33 +217,18 @@ contract TrailblazersBadgesS2Test is Test { test_influenceRecruitment(); vm.startPrank(minters[0]); vm.expectRevert(); - recruitment.influenceRecruitment(_hash, v, r, s, points, BadgeRecruitment.InfluenceColor.Whale); + recruitment.influenceRecruitment( + _hash, v, r, s, points, BadgeRecruitment.InfluenceColor.Whale + ); vm.stopPrank(); } - function test_resetInfluences() public { - test_influenceRecruitment(); - assertEq(recruitment.isInfluenceActive(minters[0]), true); - (uint256 whaleInfluences, uint256 minnowInfluences) = recruitment.getRecruitmentInfluences(minters[0]); - - assertEq(whaleInfluences, MAX_TAMPERS); - assertEq(minnowInfluences, 2); - - vm.prank(minters[0]); - recruitment.resetInfluences(); - - assertEq(recruitment.isInfluenceActive(minters[0]), false); - (whaleInfluences, minnowInfluences) = recruitment.getRecruitmentInfluences(minters[0]); - assertEq(whaleInfluences, 0); - assertEq(minnowInfluences, 0); - } - function test_endRecruitment() public { test_influenceRecruitment(); - wait(COOLDOWN_TAMPER); - wait(COOLDOWN_MIGRATION); + wait(COOLDOWN_INFLUENCE); + wait(COOLDOWN_RECRUITMENT); // generate the claim hash for the current recruitment bytes32 claimHash = recruitment.generateClaimHash( @@ -325,7 +318,8 @@ contract TrailblazersBadgesS2Test is Test { } function test_setConfig() public { - BadgeRecruitment.Config memory config = BadgeRecruitment.Config(1 hours, 5 minutes, 5, 3, 1); + BadgeRecruitment.Config memory config = + BadgeRecruitment.Config(1 hours, 5 minutes, 5, 3, 100); vm.prank(owner); recruitment.setConfig(config); @@ -338,7 +332,8 @@ contract TrailblazersBadgesS2Test is Test { } function test_setConfig_revert__notOwner() public { - BadgeRecruitment.Config memory config = BadgeRecruitment.Config(1 hours, 5 minutes, 5, 3, 1); + BadgeRecruitment.Config memory config = + BadgeRecruitment.Config(1 hours, 5 minutes, 5, 3, 100); vm.startPrank(minters[0]); vm.expectRevert(); From d383eea0e5abd19058d9699d11a4c23ab20c0ad9 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 4 Nov 2024 13:18:30 +0100 Subject: [PATCH 67/79] hekla deployment --- packages/nfts/deployments/trailblazers-season-2/hekla.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index 512c5036c44..526a76fb491 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,6 +1,6 @@ { - "BadgeRecruitment": "0x1BE5a1C0Ba277D5e3485f51a1107aBcaCC96B086", + "BadgeRecruitment": "0x0FA969eF8378853E96556f6a1140B51DCF9Dfb2c", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0xC249C4c54DD42a3d22d38426d69cD3ba41e9549F", - "TrailblazersBadgesS2": "0x9519173A3E718C61e93C587ae7136455CC6FD69e" + "TrailblazersBadges": "0x0a324CBb894c298F09657c7A3D49cBC9346595e6", + "TrailblazersBadgesS2": "0x1D95C1C60F71032add67c04ab9228b634a4F442F" } From f889c2ab3352ffd25c11d885973852648400e52e Mon Sep 17 00:00:00 2001 From: bearni95 Date: Wed, 6 Nov 2024 13:05:40 +0100 Subject: [PATCH 68/79] recruitment type and hash split --- .../BadgeRecruitment.sol | 128 +++++++++++++++--- .../trailblazers-season-2/hekla.json | 6 +- .../BadgeRecruitment.t.sol | 16 ++- 3 files changed, 120 insertions(+), 30 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol index 529291979f9..9ba678ee318 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol @@ -47,7 +47,13 @@ contract BadgeRecruitment is /// @notice Mapping of unique user-per-mint-per-cycle mapping( uint256 recruitmentCycle - => mapping(address minter => mapping(uint256 s1BadgeId => bool mintEnded)) + => mapping( + address minter + => mapping( + uint256 s1BadgeId + => mapping(RecruitmentType recruitmentType => bool mintEnded) + ) + ) ) public recruitmentCycleUniqueMints; /// @notice User experience points mapping(address user => uint256 experience) public userExperience; @@ -60,6 +66,20 @@ contract BadgeRecruitment is } + /// @notice Recruitment types + enum RecruitmentType { + Undefined, + Claim, + Migration + } + /// @notice Hash types + enum HashType { + Undefined, + Start, + End, + Influence + } + /// @notice Configuration struct struct Config { uint256 cooldownRecruitment; @@ -163,9 +183,14 @@ contract BadgeRecruitment is /// @notice Limits recruitments to one per user, badge and cycle /// @param _s1BadgeId The badge ID /// @param _minter The minter address - modifier hasntMigratedInCycle(uint256 _s1BadgeId, address _minter) { + /// @param _recruitmentType The recruitment type + modifier hasntMigratedInCycle( + uint256 _s1BadgeId, + address _minter, + RecruitmentType _recruitmentType + ) { // check that the minter hasn't used the recruitment within this cycle - if (recruitmentCycleUniqueMints[recruitmentCycle][_minter][_s1BadgeId]) { + if (recruitmentCycleUniqueMints[recruitmentCycle][_minter][_s1BadgeId][_recruitmentType]) { revert ALREADY_MIGRATED_IN_CYCLE(); } _; @@ -253,10 +278,12 @@ contract BadgeRecruitment is /// @param _user The user address /// @param _s1BadgeId The badge ID /// @param _s1TokenId The badge token ID + /// @param _recruitmentType The recruitment type function _startRecruitment( address _user, uint256 _s1BadgeId, - uint256 _s1TokenId + uint256 _s1TokenId, + RecruitmentType _recruitmentType ) internal virtual @@ -274,7 +301,7 @@ contract BadgeRecruitment is ); recruitments[_user].push(_recruitment); - recruitmentCycleUniqueMints[recruitmentCycle][_user][_s1BadgeId] = true; + recruitmentCycleUniqueMints[recruitmentCycle][_user][_s1BadgeId][_recruitmentType] = true; emit RecruitmentUpdated( _recruitment.recruitmentCycle, @@ -306,7 +333,7 @@ contract BadgeRecruitment is virtual isNotMigrating(_msgSender()) { - bytes32 calculatedHash_ = generateClaimHash(_msgSender(), _exp); + bytes32 calculatedHash_ = generateClaimHash(HashType.Start, _msgSender(), _exp); if (calculatedHash_ != _hash) { revert HASH_MISMATCH(); @@ -327,11 +354,54 @@ contract BadgeRecruitment is uint256 s1BadgeId_ = currentCycleEnabledRecruitmentIds[randomSeed_ % currentCycleEnabledRecruitmentIds.length]; - if (recruitmentCycleUniqueMints[recruitmentCycle][_msgSender()][s1BadgeId_]) { + if ( + recruitmentCycleUniqueMints[recruitmentCycle][_msgSender()][s1BadgeId_][RecruitmentType + .Claim] + ) { revert ALREADY_MIGRATED_IN_CYCLE(); } - _startRecruitment(_msgSender(), (randomSeed_ % 8), 0); + _startRecruitment(_msgSender(), s1BadgeId_, 0, RecruitmentType.Claim); + } + + /// @notice Start a recruitment for a badge using the user's experience points + /// @param _hash The hash to sign of the signature + /// @param _v The signature V field + /// @param _r The signature R field + /// @param _s The signature S field + /// @param _exp The user's experience points + /// @param _s1BadgeId The badge ID (s1) + function startRecruitment( + bytes32 _hash, + uint8 _v, + bytes32 _r, + bytes32 _s, + uint256 _exp, + uint256 _s1BadgeId + ) + external + virtual + isNotMigrating(_msgSender()) + hasntMigratedInCycle(_s1BadgeId, _msgSender(), RecruitmentType.Claim) + { + bytes32 calculatedHash_ = generateClaimHash(HashType.Start, _msgSender(), _exp); + + if (calculatedHash_ != _hash) { + revert HASH_MISMATCH(); + } + + (address recovered_,,) = ECDSA.tryRecover(_hash, _v, _r, _s); + if (recovered_ != randomSigner) { + revert NOT_RANDOM_SIGNER(); + } + + if (_exp < userExperience[_msgSender()]) { + revert EXP_TOO_LOW(); + } + + userExperience[_msgSender()] = _exp; + + _startRecruitment(_msgSender(), _s1BadgeId, 0, RecruitmentType.Claim); } /// @notice Start a recruitment for a badge @@ -349,14 +419,14 @@ contract BadgeRecruitment is onlyRole(S1_BADGES_ROLE) recruitmentOpen(_s1BadgeId) isNotMigrating(_user) - hasntMigratedInCycle(_s1BadgeId, _user) + hasntMigratedInCycle(_s1BadgeId, _user, RecruitmentType.Migration) { uint256 s1TokenId_ = s1Badges.getTokenId(_user, _s1BadgeId); if (s1Badges.ownerOf(s1TokenId_) != _user) { revert TOKEN_NOT_OWNED(); } - _startRecruitment(_user, _s1BadgeId, s1TokenId_); + _startRecruitment(_user, _s1BadgeId, s1TokenId_, RecruitmentType.Migration); } /// @notice Get the active recruitment for a user @@ -397,29 +467,35 @@ contract BadgeRecruitment is /// @notice Influence (alter) the chances during a recruitment /// @param _hash The hash to sign - /// @param v signature V field - /// @param r signature R field - /// @param s signature S field + /// @param _v signature V field + /// @param _r signature R field + /// @param _s signature S field /// @param _influenceColor the influence's color /// @dev Can be called only during an active recruitment /// @dev Implements a cooldown before allowing to re-influence /// @dev The max influence amount is determined by Pass Tier function influenceRecruitment( bytes32 _hash, - uint8 v, - bytes32 r, - bytes32 s, - uint256 exp, + uint8 _v, + bytes32 _r, + bytes32 _s, + uint256 _exp, InfluenceColor _influenceColor ) external isMigrating { - (address recovered_,,) = ECDSA.tryRecover(_hash, v, r, s); + bytes32 calculatedHash_ = generateClaimHash(HashType.Influence, _msgSender(), _exp); + + if (calculatedHash_ != _hash) { + revert HASH_MISMATCH(); + } + + (address recovered_,,) = ECDSA.tryRecover(_hash, _v, _r, _s); if (recovered_ != randomSigner) revert NOT_RANDOM_SIGNER(); Recruitment memory recruitment_ = getActiveRecruitmentFor(_msgSender()); - if ((recruitment_.whaleInfluences + recruitment_.minnowInfluences) > maxInfluences(exp)) { + if ((recruitment_.whaleInfluences + recruitment_.minnowInfluences) > maxInfluences(_exp)) { revert MAX_INFLUENCES_REACHED(); } @@ -471,7 +547,7 @@ contract BadgeRecruitment is revert RECRUITMENT_NOT_READY(); } // ensure the hash corresponds to the start time - bytes32 calculatedHash_ = generateClaimHash(_msgSender(), _exp); + bytes32 calculatedHash_ = generateClaimHash(HashType.End, _msgSender(), _exp); if (calculatedHash_ != _hash) { revert HASH_MISMATCH(); @@ -518,8 +594,16 @@ contract BadgeRecruitment is /// @param _user The user address /// @param _exp The users experience points /// @return _hash The unique hash - function generateClaimHash(address _user, uint256 _exp) public pure returns (bytes32) { - return keccak256(abi.encodePacked(_user, _exp)); + function generateClaimHash( + HashType _hashType, + address _user, + uint256 _exp + ) + public + pure + returns (bytes32) + { + return keccak256(abi.encodePacked(_hashType, _user, _exp)); } /// @notice Check if a recruitment is active for a user diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index 526a76fb491..05db062878f 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,6 +1,6 @@ { - "BadgeRecruitment": "0x0FA969eF8378853E96556f6a1140B51DCF9Dfb2c", + "BadgeRecruitment": "0x66a35cFc2D19387FAd839d961a2e1a9229e28FAa", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x0a324CBb894c298F09657c7A3D49cBC9346595e6", - "TrailblazersBadgesS2": "0x1D95C1C60F71032add67c04ab9228b634a4F442F" + "TrailblazersBadges": "0x2aacc380084A0AAbb0D64DBf970EBE4aAE6f340a", + "TrailblazersBadgesS2": "0xEF3Adf8FA8AFc11B8031ABaeB77c88587750680E" } diff --git a/packages/nfts/test/trailblazers-season-2/BadgeRecruitment.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeRecruitment.t.sol index 9e4b38f624b..14ad076b125 100644 --- a/packages/nfts/test/trailblazers-season-2/BadgeRecruitment.t.sol +++ b/packages/nfts/test/trailblazers-season-2/BadgeRecruitment.t.sol @@ -174,7 +174,8 @@ contract TrailblazersBadgesS2Test is Test { vm.startPrank(minters[0]); uint256 points = 0; - bytes32 _hash = recruitment.generateClaimHash(minters[0], points); + bytes32 _hash = + recruitment.generateClaimHash(BadgeRecruitment.HashType.Influence, minters[0], points); (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); @@ -210,7 +211,8 @@ contract TrailblazersBadgesS2Test is Test { function test_revert_tooManyInfluences() public { uint256 points = 0; - bytes32 _hash = recruitment.generateClaimHash(minters[0], points); + bytes32 _hash = + recruitment.generateClaimHash(BadgeRecruitment.HashType.Influence, minters[0], points); (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); @@ -232,6 +234,7 @@ contract TrailblazersBadgesS2Test is Test { // generate the claim hash for the current recruitment bytes32 claimHash = recruitment.generateClaimHash( + BadgeRecruitment.HashType.End, minters[0], 0 // experience points ); @@ -371,7 +374,8 @@ contract TrailblazersBadgesS2Test is Test { mint_s1(minters[0], BADGE_ID); uint256 points = 100; - bytes32 _hash = recruitment.generateClaimHash(minters[0], points); + bytes32 _hash = + recruitment.generateClaimHash(BadgeRecruitment.HashType.Start, minters[0], points); (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); @@ -386,7 +390,8 @@ contract TrailblazersBadgesS2Test is Test { mint_s1(minters[0], BADGE_ID); uint256 points = 100; - bytes32 _hash = recruitment.generateClaimHash(minters[0], points); + bytes32 _hash = + recruitment.generateClaimHash(BadgeRecruitment.HashType.Start, minters[0], points); (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, _hash); @@ -399,7 +404,8 @@ contract TrailblazersBadgesS2Test is Test { mint_s1(minters[0], BADGE_ID); uint256 points = 100; - bytes32 _hash = recruitment.generateClaimHash(minters[0], points); + bytes32 _hash = + recruitment.generateClaimHash(BadgeRecruitment.HashType.Start, minters[0], points); (, uint256 badSignerPk) = makeAddrAndKey("badSigner"); (uint8 v, bytes32 r, bytes32 s) = vm.sign(badSignerPk, _hash); From 88c6d599482473e6615dad075984bcd1c1c577ef Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 14 Nov 2024 12:41:49 +0100 Subject: [PATCH 69/79] updated hekla deployment --- .../BadgeRecruitment.sol | 152 +++++++++++++----- .../trailblazers-season-2/hekla.json | 6 +- .../script/trailblazers-season-2/Deploy.s.sol | 4 +- .../BadgeRecruitment.t.sol | 145 +++++++++++++---- 4 files changed, 230 insertions(+), 77 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol index 9ba678ee318..4c6200205b9 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol @@ -11,7 +11,6 @@ import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; -import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; @@ -25,7 +24,6 @@ import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "./TrailblazersBadgesS2.sol"; contract BadgeRecruitment is - PausableUpgradeable, UUPSUpgradeable, Ownable2StepUpgradeable, AccessControlUpgradeable, @@ -40,10 +38,11 @@ contract BadgeRecruitment is /// @notice Wallet authorized to sign as a source of randomness address public randomSigner; /// @notice Recruitment-enabled badge IDs per cycle - mapping(uint256 cycle => mapping(uint256 s1BadgeId => bool enabled)) public enabledBadgeIds; - uint256[] public currentCycleEnabledRecruitmentIds; + //mapping(uint256 cycle => mapping(uint256 s1BadgeId => bool enabled)) public enabledBadgeIds; + // uint256[] public currentCycleEnabledRecruitmentIds; /// @notice Current recruitment cycle - uint256 private recruitmentCycle; + uint256 public recruitmentCycleId; + /// @notice Mapping of unique user-per-mint-per-cycle mapping( uint256 recruitmentCycle @@ -56,6 +55,7 @@ contract BadgeRecruitment is ) ) public recruitmentCycleUniqueMints; /// @notice User experience points + mapping(address user => uint256 experience) public userExperience; /// @notice Influence colors available @@ -87,6 +87,7 @@ contract BadgeRecruitment is uint256 influenceWeightPercent; uint256 baseMaxInfluences; uint256 maxInfluencesDivider; + uint256 defaultCycleDuration; } /// @notice Current config @@ -104,6 +105,18 @@ contract BadgeRecruitment is uint256 whaleInfluences; uint256 minnowInfluences; } + /// @notice Recruitment Cycle struct + + struct RecruitmentCycle { + uint256 cycleId; + uint256 startTime; + uint256 endTime; + uint256[] s1BadgeIds; + } + + /// @notice Recruitment cycles + mapping(uint256 cycleId => RecruitmentCycle recruitmentCycle) public recruitmentCycles; + /// @notice Recruitments per user mapping(address _user => Recruitment[] _recruitment) public recruitments; @@ -124,10 +137,15 @@ contract BadgeRecruitment is error NOT_S1_CONTRACT(); error EXP_TOO_LOW(); error INVALID_INFLUENCE_COLOR(); + error CURRENT_CYCLE_NOT_OVER(); /// @notice Events event RecruitmentCycleToggled( - uint256 indexed recruitmentCycleId, uint256 s1BadgeId, bool enabled + uint256 indexed recruitmentCycleId, + uint256 indexed startTime, + uint256 indexed endTime, + uint256[] s1BadgeIds, + bool enabled ); event RecruitmentUpdated( @@ -174,7 +192,22 @@ contract BadgeRecruitment is /// @notice Reverts if recruitments aren't enabled for that badge /// @param _s1BadgeId The badge ID modifier recruitmentOpen(uint256 _s1BadgeId) { - if (!enabledBadgeIds[recruitmentCycle][_s1BadgeId]) { + RecruitmentCycle memory cycle_ = recruitmentCycles[recruitmentCycleId]; + + if (cycle_.startTime > block.timestamp || cycle_.endTime < block.timestamp) { + revert RECRUITMENT_NOT_ENABLED(); + } + + bool found_ = false; + + for (uint256 i = 0; i < cycle_.s1BadgeIds.length; i++) { + if (cycle_.s1BadgeIds[i] == _s1BadgeId) { + found_ = true; + break; + } + } + + if (!found_) { revert RECRUITMENT_NOT_ENABLED(); } _; @@ -190,7 +223,8 @@ contract BadgeRecruitment is RecruitmentType _recruitmentType ) { // check that the minter hasn't used the recruitment within this cycle - if (recruitmentCycleUniqueMints[recruitmentCycle][_minter][_s1BadgeId][_recruitmentType]) { + if (recruitmentCycleUniqueMints[recruitmentCycleId][_minter][_s1BadgeId][_recruitmentType]) + { revert ALREADY_MIGRATED_IN_CYCLE(); } _; @@ -232,18 +266,44 @@ contract BadgeRecruitment is return config; } - /// @notice Disable all new recruitments - /// @dev Doesn't allow for new recruitment attempts, but influences and active recruitments - /// still run - function _disableRecruitments() internal onlyRole(DEFAULT_ADMIN_ROLE) { - for (uint256 i = 0; i < 8; i++) { - if (enabledBadgeIds[recruitmentCycle][i]) { - emit RecruitmentCycleToggled(recruitmentCycle, i, false); - } + /// @notice Disable all current recruitments + /// @dev Bypasses the default date checks + function forceDisableRecruitments() internal onlyRole(DEFAULT_ADMIN_ROLE) { + recruitmentCycles[recruitmentCycleId].endTime = block.timestamp; + } - enabledBadgeIds[recruitmentCycle][i] = false; + /// @notice Enable recruitments for a set of badges + /// @param _startTime The start time of the recruitment cycle + /// @param _endTime The end time of the recruitment cycle + /// @param _s1BadgeIds The badge IDs to enable + function _enableRecruitments( + uint256 _startTime, + uint256 _endTime, + uint256[] calldata _s1BadgeIds + ) + internal + { + if ( + recruitmentCycleId > 0 + && recruitmentCycles[recruitmentCycleId].endTime > block.timestamp + ) { + revert CURRENT_CYCLE_NOT_OVER(); } - currentCycleEnabledRecruitmentIds = new uint256[](0); + // emit disabled badges + emit RecruitmentCycleToggled( + recruitmentCycleId, + recruitmentCycles[recruitmentCycleId].startTime, + recruitmentCycles[recruitmentCycleId].endTime, + recruitmentCycles[recruitmentCycleId].s1BadgeIds, + false + ); + + recruitmentCycleId++; + recruitmentCycles[recruitmentCycleId] = + RecruitmentCycle(recruitmentCycleId, _startTime, _endTime, _s1BadgeIds); + + // emit enabled badges + emit RecruitmentCycleToggled(recruitmentCycleId, _startTime, _endTime, _s1BadgeIds, true); } /// @notice Enable recruitments for a set of badges @@ -253,25 +313,35 @@ contract BadgeRecruitment is external onlyRole(DEFAULT_ADMIN_ROLE) { - recruitmentCycle++; - for (uint256 i = 0; i < _s1BadgeIds.length; i++) { - enabledBadgeIds[recruitmentCycle][_s1BadgeIds[i]] = true; - emit RecruitmentCycleToggled(recruitmentCycle, _s1BadgeIds[i], true); - } - currentCycleEnabledRecruitmentIds = _s1BadgeIds; + _enableRecruitments( + block.timestamp, block.timestamp + config.defaultCycleDuration, _s1BadgeIds + ); } - /// @notice Get the current recruitment cycle - /// @return The current recruitment cycle - function getRecruitmentCycle() external view returns (uint256) { - return recruitmentCycle; + /// @notice Enable recruitments for a set of badges + /// @param _startTime The start time of the recruitment cycle + /// @param _endTime The end time of the recruitment cycle + /// @param _s1BadgeIds The badge IDs to enable + /// @dev Can be called only by the contract owner/admin + function enableRecruitments( + uint256 _startTime, + uint256 _endTime, + uint256[] calldata _s1BadgeIds + ) + external + onlyRole(DEFAULT_ADMIN_ROLE) + { + _enableRecruitments(_startTime, _endTime, _s1BadgeIds); } - /// @notice Pause the contract - /// @dev Can be called only by the contract owner/admin - function pause() public onlyRole(DEFAULT_ADMIN_ROLE) { - _disableRecruitments(); - _pause(); + /// @notice Get the current recruitment cycle + /// @return The current recruitment cycle + function getRecruitmentCycle(uint256 _cycleId) + external + view + returns (RecruitmentCycle memory) + { + return recruitmentCycles[_cycleId]; } /// @notice Internal logic to start a recruitment @@ -289,7 +359,7 @@ contract BadgeRecruitment is virtual { Recruitment memory _recruitment = Recruitment( - recruitmentCycle, // recruitmentCycle + recruitmentCycleId, // recruitmentCycle _user, // user _s1BadgeId, _s1TokenId, @@ -301,7 +371,7 @@ contract BadgeRecruitment is ); recruitments[_user].push(_recruitment); - recruitmentCycleUniqueMints[recruitmentCycle][_user][_s1BadgeId][_recruitmentType] = true; + recruitmentCycleUniqueMints[recruitmentCycleId][_user][_s1BadgeId][_recruitmentType] = true; emit RecruitmentUpdated( _recruitment.recruitmentCycle, @@ -350,12 +420,15 @@ contract BadgeRecruitment is userExperience[_msgSender()] = _exp; + RecruitmentCycle memory cycle_ = recruitmentCycles[recruitmentCycleId]; + if (cycle_.startTime > block.timestamp || cycle_.endTime < block.timestamp) { + revert RECRUITMENT_NOT_ENABLED(); + } uint256 randomSeed_ = randomFromSignature(_hash, _v, _r, _s); - uint256 s1BadgeId_ = currentCycleEnabledRecruitmentIds[randomSeed_ - % currentCycleEnabledRecruitmentIds.length]; + uint256 s1BadgeId_ = cycle_.s1BadgeIds[randomSeed_ % cycle_.s1BadgeIds.length]; if ( - recruitmentCycleUniqueMints[recruitmentCycle][_msgSender()][s1BadgeId_][RecruitmentType + recruitmentCycleUniqueMints[recruitmentCycleId][_msgSender()][s1BadgeId_][RecruitmentType .Claim] ) { revert ALREADY_MIGRATED_IN_CYCLE(); @@ -382,9 +455,10 @@ contract BadgeRecruitment is external virtual isNotMigrating(_msgSender()) + recruitmentOpen(_s1BadgeId) hasntMigratedInCycle(_s1BadgeId, _msgSender(), RecruitmentType.Claim) { - bytes32 calculatedHash_ = generateClaimHash(HashType.Start, _msgSender(), _exp); + bytes32 calculatedHash_ = generateClaimHash(HashType.Start, _msgSender(), _s1BadgeId); if (calculatedHash_ != _hash) { revert HASH_MISMATCH(); diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index 05db062878f..16e5139ad87 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,6 +1,6 @@ { - "BadgeRecruitment": "0x66a35cFc2D19387FAd839d961a2e1a9229e28FAa", + "BadgeRecruitment": "0x7a5779ccD0E9a4c6DB4EA594C5e5f782B5b79b24", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x2aacc380084A0AAbb0D64DBf970EBE4aAE6f340a", - "TrailblazersBadgesS2": "0xEF3Adf8FA8AFc11B8031ABaeB77c88587750680E" + "TrailblazersBadges": "0x406f733CF3de0524D5949AA1B0296b29398Aadb3", + "TrailblazersBadgesS2": "0x820E659971790429257Fd41FccD15F9438D9dEAB" } diff --git a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol index e6db2b59eec..f597e402f6d 100644 --- a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol @@ -29,6 +29,7 @@ contract DeployS2Script is Script { uint256 public COOLDOWN_INFLUENCE = 2 minutes; uint256 public INFLUENCE_WEIGHT_PERCENT = 5; uint256 public MAX_INFLUENCES_DIVIDER = 100; + uint256 public DEFAULT_CYCLE_DURATION = 7 days; uint256 public S1_LOCK_DURATION = 365 days; // Taiko Mainnet Values //address owner = 0xf8ff2AF0DC1D5BA4811f22aCb02936A1529fd2Be; @@ -120,7 +121,8 @@ contract DeployS2Script is Script { COOLDOWN_INFLUENCE, INFLUENCE_WEIGHT_PERCENT, MAX_INFLUENCES, - MAX_INFLUENCES_DIVIDER + MAX_INFLUENCES_DIVIDER, + DEFAULT_CYCLE_DURATION ); impl = address(new BadgeRecruitment()); diff --git a/packages/nfts/test/trailblazers-season-2/BadgeRecruitment.t.sol b/packages/nfts/test/trailblazers-season-2/BadgeRecruitment.t.sol index 14ad076b125..45ab1952fcc 100644 --- a/packages/nfts/test/trailblazers-season-2/BadgeRecruitment.t.sol +++ b/packages/nfts/test/trailblazers-season-2/BadgeRecruitment.t.sol @@ -38,6 +38,7 @@ contract TrailblazersBadgesS2Test is Test { uint256 public COOLDOWN_INFLUENCE = 5 minutes; uint256 public INFLUENCE_WEIGHT_PERCENT = 5; uint256 public MAX_INFLUENCES_DIVIDER = 100; + uint256 public DEFAULT_CYCLE_DURATION = 7 days; BadgeRecruitment public recruitment; @@ -100,7 +101,8 @@ contract TrailblazersBadgesS2Test is Test { COOLDOWN_INFLUENCE, INFLUENCE_WEIGHT_PERCENT, MAX_INFLUENCES, - MAX_INFLUENCES_DIVIDER + MAX_INFLUENCES_DIVIDER, + DEFAULT_CYCLE_DURATION ); impl = address(new BadgeRecruitment()); @@ -155,6 +157,7 @@ contract TrailblazersBadgesS2Test is Test { mint_s1(minters[0], BADGE_ID); vm.prank(minters[0]); + wait(100); s1BadgesV4.startRecruitment(BADGE_ID); uint256 tokenId = s1BadgesV4.getTokenId(minters[0], BADGE_ID); @@ -280,28 +283,6 @@ contract TrailblazersBadgesS2Test is Test { assertEq(recruitment.isRecruitmentActive(minters[0]), false); } - function test_revert_pausedContract() public { - // have the admin pause the contract - // ensure no badges are mintable afterwards - vm.startPrank(owner); - recruitment.pause(); - vm.stopPrank(); - - mint_s1(minters[0], BADGE_ID); - - uint256 tokenId = s1BadgesV4.tokenOfOwnerByIndex(minters[0], 0); - - vm.startPrank(minters[0]); - vm.expectRevert(); - s1BadgesV4.startRecruitment(BADGE_ID); - vm.stopPrank(); - // ensure no values got changed/updated - assertEq(s1BadgesV4.balanceOf(minters[0]), 1); - assertEq(s1BadgesV4.balanceOf(address(s2Badges)), 0); - assertEq(s1BadgesV4.ownerOf(tokenId), minters[0]); - assertEq(recruitment.isRecruitmentActive(minters[0]), false); - } - function test_randomFromSignature() public view { bytes32 signatureHash = keccak256( abi.encodePacked( @@ -322,7 +303,7 @@ contract TrailblazersBadgesS2Test is Test { function test_setConfig() public { BadgeRecruitment.Config memory config = - BadgeRecruitment.Config(1 hours, 5 minutes, 5, 3, 100); + BadgeRecruitment.Config(1 hours, 5 minutes, 5, 3, 100, DEFAULT_CYCLE_DURATION); vm.prank(owner); recruitment.setConfig(config); @@ -336,7 +317,7 @@ contract TrailblazersBadgesS2Test is Test { function test_setConfig_revert__notOwner() public { BadgeRecruitment.Config memory config = - BadgeRecruitment.Config(1 hours, 5 minutes, 5, 3, 100); + BadgeRecruitment.Config(1 hours, 5 minutes, 5, 3, 100, DEFAULT_CYCLE_DURATION); vm.startPrank(minters[0]); vm.expectRevert(); @@ -345,20 +326,31 @@ contract TrailblazersBadgesS2Test is Test { } function test_rollCycle() public { - assertEq(recruitment.getRecruitmentCycle(), 1); - + BadgeRecruitment.RecruitmentCycle memory cycle = + recruitment.getRecruitmentCycle(recruitment.recruitmentCycleId()); + assertEq(cycle.cycleId, 1); + assertEq(cycle.startTime, block.timestamp); + assertEq(cycle.endTime, block.timestamp + DEFAULT_CYCLE_DURATION); + assertEq(cycle.s1BadgeIds.length, 1); + assertEq(cycle.s1BadgeIds[0], BADGE_ID); test_endRecruitment(); // close the current cycle vm.startPrank(owner); - recruitment.pause(); + //recruitment.endRecruitment(); + wait(DEFAULT_CYCLE_DURATION + 1); // launch the next cycle uint256[] memory enabledBadgeIds = new uint256[](1); - enabledBadgeIds[0] = BADGE_ID; + enabledBadgeIds[0] = 2; recruitment.enableRecruitments(enabledBadgeIds); - // check cycle id - assertEq(recruitment.getRecruitmentCycle(), 2); + // check cycle roll forward + cycle = recruitment.getRecruitmentCycle(recruitment.recruitmentCycleId()); + assertEq(cycle.cycleId, 2); + assertEq(cycle.startTime, block.timestamp); + assertEq(cycle.endTime, block.timestamp + DEFAULT_CYCLE_DURATION); + assertEq(cycle.s1BadgeIds.length, 1); + assertEq(cycle.s1BadgeIds[0], 2); } function test_revertTransferAfterRecruitmentStarts() public { @@ -371,8 +363,6 @@ contract TrailblazersBadgesS2Test is Test { } function test_startRecruitment_expBased() public { - mint_s1(minters[0], BADGE_ID); - uint256 points = 100; bytes32 _hash = recruitment.generateClaimHash(BadgeRecruitment.HashType.Start, minters[0], points); @@ -382,7 +372,6 @@ contract TrailblazersBadgesS2Test is Test { vm.prank(minters[0]); recruitment.startRecruitment(_hash, v, r, s, points); - assertEq(s1BadgesV4.balanceOf(minters[0]), 1); assertEq(recruitment.isRecruitmentActive(minters[0]), true); } @@ -413,4 +402,92 @@ contract TrailblazersBadgesS2Test is Test { vm.expectRevert(BadgeRecruitment.NOT_RANDOM_SIGNER.selector); recruitment.startRecruitment(_hash, v, r, s, points); } + + function test_startRecruitment_multiCycle() public { + // start a recruitment for minters[0] and badgeId + test_endRecruitment(); + + // mint the same badge on minters[1], and transfer to minters[0] + mint_s1(minters[1], BADGE_ID); + uint256 tokenId = s1BadgesV4.getTokenId(minters[1], BADGE_ID); + vm.prank(minters[1]); + s1BadgesV4.transferFrom(minters[1], minters[0], tokenId); + assertEq(s1BadgesV4.balanceOf(minters[0]), 2); + + // ensure they can migrate via exp + test_startRecruitment_expBased(); + wait(COOLDOWN_INFLUENCE); + wait(COOLDOWN_RECRUITMENT); + + // generate the claim hash for the current recruitment + bytes32 claimHash = recruitment.generateClaimHash( + BadgeRecruitment.HashType.End, + minters[0], + 0 // experience points + ); + + // simulate the backend signing the hash + (uint8 v, bytes32 r, bytes32 s) = vm.sign(mintSignerPk, claimHash); + + // exercise the randomFromSignature function + vm.prank(minters[0]); + recruitment.endRecruitment(claimHash, v, r, s, 0); + assertEq(s2Badges.balanceOf(minters[0], 1), 1); + + // + + // ensure minters[0] cannot recruit again within this same cycle + vm.startPrank(minters[0]); + vm.expectRevert(BadgeRecruitment.ALREADY_MIGRATED_IN_CYCLE.selector); + s1BadgesV4.startRecruitment(BADGE_ID); + // ensure they can't either via exp call + uint256 points = 100; + bytes32 _hash = + recruitment.generateClaimHash(BadgeRecruitment.HashType.Start, minters[0], points); + + (v, r, s) = vm.sign(mintSignerPk, _hash); + + vm.expectRevert(BadgeRecruitment.ALREADY_MIGRATED_IN_CYCLE.selector); + recruitment.startRecruitment(_hash, v, r, s, points); + + // move the cycle forward + wait(DEFAULT_CYCLE_DURATION + 1); + + // no cycle is set, should fail to recruit + vm.startPrank(minters[0]); + vm.expectRevert(BadgeRecruitment.RECRUITMENT_NOT_ENABLED.selector); + s1BadgesV4.startRecruitment(BADGE_ID); + + // enable the next cycle + uint256[] memory enabledBadgeIds = new uint256[](1); + enabledBadgeIds[0] = BADGE_ID; + vm.startPrank(owner); + recruitment.enableRecruitments(enabledBadgeIds); + + // ensure they can recruit with the second badge + vm.startPrank(minters[0]); + s1BadgesV4.startRecruitment(BADGE_ID); + + tokenId = s1BadgesV4.getTokenId(minters[0], BADGE_ID); + assertEq(s1BadgesV4.balanceOf(minters[0]), 2); + assertEq(recruitment.isRecruitmentActive(minters[0]), true); + assertEq(s1BadgesV4.unlockTimestamps(tokenId), block.timestamp + 365 days); + + // ensure they cannot start it again + vm.expectRevert(BadgeRecruitment.RECRUITMENT_ALREADY_STARTED.selector); + s1BadgesV4.startRecruitment(BADGE_ID); + } + + function test_enableDisableRecruitment_admin() public { + // should fail to enable new recruitments + uint256[] memory enabledBadgeIds = new uint256[](1); + enabledBadgeIds[0] = BADGE_ID; + vm.startPrank(owner); + vm.expectRevert(BadgeRecruitment.CURRENT_CYCLE_NOT_OVER.selector); + recruitment.enableRecruitments(enabledBadgeIds); + // wait out the currently-open cycle + wait(DEFAULT_CYCLE_DURATION + 1); + // create a second cycle + recruitment.enableRecruitments(enabledBadgeIds); + } } From dc9a65b63e6c89a9dff8d13afb5e915d900f6b97 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 14 Nov 2024 14:41:53 +0100 Subject: [PATCH 70/79] qa deployment --- .../contracts/trailblazers-season-2/BadgeRecruitment.sol | 6 +++--- packages/nfts/deployments/trailblazers-season-2/hekla.json | 6 +++--- packages/nfts/script/trailblazers-season-2/Deploy.s.sol | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol b/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol index 4c6200205b9..4b2e1f57a90 100644 --- a/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol +++ b/packages/nfts/contracts/trailblazers-season-2/BadgeRecruitment.sol @@ -534,8 +534,8 @@ contract BadgeRecruitment is /// @notice Get the maximum number of influences for a given experience /// @param _exp The user's experience points function maxInfluences(uint256 _exp) public view virtual returns (uint256 value) { - value = _exp / config.maxInfluencesDivider; - value += 2 * config.baseMaxInfluences; + value = 0; // _exp / config.maxInfluencesDivider; + value += config.baseMaxInfluences; return value; } @@ -569,7 +569,7 @@ contract BadgeRecruitment is if (recovered_ != randomSigner) revert NOT_RANDOM_SIGNER(); Recruitment memory recruitment_ = getActiveRecruitmentFor(_msgSender()); - if ((recruitment_.whaleInfluences + recruitment_.minnowInfluences) > maxInfluences(_exp)) { + if ((recruitment_.whaleInfluences + recruitment_.minnowInfluences) >= maxInfluences(_exp)) { revert MAX_INFLUENCES_REACHED(); } diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index 16e5139ad87..9cdda21ac85 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,6 +1,6 @@ { - "BadgeRecruitment": "0x7a5779ccD0E9a4c6DB4EA594C5e5f782B5b79b24", + "BadgeRecruitment": "0x32F0154a4585A7114f65d734e721b627AEa651ea", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x406f733CF3de0524D5949AA1B0296b29398Aadb3", - "TrailblazersBadgesS2": "0x820E659971790429257Fd41FccD15F9438D9dEAB" + "TrailblazersBadges": "0xB3f741415fB4AaB993dD9CFcaC2e7c6650459C9E", + "TrailblazersBadgesS2": "0x60EAb06c9711784a59DF7d3e52BE520109eEE023" } diff --git a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol index f597e402f6d..ea261a493d5 100644 --- a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol @@ -25,8 +25,8 @@ contract DeployS2Script is Script { bool constant PURPLE_INFLUENCE = false; uint256 public MAX_INFLUENCES = 3; - uint256 public COOLDOWN_RECRUITMENT = 10 minutes; - uint256 public COOLDOWN_INFLUENCE = 2 minutes; + uint256 public COOLDOWN_RECRUITMENT = 5 minutes; + uint256 public COOLDOWN_INFLUENCE = 1 minutes; uint256 public INFLUENCE_WEIGHT_PERCENT = 5; uint256 public MAX_INFLUENCES_DIVIDER = 100; uint256 public DEFAULT_CYCLE_DURATION = 7 days; From 099aa8b57d19056dce1ad1dd2a2815fd931ef1aa Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 28 Nov 2024 21:34:45 +0100 Subject: [PATCH 71/79] predeployment commit --- .../TrailblazersBadgesS2.sol | 6 +-- .../trailblazers-season-2/hekla.json | 6 +-- .../script/trailblazers-season-2/Deploy.s.sol | 45 ++++++++++--------- .../TrailblazersBadgesS2.t.sol | 31 +++++++++++-- 4 files changed, 58 insertions(+), 30 deletions(-) diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol index 8d3e7705dc3..76d1853ecb1 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol @@ -37,8 +37,8 @@ contract TrailblazersBadgesS2 is Bouncers, // s1 id: 2 Masters, // s1 id: 3 Monks, // s1 id: 4 - Drummers, // s1 id: 5 - Androids, // s1 id: 6 + Androids, // s1 id: 5 + Drummers, // s1 id: 6 Shinto // s1 id: 7 } @@ -143,7 +143,7 @@ contract TrailblazersBadgesS2 is string memory badgeType_ = Strings.toString(uint256(_badgeType)); string memory movementType_ = Strings.toString(uint256(_movementType)); - return string(abi.encodePacked(uriTemplate, badgeType_, "/", movementType_, ".json")); + return string(abi.encodePacked(uriTemplate, "/", movementType_, "/", badgeType_)); } /// @notice Retrieve the URI for a badge given the type & movement diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index 9cdda21ac85..58f8c5c506d 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,6 +1,6 @@ { - "BadgeRecruitment": "0x32F0154a4585A7114f65d734e721b627AEa651ea", + "BadgeRecruitment": "0xA705bDE7EED0162465DBea7483E68a4a4b41A37C", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0xB3f741415fB4AaB993dD9CFcaC2e7c6650459C9E", - "TrailblazersBadgesS2": "0x60EAb06c9711784a59DF7d3e52BE520109eEE023" + "TrailblazersBadges": "0x629E9d0f3968D63ee657b602Be0688E2AbAe9fa3", + "TrailblazersBadgesS2": "0xa20B517F52Afa6D690f84931abf63409655256A2" } diff --git a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol index ea261a493d5..841870b404d 100644 --- a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol @@ -21,37 +21,40 @@ contract DeployS2Script is Script { BadgeRecruitment recruitment; - bool constant PINK_INFLUENCE = true; - bool constant PURPLE_INFLUENCE = false; + // Taiko Mainnet Values + //address owner = 0xf8ff2AF0DC1D5BA4811f22aCb02936A1529fd2Be; + address claimMintSigner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; + address recruitmentSigner = 0x3cda4F2EaC3fc2FdE78B3DFFe1A1A1Eff88c68c5; + string baseURI = + "https://taikonfts.4everland.link/ipfs/bafybeiatuzeeeznd3hi5qiulslxcjd22ebu45t4fra2jvi3smhocr2c66a"; + IMinimalBlacklist blacklist = IMinimalBlacklist(0xfA5EA6f9A13532cd64e805996a941F101CCaAc9a); - uint256 public MAX_INFLUENCES = 3; - uint256 public COOLDOWN_RECRUITMENT = 5 minutes; - uint256 public COOLDOWN_INFLUENCE = 1 minutes; - uint256 public INFLUENCE_WEIGHT_PERCENT = 5; + uint256 public MAX_INFLUENCES = 5; + uint256 public COOLDOWN_RECRUITMENT = 24 hours; + uint256 public COOLDOWN_INFLUENCE = 30 minutes; + uint256 public INFLUENCE_WEIGHT_PERCENT = 9; uint256 public MAX_INFLUENCES_DIVIDER = 100; uint256 public DEFAULT_CYCLE_DURATION = 7 days; - uint256 public S1_LOCK_DURATION = 365 days; - // Taiko Mainnet Values - //address owner = 0xf8ff2AF0DC1D5BA4811f22aCb02936A1529fd2Be; - //bytes32 root = 0xa7e510d5aed347e65609cf6f0e0738cdd752ffdf5980749057c634489fd09fc3; - // string baseURI = "bafybeierqzehlrqeqqeb6fwmil4dj3ij2p6exgoj4lysl53fsxwob6wbdy"; - // IMinimalBlacklist blacklist = IMinimalBlacklist(0xfA5EA6f9A13532cd64e805996a941F101CCaAc9a); + uint256 public s1EndDate = 1_734_350_400; // Dec 16th 2024, noon UTC + uint256 public S1_LOCK_DURATION = (s1EndDate - block.timestamp); // Hekla Testnet Values - bytes32 root = 0xf1359c4c4ba41a72025f2534ea8ad23c6b941b55a715838ebdc71202a78c6c87; + /* string baseURI = - "https://taikonfts.4everland.link/ipfs/bafybeiebmvj6roz4iuoinackb5c6eeshvppctkydrckqrnxexdnzh6odq4"; + "https://taikonfts.4everland.link/ipfs/bafybeiatuzeeeznd3hi5qiulslxcjd22ebu45t4fra2jvi3smhocr2c66a"; IMinimalBlacklist blacklist = IMinimalBlacklist(0xe61E9034b5633977eC98E302b33e321e8140F105); address claimMintSigner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; address recruitmentSigner = 0x3cda4F2EaC3fc2FdE78B3DFFe1A1A1Eff88c68c5; - // Hardhat Testnet Values - // address owner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; - // address mintSigner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; - // string baseURI = "https://taikonfts.4everland.link/ipfs/bafybeierqzehlrqeqqeb6fwmil4dj3ij2p6exgoj4lysl53fsxwob6wbdy"; - // IMinimalBlacklist blacklist = - // IMinimalBlacklist(0xe61E9034b5633977eC98E302b33e321e8140F105); + uint256 public MAX_INFLUENCES = 5; + uint256 public COOLDOWN_RECRUITMENT = 5 minutes; + uint256 public COOLDOWN_INFLUENCE = 1 minutes; + uint256 public INFLUENCE_WEIGHT_PERCENT = 9; + uint256 public MAX_INFLUENCES_DIVIDER = 100; + uint256 public DEFAULT_CYCLE_DURATION = 7 days; + uint256 public S1_LOCK_DURATION = 365 days; + */ address s1Contract = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; @@ -108,7 +111,7 @@ contract DeployS2Script is Script { impl = address(new TrailblazersBadgesS2()); proxy = address( new ERC1967Proxy( - impl, abi.encodeCall(TrailblazersBadgesS2.initialize, (address(owner), "ipfs://")) + impl, abi.encodeCall(TrailblazersBadgesS2.initialize, (address(owner), baseURI)) ) ); diff --git a/packages/nfts/test/trailblazers-season-2/TrailblazersBadgesS2.t.sol b/packages/nfts/test/trailblazers-season-2/TrailblazersBadgesS2.t.sol index 5c3345f54bb..40918273115 100644 --- a/packages/nfts/test/trailblazers-season-2/TrailblazersBadgesS2.t.sol +++ b/packages/nfts/test/trailblazers-season-2/TrailblazersBadgesS2.t.sol @@ -15,7 +15,7 @@ contract TrailblazersBadgesS2Test is Test { address public authorizedMinter = vm.addr(0x6); address[3] public minters = [vm.addr(0x1), vm.addr(0x2), vm.addr(0x3)]; - string public uriTemplate = "ipfs://hash/"; + string public uriTemplate = "ipfs://hash"; TrailblazersBadgesS2 public nft; @@ -58,17 +58,42 @@ contract TrailblazersBadgesS2Test is Test { function test_uri_byTokenId() public { test_mint(); - assertEq(nft.uri(TOKEN_ID), "ipfs://hash/0/2.json"); + assertEq(nft.uri(TOKEN_ID), "ipfs://hash/2/0"); } function test_uri_byTypeAndMovement() public { test_mint(); assertEq( nft.uri(TrailblazersBadgesS2.BadgeType.Ravers, TrailblazersBadgesS2.MovementType.Minnow), - "ipfs://hash/0/2.json" + "ipfs://hash/2/0" ); } + function test_uri_full() public { + vm.startPrank(authorizedMinter); + uint8 tokenId = 1; + + TrailblazersBadgesS2.Badge memory badge; + for (uint8 i = 1; i < 3; i++) { + for (uint8 j = 0; j < 8; j++) { + nft.mint( + minters[0], + TrailblazersBadgesS2.BadgeType(j), + TrailblazersBadgesS2.MovementType(i) + ); + + badge = nft.getBadge(tokenId); + string memory badgeType = vm.toString(uint256(badge.badgeType)); + string memory movementType = vm.toString(uint256(badge.movementType)); + + string memory uri = + string(abi.encodePacked("ipfs://hash/", movementType, "/", badgeType)); + assertEq(nft.uri(tokenId), uri); + tokenId++; + } + } + } + function test_uri_revert__tokenNotMinted() public { vm.expectRevert(); nft.uri(TOKEN_ID); From 8213699a08799345fc087ccddd9c9978a13ed73a Mon Sep 17 00:00:00 2001 From: bearni95 Date: Thu, 28 Nov 2024 22:58:29 +0100 Subject: [PATCH 72/79] production deployment --- .../TrailblazersBadgesS2.sol | 10 ++++ packages/nfts/deployments/taikoon/hekla.json | 2 +- .../trailblazers-season-2/hekla.json | 6 +-- .../trailblazers-season-2/mainnet.json | 7 +-- packages/nfts/package.json | 4 +- .../trailblazers-badges/UpgradeV4.s.sol | 51 +++++++++++++++++++ .../script/trailblazers-season-2/Deploy.s.sol | 4 +- .../trailblazers-season-2/UpgradeV2.s.sol | 50 ++++++++++++++++++ 8 files changed, 124 insertions(+), 10 deletions(-) create mode 100644 packages/nfts/script/trailblazers-badges/UpgradeV4.s.sol create mode 100644 packages/nfts/script/trailblazers-season-2/UpgradeV2.s.sol diff --git a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol index 76d1853ecb1..5984e3a3e75 100644 --- a/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol +++ b/packages/nfts/contracts/trailblazers-season-2/TrailblazersBadgesS2.sol @@ -198,4 +198,14 @@ contract TrailblazersBadgesS2 is /// @notice Internal method to authorize an upgrade function _authorizeUpgrade(address) internal virtual override onlyOwner { } + + // v2 + + function version() public pure returns (string memory) { + return "v2"; + } + + function setUri(string memory __uri) public onlyRole(DEFAULT_ADMIN_ROLE) { + uriTemplate = __uri; + } } diff --git a/packages/nfts/deployments/taikoon/hekla.json b/packages/nfts/deployments/taikoon/hekla.json index 6d54379cbe2..f9241cbc4ef 100644 --- a/packages/nfts/deployments/taikoon/hekla.json +++ b/packages/nfts/deployments/taikoon/hekla.json @@ -1,5 +1,5 @@ { "MerkleRoot": "0x1c3b504b4d5640d26ad1aa3b57a9df9ec034f19239768e734b849c306d10b110", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TaikoonToken": "0xf3FBa6f1E6C1998195239e7DD794c1EcEA8Da66B" + "TaikoonToken": "0x6e68900B53D6de5c20A4b81CE42A488b887f40Ce" } diff --git a/packages/nfts/deployments/trailblazers-season-2/hekla.json b/packages/nfts/deployments/trailblazers-season-2/hekla.json index 58f8c5c506d..0b70fbc0bf4 100644 --- a/packages/nfts/deployments/trailblazers-season-2/hekla.json +++ b/packages/nfts/deployments/trailblazers-season-2/hekla.json @@ -1,6 +1,6 @@ { - "BadgeRecruitment": "0xA705bDE7EED0162465DBea7483E68a4a4b41A37C", + "BadgeRecruitment": "0xBd368C65Cb354eBAd6c1429b551bD0197f19C2B8", "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0x629E9d0f3968D63ee657b602Be0688E2AbAe9fa3", - "TrailblazersBadgesS2": "0xa20B517F52Afa6D690f84931abf63409655256A2" + "TrailblazersBadges": "0x9E14C357E964BeE012bA82Ce9d6513dAec6ea961", + "TrailblazersBadgesS2": "0xc84B76a5836Cb0CeF094808af445F7E98504ED5B" } diff --git a/packages/nfts/deployments/trailblazers-season-2/mainnet.json b/packages/nfts/deployments/trailblazers-season-2/mainnet.json index 91512ed23a8..4430837567d 100644 --- a/packages/nfts/deployments/trailblazers-season-2/mainnet.json +++ b/packages/nfts/deployments/trailblazers-season-2/mainnet.json @@ -1,5 +1,6 @@ { - "Owner": "0x4100a9B680B1Be1F10Cb8b5a57fE59eA77A8184e", - "TrailblazersBadges": "0xA951f812D8B52db3E001c6f1F061Be941208a918", - "TrailblazersBadgesS2": "0x5fb9662549105Ba46f3153b4e3DCA9CC7923D323" + "BadgeRecruitment": "0xa9Ceb04F3aF71fF123409d426A92BABb5124970C", + "Owner": "0x7d70236E2517f5B95247AF1d806A9E3C328a7860", + "TrailblazersBadges": "0xa20a8856e00F5ad024a55A663F06DCc419FFc4d5", + "TrailblazersBadgesS2": "0x52A7dBeC10B404548066F59DE89484e27b4181dA" } diff --git a/packages/nfts/package.json b/packages/nfts/package.json index 52fc939bc09..41926afa56c 100644 --- a/packages/nfts/package.json +++ b/packages/nfts/package.json @@ -39,7 +39,9 @@ "tbz:airdrop:hekla": "forge clean && pnpm compile && forge script script/trailblazers-airdrop/Deploy.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", "tbz:airdrop:mainnet": "forge clean && pnpm compile && forge script script/trailblazers-airdrop/Deploy.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --gas-estimate-multiplier 100", "tbz:upgradeV3:hekla": "forge clean && pnpm compile && forge script script/trailblazers-badges/sol/UpgradeV3.s.sol --rpc-url https://rpc.hekla.taiko.xyz --broadcast --gas-estimate-multiplier 200", - "tbz:upgradeV3:mainnet": "forge clean && pnpm compile && forge script script/trailblazers-badges/sol/UpgradeV3.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --gas-estimate-multiplier 100" + "tbz:upgradeV3:mainnet": "forge clean && pnpm compile && forge script script/trailblazers-badges/sol/UpgradeV3.s.sol --rpc-url https://rpc.mainnet.taiko.xyz --broadcast --gas-estimate-multiplier 100", + "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" }, "devDependencies": { "@types/node": "^20.11.30", diff --git a/packages/nfts/script/trailblazers-badges/UpgradeV4.s.sol b/packages/nfts/script/trailblazers-badges/UpgradeV4.s.sol new file mode 100644 index 00000000000..6627496ba66 --- /dev/null +++ b/packages/nfts/script/trailblazers-badges/UpgradeV4.s.sol @@ -0,0 +1,51 @@ +// 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 { TrailblazersBadgesV3 } from "../../contracts/trailblazers-badges/TrailblazersBadgesV3.sol"; +import { TrailblazersBadgesV4 } from + "../../contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol"; + +contract UpgradeV4 is Script { + UtilsScript public utils; + string public jsonLocation; + uint256 public deployerPrivateKey; + address public deployerAddress; + + address tokenV3Address = 0xa20a8856e00F5ad024a55A663F06DCc419FFc4d5; + TrailblazersBadgesV3 public tokenV3; + TrailblazersBadgesV4 public tokenV4; + + function setUp() public { + utils = new UtilsScript(); + utils.setUp(); + + jsonLocation = utils.getContractJsonLocation(); + deployerPrivateKey = utils.getPrivateKey(); + deployerAddress = utils.getAddress(); + } + + function run() public { + vm.startBroadcast(deployerPrivateKey); + tokenV3 = TrailblazersBadgesV3(tokenV3Address); + + tokenV3.upgradeToAndCall( + address(new TrailblazersBadgesV4()), abi.encodeCall(TrailblazersBadgesV4.version, ()) + ); + + tokenV4 = TrailblazersBadgesV4(address(tokenV3)); + + console.log("Upgraded TrailblazersBadgesV3 to:", address(tokenV4)); + + // update uri + tokenV4.setUri( + "https://taikonfts.4everland.link/ipfs/bafybeiatuzeeeznd3hi5qiulslxcjd22ebu45t4fra2jvi3smhocr2c66a" + ); + console.log("Updated token URI"); + } +} diff --git a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol index 841870b404d..2775e877772 100644 --- a/packages/nfts/script/trailblazers-season-2/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-season-2/Deploy.s.sol @@ -24,7 +24,7 @@ contract DeployS2Script is Script { // Taiko Mainnet Values //address owner = 0xf8ff2AF0DC1D5BA4811f22aCb02936A1529fd2Be; address claimMintSigner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; - address recruitmentSigner = 0x3cda4F2EaC3fc2FdE78B3DFFe1A1A1Eff88c68c5; + address recruitmentSigner = 0x9Fc8d56c7376f9b062FEe7E02BAdFA670d603248; string baseURI = "https://taikonfts.4everland.link/ipfs/bafybeiatuzeeeznd3hi5qiulslxcjd22ebu45t4fra2jvi3smhocr2c66a"; IMinimalBlacklist blacklist = IMinimalBlacklist(0xfA5EA6f9A13532cd64e805996a941F101CCaAc9a); @@ -56,7 +56,7 @@ contract DeployS2Script is Script { uint256 public S1_LOCK_DURATION = 365 days; */ - address s1Contract = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; + address s1Contract = 0xa20a8856e00F5ad024a55A663F06DCc419FFc4d5; function setUp() public { utils = new UtilsScript(); diff --git a/packages/nfts/script/trailblazers-season-2/UpgradeV2.s.sol b/packages/nfts/script/trailblazers-season-2/UpgradeV2.s.sol new file mode 100644 index 00000000000..14c71373b27 --- /dev/null +++ b/packages/nfts/script/trailblazers-season-2/UpgradeV2.s.sol @@ -0,0 +1,50 @@ +// 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 { TrailblazersBadgesS2 } from + "../../contracts/trailblazers-season-2/TrailblazersBadgesS2.sol"; + +contract UpgradeV2 is Script { + UtilsScript public utils; + string public jsonLocation; + uint256 public deployerPrivateKey; + address public deployerAddress; + + address tokenAddress = 0x52A7dBeC10B404548066F59DE89484e27b4181dA; + TrailblazersBadgesS2 public token; + + function setUp() public { + utils = new UtilsScript(); + utils.setUp(); + + jsonLocation = utils.getContractJsonLocation(); + deployerPrivateKey = utils.getPrivateKey(); + deployerAddress = utils.getAddress(); + } + + function run() public { + vm.startBroadcast(deployerPrivateKey); + token = TrailblazersBadgesS2(tokenAddress); + + token.upgradeToAndCall( + address(new TrailblazersBadgesS2()), abi.encodeCall(TrailblazersBadgesS2.version, ()) + ); + + token = TrailblazersBadgesS2(address(token)); + + console.log("Upgraded TrailblazersBadgesV3 to:", address(token)); + + // update uri + token.setUri( + "https://taikonfts.4everland.link/ipfs/bafybeief7o4u6f676e6uz4yt4cv34ai4mesd7motoq6y4xxaoyjfbna5de" + ); + console.log("Updated token URI"); + } +} From 548217bdfeb2ed362093111938d0ba768bfd34d9 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 2 Dec 2024 10:26:22 +0100 Subject: [PATCH 73/79] reverted unwanted changes on external packages From f4e5beaa50aeffd33c3127217d7b5688705f049f Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 2 Dec 2024 10:26:56 +0100 Subject: [PATCH 74/79] restored workflow From 83e2d4a455fd04248b8500cbe73a773d7c31aed2 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 2 Dec 2024 10:27:47 +0100 Subject: [PATCH 75/79] restored gha --- .github/workflows/guardian-prover-health-check-ui.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/guardian-prover-health-check-ui.yml b/.github/workflows/guardian-prover-health-check-ui.yml index 2312694c0fe..ad0d4aa069c 100644 --- a/.github/workflows/guardian-prover-health-check-ui.yml +++ b/.github/workflows/guardian-prover-health-check-ui.yml @@ -28,6 +28,8 @@ jobs: # vercel_org_id: ${{ secrets.VERCEL_ORG_ID }} # vercel_token: ${{ secrets.VERCEL_TOKEN }} + + deploy_guardians-ui_hekla_preview: if: ${{ github.event.pull_request.draft == false && !startsWith(github.head_ref, 'release-please') }} needs: build-and-test From 5dd4fab853ac7c6df6bbb426bcd685e26ac8801f Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 2 Dec 2024 10:28:37 +0100 Subject: [PATCH 76/79] restored docs-site --- .../src/content/docs/core-concepts/contestable-rollups.md | 1 + .../software-releases-and-deployments.md | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/docs-site/src/content/docs/core-concepts/contestable-rollups.md b/packages/docs-site/src/content/docs/core-concepts/contestable-rollups.md index 448f4d2016d..18f71b74922 100644 --- a/packages/docs-site/src/content/docs/core-concepts/contestable-rollups.md +++ b/packages/docs-site/src/content/docs/core-concepts/contestable-rollups.md @@ -23,4 +23,5 @@ If the original prover wins: The original prover reclaims their validity bond an ![BCR Workflow](~/assets/content/docs/core-concepts/contestable.png) + Check out our blog post on the [Based Contestable Rollup (BCR): A configurable, multi-proof rollup design](https://taiko.mirror.xyz/Z4I5ZhreGkyfdaL5I9P0Rj0DNX4zaWFmcws-0CVMJ2A). diff --git a/packages/docs-site/src/content/docs/network-reference/software-releases-and-deployments.md b/packages/docs-site/src/content/docs/network-reference/software-releases-and-deployments.md index 484abe86d4c..336964cf320 100644 --- a/packages/docs-site/src/content/docs/network-reference/software-releases-and-deployments.md +++ b/packages/docs-site/src/content/docs/network-reference/software-releases-and-deployments.md @@ -9,11 +9,11 @@ It is **highly recommended** you use the latest software. You can find the lates | Package | Release notes | | :------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| [protocol](https://github.com/taikoxyz/taiko-mono/tree/main/packages/protocol) | [![Github Release](https://img.shields.io/github/v/release/taikoxyz/taiko-mono?filter=protocol*&label=)](https://github.com/taikoxyz/taiko-mono/blob/main/packages/protocol/CHANGELOG.md) | -| [taiko-geth](https://github.com/taikoxyz/taiko-geth) | [![GitHub Release](https://img.shields.io/github/v/release/taikoxyz/taiko-geth?label=)](https://github.com/taikoxyz/taiko-geth/blob/taiko/CHANGELOG.md) | +| [protocol](https://github.com/taikoxyz/taiko-mono/tree/main/packages/protocol) | [![Github Release](https://img.shields.io/github/v/release/taikoxyz/taiko-mono?filter=protocol*&label=)](https://github.com/taikoxyz/taiko-mono/blob/main/packages/protocol/CHANGELOG.md) | +| [taiko-geth](https://github.com/taikoxyz/taiko-geth) | [![GitHub Release](https://img.shields.io/github/v/release/taikoxyz/taiko-geth?label=)](https://github.com/taikoxyz/taiko-geth/blob/taiko/CHANGELOG.md) | | [taiko-client](https://github.com/taikoxyz/taiko-mono/tree/main/packages/taiko-client) | [![GitHub Release](https://img.shields.io/github/v/release/taikoxyz/taiko-mono?filter=taiko-client*&label=)](https://github.com/taikoxyz/taiko-mono/blob/main/packages/taiko-client/CHANGELOG.md) | -| [simple-taiko-node](https://github.com/taikoxyz/simple-taiko-node/tree/main) | [![Github Release](https://img.shields.io/github/v/release/taikoxyz/simple-taiko-node?label=)](https://github.com/taikoxyz/simple-taiko-node/blob/main/CHANGELOG.md) | -| [raiko](https://github.com/taikoxyz/raiko/tree/main) | [![Github Release](https://img.shields.io/github/v/release/taikoxyz/raiko?label=)](https://github.com/taikoxyz/raiko/blob/main/CHANGELOG.md) | +| [simple-taiko-node](https://github.com/taikoxyz/simple-taiko-node/tree/main) | [![Github Release](https://img.shields.io/github/v/release/taikoxyz/simple-taiko-node?label=)](https://github.com/taikoxyz/simple-taiko-node/blob/main/CHANGELOG.md) | +| [raiko](https://github.com/taikoxyz/raiko/tree/main) | [![Github Release](https://img.shields.io/github/v/release/taikoxyz/raiko?label=)](https://github.com/taikoxyz/raiko/blob/main/CHANGELOG.md) | ## Mainnet Deployment Logs From 56765ab617665e0942ffe8f56b50b83c8b82d76b Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 2 Dec 2024 10:29:12 +0100 Subject: [PATCH 77/79] restored protocol --- packages/protocol/contract_layout_layer1.md | 1651 +++++++++---------- packages/protocol/contract_layout_layer2.md | 783 +++++---- 2 files changed, 1185 insertions(+), 1249 deletions(-) diff --git a/packages/protocol/contract_layout_layer1.md b/packages/protocol/contract_layout_layer1.md index 0a917b8b612..299e675c91e 100644 --- a/packages/protocol/contract_layout_layer1.md +++ b/packages/protocol/contract_layout_layer1.md @@ -1,509 +1,487 @@ ## ERC1155Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ------------ | -| \_initialized | uint8 | 0 | 0 | 1 | ERC1155Vault | -| \_initializing | bool | 0 | 1 | 1 | ERC1155Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ERC1155Vault | -| \_owner | address | 51 | 0 | 20 | ERC1155Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ERC1155Vault | -| \_pendingOwner | address | 101 | 0 | 20 | ERC1155Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ERC1155Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|-----------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ERC1155Vault | +| _initializing | bool | 0 | 1 | 1 | ERC1155Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | ERC1155Vault | +| _owner | address | 51 | 0 | 20 | ERC1155Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | ERC1155Vault | +| _pendingOwner | address | 101 | 0 | 20 | ERC1155Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | ERC1155Vault | | addressManager | address | 151 | 0 | 20 | ERC1155Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ERC1155Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | ERC1155Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | ERC1155Vault | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC1155Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ERC1155Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ERC1155Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | ERC1155Vault | +| __reentry | uint8 | 201 | 0 | 1 | ERC1155Vault | +| __paused | uint8 | 201 | 1 | 1 | ERC1155Vault | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC1155Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | ERC1155Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | ERC1155Vault | | bridgedToCanonical | mapping(address => struct BaseNFTVault.CanonicalNFT) | 301 | 0 | 32 | ERC1155Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | ERC1155Vault | -| \_\_gap | uint256[48] | 303 | 0 | 1536 | ERC1155Vault | -| \_\_gap | uint256[50] | 351 | 0 | 1600 | ERC1155Vault | -| \_\_gap | uint256[50] | 401 | 0 | 1600 | ERC1155Vault | -| \_\_gap | uint256[50] | 451 | 0 | 1600 | ERC1155Vault | +| __gap | uint256[48] | 303 | 0 | 1536 | ERC1155Vault | +| __gap | uint256[50] | 351 | 0 | 1600 | ERC1155Vault | +| __gap | uint256[50] | 401 | 0 | 1600 | ERC1155Vault | +| __gap | uint256[50] | 451 | 0 | 1600 | ERC1155Vault | ## ERC20Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ---------- | -| \_initialized | uint8 | 0 | 0 | 1 | ERC20Vault | -| \_initializing | bool | 0 | 1 | 1 | ERC20Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ERC20Vault | -| \_owner | address | 51 | 0 | 20 | ERC20Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ERC20Vault | -| \_pendingOwner | address | 101 | 0 | 20 | ERC20Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ERC20Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|-------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ERC20Vault | +| _initializing | bool | 0 | 1 | 1 | ERC20Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | ERC20Vault | +| _owner | address | 51 | 0 | 20 | ERC20Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | ERC20Vault | +| _pendingOwner | address | 101 | 0 | 20 | ERC20Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | ERC20Vault | | addressManager | address | 151 | 0 | 20 | ERC20Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ERC20Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | ERC20Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | ERC20Vault | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC20Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ERC20Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ERC20Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | ERC20Vault | +| __reentry | uint8 | 201 | 0 | 1 | ERC20Vault | +| __paused | uint8 | 201 | 1 | 1 | ERC20Vault | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC20Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | ERC20Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | ERC20Vault | | bridgedToCanonical | mapping(address => struct ERC20Vault.CanonicalERC20) | 301 | 0 | 32 | ERC20Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | ERC20Vault | | btokenDenylist | mapping(address => bool) | 303 | 0 | 32 | ERC20Vault | | lastMigrationStart | mapping(uint256 => mapping(address => uint256)) | 304 | 0 | 32 | ERC20Vault | -| \_\_gap | uint256[46] | 305 | 0 | 1472 | ERC20Vault | +| __gap | uint256[46] | 305 | 0 | 1472 | ERC20Vault | ## ERC721Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ----------- | -| \_initialized | uint8 | 0 | 0 | 1 | ERC721Vault | -| \_initializing | bool | 0 | 1 | 1 | ERC721Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ERC721Vault | -| \_owner | address | 51 | 0 | 20 | ERC721Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ERC721Vault | -| \_pendingOwner | address | 101 | 0 | 20 | ERC721Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ERC721Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|---------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ERC721Vault | +| _initializing | bool | 0 | 1 | 1 | ERC721Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | ERC721Vault | +| _owner | address | 51 | 0 | 20 | ERC721Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | ERC721Vault | +| _pendingOwner | address | 101 | 0 | 20 | ERC721Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | ERC721Vault | | addressManager | address | 151 | 0 | 20 | ERC721Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ERC721Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | ERC721Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | ERC721Vault | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC721Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ERC721Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ERC721Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | ERC721Vault | +| __reentry | uint8 | 201 | 0 | 1 | ERC721Vault | +| __paused | uint8 | 201 | 1 | 1 | ERC721Vault | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC721Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | ERC721Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | ERC721Vault | | bridgedToCanonical | mapping(address => struct BaseNFTVault.CanonicalNFT) | 301 | 0 | 32 | ERC721Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | ERC721Vault | -| \_\_gap | uint256[48] | 303 | 0 | 1536 | ERC721Vault | -| \_\_gap | uint256[50] | 351 | 0 | 1600 | ERC721Vault | +| __gap | uint256[48] | 303 | 0 | 1536 | ERC721Vault | +| __gap | uint256[50] | 351 | 0 | 1600 | ERC721Vault | ## BridgedERC20 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------------------------------------------- | ---- | ------ | ----- | ------------ | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedERC20 | -| \_initializing | bool | 0 | 1 | 1 | BridgedERC20 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20 | -| \_owner | address | 51 | 0 | 20 | BridgedERC20 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedERC20 | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedERC20 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedERC20 | -| addressManager | address | 151 | 0 | 20 | BridgedERC20 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedERC20 | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedERC20 | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedERC20 | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC20 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedERC20 | -| \_balances | mapping(address => uint256) | 251 | 0 | 32 | BridgedERC20 | -| \_allowances | mapping(address => mapping(address => uint256)) | 252 | 0 | 32 | BridgedERC20 | -| \_totalSupply | uint256 | 253 | 0 | 32 | BridgedERC20 | -| \_name | string | 254 | 0 | 32 | BridgedERC20 | -| \_symbol | string | 255 | 0 | 32 | BridgedERC20 | -| \_\_gap | uint256[45] | 256 | 0 | 1440 | BridgedERC20 | -| srcToken | address | 301 | 0 | 20 | BridgedERC20 | -| \_\_srcDecimals | uint8 | 301 | 20 | 1 | BridgedERC20 | -| srcChainId | uint256 | 302 | 0 | 32 | BridgedERC20 | -| migratingAddress | address | 303 | 0 | 20 | BridgedERC20 | -| migratingInbound | bool | 303 | 20 | 1 | BridgedERC20 | -| \_\_gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20 | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------------------------------------------|------|--------|-------|-----------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedERC20 | +| _initializing | bool | 0 | 1 | 1 | BridgedERC20 | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20 | +| _owner | address | 51 | 0 | 20 | BridgedERC20 | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedERC20 | +| _pendingOwner | address | 101 | 0 | 20 | BridgedERC20 | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedERC20 | +| addressManager | address | 151 | 0 | 20 | BridgedERC20 | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedERC20 | +| __reentry | uint8 | 201 | 0 | 1 | BridgedERC20 | +| __paused | uint8 | 201 | 1 | 1 | BridgedERC20 | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC20 | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedERC20 | +| _balances | mapping(address => uint256) | 251 | 0 | 32 | BridgedERC20 | +| _allowances | mapping(address => mapping(address => uint256)) | 252 | 0 | 32 | BridgedERC20 | +| _totalSupply | uint256 | 253 | 0 | 32 | BridgedERC20 | +| _name | string | 254 | 0 | 32 | BridgedERC20 | +| _symbol | string | 255 | 0 | 32 | BridgedERC20 | +| __gap | uint256[45] | 256 | 0 | 1440 | BridgedERC20 | +| srcToken | address | 301 | 0 | 20 | BridgedERC20 | +| __srcDecimals | uint8 | 301 | 20 | 1 | BridgedERC20 | +| srcChainId | uint256 | 302 | 0 | 32 | BridgedERC20 | +| migratingAddress | address | 303 | 0 | 20 | BridgedERC20 | +| migratingInbound | bool | 303 | 20 | 1 | BridgedERC20 | +| __gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20 | ## BridgedERC20V2 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ------------------------------------------------------ | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedERC20V2 | -| \_initializing | bool | 0 | 1 | 1 | BridgedERC20V2 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20V2 | -| \_owner | address | 51 | 0 | 20 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedERC20V2 | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedERC20V2 | -| addressManager | address | 151 | 0 | 20 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedERC20V2 | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedERC20V2 | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedERC20V2 | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedERC20V2 | -| \_balances | mapping(address => uint256) | 251 | 0 | 32 | BridgedERC20V2 | -| \_allowances | mapping(address => mapping(address => uint256)) | 252 | 0 | 32 | BridgedERC20V2 | -| \_totalSupply | uint256 | 253 | 0 | 32 | BridgedERC20V2 | -| \_name | string | 254 | 0 | 32 | BridgedERC20V2 | -| \_symbol | string | 255 | 0 | 32 | BridgedERC20V2 | -| \_\_gap | uint256[45] | 256 | 0 | 1440 | BridgedERC20V2 | -| srcToken | address | 301 | 0 | 20 | BridgedERC20V2 | -| \_\_srcDecimals | uint8 | 301 | 20 | 1 | BridgedERC20V2 | -| srcChainId | uint256 | 302 | 0 | 32 | BridgedERC20V2 | -| migratingAddress | address | 303 | 0 | 20 | BridgedERC20V2 | -| migratingInbound | bool | 303 | 20 | 1 | BridgedERC20V2 | -| \_\_gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20V2 | -| \_hashedName | bytes32 | 351 | 0 | 32 | BridgedERC20V2 | -| \_hashedVersion | bytes32 | 352 | 0 | 32 | BridgedERC20V2 | -| \_name | string | 353 | 0 | 32 | BridgedERC20V2 | -| \_version | string | 354 | 0 | 32 | BridgedERC20V2 | -| \_\_gap | uint256[48] | 355 | 0 | 1536 | BridgedERC20V2 | -| \_nonces | mapping(address => struct CountersUpgradeable.Counter) | 403 | 0 | 32 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 404 | 0 | 1568 | BridgedERC20V2 | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|--------------------------------------------------------|------|--------|-------|---------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedERC20V2 | +| _initializing | bool | 0 | 1 | 1 | BridgedERC20V2 | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20V2 | +| _owner | address | 51 | 0 | 20 | BridgedERC20V2 | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedERC20V2 | +| _pendingOwner | address | 101 | 0 | 20 | BridgedERC20V2 | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedERC20V2 | +| addressManager | address | 151 | 0 | 20 | BridgedERC20V2 | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedERC20V2 | +| __reentry | uint8 | 201 | 0 | 1 | BridgedERC20V2 | +| __paused | uint8 | 201 | 1 | 1 | BridgedERC20V2 | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC20V2 | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedERC20V2 | +| _balances | mapping(address => uint256) | 251 | 0 | 32 | BridgedERC20V2 | +| _allowances | mapping(address => mapping(address => uint256)) | 252 | 0 | 32 | BridgedERC20V2 | +| _totalSupply | uint256 | 253 | 0 | 32 | BridgedERC20V2 | +| _name | string | 254 | 0 | 32 | BridgedERC20V2 | +| _symbol | string | 255 | 0 | 32 | BridgedERC20V2 | +| __gap | uint256[45] | 256 | 0 | 1440 | BridgedERC20V2 | +| srcToken | address | 301 | 0 | 20 | BridgedERC20V2 | +| __srcDecimals | uint8 | 301 | 20 | 1 | BridgedERC20V2 | +| srcChainId | uint256 | 302 | 0 | 32 | BridgedERC20V2 | +| migratingAddress | address | 303 | 0 | 20 | BridgedERC20V2 | +| migratingInbound | bool | 303 | 20 | 1 | BridgedERC20V2 | +| __gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20V2 | +| _hashedName | bytes32 | 351 | 0 | 32 | BridgedERC20V2 | +| _hashedVersion | bytes32 | 352 | 0 | 32 | BridgedERC20V2 | +| _name | string | 353 | 0 | 32 | BridgedERC20V2 | +| _version | string | 354 | 0 | 32 | BridgedERC20V2 | +| __gap | uint256[48] | 355 | 0 | 1536 | BridgedERC20V2 | +| _nonces | mapping(address => struct CountersUpgradeable.Counter) | 403 | 0 | 32 | BridgedERC20V2 | +| __gap | uint256[49] | 404 | 0 | 1568 | BridgedERC20V2 | ## BridgedERC721 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------- | -------------------------------------------- | ---- | ------ | ----- | ------------- | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedERC721 | -| \_initializing | bool | 0 | 1 | 1 | BridgedERC721 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedERC721 | -| \_owner | address | 51 | 0 | 20 | BridgedERC721 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedERC721 | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedERC721 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedERC721 | -| addressManager | address | 151 | 0 | 20 | BridgedERC721 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedERC721 | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedERC721 | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedERC721 | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC721 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedERC721 | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | BridgedERC721 | -| \_name | string | 301 | 0 | 32 | BridgedERC721 | -| \_symbol | string | 302 | 0 | 32 | BridgedERC721 | -| \_owners | mapping(uint256 => address) | 303 | 0 | 32 | BridgedERC721 | -| \_balances | mapping(address => uint256) | 304 | 0 | 32 | BridgedERC721 | -| \_tokenApprovals | mapping(uint256 => address) | 305 | 0 | 32 | BridgedERC721 | -| \_operatorApprovals | mapping(address => mapping(address => bool)) | 306 | 0 | 32 | BridgedERC721 | -| \_\_gap | uint256[44] | 307 | 0 | 1408 | BridgedERC721 | -| srcToken | address | 351 | 0 | 20 | BridgedERC721 | -| srcChainId | uint256 | 352 | 0 | 32 | BridgedERC721 | -| \_\_gap | uint256[48] | 353 | 0 | 1536 | BridgedERC721 | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|----------------------------------------------|------|--------|-------|-------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedERC721 | +| _initializing | bool | 0 | 1 | 1 | BridgedERC721 | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC721 | +| _owner | address | 51 | 0 | 20 | BridgedERC721 | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedERC721 | +| _pendingOwner | address | 101 | 0 | 20 | BridgedERC721 | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedERC721 | +| addressManager | address | 151 | 0 | 20 | BridgedERC721 | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedERC721 | +| __reentry | uint8 | 201 | 0 | 1 | BridgedERC721 | +| __paused | uint8 | 201 | 1 | 1 | BridgedERC721 | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC721 | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedERC721 | +| __gap | uint256[50] | 251 | 0 | 1600 | BridgedERC721 | +| _name | string | 301 | 0 | 32 | BridgedERC721 | +| _symbol | string | 302 | 0 | 32 | BridgedERC721 | +| _owners | mapping(uint256 => address) | 303 | 0 | 32 | BridgedERC721 | +| _balances | mapping(address => uint256) | 304 | 0 | 32 | BridgedERC721 | +| _tokenApprovals | mapping(uint256 => address) | 305 | 0 | 32 | BridgedERC721 | +| _operatorApprovals | mapping(address => mapping(address => bool)) | 306 | 0 | 32 | BridgedERC721 | +| __gap | uint256[44] | 307 | 0 | 1408 | BridgedERC721 | +| srcToken | address | 351 | 0 | 20 | BridgedERC721 | +| srcChainId | uint256 | 352 | 0 | 32 | BridgedERC721 | +| __gap | uint256[48] | 353 | 0 | 1536 | BridgedERC721 | ## BridgedERC1155 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------- | ----------------------------------------------- | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedERC1155 | -| \_initializing | bool | 0 | 1 | 1 | BridgedERC1155 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedERC1155 | -| \_owner | address | 51 | 0 | 20 | BridgedERC1155 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedERC1155 | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedERC1155 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedERC1155 | -| addressManager | address | 151 | 0 | 20 | BridgedERC1155 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedERC1155 | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedERC1155 | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedERC1155 | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC1155 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedERC1155 | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | BridgedERC1155 | -| \_balances | mapping(uint256 => mapping(address => uint256)) | 301 | 0 | 32 | BridgedERC1155 | -| \_operatorApprovals | mapping(address => mapping(address => bool)) | 302 | 0 | 32 | BridgedERC1155 | -| \_uri | string | 303 | 0 | 32 | BridgedERC1155 | -| \_\_gap | uint256[47] | 304 | 0 | 1504 | BridgedERC1155 | -| srcToken | address | 351 | 0 | 20 | BridgedERC1155 | -| srcChainId | uint256 | 352 | 0 | 32 | BridgedERC1155 | -| symbol | string | 353 | 0 | 32 | BridgedERC1155 | -| name | string | 354 | 0 | 32 | BridgedERC1155 | -| \_\_gap | uint256[46] | 355 | 0 | 1472 | BridgedERC1155 | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|-------------------------------------------------|------|--------|-------|---------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedERC1155 | +| _initializing | bool | 0 | 1 | 1 | BridgedERC1155 | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC1155 | +| _owner | address | 51 | 0 | 20 | BridgedERC1155 | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedERC1155 | +| _pendingOwner | address | 101 | 0 | 20 | BridgedERC1155 | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedERC1155 | +| addressManager | address | 151 | 0 | 20 | BridgedERC1155 | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedERC1155 | +| __reentry | uint8 | 201 | 0 | 1 | BridgedERC1155 | +| __paused | uint8 | 201 | 1 | 1 | BridgedERC1155 | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC1155 | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedERC1155 | +| __gap | uint256[50] | 251 | 0 | 1600 | BridgedERC1155 | +| _balances | mapping(uint256 => mapping(address => uint256)) | 301 | 0 | 32 | BridgedERC1155 | +| _operatorApprovals | mapping(address => mapping(address => bool)) | 302 | 0 | 32 | BridgedERC1155 | +| _uri | string | 303 | 0 | 32 | BridgedERC1155 | +| __gap | uint256[47] | 304 | 0 | 1504 | BridgedERC1155 | +| srcToken | address | 351 | 0 | 20 | BridgedERC1155 | +| srcChainId | uint256 | 352 | 0 | 32 | BridgedERC1155 | +| symbol | string | 353 | 0 | 32 | BridgedERC1155 | +| name | string | 354 | 0 | 32 | BridgedERC1155 | +| __gap | uint256[46] | 355 | 0 | 1472 | BridgedERC1155 | ## Bridge - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | --------------------------------------- | ---- | ------ | ----- | -------- | -| \_initialized | uint8 | 0 | 0 | 1 | Bridge | -| \_initializing | bool | 0 | 1 | 1 | Bridge | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | Bridge | -| \_owner | address | 51 | 0 | 20 | Bridge | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | Bridge | -| \_pendingOwner | address | 101 | 0 | 20 | Bridge | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | Bridge | -| addressManager | address | 151 | 0 | 20 | Bridge | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | Bridge | -| \_\_reentry | uint8 | 201 | 0 | 1 | Bridge | -| \_\_paused | uint8 | 201 | 1 | 1 | Bridge | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | Bridge | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | Bridge | -| \_\_reserved1 | uint64 | 251 | 0 | 8 | Bridge | -| nextMessageId | uint64 | 251 | 8 | 8 | Bridge | -| messageStatus | mapping(bytes32 => enum IBridge.Status) | 252 | 0 | 32 | Bridge | -| \_\_ctx | struct IBridge.Context | 253 | 0 | 64 | Bridge | -| \_\_reserved2 | uint256 | 255 | 0 | 32 | Bridge | -| \_\_reserved3 | uint256 | 256 | 0 | 32 | Bridge | -| \_\_gap | uint256[44] | 257 | 0 | 1408 | Bridge | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-----------------------------------------|------|--------|-------|-------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | Bridge | +| _initializing | bool | 0 | 1 | 1 | Bridge | +| __gap | uint256[50] | 1 | 0 | 1600 | Bridge | +| _owner | address | 51 | 0 | 20 | Bridge | +| __gap | uint256[49] | 52 | 0 | 1568 | Bridge | +| _pendingOwner | address | 101 | 0 | 20 | Bridge | +| __gap | uint256[49] | 102 | 0 | 1568 | Bridge | +| addressManager | address | 151 | 0 | 20 | Bridge | +| __gap | uint256[49] | 152 | 0 | 1568 | Bridge | +| __reentry | uint8 | 201 | 0 | 1 | Bridge | +| __paused | uint8 | 201 | 1 | 1 | Bridge | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | Bridge | +| __gap | uint256[49] | 202 | 0 | 1568 | Bridge | +| __reserved1 | uint64 | 251 | 0 | 8 | Bridge | +| nextMessageId | uint64 | 251 | 8 | 8 | Bridge | +| messageStatus | mapping(bytes32 => enum IBridge.Status) | 252 | 0 | 32 | Bridge | +| __ctx | struct IBridge.Context | 253 | 0 | 64 | Bridge | +| __reserved2 | uint256 | 255 | 0 | 32 | Bridge | +| __reserved3 | uint256 | 256 | 0 | 32 | Bridge | +| __gap | uint256[44] | 257 | 0 | 1408 | Bridge | ## QuotaManager - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | --------------------------------------------- | ---- | ------ | ----- | ------------ | -| \_initialized | uint8 | 0 | 0 | 1 | QuotaManager | -| \_initializing | bool | 0 | 1 | 1 | QuotaManager | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | QuotaManager | -| \_owner | address | 51 | 0 | 20 | QuotaManager | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | QuotaManager | -| \_pendingOwner | address | 101 | 0 | 20 | QuotaManager | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | QuotaManager | -| addressManager | address | 151 | 0 | 20 | QuotaManager | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | QuotaManager | -| \_\_reentry | uint8 | 201 | 0 | 1 | QuotaManager | -| \_\_paused | uint8 | 201 | 1 | 1 | QuotaManager | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | QuotaManager | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | QuotaManager | -| tokenQuota | mapping(address => struct QuotaManager.Quota) | 251 | 0 | 32 | QuotaManager | -| quotaPeriod | uint24 | 252 | 0 | 3 | QuotaManager | -| \_\_gap | uint256[48] | 253 | 0 | 1536 | QuotaManager | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-----------------------------------------------|------|--------|-------|-------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | QuotaManager | +| _initializing | bool | 0 | 1 | 1 | QuotaManager | +| __gap | uint256[50] | 1 | 0 | 1600 | QuotaManager | +| _owner | address | 51 | 0 | 20 | QuotaManager | +| __gap | uint256[49] | 52 | 0 | 1568 | QuotaManager | +| _pendingOwner | address | 101 | 0 | 20 | QuotaManager | +| __gap | uint256[49] | 102 | 0 | 1568 | QuotaManager | +| addressManager | address | 151 | 0 | 20 | QuotaManager | +| __gap | uint256[49] | 152 | 0 | 1568 | QuotaManager | +| __reentry | uint8 | 201 | 0 | 1 | QuotaManager | +| __paused | uint8 | 201 | 1 | 1 | QuotaManager | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | QuotaManager | +| __gap | uint256[49] | 202 | 0 | 1568 | QuotaManager | +| tokenQuota | mapping(address => struct QuotaManager.Quota) | 251 | 0 | 32 | QuotaManager | +| quotaPeriod | uint24 | 252 | 0 | 3 | QuotaManager | +| __gap | uint256[48] | 253 | 0 | 1536 | QuotaManager | ## AddressManager - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------------------------------------------- | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | AddressManager | -| \_initializing | bool | 0 | 1 | 1 | AddressManager | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | AddressManager | -| \_owner | address | 51 | 0 | 20 | AddressManager | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | AddressManager | -| \_pendingOwner | address | 101 | 0 | 20 | AddressManager | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | AddressManager | -| addressManager | address | 151 | 0 | 20 | AddressManager | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | AddressManager | -| \_\_reentry | uint8 | 201 | 0 | 1 | AddressManager | -| \_\_paused | uint8 | 201 | 1 | 1 | AddressManager | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | AddressManager | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | AddressManager | -| \_\_addresses | mapping(uint256 => mapping(bytes32 => address)) | 251 | 0 | 32 | AddressManager | -| \_\_gap | uint256[49] | 252 | 0 | 1568 | AddressManager | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------------------------------------------|------|--------|-------|-----------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | AddressManager | +| _initializing | bool | 0 | 1 | 1 | AddressManager | +| __gap | uint256[50] | 1 | 0 | 1600 | AddressManager | +| _owner | address | 51 | 0 | 20 | AddressManager | +| __gap | uint256[49] | 52 | 0 | 1568 | AddressManager | +| _pendingOwner | address | 101 | 0 | 20 | AddressManager | +| __gap | uint256[49] | 102 | 0 | 1568 | AddressManager | +| addressManager | address | 151 | 0 | 20 | AddressManager | +| __gap | uint256[49] | 152 | 0 | 1568 | AddressManager | +| __reentry | uint8 | 201 | 0 | 1 | AddressManager | +| __paused | uint8 | 201 | 1 | 1 | AddressManager | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | AddressManager | +| __gap | uint256[49] | 202 | 0 | 1568 | AddressManager | +| __addresses | mapping(uint256 => mapping(bytes32 => address)) | 251 | 0 | 32 | AddressManager | +| __gap | uint256[49] | 252 | 0 | 1568 | AddressManager | ## AddressResolver - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------- | ---- | ------ | ----- | --------------- | -| \_initialized | uint8 | 0 | 0 | 1 | AddressResolver | -| \_initializing | bool | 0 | 1 | 1 | AddressResolver | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|-------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | AddressResolver | +| _initializing | bool | 0 | 1 | 1 | AddressResolver | | addressManager | address | 0 | 2 | 20 | AddressResolver | -| \_\_gap | uint256[49] | 1 | 0 | 1568 | AddressResolver | +| __gap | uint256[49] | 1 | 0 | 1568 | AddressResolver | ## EssentialContract - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------- | ---- | ------ | ----- | ----------------- | -| \_initialized | uint8 | 0 | 0 | 1 | EssentialContract | -| \_initializing | bool | 0 | 1 | 1 | EssentialContract | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | EssentialContract | -| \_owner | address | 51 | 0 | 20 | EssentialContract | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | EssentialContract | -| \_pendingOwner | address | 101 | 0 | 20 | EssentialContract | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | EssentialContract | -| addressManager | address | 151 | 0 | 20 | EssentialContract | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | EssentialContract | -| \_\_reentry | uint8 | 201 | 0 | 1 | EssentialContract | -| \_\_paused | uint8 | 201 | 1 | 1 | EssentialContract | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | EssentialContract | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | EssentialContract | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------|------|--------|-------|-----------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | EssentialContract | +| _initializing | bool | 0 | 1 | 1 | EssentialContract | +| __gap | uint256[50] | 1 | 0 | 1600 | EssentialContract | +| _owner | address | 51 | 0 | 20 | EssentialContract | +| __gap | uint256[49] | 52 | 0 | 1568 | EssentialContract | +| _pendingOwner | address | 101 | 0 | 20 | EssentialContract | +| __gap | uint256[49] | 102 | 0 | 1568 | EssentialContract | +| addressManager | address | 151 | 0 | 20 | EssentialContract | +| __gap | uint256[49] | 152 | 0 | 1568 | EssentialContract | +| __reentry | uint8 | 201 | 0 | 1 | EssentialContract | +| __paused | uint8 | 201 | 1 | 1 | EssentialContract | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | EssentialContract | +| __gap | uint256[49] | 202 | 0 | 1568 | EssentialContract | ## SignalService - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | --------------------------------------------- | ---- | ------ | ----- | ------------- | -| \_initialized | uint8 | 0 | 0 | 1 | SignalService | -| \_initializing | bool | 0 | 1 | 1 | SignalService | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | SignalService | -| \_owner | address | 51 | 0 | 20 | SignalService | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | SignalService | -| \_pendingOwner | address | 101 | 0 | 20 | SignalService | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | SignalService | -| addressManager | address | 151 | 0 | 20 | SignalService | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | SignalService | -| \_\_reentry | uint8 | 201 | 0 | 1 | SignalService | -| \_\_paused | uint8 | 201 | 1 | 1 | SignalService | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | SignalService | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | SignalService | -| topBlockId | mapping(uint64 => mapping(bytes32 => uint64)) | 251 | 0 | 32 | SignalService | -| isAuthorized | mapping(address => bool) | 252 | 0 | 32 | SignalService | -| \_\_gap | uint256[48] | 253 | 0 | 1536 | SignalService | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-----------------------------------------------|------|--------|-------|---------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | SignalService | +| _initializing | bool | 0 | 1 | 1 | SignalService | +| __gap | uint256[50] | 1 | 0 | 1600 | SignalService | +| _owner | address | 51 | 0 | 20 | SignalService | +| __gap | uint256[49] | 52 | 0 | 1568 | SignalService | +| _pendingOwner | address | 101 | 0 | 20 | SignalService | +| __gap | uint256[49] | 102 | 0 | 1568 | SignalService | +| addressManager | address | 151 | 0 | 20 | SignalService | +| __gap | uint256[49] | 152 | 0 | 1568 | SignalService | +| __reentry | uint8 | 201 | 0 | 1 | SignalService | +| __paused | uint8 | 201 | 1 | 1 | SignalService | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | SignalService | +| __gap | uint256[49] | 202 | 0 | 1568 | SignalService | +| topBlockId | mapping(uint64 => mapping(bytes32 => uint64)) | 251 | 0 | 32 | SignalService | +| isAuthorized | mapping(address => bool) | 252 | 0 | 32 | SignalService | +| __gap | uint256[48] | 253 | 0 | 1536 | SignalService | ## TaikoToken - -| Name | Type | Slot | Offset | Bytes | Contract | -| ----------------------------------------------------- | ------------------------------------------------------------- | ---- | ------ | ----- | ---------- | -| \_initialized | uint8 | 0 | 0 | 1 | TaikoToken | -| \_initializing | bool | 0 | 1 | 1 | TaikoToken | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | TaikoToken | -| \_owner | address | 51 | 0 | 20 | TaikoToken | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | TaikoToken | -| \_pendingOwner | address | 101 | 0 | 20 | TaikoToken | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | TaikoToken | -| addressManager | address | 151 | 0 | 20 | TaikoToken | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | TaikoToken | -| \_\_reentry | uint8 | 201 | 0 | 1 | TaikoToken | -| \_\_paused | uint8 | 201 | 1 | 1 | TaikoToken | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | TaikoToken | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | TaikoToken | -| \_\_slots_previously_used_by_ERC20SnapshotUpgradeable | uint256[50] | 251 | 0 | 1600 | TaikoToken | -| \_balances | mapping(address => uint256) | 301 | 0 | 32 | TaikoToken | -| \_allowances | mapping(address => mapping(address => uint256)) | 302 | 0 | 32 | TaikoToken | -| \_totalSupply | uint256 | 303 | 0 | 32 | TaikoToken | -| \_name | string | 304 | 0 | 32 | TaikoToken | -| \_symbol | string | 305 | 0 | 32 | TaikoToken | -| \_\_gap | uint256[45] | 306 | 0 | 1440 | TaikoToken | -| \_hashedName | bytes32 | 351 | 0 | 32 | TaikoToken | -| \_hashedVersion | bytes32 | 352 | 0 | 32 | TaikoToken | -| \_name | string | 353 | 0 | 32 | TaikoToken | -| \_version | string | 354 | 0 | 32 | TaikoToken | -| \_\_gap | uint256[48] | 355 | 0 | 1536 | TaikoToken | -| \_nonces | mapping(address => struct CountersUpgradeable.Counter) | 403 | 0 | 32 | TaikoToken | -| \_PERMIT_TYPEHASH_DEPRECATED_SLOT | bytes32 | 404 | 0 | 32 | TaikoToken | -| \_\_gap | uint256[49] | 405 | 0 | 1568 | TaikoToken | -| \_delegates | mapping(address => address) | 454 | 0 | 32 | TaikoToken | -| \_checkpoints | mapping(address => struct ERC20VotesUpgradeable.Checkpoint[]) | 455 | 0 | 32 | TaikoToken | -| \_totalSupplyCheckpoints | struct ERC20VotesUpgradeable.Checkpoint[] | 456 | 0 | 32 | TaikoToken | -| \_\_gap | uint256[47] | 457 | 0 | 1504 | TaikoToken | -| \_\_gap | uint256[50] | 504 | 0 | 1600 | TaikoToken | +| Name | Type | Slot | Offset | Bytes | Contract | +|-----------------------------------------------------|---------------------------------------------------------------|------|--------|-------|--------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | TaikoToken | +| _initializing | bool | 0 | 1 | 1 | TaikoToken | +| __gap | uint256[50] | 1 | 0 | 1600 | TaikoToken | +| _owner | address | 51 | 0 | 20 | TaikoToken | +| __gap | uint256[49] | 52 | 0 | 1568 | TaikoToken | +| _pendingOwner | address | 101 | 0 | 20 | TaikoToken | +| __gap | uint256[49] | 102 | 0 | 1568 | TaikoToken | +| addressManager | address | 151 | 0 | 20 | TaikoToken | +| __gap | uint256[49] | 152 | 0 | 1568 | TaikoToken | +| __reentry | uint8 | 201 | 0 | 1 | TaikoToken | +| __paused | uint8 | 201 | 1 | 1 | TaikoToken | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | TaikoToken | +| __gap | uint256[49] | 202 | 0 | 1568 | TaikoToken | +| __slots_previously_used_by_ERC20SnapshotUpgradeable | uint256[50] | 251 | 0 | 1600 | TaikoToken | +| _balances | mapping(address => uint256) | 301 | 0 | 32 | TaikoToken | +| _allowances | mapping(address => mapping(address => uint256)) | 302 | 0 | 32 | TaikoToken | +| _totalSupply | uint256 | 303 | 0 | 32 | TaikoToken | +| _name | string | 304 | 0 | 32 | TaikoToken | +| _symbol | string | 305 | 0 | 32 | TaikoToken | +| __gap | uint256[45] | 306 | 0 | 1440 | TaikoToken | +| _hashedName | bytes32 | 351 | 0 | 32 | TaikoToken | +| _hashedVersion | bytes32 | 352 | 0 | 32 | TaikoToken | +| _name | string | 353 | 0 | 32 | TaikoToken | +| _version | string | 354 | 0 | 32 | TaikoToken | +| __gap | uint256[48] | 355 | 0 | 1536 | TaikoToken | +| _nonces | mapping(address => struct CountersUpgradeable.Counter) | 403 | 0 | 32 | TaikoToken | +| _PERMIT_TYPEHASH_DEPRECATED_SLOT | bytes32 | 404 | 0 | 32 | TaikoToken | +| __gap | uint256[49] | 405 | 0 | 1568 | TaikoToken | +| _delegates | mapping(address => address) | 454 | 0 | 32 | TaikoToken | +| _checkpoints | mapping(address => struct ERC20VotesUpgradeable.Checkpoint[]) | 455 | 0 | 32 | TaikoToken | +| _totalSupplyCheckpoints | struct ERC20VotesUpgradeable.Checkpoint[] | 456 | 0 | 32 | TaikoToken | +| __gap | uint256[47] | 457 | 0 | 1504 | TaikoToken | +| __gap | uint256[50] | 504 | 0 | 1600 | TaikoToken | ## ComposeVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------- | ---- | ------ | ----- | --------------- | -| \_initialized | uint8 | 0 | 0 | 1 | ComposeVerifier | -| \_initializing | bool | 0 | 1 | 1 | ComposeVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ComposeVerifier | -| \_owner | address | 51 | 0 | 20 | ComposeVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ComposeVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | ComposeVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ComposeVerifier | -| addressManager | address | 151 | 0 | 20 | ComposeVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ComposeVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | ComposeVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | ComposeVerifier | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | ComposeVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ComposeVerifier | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ComposeVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------|------|--------|-------|------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ComposeVerifier | +| _initializing | bool | 0 | 1 | 1 | ComposeVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | ComposeVerifier | +| _owner | address | 51 | 0 | 20 | ComposeVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | ComposeVerifier | +| _pendingOwner | address | 101 | 0 | 20 | ComposeVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | ComposeVerifier | +| addressManager | address | 151 | 0 | 20 | ComposeVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | ComposeVerifier | +| __reentry | uint8 | 201 | 0 | 1 | ComposeVerifier | +| __paused | uint8 | 201 | 1 | 1 | ComposeVerifier | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | ComposeVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | ComposeVerifier | +| __gap | uint256[50] | 251 | 0 | 1600 | ComposeVerifier | ## TeeAnyVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------- | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | TeeAnyVerifier | -| \_initializing | bool | 0 | 1 | 1 | TeeAnyVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | TeeAnyVerifier | -| \_owner | address | 51 | 0 | 20 | TeeAnyVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | TeeAnyVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | TeeAnyVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | TeeAnyVerifier | -| addressManager | address | 151 | 0 | 20 | TeeAnyVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | TeeAnyVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | TeeAnyVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | TeeAnyVerifier | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | TeeAnyVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | TeeAnyVerifier | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | TeeAnyVerifier | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | TeeAnyVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------|------|--------|-------|----------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | TeeAnyVerifier | +| _initializing | bool | 0 | 1 | 1 | TeeAnyVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | TeeAnyVerifier | +| _owner | address | 51 | 0 | 20 | TeeAnyVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | TeeAnyVerifier | +| _pendingOwner | address | 101 | 0 | 20 | TeeAnyVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | TeeAnyVerifier | +| addressManager | address | 151 | 0 | 20 | TeeAnyVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | TeeAnyVerifier | +| __reentry | uint8 | 201 | 0 | 1 | TeeAnyVerifier | +| __paused | uint8 | 201 | 1 | 1 | TeeAnyVerifier | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | TeeAnyVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | TeeAnyVerifier | +| __gap | uint256[50] | 251 | 0 | 1600 | TeeAnyVerifier | +| __gap | uint256[50] | 301 | 0 | 1600 | TeeAnyVerifier | ## ZkAndTeeVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------- | ---- | ------ | ----- | ---------------- | -| \_initialized | uint8 | 0 | 0 | 1 | ZkAndTeeVerifier | -| \_initializing | bool | 0 | 1 | 1 | ZkAndTeeVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ZkAndTeeVerifier | -| \_owner | address | 51 | 0 | 20 | ZkAndTeeVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ZkAndTeeVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | ZkAndTeeVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ZkAndTeeVerifier | -| addressManager | address | 151 | 0 | 20 | ZkAndTeeVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ZkAndTeeVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | ZkAndTeeVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | ZkAndTeeVerifier | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | ZkAndTeeVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ZkAndTeeVerifier | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ZkAndTeeVerifier | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | ZkAndTeeVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------|------|--------|-------|--------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ZkAndTeeVerifier | +| _initializing | bool | 0 | 1 | 1 | ZkAndTeeVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | ZkAndTeeVerifier | +| _owner | address | 51 | 0 | 20 | ZkAndTeeVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | ZkAndTeeVerifier | +| _pendingOwner | address | 101 | 0 | 20 | ZkAndTeeVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | ZkAndTeeVerifier | +| addressManager | address | 151 | 0 | 20 | ZkAndTeeVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | ZkAndTeeVerifier | +| __reentry | uint8 | 201 | 0 | 1 | ZkAndTeeVerifier | +| __paused | uint8 | 201 | 1 | 1 | ZkAndTeeVerifier | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | ZkAndTeeVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | ZkAndTeeVerifier | +| __gap | uint256[50] | 251 | 0 | 1600 | ZkAndTeeVerifier | +| __gap | uint256[50] | 301 | 0 | 1600 | ZkAndTeeVerifier | ## ZkAnyVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------- | ---- | ------ | ----- | ------------- | -| \_initialized | uint8 | 0 | 0 | 1 | ZkAnyVerifier | -| \_initializing | bool | 0 | 1 | 1 | ZkAnyVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ZkAnyVerifier | -| \_owner | address | 51 | 0 | 20 | ZkAnyVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ZkAnyVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | ZkAnyVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ZkAnyVerifier | -| addressManager | address | 151 | 0 | 20 | ZkAnyVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ZkAnyVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | ZkAnyVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | ZkAnyVerifier | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | ZkAnyVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ZkAnyVerifier | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ZkAnyVerifier | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | ZkAnyVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------|------|--------|-------|--------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ZkAnyVerifier | +| _initializing | bool | 0 | 1 | 1 | ZkAnyVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | ZkAnyVerifier | +| _owner | address | 51 | 0 | 20 | ZkAnyVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | ZkAnyVerifier | +| _pendingOwner | address | 101 | 0 | 20 | ZkAnyVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | ZkAnyVerifier | +| addressManager | address | 151 | 0 | 20 | ZkAnyVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | ZkAnyVerifier | +| __reentry | uint8 | 201 | 0 | 1 | ZkAnyVerifier | +| __paused | uint8 | 201 | 1 | 1 | ZkAnyVerifier | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | ZkAnyVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | ZkAnyVerifier | +| __gap | uint256[50] | 251 | 0 | 1600 | ZkAnyVerifier | +| __gap | uint256[50] | 301 | 0 | 1600 | ZkAnyVerifier | ## Risc0Verifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ------------------------ | ---- | ------ | ----- | ------------- | -| \_initialized | uint8 | 0 | 0 | 1 | Risc0Verifier | -| \_initializing | bool | 0 | 1 | 1 | Risc0Verifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | Risc0Verifier | -| \_owner | address | 51 | 0 | 20 | Risc0Verifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | Risc0Verifier | -| \_pendingOwner | address | 101 | 0 | 20 | Risc0Verifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | Risc0Verifier | -| addressManager | address | 151 | 0 | 20 | Risc0Verifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | Risc0Verifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | Risc0Verifier | -| \_\_paused | uint8 | 201 | 1 | 1 | Risc0Verifier | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | Risc0Verifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | Risc0Verifier | -| isImageTrusted | mapping(bytes32 => bool) | 251 | 0 | 32 | Risc0Verifier | -| \_\_gap | uint256[49] | 252 | 0 | 1568 | Risc0Verifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|--------------------------|------|--------|-------|------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | Risc0Verifier | +| _initializing | bool | 0 | 1 | 1 | Risc0Verifier | +| __gap | uint256[50] | 1 | 0 | 1600 | Risc0Verifier | +| _owner | address | 51 | 0 | 20 | Risc0Verifier | +| __gap | uint256[49] | 52 | 0 | 1568 | Risc0Verifier | +| _pendingOwner | address | 101 | 0 | 20 | Risc0Verifier | +| __gap | uint256[49] | 102 | 0 | 1568 | Risc0Verifier | +| addressManager | address | 151 | 0 | 20 | Risc0Verifier | +| __gap | uint256[49] | 152 | 0 | 1568 | Risc0Verifier | +| __reentry | uint8 | 201 | 0 | 1 | Risc0Verifier | +| __paused | uint8 | 201 | 1 | 1 | Risc0Verifier | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | Risc0Verifier | +| __gap | uint256[49] | 202 | 0 | 1568 | Risc0Verifier | +| isImageTrusted | mapping(bytes32 => bool) | 251 | 0 | 32 | Risc0Verifier | +| __gap | uint256[49] | 252 | 0 | 1568 | Risc0Verifier | ## SP1Verifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ------------------------ | ---- | ------ | ----- | ----------- | -| \_initialized | uint8 | 0 | 0 | 1 | SP1Verifier | -| \_initializing | bool | 0 | 1 | 1 | SP1Verifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | SP1Verifier | -| \_owner | address | 51 | 0 | 20 | SP1Verifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | SP1Verifier | -| \_pendingOwner | address | 101 | 0 | 20 | SP1Verifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | SP1Verifier | -| addressManager | address | 151 | 0 | 20 | SP1Verifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | SP1Verifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | SP1Verifier | -| \_\_paused | uint8 | 201 | 1 | 1 | SP1Verifier | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | SP1Verifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | SP1Verifier | -| isProgramTrusted | mapping(bytes32 => bool) | 251 | 0 | 32 | SP1Verifier | -| \_\_gap | uint256[49] | 252 | 0 | 1568 | SP1Verifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|--------------------------|------|--------|-------|--------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | SP1Verifier | +| _initializing | bool | 0 | 1 | 1 | SP1Verifier | +| __gap | uint256[50] | 1 | 0 | 1600 | SP1Verifier | +| _owner | address | 51 | 0 | 20 | SP1Verifier | +| __gap | uint256[49] | 52 | 0 | 1568 | SP1Verifier | +| _pendingOwner | address | 101 | 0 | 20 | SP1Verifier | +| __gap | uint256[49] | 102 | 0 | 1568 | SP1Verifier | +| addressManager | address | 151 | 0 | 20 | SP1Verifier | +| __gap | uint256[49] | 152 | 0 | 1568 | SP1Verifier | +| __reentry | uint8 | 201 | 0 | 1 | SP1Verifier | +| __paused | uint8 | 201 | 1 | 1 | SP1Verifier | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | SP1Verifier | +| __gap | uint256[49] | 202 | 0 | 1568 | SP1Verifier | +| isProgramTrusted | mapping(bytes32 => bool) | 251 | 0 | 32 | SP1Verifier | +| __gap | uint256[49] | 252 | 0 | 1568 | SP1Verifier | ## SgxVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------------------------------------------- | ---- | ------ | ----- | ----------- | -| \_initialized | uint8 | 0 | 0 | 1 | SgxVerifier | -| \_initializing | bool | 0 | 1 | 1 | SgxVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | SgxVerifier | -| \_owner | address | 51 | 0 | 20 | SgxVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | SgxVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | SgxVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | SgxVerifier | -| addressManager | address | 151 | 0 | 20 | SgxVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | SgxVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | SgxVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | SgxVerifier | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | SgxVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | SgxVerifier | -| nextInstanceId | uint256 | 251 | 0 | 32 | SgxVerifier | -| instances | mapping(uint256 => struct SgxVerifier.Instance) | 252 | 0 | 32 | SgxVerifier | -| addressRegistered | mapping(address => bool) | 253 | 0 | 32 | SgxVerifier | -| \_\_gap | uint256[47] | 254 | 0 | 1504 | SgxVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|-------------------|-------------------------------------------------|------|--------|-------|--------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | SgxVerifier | +| _initializing | bool | 0 | 1 | 1 | SgxVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | SgxVerifier | +| _owner | address | 51 | 0 | 20 | SgxVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | SgxVerifier | +| _pendingOwner | address | 101 | 0 | 20 | SgxVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | SgxVerifier | +| addressManager | address | 151 | 0 | 20 | SgxVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | SgxVerifier | +| __reentry | uint8 | 201 | 0 | 1 | SgxVerifier | +| __paused | uint8 | 201 | 1 | 1 | SgxVerifier | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | SgxVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | SgxVerifier | +| nextInstanceId | uint256 | 251 | 0 | 32 | SgxVerifier | +| instances | mapping(uint256 => struct SgxVerifier.Instance) | 252 | 0 | 32 | SgxVerifier | +| addressRegistered | mapping(address => bool) | 253 | 0 | 32 | SgxVerifier | +| __gap | uint256[47] | 254 | 0 | 1504 | SgxVerifier | ## AutomataDcapV3Attestation - -| Name | Type | Slot | Offset | Bytes | Contract | -| ----------------------- | ----------------------------------------------- | ---- | ------ | ----- | ------------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | AutomataDcapV3Attestation | -| \_initializing | bool | 0 | 1 | 1 | AutomataDcapV3Attestation | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | AutomataDcapV3Attestation | -| \_owner | address | 51 | 0 | 20 | AutomataDcapV3Attestation | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | AutomataDcapV3Attestation | -| \_pendingOwner | address | 101 | 0 | 20 | AutomataDcapV3Attestation | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | AutomataDcapV3Attestation | +| Name | Type | Slot | Offset | Bytes | Contract | +|-------------------------|-------------------------------------------------|------|--------|-------|-----------------------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | AutomataDcapV3Attestation | +| _initializing | bool | 0 | 1 | 1 | AutomataDcapV3Attestation | +| __gap | uint256[50] | 1 | 0 | 1600 | AutomataDcapV3Attestation | +| _owner | address | 51 | 0 | 20 | AutomataDcapV3Attestation | +| __gap | uint256[49] | 52 | 0 | 1568 | AutomataDcapV3Attestation | +| _pendingOwner | address | 101 | 0 | 20 | AutomataDcapV3Attestation | +| __gap | uint256[49] | 102 | 0 | 1568 | AutomataDcapV3Attestation | | addressManager | address | 151 | 0 | 20 | AutomataDcapV3Attestation | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | AutomataDcapV3Attestation | -| \_\_reentry | uint8 | 201 | 0 | 1 | AutomataDcapV3Attestation | -| \_\_paused | uint8 | 201 | 1 | 1 | AutomataDcapV3Attestation | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | AutomataDcapV3Attestation | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | AutomataDcapV3Attestation | +| __gap | uint256[49] | 152 | 0 | 1568 | AutomataDcapV3Attestation | +| __reentry | uint8 | 201 | 0 | 1 | AutomataDcapV3Attestation | +| __paused | uint8 | 201 | 1 | 1 | AutomataDcapV3Attestation | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | AutomataDcapV3Attestation | +| __gap | uint256[49] | 202 | 0 | 1568 | AutomataDcapV3Attestation | | sigVerifyLib | contract ISigVerifyLib | 251 | 0 | 20 | AutomataDcapV3Attestation | | pemCertLib | contract IPEMCertChainLib | 252 | 0 | 20 | AutomataDcapV3Attestation | | checkLocalEnclaveReport | bool | 252 | 20 | 1 | AutomataDcapV3Attestation | @@ -512,345 +490,326 @@ | serialNumIsRevoked | mapping(uint256 => mapping(bytes => bool)) | 255 | 0 | 32 | AutomataDcapV3Attestation | | tcbInfo | mapping(string => struct TCBInfoStruct.TCBInfo) | 256 | 0 | 32 | AutomataDcapV3Attestation | | qeIdentity | struct EnclaveIdStruct.EnclaveId | 257 | 0 | 128 | AutomataDcapV3Attestation | -| \_\_gap | uint256[39] | 261 | 0 | 1248 | AutomataDcapV3Attestation | +| __gap | uint256[39] | 261 | 0 | 1248 | AutomataDcapV3Attestation | ## TaikoL1 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------- | ---- | ------ | ----- | -------- | -| \_initialized | uint8 | 0 | 0 | 1 | TaikoL1 | -| \_initializing | bool | 0 | 1 | 1 | TaikoL1 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | TaikoL1 | -| \_owner | address | 51 | 0 | 20 | TaikoL1 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | TaikoL1 | -| \_pendingOwner | address | 101 | 0 | 20 | TaikoL1 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | TaikoL1 | -| addressManager | address | 151 | 0 | 20 | TaikoL1 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | TaikoL1 | -| \_\_reentry | uint8 | 201 | 0 | 1 | TaikoL1 | -| \_\_paused | uint8 | 201 | 1 | 1 | TaikoL1 | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | TaikoL1 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | TaikoL1 | -| state | struct TaikoData.State | 251 | 0 | 1600 | TaikoL1 | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | TaikoL1 | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|------------------------|------|--------|-------|--------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | TaikoL1 | +| _initializing | bool | 0 | 1 | 1 | TaikoL1 | +| __gap | uint256[50] | 1 | 0 | 1600 | TaikoL1 | +| _owner | address | 51 | 0 | 20 | TaikoL1 | +| __gap | uint256[49] | 52 | 0 | 1568 | TaikoL1 | +| _pendingOwner | address | 101 | 0 | 20 | TaikoL1 | +| __gap | uint256[49] | 102 | 0 | 1568 | TaikoL1 | +| addressManager | address | 151 | 0 | 20 | TaikoL1 | +| __gap | uint256[49] | 152 | 0 | 1568 | TaikoL1 | +| __reentry | uint8 | 201 | 0 | 1 | TaikoL1 | +| __paused | uint8 | 201 | 1 | 1 | TaikoL1 | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | TaikoL1 | +| __gap | uint256[49] | 202 | 0 | 1568 | TaikoL1 | +| state | struct TaikoData.State | 251 | 0 | 1600 | TaikoL1 | +| __gap | uint256[50] | 301 | 0 | 1600 | TaikoL1 | ## HeklaTaikoL1 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------- | ---- | ------ | ----- | ------------ | -| \_initialized | uint8 | 0 | 0 | 1 | HeklaTaikoL1 | -| \_initializing | bool | 0 | 1 | 1 | HeklaTaikoL1 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | HeklaTaikoL1 | -| \_owner | address | 51 | 0 | 20 | HeklaTaikoL1 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | HeklaTaikoL1 | -| \_pendingOwner | address | 101 | 0 | 20 | HeklaTaikoL1 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | HeklaTaikoL1 | -| addressManager | address | 151 | 0 | 20 | HeklaTaikoL1 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | HeklaTaikoL1 | -| \_\_reentry | uint8 | 201 | 0 | 1 | HeklaTaikoL1 | -| \_\_paused | uint8 | 201 | 1 | 1 | HeklaTaikoL1 | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | HeklaTaikoL1 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | HeklaTaikoL1 | -| state | struct TaikoData.State | 251 | 0 | 1600 | HeklaTaikoL1 | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | HeklaTaikoL1 | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|------------------------|------|--------|-------|------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | HeklaTaikoL1 | +| _initializing | bool | 0 | 1 | 1 | HeklaTaikoL1 | +| __gap | uint256[50] | 1 | 0 | 1600 | HeklaTaikoL1 | +| _owner | address | 51 | 0 | 20 | HeklaTaikoL1 | +| __gap | uint256[49] | 52 | 0 | 1568 | HeklaTaikoL1 | +| _pendingOwner | address | 101 | 0 | 20 | HeklaTaikoL1 | +| __gap | uint256[49] | 102 | 0 | 1568 | HeklaTaikoL1 | +| addressManager | address | 151 | 0 | 20 | HeklaTaikoL1 | +| __gap | uint256[49] | 152 | 0 | 1568 | HeklaTaikoL1 | +| __reentry | uint8 | 201 | 0 | 1 | HeklaTaikoL1 | +| __paused | uint8 | 201 | 1 | 1 | HeklaTaikoL1 | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | HeklaTaikoL1 | +| __gap | uint256[49] | 202 | 0 | 1568 | HeklaTaikoL1 | +| state | struct TaikoData.State | 251 | 0 | 1600 | HeklaTaikoL1 | +| __gap | uint256[50] | 301 | 0 | 1600 | HeklaTaikoL1 | ## HeklaTierRouter - | Name | Type | Slot | Offset | Bytes | Contract | -| ---- | ---- | ---- | ------ | ----- | -------- | +|------|------|------|--------|-------|----------| ## MainnetBridge - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | --------------------------------------- | ---- | ------ | ----- | ------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetBridge | -| \_initializing | bool | 0 | 1 | 1 | MainnetBridge | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetBridge | -| \_owner | address | 51 | 0 | 20 | MainnetBridge | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetBridge | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetBridge | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetBridge | -| addressManager | address | 151 | 0 | 20 | MainnetBridge | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetBridge | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetBridge | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetBridge | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetBridge | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetBridge | -| \_\_reserved1 | uint64 | 251 | 0 | 8 | MainnetBridge | -| nextMessageId | uint64 | 251 | 8 | 8 | MainnetBridge | -| messageStatus | mapping(bytes32 => enum IBridge.Status) | 252 | 0 | 32 | MainnetBridge | -| \_\_ctx | struct IBridge.Context | 253 | 0 | 64 | MainnetBridge | -| \_\_reserved2 | uint256 | 255 | 0 | 32 | MainnetBridge | -| \_\_reserved3 | uint256 | 256 | 0 | 32 | MainnetBridge | -| \_\_gap | uint256[44] | 257 | 0 | 1408 | MainnetBridge | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-----------------------------------------|------|--------|-------|----------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetBridge | +| _initializing | bool | 0 | 1 | 1 | MainnetBridge | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetBridge | +| _owner | address | 51 | 0 | 20 | MainnetBridge | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetBridge | +| _pendingOwner | address | 101 | 0 | 20 | MainnetBridge | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetBridge | +| addressManager | address | 151 | 0 | 20 | MainnetBridge | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetBridge | +| __reentry | uint8 | 201 | 0 | 1 | MainnetBridge | +| __paused | uint8 | 201 | 1 | 1 | MainnetBridge | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetBridge | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetBridge | +| __reserved1 | uint64 | 251 | 0 | 8 | MainnetBridge | +| nextMessageId | uint64 | 251 | 8 | 8 | MainnetBridge | +| messageStatus | mapping(bytes32 => enum IBridge.Status) | 252 | 0 | 32 | MainnetBridge | +| __ctx | struct IBridge.Context | 253 | 0 | 64 | MainnetBridge | +| __reserved2 | uint256 | 255 | 0 | 32 | MainnetBridge | +| __reserved3 | uint256 | 256 | 0 | 32 | MainnetBridge | +| __gap | uint256[44] | 257 | 0 | 1408 | MainnetBridge | ## MainnetSignalService - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | --------------------------------------------- | ---- | ------ | ----- | -------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetSignalService | -| \_initializing | bool | 0 | 1 | 1 | MainnetSignalService | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetSignalService | -| \_owner | address | 51 | 0 | 20 | MainnetSignalService | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetSignalService | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetSignalService | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetSignalService | -| addressManager | address | 151 | 0 | 20 | MainnetSignalService | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetSignalService | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetSignalService | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetSignalService | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetSignalService | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetSignalService | -| topBlockId | mapping(uint64 => mapping(bytes32 => uint64)) | 251 | 0 | 32 | MainnetSignalService | -| isAuthorized | mapping(address => bool) | 252 | 0 | 32 | MainnetSignalService | -| \_\_gap | uint256[48] | 253 | 0 | 1536 | MainnetSignalService | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-----------------------------------------------|------|--------|-------|------------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetSignalService | +| _initializing | bool | 0 | 1 | 1 | MainnetSignalService | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetSignalService | +| _owner | address | 51 | 0 | 20 | MainnetSignalService | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetSignalService | +| _pendingOwner | address | 101 | 0 | 20 | MainnetSignalService | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetSignalService | +| addressManager | address | 151 | 0 | 20 | MainnetSignalService | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetSignalService | +| __reentry | uint8 | 201 | 0 | 1 | MainnetSignalService | +| __paused | uint8 | 201 | 1 | 1 | MainnetSignalService | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetSignalService | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetSignalService | +| topBlockId | mapping(uint64 => mapping(bytes32 => uint64)) | 251 | 0 | 32 | MainnetSignalService | +| isAuthorized | mapping(address => bool) | 252 | 0 | 32 | MainnetSignalService | +| __gap | uint256[48] | 253 | 0 | 1536 | MainnetSignalService | ## MainnetERC20Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ----------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetERC20Vault | -| \_initializing | bool | 0 | 1 | 1 | MainnetERC20Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetERC20Vault | -| \_owner | address | 51 | 0 | 20 | MainnetERC20Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetERC20Vault | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetERC20Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetERC20Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetERC20Vault | +| _initializing | bool | 0 | 1 | 1 | MainnetERC20Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetERC20Vault | +| _owner | address | 51 | 0 | 20 | MainnetERC20Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetERC20Vault | +| _pendingOwner | address | 101 | 0 | 20 | MainnetERC20Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetERC20Vault | | addressManager | address | 151 | 0 | 20 | MainnetERC20Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetERC20Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetERC20Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetERC20Vault | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetERC20Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetERC20Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | MainnetERC20Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetERC20Vault | +| __reentry | uint8 | 201 | 0 | 1 | MainnetERC20Vault | +| __paused | uint8 | 201 | 1 | 1 | MainnetERC20Vault | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetERC20Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetERC20Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | MainnetERC20Vault | | bridgedToCanonical | mapping(address => struct ERC20Vault.CanonicalERC20) | 301 | 0 | 32 | MainnetERC20Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | MainnetERC20Vault | | btokenDenylist | mapping(address => bool) | 303 | 0 | 32 | MainnetERC20Vault | | lastMigrationStart | mapping(uint256 => mapping(address => uint256)) | 304 | 0 | 32 | MainnetERC20Vault | -| \_\_gap | uint256[46] | 305 | 0 | 1472 | MainnetERC20Vault | +| __gap | uint256[46] | 305 | 0 | 1472 | MainnetERC20Vault | ## MainnetERC1155Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetERC1155Vault | -| \_initializing | bool | 0 | 1 | 1 | MainnetERC1155Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetERC1155Vault | -| \_owner | address | 51 | 0 | 20 | MainnetERC1155Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetERC1155Vault | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetERC1155Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetERC1155Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|----------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetERC1155Vault | +| _initializing | bool | 0 | 1 | 1 | MainnetERC1155Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetERC1155Vault | +| _owner | address | 51 | 0 | 20 | MainnetERC1155Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetERC1155Vault | +| _pendingOwner | address | 101 | 0 | 20 | MainnetERC1155Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetERC1155Vault | | addressManager | address | 151 | 0 | 20 | MainnetERC1155Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetERC1155Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetERC1155Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetERC1155Vault | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetERC1155Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetERC1155Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | MainnetERC1155Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetERC1155Vault | +| __reentry | uint8 | 201 | 0 | 1 | MainnetERC1155Vault | +| __paused | uint8 | 201 | 1 | 1 | MainnetERC1155Vault | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetERC1155Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetERC1155Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | MainnetERC1155Vault | | bridgedToCanonical | mapping(address => struct BaseNFTVault.CanonicalNFT) | 301 | 0 | 32 | MainnetERC1155Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | MainnetERC1155Vault | -| \_\_gap | uint256[48] | 303 | 0 | 1536 | MainnetERC1155Vault | -| \_\_gap | uint256[50] | 351 | 0 | 1600 | MainnetERC1155Vault | -| \_\_gap | uint256[50] | 401 | 0 | 1600 | MainnetERC1155Vault | -| \_\_gap | uint256[50] | 451 | 0 | 1600 | MainnetERC1155Vault | +| __gap | uint256[48] | 303 | 0 | 1536 | MainnetERC1155Vault | +| __gap | uint256[50] | 351 | 0 | 1600 | MainnetERC1155Vault | +| __gap | uint256[50] | 401 | 0 | 1600 | MainnetERC1155Vault | +| __gap | uint256[50] | 451 | 0 | 1600 | MainnetERC1155Vault | ## MainnetERC721Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ------------------ | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetERC721Vault | -| \_initializing | bool | 0 | 1 | 1 | MainnetERC721Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetERC721Vault | -| \_owner | address | 51 | 0 | 20 | MainnetERC721Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetERC721Vault | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetERC721Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetERC721Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|--------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetERC721Vault | +| _initializing | bool | 0 | 1 | 1 | MainnetERC721Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetERC721Vault | +| _owner | address | 51 | 0 | 20 | MainnetERC721Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetERC721Vault | +| _pendingOwner | address | 101 | 0 | 20 | MainnetERC721Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetERC721Vault | | addressManager | address | 151 | 0 | 20 | MainnetERC721Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetERC721Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetERC721Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetERC721Vault | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetERC721Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetERC721Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | MainnetERC721Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetERC721Vault | +| __reentry | uint8 | 201 | 0 | 1 | MainnetERC721Vault | +| __paused | uint8 | 201 | 1 | 1 | MainnetERC721Vault | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetERC721Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetERC721Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | MainnetERC721Vault | | bridgedToCanonical | mapping(address => struct BaseNFTVault.CanonicalNFT) | 301 | 0 | 32 | MainnetERC721Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | MainnetERC721Vault | -| \_\_gap | uint256[48] | 303 | 0 | 1536 | MainnetERC721Vault | -| \_\_gap | uint256[50] | 351 | 0 | 1600 | MainnetERC721Vault | +| __gap | uint256[48] | 303 | 0 | 1536 | MainnetERC721Vault | +| __gap | uint256[50] | 351 | 0 | 1600 | MainnetERC721Vault | ## MainnetSharedAddressManager - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------------------------------------------- | ---- | ------ | ----- | --------------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetSharedAddressManager | -| \_initializing | bool | 0 | 1 | 1 | MainnetSharedAddressManager | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetSharedAddressManager | -| \_owner | address | 51 | 0 | 20 | MainnetSharedAddressManager | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetSharedAddressManager | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetSharedAddressManager | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetSharedAddressManager | -| addressManager | address | 151 | 0 | 20 | MainnetSharedAddressManager | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetSharedAddressManager | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetSharedAddressManager | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetSharedAddressManager | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetSharedAddressManager | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetSharedAddressManager | -| \_\_addresses | mapping(uint256 => mapping(bytes32 => address)) | 251 | 0 | 32 | MainnetSharedAddressManager | -| \_\_gap | uint256[49] | 252 | 0 | 1568 | MainnetSharedAddressManager | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------------------------------------------|------|--------|-------|--------------------------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetSharedAddressManager | +| _initializing | bool | 0 | 1 | 1 | MainnetSharedAddressManager | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetSharedAddressManager | +| _owner | address | 51 | 0 | 20 | MainnetSharedAddressManager | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetSharedAddressManager | +| _pendingOwner | address | 101 | 0 | 20 | MainnetSharedAddressManager | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetSharedAddressManager | +| addressManager | address | 151 | 0 | 20 | MainnetSharedAddressManager | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetSharedAddressManager | +| __reentry | uint8 | 201 | 0 | 1 | MainnetSharedAddressManager | +| __paused | uint8 | 201 | 1 | 1 | MainnetSharedAddressManager | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetSharedAddressManager | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetSharedAddressManager | +| __addresses | mapping(uint256 => mapping(bytes32 => address)) | 251 | 0 | 32 | MainnetSharedAddressManager | +| __gap | uint256[49] | 252 | 0 | 1568 | MainnetSharedAddressManager | ## RollupAddressCache - | Name | Type | Slot | Offset | Bytes | Contract | -| ---- | ---- | ---- | ------ | ----- | -------- | +|------|------|------|--------|-------|----------| ## SharedAddressCache - | Name | Type | Slot | Offset | Bytes | Contract | -| ---- | ---- | ---- | ------ | ----- | -------- | +|------|------|------|--------|-------|----------| ## AddressCache - | Name | Type | Slot | Offset | Bytes | Contract | -| ---- | ---- | ---- | ------ | ----- | -------- | +|------|------|------|--------|-------|----------| ## MainnetSgxVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------------------------------------------- | ---- | ------ | ----- | ------------------ | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetSgxVerifier | -| \_initializing | bool | 0 | 1 | 1 | MainnetSgxVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetSgxVerifier | -| \_owner | address | 51 | 0 | 20 | MainnetSgxVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetSgxVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetSgxVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetSgxVerifier | -| addressManager | address | 151 | 0 | 20 | MainnetSgxVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetSgxVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetSgxVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetSgxVerifier | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetSgxVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetSgxVerifier | -| nextInstanceId | uint256 | 251 | 0 | 32 | MainnetSgxVerifier | -| instances | mapping(uint256 => struct SgxVerifier.Instance) | 252 | 0 | 32 | MainnetSgxVerifier | -| addressRegistered | mapping(address => bool) | 253 | 0 | 32 | MainnetSgxVerifier | -| \_\_gap | uint256[47] | 254 | 0 | 1504 | MainnetSgxVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|-------------------|-------------------------------------------------|------|--------|-------|-------------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetSgxVerifier | +| _initializing | bool | 0 | 1 | 1 | MainnetSgxVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetSgxVerifier | +| _owner | address | 51 | 0 | 20 | MainnetSgxVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetSgxVerifier | +| _pendingOwner | address | 101 | 0 | 20 | MainnetSgxVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetSgxVerifier | +| addressManager | address | 151 | 0 | 20 | MainnetSgxVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetSgxVerifier | +| __reentry | uint8 | 201 | 0 | 1 | MainnetSgxVerifier | +| __paused | uint8 | 201 | 1 | 1 | MainnetSgxVerifier | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetSgxVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetSgxVerifier | +| nextInstanceId | uint256 | 251 | 0 | 32 | MainnetSgxVerifier | +| instances | mapping(uint256 => struct SgxVerifier.Instance) | 252 | 0 | 32 | MainnetSgxVerifier | +| addressRegistered | mapping(address => bool) | 253 | 0 | 32 | MainnetSgxVerifier | +| __gap | uint256[47] | 254 | 0 | 1504 | MainnetSgxVerifier | ## MainnetSP1Verifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ------------------------ | ---- | ------ | ----- | ------------------ | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetSP1Verifier | -| \_initializing | bool | 0 | 1 | 1 | MainnetSP1Verifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetSP1Verifier | -| \_owner | address | 51 | 0 | 20 | MainnetSP1Verifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetSP1Verifier | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetSP1Verifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetSP1Verifier | -| addressManager | address | 151 | 0 | 20 | MainnetSP1Verifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetSP1Verifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetSP1Verifier | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetSP1Verifier | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetSP1Verifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetSP1Verifier | -| isProgramTrusted | mapping(bytes32 => bool) | 251 | 0 | 32 | MainnetSP1Verifier | -| \_\_gap | uint256[49] | 252 | 0 | 1568 | MainnetSP1Verifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|--------------------------|------|--------|-------|-------------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetSP1Verifier | +| _initializing | bool | 0 | 1 | 1 | MainnetSP1Verifier | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetSP1Verifier | +| _owner | address | 51 | 0 | 20 | MainnetSP1Verifier | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetSP1Verifier | +| _pendingOwner | address | 101 | 0 | 20 | MainnetSP1Verifier | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetSP1Verifier | +| addressManager | address | 151 | 0 | 20 | MainnetSP1Verifier | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetSP1Verifier | +| __reentry | uint8 | 201 | 0 | 1 | MainnetSP1Verifier | +| __paused | uint8 | 201 | 1 | 1 | MainnetSP1Verifier | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetSP1Verifier | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetSP1Verifier | +| isProgramTrusted | mapping(bytes32 => bool) | 251 | 0 | 32 | MainnetSP1Verifier | +| __gap | uint256[49] | 252 | 0 | 1568 | MainnetSP1Verifier | ## MainnetZkAnyVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------- | ---- | ------ | ----- | -------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetZkAnyVerifier | -| \_initializing | bool | 0 | 1 | 1 | MainnetZkAnyVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetZkAnyVerifier | -| \_owner | address | 51 | 0 | 20 | MainnetZkAnyVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetZkAnyVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetZkAnyVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetZkAnyVerifier | -| addressManager | address | 151 | 0 | 20 | MainnetZkAnyVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetZkAnyVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetZkAnyVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetZkAnyVerifier | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetZkAnyVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetZkAnyVerifier | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | MainnetZkAnyVerifier | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | MainnetZkAnyVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------|------|--------|-------|-----------------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetZkAnyVerifier | +| _initializing | bool | 0 | 1 | 1 | MainnetZkAnyVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetZkAnyVerifier | +| _owner | address | 51 | 0 | 20 | MainnetZkAnyVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetZkAnyVerifier | +| _pendingOwner | address | 101 | 0 | 20 | MainnetZkAnyVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetZkAnyVerifier | +| addressManager | address | 151 | 0 | 20 | MainnetZkAnyVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetZkAnyVerifier | +| __reentry | uint8 | 201 | 0 | 1 | MainnetZkAnyVerifier | +| __paused | uint8 | 201 | 1 | 1 | MainnetZkAnyVerifier | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetZkAnyVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetZkAnyVerifier | +| __gap | uint256[50] | 251 | 0 | 1600 | MainnetZkAnyVerifier | +| __gap | uint256[50] | 301 | 0 | 1600 | MainnetZkAnyVerifier | ## MainnetRisc0Verifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ------------------------ | ---- | ------ | ----- | -------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetRisc0Verifier | -| \_initializing | bool | 0 | 1 | 1 | MainnetRisc0Verifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetRisc0Verifier | -| \_owner | address | 51 | 0 | 20 | MainnetRisc0Verifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetRisc0Verifier | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetRisc0Verifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetRisc0Verifier | -| addressManager | address | 151 | 0 | 20 | MainnetRisc0Verifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetRisc0Verifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetRisc0Verifier | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetRisc0Verifier | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetRisc0Verifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetRisc0Verifier | -| isImageTrusted | mapping(bytes32 => bool) | 251 | 0 | 32 | MainnetRisc0Verifier | -| \_\_gap | uint256[49] | 252 | 0 | 1568 | MainnetRisc0Verifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|--------------------------|------|--------|-------|-----------------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetRisc0Verifier | +| _initializing | bool | 0 | 1 | 1 | MainnetRisc0Verifier | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetRisc0Verifier | +| _owner | address | 51 | 0 | 20 | MainnetRisc0Verifier | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetRisc0Verifier | +| _pendingOwner | address | 101 | 0 | 20 | MainnetRisc0Verifier | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetRisc0Verifier | +| addressManager | address | 151 | 0 | 20 | MainnetRisc0Verifier | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetRisc0Verifier | +| __reentry | uint8 | 201 | 0 | 1 | MainnetRisc0Verifier | +| __paused | uint8 | 201 | 1 | 1 | MainnetRisc0Verifier | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetRisc0Verifier | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetRisc0Verifier | +| isImageTrusted | mapping(bytes32 => bool) | 251 | 0 | 32 | MainnetRisc0Verifier | +| __gap | uint256[49] | 252 | 0 | 1568 | MainnetRisc0Verifier | ## MainnetZkAndTeeVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------- | ---- | ------ | ----- | ----------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetZkAndTeeVerifier | -| \_initializing | bool | 0 | 1 | 1 | MainnetZkAndTeeVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetZkAndTeeVerifier | -| \_owner | address | 51 | 0 | 20 | MainnetZkAndTeeVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetZkAndTeeVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetZkAndTeeVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetZkAndTeeVerifier | -| addressManager | address | 151 | 0 | 20 | MainnetZkAndTeeVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetZkAndTeeVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetZkAndTeeVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetZkAndTeeVerifier | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetZkAndTeeVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetZkAndTeeVerifier | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | MainnetZkAndTeeVerifier | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | MainnetZkAndTeeVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------|------|--------|-------|-----------------------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetZkAndTeeVerifier | +| _initializing | bool | 0 | 1 | 1 | MainnetZkAndTeeVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetZkAndTeeVerifier | +| _owner | address | 51 | 0 | 20 | MainnetZkAndTeeVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetZkAndTeeVerifier | +| _pendingOwner | address | 101 | 0 | 20 | MainnetZkAndTeeVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetZkAndTeeVerifier | +| addressManager | address | 151 | 0 | 20 | MainnetZkAndTeeVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetZkAndTeeVerifier | +| __reentry | uint8 | 201 | 0 | 1 | MainnetZkAndTeeVerifier | +| __paused | uint8 | 201 | 1 | 1 | MainnetZkAndTeeVerifier | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetZkAndTeeVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetZkAndTeeVerifier | +| __gap | uint256[50] | 251 | 0 | 1600 | MainnetZkAndTeeVerifier | +| __gap | uint256[50] | 301 | 0 | 1600 | MainnetZkAndTeeVerifier | ## MainnetTeeAnyVerifier - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------- | ---- | ------ | ----- | --------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetTeeAnyVerifier | -| \_initializing | bool | 0 | 1 | 1 | MainnetTeeAnyVerifier | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetTeeAnyVerifier | -| \_owner | address | 51 | 0 | 20 | MainnetTeeAnyVerifier | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetTeeAnyVerifier | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetTeeAnyVerifier | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetTeeAnyVerifier | -| addressManager | address | 151 | 0 | 20 | MainnetTeeAnyVerifier | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetTeeAnyVerifier | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetTeeAnyVerifier | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetTeeAnyVerifier | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetTeeAnyVerifier | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetTeeAnyVerifier | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | MainnetTeeAnyVerifier | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | MainnetTeeAnyVerifier | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------|------|--------|-------|-------------------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetTeeAnyVerifier | +| _initializing | bool | 0 | 1 | 1 | MainnetTeeAnyVerifier | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetTeeAnyVerifier | +| _owner | address | 51 | 0 | 20 | MainnetTeeAnyVerifier | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetTeeAnyVerifier | +| _pendingOwner | address | 101 | 0 | 20 | MainnetTeeAnyVerifier | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetTeeAnyVerifier | +| addressManager | address | 151 | 0 | 20 | MainnetTeeAnyVerifier | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetTeeAnyVerifier | +| __reentry | uint8 | 201 | 0 | 1 | MainnetTeeAnyVerifier | +| __paused | uint8 | 201 | 1 | 1 | MainnetTeeAnyVerifier | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetTeeAnyVerifier | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetTeeAnyVerifier | +| __gap | uint256[50] | 251 | 0 | 1600 | MainnetTeeAnyVerifier | +| __gap | uint256[50] | 301 | 0 | 1600 | MainnetTeeAnyVerifier | ## MainnetGuardianProver - -| Name | Type | Slot | Offset | Bytes | Contract | -| ----------------------- | ----------------------------------------------- | ---- | ------ | ----- | --------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetGuardianProver | -| \_initializing | bool | 0 | 1 | 1 | MainnetGuardianProver | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetGuardianProver | -| \_owner | address | 51 | 0 | 20 | MainnetGuardianProver | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetGuardianProver | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetGuardianProver | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetGuardianProver | +| Name | Type | Slot | Offset | Bytes | Contract | +|-------------------------|-------------------------------------------------|------|--------|-------|---------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetGuardianProver | +| _initializing | bool | 0 | 1 | 1 | MainnetGuardianProver | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetGuardianProver | +| _owner | address | 51 | 0 | 20 | MainnetGuardianProver | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetGuardianProver | +| _pendingOwner | address | 101 | 0 | 20 | MainnetGuardianProver | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetGuardianProver | | addressManager | address | 151 | 0 | 20 | MainnetGuardianProver | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetGuardianProver | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetGuardianProver | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetGuardianProver | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetGuardianProver | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetGuardianProver | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetGuardianProver | +| __reentry | uint8 | 201 | 0 | 1 | MainnetGuardianProver | +| __paused | uint8 | 201 | 1 | 1 | MainnetGuardianProver | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetGuardianProver | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetGuardianProver | | guardianIds | mapping(address => uint256) | 251 | 0 | 32 | MainnetGuardianProver | | approvals | mapping(uint256 => mapping(bytes32 => uint256)) | 252 | 0 | 32 | MainnetGuardianProver | | guardians | address[] | 253 | 0 | 32 | MainnetGuardianProver | @@ -858,135 +817,128 @@ | minGuardians | uint32 | 254 | 4 | 4 | MainnetGuardianProver | | provingAutoPauseEnabled | bool | 254 | 8 | 1 | MainnetGuardianProver | | latestProofHash | mapping(uint256 => mapping(uint256 => bytes32)) | 255 | 0 | 32 | MainnetGuardianProver | -| \_\_gap | uint256[45] | 256 | 0 | 1440 | MainnetGuardianProver | +| __gap | uint256[45] | 256 | 0 | 1440 | MainnetGuardianProver | ## MainnetTaikoL1 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------- | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetTaikoL1 | -| \_initializing | bool | 0 | 1 | 1 | MainnetTaikoL1 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetTaikoL1 | -| \_owner | address | 51 | 0 | 20 | MainnetTaikoL1 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetTaikoL1 | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetTaikoL1 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetTaikoL1 | -| addressManager | address | 151 | 0 | 20 | MainnetTaikoL1 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetTaikoL1 | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetTaikoL1 | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetTaikoL1 | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetTaikoL1 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetTaikoL1 | -| state | struct TaikoData.State | 251 | 0 | 1600 | MainnetTaikoL1 | -| \_\_gap | uint256[50] | 301 | 0 | 1600 | MainnetTaikoL1 | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|------------------------|------|--------|-------|-------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetTaikoL1 | +| _initializing | bool | 0 | 1 | 1 | MainnetTaikoL1 | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetTaikoL1 | +| _owner | address | 51 | 0 | 20 | MainnetTaikoL1 | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetTaikoL1 | +| _pendingOwner | address | 101 | 0 | 20 | MainnetTaikoL1 | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetTaikoL1 | +| addressManager | address | 151 | 0 | 20 | MainnetTaikoL1 | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetTaikoL1 | +| __reentry | uint8 | 201 | 0 | 1 | MainnetTaikoL1 | +| __paused | uint8 | 201 | 1 | 1 | MainnetTaikoL1 | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetTaikoL1 | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetTaikoL1 | +| state | struct TaikoData.State | 251 | 0 | 1600 | MainnetTaikoL1 | +| __gap | uint256[50] | 301 | 0 | 1600 | MainnetTaikoL1 | ## MainnetRollupAddressManager - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------------------------------------------- | ---- | ------ | ----- | --------------------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetRollupAddressManager | -| \_initializing | bool | 0 | 1 | 1 | MainnetRollupAddressManager | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetRollupAddressManager | -| \_owner | address | 51 | 0 | 20 | MainnetRollupAddressManager | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetRollupAddressManager | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetRollupAddressManager | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetRollupAddressManager | -| addressManager | address | 151 | 0 | 20 | MainnetRollupAddressManager | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetRollupAddressManager | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetRollupAddressManager | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetRollupAddressManager | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetRollupAddressManager | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetRollupAddressManager | -| \_\_addresses | mapping(uint256 => mapping(bytes32 => address)) | 251 | 0 | 32 | MainnetRollupAddressManager | -| \_\_gap | uint256[49] | 252 | 0 | 1568 | MainnetRollupAddressManager | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------------------------------------------|------|--------|-------|---------------------------------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetRollupAddressManager | +| _initializing | bool | 0 | 1 | 1 | MainnetRollupAddressManager | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetRollupAddressManager | +| _owner | address | 51 | 0 | 20 | MainnetRollupAddressManager | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetRollupAddressManager | +| _pendingOwner | address | 101 | 0 | 20 | MainnetRollupAddressManager | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetRollupAddressManager | +| addressManager | address | 151 | 0 | 20 | MainnetRollupAddressManager | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetRollupAddressManager | +| __reentry | uint8 | 201 | 0 | 1 | MainnetRollupAddressManager | +| __paused | uint8 | 201 | 1 | 1 | MainnetRollupAddressManager | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetRollupAddressManager | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetRollupAddressManager | +| __addresses | mapping(uint256 => mapping(bytes32 => address)) | 251 | 0 | 32 | MainnetRollupAddressManager | +| __gap | uint256[49] | 252 | 0 | 1568 | MainnetRollupAddressManager | ## MainnetTierRouter - | Name | Type | Slot | Offset | Bytes | Contract | -| ---- | ---- | ---- | ------ | ----- | -------- | +|------|------|------|--------|-------|----------| ## MainnetProverSet - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ------------------------ | ---- | ------ | ----- | ---------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetProverSet | -| \_initializing | bool | 0 | 1 | 1 | MainnetProverSet | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetProverSet | -| \_owner | address | 51 | 0 | 20 | MainnetProverSet | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetProverSet | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetProverSet | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetProverSet | -| addressManager | address | 151 | 0 | 20 | MainnetProverSet | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetProverSet | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetProverSet | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetProverSet | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetProverSet | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetProverSet | -| isProver | mapping(address => bool) | 251 | 0 | 32 | MainnetProverSet | -| admin | address | 252 | 0 | 20 | MainnetProverSet | -| \_\_gap | uint256[48] | 253 | 0 | 1536 | MainnetProverSet | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|--------------------------|------|--------|-------|-----------------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetProverSet | +| _initializing | bool | 0 | 1 | 1 | MainnetProverSet | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetProverSet | +| _owner | address | 51 | 0 | 20 | MainnetProverSet | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetProverSet | +| _pendingOwner | address | 101 | 0 | 20 | MainnetProverSet | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetProverSet | +| addressManager | address | 151 | 0 | 20 | MainnetProverSet | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetProverSet | +| __reentry | uint8 | 201 | 0 | 1 | MainnetProverSet | +| __paused | uint8 | 201 | 1 | 1 | MainnetProverSet | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetProverSet | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetProverSet | +| isProver | mapping(address => bool) | 251 | 0 | 32 | MainnetProverSet | +| admin | address | 252 | 0 | 20 | MainnetProverSet | +| __gap | uint256[48] | 253 | 0 | 1536 | MainnetProverSet | ## TokenUnlock - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ------------------------ | ---- | ------ | ----- | ----------- | -| \_initialized | uint8 | 0 | 0 | 1 | TokenUnlock | -| \_initializing | bool | 0 | 1 | 1 | TokenUnlock | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | TokenUnlock | -| \_owner | address | 51 | 0 | 20 | TokenUnlock | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | TokenUnlock | -| \_pendingOwner | address | 101 | 0 | 20 | TokenUnlock | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | TokenUnlock | -| addressManager | address | 151 | 0 | 20 | TokenUnlock | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | TokenUnlock | -| \_\_reentry | uint8 | 201 | 0 | 1 | TokenUnlock | -| \_\_paused | uint8 | 201 | 1 | 1 | TokenUnlock | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | TokenUnlock | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | TokenUnlock | -| amountVested | uint256 | 251 | 0 | 32 | TokenUnlock | -| recipient | address | 252 | 0 | 20 | TokenUnlock | -| tgeTimestamp | uint64 | 252 | 20 | 8 | TokenUnlock | -| isProverSet | mapping(address => bool) | 253 | 0 | 32 | TokenUnlock | -| \_\_gap | uint256[47] | 254 | 0 | 1504 | TokenUnlock | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|--------------------------|------|--------|-------|---------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | TokenUnlock | +| _initializing | bool | 0 | 1 | 1 | TokenUnlock | +| __gap | uint256[50] | 1 | 0 | 1600 | TokenUnlock | +| _owner | address | 51 | 0 | 20 | TokenUnlock | +| __gap | uint256[49] | 52 | 0 | 1568 | TokenUnlock | +| _pendingOwner | address | 101 | 0 | 20 | TokenUnlock | +| __gap | uint256[49] | 102 | 0 | 1568 | TokenUnlock | +| addressManager | address | 151 | 0 | 20 | TokenUnlock | +| __gap | uint256[49] | 152 | 0 | 1568 | TokenUnlock | +| __reentry | uint8 | 201 | 0 | 1 | TokenUnlock | +| __paused | uint8 | 201 | 1 | 1 | TokenUnlock | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | TokenUnlock | +| __gap | uint256[49] | 202 | 0 | 1568 | TokenUnlock | +| amountVested | uint256 | 251 | 0 | 32 | TokenUnlock | +| recipient | address | 252 | 0 | 20 | TokenUnlock | +| tgeTimestamp | uint64 | 252 | 20 | 8 | TokenUnlock | +| isProverSet | mapping(address => bool) | 253 | 0 | 32 | TokenUnlock | +| __gap | uint256[47] | 254 | 0 | 1504 | TokenUnlock | ## ProverSet - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ------------------------ | ---- | ------ | ----- | --------- | -| \_initialized | uint8 | 0 | 0 | 1 | ProverSet | -| \_initializing | bool | 0 | 1 | 1 | ProverSet | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ProverSet | -| \_owner | address | 51 | 0 | 20 | ProverSet | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ProverSet | -| \_pendingOwner | address | 101 | 0 | 20 | ProverSet | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ProverSet | -| addressManager | address | 151 | 0 | 20 | ProverSet | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ProverSet | -| \_\_reentry | uint8 | 201 | 0 | 1 | ProverSet | -| \_\_paused | uint8 | 201 | 1 | 1 | ProverSet | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | ProverSet | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ProverSet | -| isProver | mapping(address => bool) | 251 | 0 | 32 | ProverSet | -| admin | address | 252 | 0 | 20 | ProverSet | -| \_\_gap | uint256[48] | 253 | 0 | 1536 | ProverSet | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|--------------------------|------|--------|-------|--------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ProverSet | +| _initializing | bool | 0 | 1 | 1 | ProverSet | +| __gap | uint256[50] | 1 | 0 | 1600 | ProverSet | +| _owner | address | 51 | 0 | 20 | ProverSet | +| __gap | uint256[49] | 52 | 0 | 1568 | ProverSet | +| _pendingOwner | address | 101 | 0 | 20 | ProverSet | +| __gap | uint256[49] | 102 | 0 | 1568 | ProverSet | +| addressManager | address | 151 | 0 | 20 | ProverSet | +| __gap | uint256[49] | 152 | 0 | 1568 | ProverSet | +| __reentry | uint8 | 201 | 0 | 1 | ProverSet | +| __paused | uint8 | 201 | 1 | 1 | ProverSet | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | ProverSet | +| __gap | uint256[49] | 202 | 0 | 1568 | ProverSet | +| isProver | mapping(address => bool) | 251 | 0 | 32 | ProverSet | +| admin | address | 252 | 0 | 20 | ProverSet | +| __gap | uint256[48] | 253 | 0 | 1536 | ProverSet | ## GuardianProver - -| Name | Type | Slot | Offset | Bytes | Contract | -| ----------------------- | ----------------------------------------------- | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | GuardianProver | -| \_initializing | bool | 0 | 1 | 1 | GuardianProver | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | GuardianProver | -| \_owner | address | 51 | 0 | 20 | GuardianProver | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | GuardianProver | -| \_pendingOwner | address | 101 | 0 | 20 | GuardianProver | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | GuardianProver | +| Name | Type | Slot | Offset | Bytes | Contract | +|-------------------------|-------------------------------------------------|------|--------|-------|------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | GuardianProver | +| _initializing | bool | 0 | 1 | 1 | GuardianProver | +| __gap | uint256[50] | 1 | 0 | 1600 | GuardianProver | +| _owner | address | 51 | 0 | 20 | GuardianProver | +| __gap | uint256[49] | 52 | 0 | 1568 | GuardianProver | +| _pendingOwner | address | 101 | 0 | 20 | GuardianProver | +| __gap | uint256[49] | 102 | 0 | 1568 | GuardianProver | | addressManager | address | 151 | 0 | 20 | GuardianProver | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | GuardianProver | -| \_\_reentry | uint8 | 201 | 0 | 1 | GuardianProver | -| \_\_paused | uint8 | 201 | 1 | 1 | GuardianProver | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | GuardianProver | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | GuardianProver | +| __gap | uint256[49] | 152 | 0 | 1568 | GuardianProver | +| __reentry | uint8 | 201 | 0 | 1 | GuardianProver | +| __paused | uint8 | 201 | 1 | 1 | GuardianProver | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | GuardianProver | +| __gap | uint256[49] | 202 | 0 | 1568 | GuardianProver | | guardianIds | mapping(address => uint256) | 251 | 0 | 32 | GuardianProver | | approvals | mapping(uint256 => mapping(bytes32 => uint256)) | 252 | 0 | 32 | GuardianProver | | guardians | address[] | 253 | 0 | 32 | GuardianProver | @@ -994,4 +946,5 @@ | minGuardians | uint32 | 254 | 4 | 4 | GuardianProver | | provingAutoPauseEnabled | bool | 254 | 8 | 1 | GuardianProver | | latestProofHash | mapping(uint256 => mapping(uint256 => bytes32)) | 255 | 0 | 32 | GuardianProver | -| \_\_gap | uint256[45] | 256 | 0 | 1440 | GuardianProver | +| __gap | uint256[45] | 256 | 0 | 1440 | GuardianProver | + diff --git a/packages/protocol/contract_layout_layer2.md b/packages/protocol/contract_layout_layer2.md index eccd1486b86..e0f97f06590 100644 --- a/packages/protocol/contract_layout_layer2.md +++ b/packages/protocol/contract_layout_layer2.md @@ -1,448 +1,431 @@ ## ERC1155Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ------------ | -| \_initialized | uint8 | 0 | 0 | 1 | ERC1155Vault | -| \_initializing | bool | 0 | 1 | 1 | ERC1155Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ERC1155Vault | -| \_owner | address | 51 | 0 | 20 | ERC1155Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ERC1155Vault | -| \_pendingOwner | address | 101 | 0 | 20 | ERC1155Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ERC1155Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|-----------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ERC1155Vault | +| _initializing | bool | 0 | 1 | 1 | ERC1155Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | ERC1155Vault | +| _owner | address | 51 | 0 | 20 | ERC1155Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | ERC1155Vault | +| _pendingOwner | address | 101 | 0 | 20 | ERC1155Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | ERC1155Vault | | addressManager | address | 151 | 0 | 20 | ERC1155Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ERC1155Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | ERC1155Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | ERC1155Vault | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC1155Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ERC1155Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ERC1155Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | ERC1155Vault | +| __reentry | uint8 | 201 | 0 | 1 | ERC1155Vault | +| __paused | uint8 | 201 | 1 | 1 | ERC1155Vault | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC1155Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | ERC1155Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | ERC1155Vault | | bridgedToCanonical | mapping(address => struct BaseNFTVault.CanonicalNFT) | 301 | 0 | 32 | ERC1155Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | ERC1155Vault | -| \_\_gap | uint256[48] | 303 | 0 | 1536 | ERC1155Vault | -| \_\_gap | uint256[50] | 351 | 0 | 1600 | ERC1155Vault | -| \_\_gap | uint256[50] | 401 | 0 | 1600 | ERC1155Vault | -| \_\_gap | uint256[50] | 451 | 0 | 1600 | ERC1155Vault | +| __gap | uint256[48] | 303 | 0 | 1536 | ERC1155Vault | +| __gap | uint256[50] | 351 | 0 | 1600 | ERC1155Vault | +| __gap | uint256[50] | 401 | 0 | 1600 | ERC1155Vault | +| __gap | uint256[50] | 451 | 0 | 1600 | ERC1155Vault | ## ERC20Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ---------- | -| \_initialized | uint8 | 0 | 0 | 1 | ERC20Vault | -| \_initializing | bool | 0 | 1 | 1 | ERC20Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ERC20Vault | -| \_owner | address | 51 | 0 | 20 | ERC20Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ERC20Vault | -| \_pendingOwner | address | 101 | 0 | 20 | ERC20Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ERC20Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|-------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ERC20Vault | +| _initializing | bool | 0 | 1 | 1 | ERC20Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | ERC20Vault | +| _owner | address | 51 | 0 | 20 | ERC20Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | ERC20Vault | +| _pendingOwner | address | 101 | 0 | 20 | ERC20Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | ERC20Vault | | addressManager | address | 151 | 0 | 20 | ERC20Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ERC20Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | ERC20Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | ERC20Vault | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC20Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ERC20Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ERC20Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | ERC20Vault | +| __reentry | uint8 | 201 | 0 | 1 | ERC20Vault | +| __paused | uint8 | 201 | 1 | 1 | ERC20Vault | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC20Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | ERC20Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | ERC20Vault | | bridgedToCanonical | mapping(address => struct ERC20Vault.CanonicalERC20) | 301 | 0 | 32 | ERC20Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | ERC20Vault | | btokenDenylist | mapping(address => bool) | 303 | 0 | 32 | ERC20Vault | | lastMigrationStart | mapping(uint256 => mapping(address => uint256)) | 304 | 0 | 32 | ERC20Vault | -| \_\_gap | uint256[46] | 305 | 0 | 1472 | ERC20Vault | +| __gap | uint256[46] | 305 | 0 | 1472 | ERC20Vault | ## ERC721Vault - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ---------------------------------------------------- | ---- | ------ | ----- | ----------- | -| \_initialized | uint8 | 0 | 0 | 1 | ERC721Vault | -| \_initializing | bool | 0 | 1 | 1 | ERC721Vault | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | ERC721Vault | -| \_owner | address | 51 | 0 | 20 | ERC721Vault | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | ERC721Vault | -| \_pendingOwner | address | 101 | 0 | 20 | ERC721Vault | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | ERC721Vault | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|------------------------------------------------------|------|--------|-------|---------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | ERC721Vault | +| _initializing | bool | 0 | 1 | 1 | ERC721Vault | +| __gap | uint256[50] | 1 | 0 | 1600 | ERC721Vault | +| _owner | address | 51 | 0 | 20 | ERC721Vault | +| __gap | uint256[49] | 52 | 0 | 1568 | ERC721Vault | +| _pendingOwner | address | 101 | 0 | 20 | ERC721Vault | +| __gap | uint256[49] | 102 | 0 | 1568 | ERC721Vault | | addressManager | address | 151 | 0 | 20 | ERC721Vault | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | ERC721Vault | -| \_\_reentry | uint8 | 201 | 0 | 1 | ERC721Vault | -| \_\_paused | uint8 | 201 | 1 | 1 | ERC721Vault | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC721Vault | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | ERC721Vault | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | ERC721Vault | +| __gap | uint256[49] | 152 | 0 | 1568 | ERC721Vault | +| __reentry | uint8 | 201 | 0 | 1 | ERC721Vault | +| __paused | uint8 | 201 | 1 | 1 | ERC721Vault | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | ERC721Vault | +| __gap | uint256[49] | 202 | 0 | 1568 | ERC721Vault | +| __gap | uint256[50] | 251 | 0 | 1600 | ERC721Vault | | bridgedToCanonical | mapping(address => struct BaseNFTVault.CanonicalNFT) | 301 | 0 | 32 | ERC721Vault | | canonicalToBridged | mapping(uint256 => mapping(address => address)) | 302 | 0 | 32 | ERC721Vault | -| \_\_gap | uint256[48] | 303 | 0 | 1536 | ERC721Vault | -| \_\_gap | uint256[50] | 351 | 0 | 1600 | ERC721Vault | +| __gap | uint256[48] | 303 | 0 | 1536 | ERC721Vault | +| __gap | uint256[50] | 351 | 0 | 1600 | ERC721Vault | ## BridgedERC20 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------------------------------------------- | ---- | ------ | ----- | ------------ | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedERC20 | -| \_initializing | bool | 0 | 1 | 1 | BridgedERC20 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20 | -| \_owner | address | 51 | 0 | 20 | BridgedERC20 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedERC20 | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedERC20 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedERC20 | -| addressManager | address | 151 | 0 | 20 | BridgedERC20 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedERC20 | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedERC20 | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedERC20 | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC20 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedERC20 | -| \_balances | mapping(address => uint256) | 251 | 0 | 32 | BridgedERC20 | -| \_allowances | mapping(address => mapping(address => uint256)) | 252 | 0 | 32 | BridgedERC20 | -| \_totalSupply | uint256 | 253 | 0 | 32 | BridgedERC20 | -| \_name | string | 254 | 0 | 32 | BridgedERC20 | -| \_symbol | string | 255 | 0 | 32 | BridgedERC20 | -| \_\_gap | uint256[45] | 256 | 0 | 1440 | BridgedERC20 | -| srcToken | address | 301 | 0 | 20 | BridgedERC20 | -| \_\_srcDecimals | uint8 | 301 | 20 | 1 | BridgedERC20 | -| srcChainId | uint256 | 302 | 0 | 32 | BridgedERC20 | -| migratingAddress | address | 303 | 0 | 20 | BridgedERC20 | -| migratingInbound | bool | 303 | 20 | 1 | BridgedERC20 | -| \_\_gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20 | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------------------------------------------|------|--------|-------|-----------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedERC20 | +| _initializing | bool | 0 | 1 | 1 | BridgedERC20 | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20 | +| _owner | address | 51 | 0 | 20 | BridgedERC20 | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedERC20 | +| _pendingOwner | address | 101 | 0 | 20 | BridgedERC20 | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedERC20 | +| addressManager | address | 151 | 0 | 20 | BridgedERC20 | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedERC20 | +| __reentry | uint8 | 201 | 0 | 1 | BridgedERC20 | +| __paused | uint8 | 201 | 1 | 1 | BridgedERC20 | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC20 | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedERC20 | +| _balances | mapping(address => uint256) | 251 | 0 | 32 | BridgedERC20 | +| _allowances | mapping(address => mapping(address => uint256)) | 252 | 0 | 32 | BridgedERC20 | +| _totalSupply | uint256 | 253 | 0 | 32 | BridgedERC20 | +| _name | string | 254 | 0 | 32 | BridgedERC20 | +| _symbol | string | 255 | 0 | 32 | BridgedERC20 | +| __gap | uint256[45] | 256 | 0 | 1440 | BridgedERC20 | +| srcToken | address | 301 | 0 | 20 | BridgedERC20 | +| __srcDecimals | uint8 | 301 | 20 | 1 | BridgedERC20 | +| srcChainId | uint256 | 302 | 0 | 32 | BridgedERC20 | +| migratingAddress | address | 303 | 0 | 20 | BridgedERC20 | +| migratingInbound | bool | 303 | 20 | 1 | BridgedERC20 | +| __gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20 | ## BridgedERC20V2 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ------------------------------------------------------ | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedERC20V2 | -| \_initializing | bool | 0 | 1 | 1 | BridgedERC20V2 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20V2 | -| \_owner | address | 51 | 0 | 20 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedERC20V2 | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedERC20V2 | -| addressManager | address | 151 | 0 | 20 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedERC20V2 | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedERC20V2 | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedERC20V2 | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedERC20V2 | -| \_balances | mapping(address => uint256) | 251 | 0 | 32 | BridgedERC20V2 | -| \_allowances | mapping(address => mapping(address => uint256)) | 252 | 0 | 32 | BridgedERC20V2 | -| \_totalSupply | uint256 | 253 | 0 | 32 | BridgedERC20V2 | -| \_name | string | 254 | 0 | 32 | BridgedERC20V2 | -| \_symbol | string | 255 | 0 | 32 | BridgedERC20V2 | -| \_\_gap | uint256[45] | 256 | 0 | 1440 | BridgedERC20V2 | -| srcToken | address | 301 | 0 | 20 | BridgedERC20V2 | -| \_\_srcDecimals | uint8 | 301 | 20 | 1 | BridgedERC20V2 | -| srcChainId | uint256 | 302 | 0 | 32 | BridgedERC20V2 | -| migratingAddress | address | 303 | 0 | 20 | BridgedERC20V2 | -| migratingInbound | bool | 303 | 20 | 1 | BridgedERC20V2 | -| \_\_gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20V2 | -| \_hashedName | bytes32 | 351 | 0 | 32 | BridgedERC20V2 | -| \_hashedVersion | bytes32 | 352 | 0 | 32 | BridgedERC20V2 | -| \_name | string | 353 | 0 | 32 | BridgedERC20V2 | -| \_version | string | 354 | 0 | 32 | BridgedERC20V2 | -| \_\_gap | uint256[48] | 355 | 0 | 1536 | BridgedERC20V2 | -| \_nonces | mapping(address => struct CountersUpgradeable.Counter) | 403 | 0 | 32 | BridgedERC20V2 | -| \_\_gap | uint256[49] | 404 | 0 | 1568 | BridgedERC20V2 | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|--------------------------------------------------------|------|--------|-------|---------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedERC20V2 | +| _initializing | bool | 0 | 1 | 1 | BridgedERC20V2 | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC20V2 | +| _owner | address | 51 | 0 | 20 | BridgedERC20V2 | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedERC20V2 | +| _pendingOwner | address | 101 | 0 | 20 | BridgedERC20V2 | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedERC20V2 | +| addressManager | address | 151 | 0 | 20 | BridgedERC20V2 | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedERC20V2 | +| __reentry | uint8 | 201 | 0 | 1 | BridgedERC20V2 | +| __paused | uint8 | 201 | 1 | 1 | BridgedERC20V2 | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC20V2 | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedERC20V2 | +| _balances | mapping(address => uint256) | 251 | 0 | 32 | BridgedERC20V2 | +| _allowances | mapping(address => mapping(address => uint256)) | 252 | 0 | 32 | BridgedERC20V2 | +| _totalSupply | uint256 | 253 | 0 | 32 | BridgedERC20V2 | +| _name | string | 254 | 0 | 32 | BridgedERC20V2 | +| _symbol | string | 255 | 0 | 32 | BridgedERC20V2 | +| __gap | uint256[45] | 256 | 0 | 1440 | BridgedERC20V2 | +| srcToken | address | 301 | 0 | 20 | BridgedERC20V2 | +| __srcDecimals | uint8 | 301 | 20 | 1 | BridgedERC20V2 | +| srcChainId | uint256 | 302 | 0 | 32 | BridgedERC20V2 | +| migratingAddress | address | 303 | 0 | 20 | BridgedERC20V2 | +| migratingInbound | bool | 303 | 20 | 1 | BridgedERC20V2 | +| __gap | uint256[47] | 304 | 0 | 1504 | BridgedERC20V2 | +| _hashedName | bytes32 | 351 | 0 | 32 | BridgedERC20V2 | +| _hashedVersion | bytes32 | 352 | 0 | 32 | BridgedERC20V2 | +| _name | string | 353 | 0 | 32 | BridgedERC20V2 | +| _version | string | 354 | 0 | 32 | BridgedERC20V2 | +| __gap | uint256[48] | 355 | 0 | 1536 | BridgedERC20V2 | +| _nonces | mapping(address => struct CountersUpgradeable.Counter) | 403 | 0 | 32 | BridgedERC20V2 | +| __gap | uint256[49] | 404 | 0 | 1568 | BridgedERC20V2 | ## BridgedERC721 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------- | -------------------------------------------- | ---- | ------ | ----- | ------------- | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedERC721 | -| \_initializing | bool | 0 | 1 | 1 | BridgedERC721 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedERC721 | -| \_owner | address | 51 | 0 | 20 | BridgedERC721 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedERC721 | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedERC721 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedERC721 | -| addressManager | address | 151 | 0 | 20 | BridgedERC721 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedERC721 | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedERC721 | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedERC721 | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC721 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedERC721 | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | BridgedERC721 | -| \_name | string | 301 | 0 | 32 | BridgedERC721 | -| \_symbol | string | 302 | 0 | 32 | BridgedERC721 | -| \_owners | mapping(uint256 => address) | 303 | 0 | 32 | BridgedERC721 | -| \_balances | mapping(address => uint256) | 304 | 0 | 32 | BridgedERC721 | -| \_tokenApprovals | mapping(uint256 => address) | 305 | 0 | 32 | BridgedERC721 | -| \_operatorApprovals | mapping(address => mapping(address => bool)) | 306 | 0 | 32 | BridgedERC721 | -| \_\_gap | uint256[44] | 307 | 0 | 1408 | BridgedERC721 | -| srcToken | address | 351 | 0 | 20 | BridgedERC721 | -| srcChainId | uint256 | 352 | 0 | 32 | BridgedERC721 | -| \_\_gap | uint256[48] | 353 | 0 | 1536 | BridgedERC721 | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|----------------------------------------------|------|--------|-------|-------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedERC721 | +| _initializing | bool | 0 | 1 | 1 | BridgedERC721 | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC721 | +| _owner | address | 51 | 0 | 20 | BridgedERC721 | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedERC721 | +| _pendingOwner | address | 101 | 0 | 20 | BridgedERC721 | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedERC721 | +| addressManager | address | 151 | 0 | 20 | BridgedERC721 | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedERC721 | +| __reentry | uint8 | 201 | 0 | 1 | BridgedERC721 | +| __paused | uint8 | 201 | 1 | 1 | BridgedERC721 | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC721 | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedERC721 | +| __gap | uint256[50] | 251 | 0 | 1600 | BridgedERC721 | +| _name | string | 301 | 0 | 32 | BridgedERC721 | +| _symbol | string | 302 | 0 | 32 | BridgedERC721 | +| _owners | mapping(uint256 => address) | 303 | 0 | 32 | BridgedERC721 | +| _balances | mapping(address => uint256) | 304 | 0 | 32 | BridgedERC721 | +| _tokenApprovals | mapping(uint256 => address) | 305 | 0 | 32 | BridgedERC721 | +| _operatorApprovals | mapping(address => mapping(address => bool)) | 306 | 0 | 32 | BridgedERC721 | +| __gap | uint256[44] | 307 | 0 | 1408 | BridgedERC721 | +| srcToken | address | 351 | 0 | 20 | BridgedERC721 | +| srcChainId | uint256 | 352 | 0 | 32 | BridgedERC721 | +| __gap | uint256[48] | 353 | 0 | 1536 | BridgedERC721 | ## BridgedERC1155 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------- | ----------------------------------------------- | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedERC1155 | -| \_initializing | bool | 0 | 1 | 1 | BridgedERC1155 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedERC1155 | -| \_owner | address | 51 | 0 | 20 | BridgedERC1155 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedERC1155 | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedERC1155 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedERC1155 | -| addressManager | address | 151 | 0 | 20 | BridgedERC1155 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedERC1155 | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedERC1155 | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedERC1155 | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC1155 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedERC1155 | -| \_\_gap | uint256[50] | 251 | 0 | 1600 | BridgedERC1155 | -| \_balances | mapping(uint256 => mapping(address => uint256)) | 301 | 0 | 32 | BridgedERC1155 | -| \_operatorApprovals | mapping(address => mapping(address => bool)) | 302 | 0 | 32 | BridgedERC1155 | -| \_uri | string | 303 | 0 | 32 | BridgedERC1155 | -| \_\_gap | uint256[47] | 304 | 0 | 1504 | BridgedERC1155 | -| srcToken | address | 351 | 0 | 20 | BridgedERC1155 | -| srcChainId | uint256 | 352 | 0 | 32 | BridgedERC1155 | -| symbol | string | 353 | 0 | 32 | BridgedERC1155 | -| name | string | 354 | 0 | 32 | BridgedERC1155 | -| \_\_gap | uint256[46] | 355 | 0 | 1472 | BridgedERC1155 | +| Name | Type | Slot | Offset | Bytes | Contract | +|--------------------|-------------------------------------------------|------|--------|-------|---------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedERC1155 | +| _initializing | bool | 0 | 1 | 1 | BridgedERC1155 | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedERC1155 | +| _owner | address | 51 | 0 | 20 | BridgedERC1155 | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedERC1155 | +| _pendingOwner | address | 101 | 0 | 20 | BridgedERC1155 | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedERC1155 | +| addressManager | address | 151 | 0 | 20 | BridgedERC1155 | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedERC1155 | +| __reentry | uint8 | 201 | 0 | 1 | BridgedERC1155 | +| __paused | uint8 | 201 | 1 | 1 | BridgedERC1155 | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedERC1155 | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedERC1155 | +| __gap | uint256[50] | 251 | 0 | 1600 | BridgedERC1155 | +| _balances | mapping(uint256 => mapping(address => uint256)) | 301 | 0 | 32 | BridgedERC1155 | +| _operatorApprovals | mapping(address => mapping(address => bool)) | 302 | 0 | 32 | BridgedERC1155 | +| _uri | string | 303 | 0 | 32 | BridgedERC1155 | +| __gap | uint256[47] | 304 | 0 | 1504 | BridgedERC1155 | +| srcToken | address | 351 | 0 | 20 | BridgedERC1155 | +| srcChainId | uint256 | 352 | 0 | 32 | BridgedERC1155 | +| symbol | string | 353 | 0 | 32 | BridgedERC1155 | +| name | string | 354 | 0 | 32 | BridgedERC1155 | +| __gap | uint256[46] | 355 | 0 | 1472 | BridgedERC1155 | ## Bridge - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | --------------------------------------- | ---- | ------ | ----- | -------- | -| \_initialized | uint8 | 0 | 0 | 1 | Bridge | -| \_initializing | bool | 0 | 1 | 1 | Bridge | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | Bridge | -| \_owner | address | 51 | 0 | 20 | Bridge | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | Bridge | -| \_pendingOwner | address | 101 | 0 | 20 | Bridge | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | Bridge | -| addressManager | address | 151 | 0 | 20 | Bridge | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | Bridge | -| \_\_reentry | uint8 | 201 | 0 | 1 | Bridge | -| \_\_paused | uint8 | 201 | 1 | 1 | Bridge | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | Bridge | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | Bridge | -| \_\_reserved1 | uint64 | 251 | 0 | 8 | Bridge | -| nextMessageId | uint64 | 251 | 8 | 8 | Bridge | -| messageStatus | mapping(bytes32 => enum IBridge.Status) | 252 | 0 | 32 | Bridge | -| \_\_ctx | struct IBridge.Context | 253 | 0 | 64 | Bridge | -| \_\_reserved2 | uint256 | 255 | 0 | 32 | Bridge | -| \_\_reserved3 | uint256 | 256 | 0 | 32 | Bridge | -| \_\_gap | uint256[44] | 257 | 0 | 1408 | Bridge | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-----------------------------------------|------|--------|-------|-------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | Bridge | +| _initializing | bool | 0 | 1 | 1 | Bridge | +| __gap | uint256[50] | 1 | 0 | 1600 | Bridge | +| _owner | address | 51 | 0 | 20 | Bridge | +| __gap | uint256[49] | 52 | 0 | 1568 | Bridge | +| _pendingOwner | address | 101 | 0 | 20 | Bridge | +| __gap | uint256[49] | 102 | 0 | 1568 | Bridge | +| addressManager | address | 151 | 0 | 20 | Bridge | +| __gap | uint256[49] | 152 | 0 | 1568 | Bridge | +| __reentry | uint8 | 201 | 0 | 1 | Bridge | +| __paused | uint8 | 201 | 1 | 1 | Bridge | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | Bridge | +| __gap | uint256[49] | 202 | 0 | 1568 | Bridge | +| __reserved1 | uint64 | 251 | 0 | 8 | Bridge | +| nextMessageId | uint64 | 251 | 8 | 8 | Bridge | +| messageStatus | mapping(bytes32 => enum IBridge.Status) | 252 | 0 | 32 | Bridge | +| __ctx | struct IBridge.Context | 253 | 0 | 64 | Bridge | +| __reserved2 | uint256 | 255 | 0 | 32 | Bridge | +| __reserved3 | uint256 | 256 | 0 | 32 | Bridge | +| __gap | uint256[44] | 257 | 0 | 1408 | Bridge | ## QuotaManager - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | --------------------------------------------- | ---- | ------ | ----- | ------------ | -| \_initialized | uint8 | 0 | 0 | 1 | QuotaManager | -| \_initializing | bool | 0 | 1 | 1 | QuotaManager | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | QuotaManager | -| \_owner | address | 51 | 0 | 20 | QuotaManager | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | QuotaManager | -| \_pendingOwner | address | 101 | 0 | 20 | QuotaManager | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | QuotaManager | -| addressManager | address | 151 | 0 | 20 | QuotaManager | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | QuotaManager | -| \_\_reentry | uint8 | 201 | 0 | 1 | QuotaManager | -| \_\_paused | uint8 | 201 | 1 | 1 | QuotaManager | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | QuotaManager | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | QuotaManager | -| tokenQuota | mapping(address => struct QuotaManager.Quota) | 251 | 0 | 32 | QuotaManager | -| quotaPeriod | uint24 | 252 | 0 | 3 | QuotaManager | -| \_\_gap | uint256[48] | 253 | 0 | 1536 | QuotaManager | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-----------------------------------------------|------|--------|-------|-------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | QuotaManager | +| _initializing | bool | 0 | 1 | 1 | QuotaManager | +| __gap | uint256[50] | 1 | 0 | 1600 | QuotaManager | +| _owner | address | 51 | 0 | 20 | QuotaManager | +| __gap | uint256[49] | 52 | 0 | 1568 | QuotaManager | +| _pendingOwner | address | 101 | 0 | 20 | QuotaManager | +| __gap | uint256[49] | 102 | 0 | 1568 | QuotaManager | +| addressManager | address | 151 | 0 | 20 | QuotaManager | +| __gap | uint256[49] | 152 | 0 | 1568 | QuotaManager | +| __reentry | uint8 | 201 | 0 | 1 | QuotaManager | +| __paused | uint8 | 201 | 1 | 1 | QuotaManager | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | QuotaManager | +| __gap | uint256[49] | 202 | 0 | 1568 | QuotaManager | +| tokenQuota | mapping(address => struct QuotaManager.Quota) | 251 | 0 | 32 | QuotaManager | +| quotaPeriod | uint24 | 252 | 0 | 3 | QuotaManager | +| __gap | uint256[48] | 253 | 0 | 1536 | QuotaManager | ## AddressManager - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------------------------------------------- | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | AddressManager | -| \_initializing | bool | 0 | 1 | 1 | AddressManager | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | AddressManager | -| \_owner | address | 51 | 0 | 20 | AddressManager | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | AddressManager | -| \_pendingOwner | address | 101 | 0 | 20 | AddressManager | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | AddressManager | -| addressManager | address | 151 | 0 | 20 | AddressManager | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | AddressManager | -| \_\_reentry | uint8 | 201 | 0 | 1 | AddressManager | -| \_\_paused | uint8 | 201 | 1 | 1 | AddressManager | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | AddressManager | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | AddressManager | -| \_\_addresses | mapping(uint256 => mapping(bytes32 => address)) | 251 | 0 | 32 | AddressManager | -| \_\_gap | uint256[49] | 252 | 0 | 1568 | AddressManager | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------------------------------------------|------|--------|-------|-----------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | AddressManager | +| _initializing | bool | 0 | 1 | 1 | AddressManager | +| __gap | uint256[50] | 1 | 0 | 1600 | AddressManager | +| _owner | address | 51 | 0 | 20 | AddressManager | +| __gap | uint256[49] | 52 | 0 | 1568 | AddressManager | +| _pendingOwner | address | 101 | 0 | 20 | AddressManager | +| __gap | uint256[49] | 102 | 0 | 1568 | AddressManager | +| addressManager | address | 151 | 0 | 20 | AddressManager | +| __gap | uint256[49] | 152 | 0 | 1568 | AddressManager | +| __reentry | uint8 | 201 | 0 | 1 | AddressManager | +| __paused | uint8 | 201 | 1 | 1 | AddressManager | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | AddressManager | +| __gap | uint256[49] | 202 | 0 | 1568 | AddressManager | +| __addresses | mapping(uint256 => mapping(bytes32 => address)) | 251 | 0 | 32 | AddressManager | +| __gap | uint256[49] | 252 | 0 | 1568 | AddressManager | ## AddressResolver - -| Name | Type | Slot | Offset | Bytes | Contract | -| -------------- | ----------- | ---- | ------ | ----- | --------------- | -| \_initialized | uint8 | 0 | 0 | 1 | AddressResolver | -| \_initializing | bool | 0 | 1 | 1 | AddressResolver | +| Name | Type | Slot | Offset | Bytes | Contract | +|----------------|-------------|------|--------|-------|-------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | AddressResolver | +| _initializing | bool | 0 | 1 | 1 | AddressResolver | | addressManager | address | 0 | 2 | 20 | AddressResolver | -| \_\_gap | uint256[49] | 1 | 0 | 1568 | AddressResolver | +| __gap | uint256[49] | 1 | 0 | 1568 | AddressResolver | ## EssentialContract - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------- | ---- | ------ | ----- | ----------------- | -| \_initialized | uint8 | 0 | 0 | 1 | EssentialContract | -| \_initializing | bool | 0 | 1 | 1 | EssentialContract | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | EssentialContract | -| \_owner | address | 51 | 0 | 20 | EssentialContract | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | EssentialContract | -| \_pendingOwner | address | 101 | 0 | 20 | EssentialContract | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | EssentialContract | -| addressManager | address | 151 | 0 | 20 | EssentialContract | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | EssentialContract | -| \_\_reentry | uint8 | 201 | 0 | 1 | EssentialContract | -| \_\_paused | uint8 | 201 | 1 | 1 | EssentialContract | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | EssentialContract | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | EssentialContract | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------|------|--------|-------|-----------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | EssentialContract | +| _initializing | bool | 0 | 1 | 1 | EssentialContract | +| __gap | uint256[50] | 1 | 0 | 1600 | EssentialContract | +| _owner | address | 51 | 0 | 20 | EssentialContract | +| __gap | uint256[49] | 52 | 0 | 1568 | EssentialContract | +| _pendingOwner | address | 101 | 0 | 20 | EssentialContract | +| __gap | uint256[49] | 102 | 0 | 1568 | EssentialContract | +| addressManager | address | 151 | 0 | 20 | EssentialContract | +| __gap | uint256[49] | 152 | 0 | 1568 | EssentialContract | +| __reentry | uint8 | 201 | 0 | 1 | EssentialContract | +| __paused | uint8 | 201 | 1 | 1 | EssentialContract | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | EssentialContract | +| __gap | uint256[49] | 202 | 0 | 1568 | EssentialContract | ## SignalService - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | --------------------------------------------- | ---- | ------ | ----- | ------------- | -| \_initialized | uint8 | 0 | 0 | 1 | SignalService | -| \_initializing | bool | 0 | 1 | 1 | SignalService | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | SignalService | -| \_owner | address | 51 | 0 | 20 | SignalService | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | SignalService | -| \_pendingOwner | address | 101 | 0 | 20 | SignalService | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | SignalService | -| addressManager | address | 151 | 0 | 20 | SignalService | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | SignalService | -| \_\_reentry | uint8 | 201 | 0 | 1 | SignalService | -| \_\_paused | uint8 | 201 | 1 | 1 | SignalService | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | SignalService | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | SignalService | -| topBlockId | mapping(uint64 => mapping(bytes32 => uint64)) | 251 | 0 | 32 | SignalService | -| isAuthorized | mapping(address => bool) | 252 | 0 | 32 | SignalService | -| \_\_gap | uint256[48] | 253 | 0 | 1536 | SignalService | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-----------------------------------------------|------|--------|-------|---------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | SignalService | +| _initializing | bool | 0 | 1 | 1 | SignalService | +| __gap | uint256[50] | 1 | 0 | 1600 | SignalService | +| _owner | address | 51 | 0 | 20 | SignalService | +| __gap | uint256[49] | 52 | 0 | 1568 | SignalService | +| _pendingOwner | address | 101 | 0 | 20 | SignalService | +| __gap | uint256[49] | 102 | 0 | 1568 | SignalService | +| addressManager | address | 151 | 0 | 20 | SignalService | +| __gap | uint256[49] | 152 | 0 | 1568 | SignalService | +| __reentry | uint8 | 201 | 0 | 1 | SignalService | +| __paused | uint8 | 201 | 1 | 1 | SignalService | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | SignalService | +| __gap | uint256[49] | 202 | 0 | 1568 | SignalService | +| topBlockId | mapping(uint64 => mapping(bytes32 => uint64)) | 251 | 0 | 32 | SignalService | +| isAuthorized | mapping(address => bool) | 252 | 0 | 32 | SignalService | +| __gap | uint256[48] | 253 | 0 | 1536 | SignalService | ## BridgedTaikoToken - -| Name | Type | Slot | Offset | Bytes | Contract | -| ----------------------------------------------------- | ------------------------------------------------------------- | ---- | ------ | ----- | ----------------- | -| \_initialized | uint8 | 0 | 0 | 1 | BridgedTaikoToken | -| \_initializing | bool | 0 | 1 | 1 | BridgedTaikoToken | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | BridgedTaikoToken | -| \_owner | address | 51 | 0 | 20 | BridgedTaikoToken | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | BridgedTaikoToken | -| \_pendingOwner | address | 101 | 0 | 20 | BridgedTaikoToken | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | BridgedTaikoToken | -| addressManager | address | 151 | 0 | 20 | BridgedTaikoToken | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | BridgedTaikoToken | -| \_\_reentry | uint8 | 201 | 0 | 1 | BridgedTaikoToken | -| \_\_paused | uint8 | 201 | 1 | 1 | BridgedTaikoToken | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedTaikoToken | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | BridgedTaikoToken | -| \_\_slots_previously_used_by_ERC20SnapshotUpgradeable | uint256[50] | 251 | 0 | 1600 | BridgedTaikoToken | -| \_balances | mapping(address => uint256) | 301 | 0 | 32 | BridgedTaikoToken | -| \_allowances | mapping(address => mapping(address => uint256)) | 302 | 0 | 32 | BridgedTaikoToken | -| \_totalSupply | uint256 | 303 | 0 | 32 | BridgedTaikoToken | -| \_name | string | 304 | 0 | 32 | BridgedTaikoToken | -| \_symbol | string | 305 | 0 | 32 | BridgedTaikoToken | -| \_\_gap | uint256[45] | 306 | 0 | 1440 | BridgedTaikoToken | -| \_hashedName | bytes32 | 351 | 0 | 32 | BridgedTaikoToken | -| \_hashedVersion | bytes32 | 352 | 0 | 32 | BridgedTaikoToken | -| \_name | string | 353 | 0 | 32 | BridgedTaikoToken | -| \_version | string | 354 | 0 | 32 | BridgedTaikoToken | -| \_\_gap | uint256[48] | 355 | 0 | 1536 | BridgedTaikoToken | -| \_nonces | mapping(address => struct CountersUpgradeable.Counter) | 403 | 0 | 32 | BridgedTaikoToken | -| \_PERMIT_TYPEHASH_DEPRECATED_SLOT | bytes32 | 404 | 0 | 32 | BridgedTaikoToken | -| \_\_gap | uint256[49] | 405 | 0 | 1568 | BridgedTaikoToken | -| \_delegates | mapping(address => address) | 454 | 0 | 32 | BridgedTaikoToken | -| \_checkpoints | mapping(address => struct ERC20VotesUpgradeable.Checkpoint[]) | 455 | 0 | 32 | BridgedTaikoToken | -| \_totalSupplyCheckpoints | struct ERC20VotesUpgradeable.Checkpoint[] | 456 | 0 | 32 | BridgedTaikoToken | -| \_\_gap | uint256[47] | 457 | 0 | 1504 | BridgedTaikoToken | -| \_\_gap | uint256[50] | 504 | 0 | 1600 | BridgedTaikoToken | +| Name | Type | Slot | Offset | Bytes | Contract | +|-----------------------------------------------------|---------------------------------------------------------------|------|--------|-------|----------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | BridgedTaikoToken | +| _initializing | bool | 0 | 1 | 1 | BridgedTaikoToken | +| __gap | uint256[50] | 1 | 0 | 1600 | BridgedTaikoToken | +| _owner | address | 51 | 0 | 20 | BridgedTaikoToken | +| __gap | uint256[49] | 52 | 0 | 1568 | BridgedTaikoToken | +| _pendingOwner | address | 101 | 0 | 20 | BridgedTaikoToken | +| __gap | uint256[49] | 102 | 0 | 1568 | BridgedTaikoToken | +| addressManager | address | 151 | 0 | 20 | BridgedTaikoToken | +| __gap | uint256[49] | 152 | 0 | 1568 | BridgedTaikoToken | +| __reentry | uint8 | 201 | 0 | 1 | BridgedTaikoToken | +| __paused | uint8 | 201 | 1 | 1 | BridgedTaikoToken | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | BridgedTaikoToken | +| __gap | uint256[49] | 202 | 0 | 1568 | BridgedTaikoToken | +| __slots_previously_used_by_ERC20SnapshotUpgradeable | uint256[50] | 251 | 0 | 1600 | BridgedTaikoToken | +| _balances | mapping(address => uint256) | 301 | 0 | 32 | BridgedTaikoToken | +| _allowances | mapping(address => mapping(address => uint256)) | 302 | 0 | 32 | BridgedTaikoToken | +| _totalSupply | uint256 | 303 | 0 | 32 | BridgedTaikoToken | +| _name | string | 304 | 0 | 32 | BridgedTaikoToken | +| _symbol | string | 305 | 0 | 32 | BridgedTaikoToken | +| __gap | uint256[45] | 306 | 0 | 1440 | BridgedTaikoToken | +| _hashedName | bytes32 | 351 | 0 | 32 | BridgedTaikoToken | +| _hashedVersion | bytes32 | 352 | 0 | 32 | BridgedTaikoToken | +| _name | string | 353 | 0 | 32 | BridgedTaikoToken | +| _version | string | 354 | 0 | 32 | BridgedTaikoToken | +| __gap | uint256[48] | 355 | 0 | 1536 | BridgedTaikoToken | +| _nonces | mapping(address => struct CountersUpgradeable.Counter) | 403 | 0 | 32 | BridgedTaikoToken | +| _PERMIT_TYPEHASH_DEPRECATED_SLOT | bytes32 | 404 | 0 | 32 | BridgedTaikoToken | +| __gap | uint256[49] | 405 | 0 | 1568 | BridgedTaikoToken | +| _delegates | mapping(address => address) | 454 | 0 | 32 | BridgedTaikoToken | +| _checkpoints | mapping(address => struct ERC20VotesUpgradeable.Checkpoint[]) | 455 | 0 | 32 | BridgedTaikoToken | +| _totalSupplyCheckpoints | struct ERC20VotesUpgradeable.Checkpoint[] | 456 | 0 | 32 | BridgedTaikoToken | +| __gap | uint256[47] | 457 | 0 | 1504 | BridgedTaikoToken | +| __gap | uint256[50] | 504 | 0 | 1600 | BridgedTaikoToken | ## DelegateOwner - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | ----------- | ---- | ------ | ----- | ------------- | -| \_initialized | uint8 | 0 | 0 | 1 | DelegateOwner | -| \_initializing | bool | 0 | 1 | 1 | DelegateOwner | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | DelegateOwner | -| \_owner | address | 51 | 0 | 20 | DelegateOwner | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | DelegateOwner | -| \_pendingOwner | address | 101 | 0 | 20 | DelegateOwner | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | DelegateOwner | -| addressManager | address | 151 | 0 | 20 | DelegateOwner | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | DelegateOwner | -| \_\_reentry | uint8 | 201 | 0 | 1 | DelegateOwner | -| \_\_paused | uint8 | 201 | 1 | 1 | DelegateOwner | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | DelegateOwner | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | DelegateOwner | -| remoteChainId | uint64 | 251 | 0 | 8 | DelegateOwner | -| admin | address | 251 | 8 | 20 | DelegateOwner | -| nextTxId | uint64 | 252 | 0 | 8 | DelegateOwner | -| remoteOwner | address | 252 | 8 | 20 | DelegateOwner | -| \_\_gap | uint256[48] | 253 | 0 | 1536 | DelegateOwner | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-------------|------|--------|-------|--------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | DelegateOwner | +| _initializing | bool | 0 | 1 | 1 | DelegateOwner | +| __gap | uint256[50] | 1 | 0 | 1600 | DelegateOwner | +| _owner | address | 51 | 0 | 20 | DelegateOwner | +| __gap | uint256[49] | 52 | 0 | 1568 | DelegateOwner | +| _pendingOwner | address | 101 | 0 | 20 | DelegateOwner | +| __gap | uint256[49] | 102 | 0 | 1568 | DelegateOwner | +| addressManager | address | 151 | 0 | 20 | DelegateOwner | +| __gap | uint256[49] | 152 | 0 | 1568 | DelegateOwner | +| __reentry | uint8 | 201 | 0 | 1 | DelegateOwner | +| __paused | uint8 | 201 | 1 | 1 | DelegateOwner | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | DelegateOwner | +| __gap | uint256[49] | 202 | 0 | 1568 | DelegateOwner | +| remoteChainId | uint64 | 251 | 0 | 8 | DelegateOwner | +| admin | address | 251 | 8 | 20 | DelegateOwner | +| nextTxId | uint64 | 252 | 0 | 8 | DelegateOwner | +| remoteOwner | address | 252 | 8 | 20 | DelegateOwner | +| __gap | uint256[48] | 253 | 0 | 1536 | DelegateOwner | ## TaikoL2 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | --------------------------- | ---- | ------ | ----- | -------- | -| \_initialized | uint8 | 0 | 0 | 1 | TaikoL2 | -| \_initializing | bool | 0 | 1 | 1 | TaikoL2 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | TaikoL2 | -| \_owner | address | 51 | 0 | 20 | TaikoL2 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | TaikoL2 | -| \_pendingOwner | address | 101 | 0 | 20 | TaikoL2 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | TaikoL2 | -| addressManager | address | 151 | 0 | 20 | TaikoL2 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | TaikoL2 | -| \_\_reentry | uint8 | 201 | 0 | 1 | TaikoL2 | -| \_\_paused | uint8 | 201 | 1 | 1 | TaikoL2 | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | TaikoL2 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | TaikoL2 | -| \_blockhashes | mapping(uint256 => bytes32) | 251 | 0 | 32 | TaikoL2 | -| publicInputHash | bytes32 | 252 | 0 | 32 | TaikoL2 | -| parentGasExcess | uint64 | 253 | 0 | 8 | TaikoL2 | -| lastSyncedBlock | uint64 | 253 | 8 | 8 | TaikoL2 | -| parentTimestamp | uint64 | 253 | 16 | 8 | TaikoL2 | -| parentGasTarget | uint64 | 253 | 24 | 8 | TaikoL2 | -| l1ChainId | uint64 | 254 | 0 | 8 | TaikoL2 | -| \_\_gap | uint256[46] | 255 | 0 | 1472 | TaikoL2 | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-----------------------------|------|--------|-------|--------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | TaikoL2 | +| _initializing | bool | 0 | 1 | 1 | TaikoL2 | +| __gap | uint256[50] | 1 | 0 | 1600 | TaikoL2 | +| _owner | address | 51 | 0 | 20 | TaikoL2 | +| __gap | uint256[49] | 52 | 0 | 1568 | TaikoL2 | +| _pendingOwner | address | 101 | 0 | 20 | TaikoL2 | +| __gap | uint256[49] | 102 | 0 | 1568 | TaikoL2 | +| addressManager | address | 151 | 0 | 20 | TaikoL2 | +| __gap | uint256[49] | 152 | 0 | 1568 | TaikoL2 | +| __reentry | uint8 | 201 | 0 | 1 | TaikoL2 | +| __paused | uint8 | 201 | 1 | 1 | TaikoL2 | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | TaikoL2 | +| __gap | uint256[49] | 202 | 0 | 1568 | TaikoL2 | +| _blockhashes | mapping(uint256 => bytes32) | 251 | 0 | 32 | TaikoL2 | +| publicInputHash | bytes32 | 252 | 0 | 32 | TaikoL2 | +| parentGasExcess | uint64 | 253 | 0 | 8 | TaikoL2 | +| lastSyncedBlock | uint64 | 253 | 8 | 8 | TaikoL2 | +| parentTimestamp | uint64 | 253 | 16 | 8 | TaikoL2 | +| parentGasTarget | uint64 | 253 | 24 | 8 | TaikoL2 | +| l1ChainId | uint64 | 254 | 0 | 8 | TaikoL2 | +| __gap | uint256[46] | 255 | 0 | 1472 | TaikoL2 | ## HeklaTaikoL2 - -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | --------------------------- | ---- | ------ | ----- | ------------ | -| \_initialized | uint8 | 0 | 0 | 1 | HeklaTaikoL2 | -| \_initializing | bool | 0 | 1 | 1 | HeklaTaikoL2 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | HeklaTaikoL2 | -| \_owner | address | 51 | 0 | 20 | HeklaTaikoL2 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | HeklaTaikoL2 | -| \_pendingOwner | address | 101 | 0 | 20 | HeklaTaikoL2 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | HeklaTaikoL2 | -| addressManager | address | 151 | 0 | 20 | HeklaTaikoL2 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | HeklaTaikoL2 | -| \_\_reentry | uint8 | 201 | 0 | 1 | HeklaTaikoL2 | -| \_\_paused | uint8 | 201 | 1 | 1 | HeklaTaikoL2 | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | HeklaTaikoL2 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | HeklaTaikoL2 | -| \_blockhashes | mapping(uint256 => bytes32) | 251 | 0 | 32 | HeklaTaikoL2 | -| publicInputHash | bytes32 | 252 | 0 | 32 | HeklaTaikoL2 | -| parentGasExcess | uint64 | 253 | 0 | 8 | HeklaTaikoL2 | -| lastSyncedBlock | uint64 | 253 | 8 | 8 | HeklaTaikoL2 | -| parentTimestamp | uint64 | 253 | 16 | 8 | HeklaTaikoL2 | -| parentGasTarget | uint64 | 253 | 24 | 8 | HeklaTaikoL2 | -| l1ChainId | uint64 | 254 | 0 | 8 | HeklaTaikoL2 | -| \_\_gap | uint256[46] | 255 | 0 | 1472 | HeklaTaikoL2 | +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-----------------------------|------|--------|-------|------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | HeklaTaikoL2 | +| _initializing | bool | 0 | 1 | 1 | HeklaTaikoL2 | +| __gap | uint256[50] | 1 | 0 | 1600 | HeklaTaikoL2 | +| _owner | address | 51 | 0 | 20 | HeklaTaikoL2 | +| __gap | uint256[49] | 52 | 0 | 1568 | HeklaTaikoL2 | +| _pendingOwner | address | 101 | 0 | 20 | HeklaTaikoL2 | +| __gap | uint256[49] | 102 | 0 | 1568 | HeklaTaikoL2 | +| addressManager | address | 151 | 0 | 20 | HeklaTaikoL2 | +| __gap | uint256[49] | 152 | 0 | 1568 | HeklaTaikoL2 | +| __reentry | uint8 | 201 | 0 | 1 | HeklaTaikoL2 | +| __paused | uint8 | 201 | 1 | 1 | HeklaTaikoL2 | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | HeklaTaikoL2 | +| __gap | uint256[49] | 202 | 0 | 1568 | HeklaTaikoL2 | +| _blockhashes | mapping(uint256 => bytes32) | 251 | 0 | 32 | HeklaTaikoL2 | +| publicInputHash | bytes32 | 252 | 0 | 32 | HeklaTaikoL2 | +| parentGasExcess | uint64 | 253 | 0 | 8 | HeklaTaikoL2 | +| lastSyncedBlock | uint64 | 253 | 8 | 8 | HeklaTaikoL2 | +| parentTimestamp | uint64 | 253 | 16 | 8 | HeklaTaikoL2 | +| parentGasTarget | uint64 | 253 | 24 | 8 | HeklaTaikoL2 | +| l1ChainId | uint64 | 254 | 0 | 8 | HeklaTaikoL2 | +| __gap | uint256[46] | 255 | 0 | 1472 | HeklaTaikoL2 | ## MainnetTaikoL2 +| Name | Type | Slot | Offset | Bytes | Contract | +|------------------|-----------------------------|------|--------|-------|------------------------------------------------------------| +| _initialized | uint8 | 0 | 0 | 1 | MainnetTaikoL2 | +| _initializing | bool | 0 | 1 | 1 | MainnetTaikoL2 | +| __gap | uint256[50] | 1 | 0 | 1600 | MainnetTaikoL2 | +| _owner | address | 51 | 0 | 20 | MainnetTaikoL2 | +| __gap | uint256[49] | 52 | 0 | 1568 | MainnetTaikoL2 | +| _pendingOwner | address | 101 | 0 | 20 | MainnetTaikoL2 | +| __gap | uint256[49] | 102 | 0 | 1568 | MainnetTaikoL2 | +| addressManager | address | 151 | 0 | 20 | MainnetTaikoL2 | +| __gap | uint256[49] | 152 | 0 | 1568 | MainnetTaikoL2 | +| __reentry | uint8 | 201 | 0 | 1 | MainnetTaikoL2 | +| __paused | uint8 | 201 | 1 | 1 | MainnetTaikoL2 | +| __lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetTaikoL2 | +| __gap | uint256[49] | 202 | 0 | 1568 | MainnetTaikoL2 | +| _blockhashes | mapping(uint256 => bytes32) | 251 | 0 | 32 | MainnetTaikoL2 | +| publicInputHash | bytes32 | 252 | 0 | 32 | MainnetTaikoL2 | +| parentGasExcess | uint64 | 253 | 0 | 8 | MainnetTaikoL2 | +| lastSyncedBlock | uint64 | 253 | 8 | 8 | MainnetTaikoL2 | +| parentTimestamp | uint64 | 253 | 16 | 8 | MainnetTaikoL2 | +| parentGasTarget | uint64 | 253 | 24 | 8 | MainnetTaikoL2 | +| l1ChainId | uint64 | 254 | 0 | 8 | MainnetTaikoL2 | +| __gap | uint256[46] | 255 | 0 | 1472 | MainnetTaikoL2 | -| Name | Type | Slot | Offset | Bytes | Contract | -| ------------------ | --------------------------- | ---- | ------ | ----- | -------------- | -| \_initialized | uint8 | 0 | 0 | 1 | MainnetTaikoL2 | -| \_initializing | bool | 0 | 1 | 1 | MainnetTaikoL2 | -| \_\_gap | uint256[50] | 1 | 0 | 1600 | MainnetTaikoL2 | -| \_owner | address | 51 | 0 | 20 | MainnetTaikoL2 | -| \_\_gap | uint256[49] | 52 | 0 | 1568 | MainnetTaikoL2 | -| \_pendingOwner | address | 101 | 0 | 20 | MainnetTaikoL2 | -| \_\_gap | uint256[49] | 102 | 0 | 1568 | MainnetTaikoL2 | -| addressManager | address | 151 | 0 | 20 | MainnetTaikoL2 | -| \_\_gap | uint256[49] | 152 | 0 | 1568 | MainnetTaikoL2 | -| \_\_reentry | uint8 | 201 | 0 | 1 | MainnetTaikoL2 | -| \_\_paused | uint8 | 201 | 1 | 1 | MainnetTaikoL2 | -| \_\_lastUnpausedAt | uint64 | 201 | 2 | 8 | MainnetTaikoL2 | -| \_\_gap | uint256[49] | 202 | 0 | 1568 | MainnetTaikoL2 | -| \_blockhashes | mapping(uint256 => bytes32) | 251 | 0 | 32 | MainnetTaikoL2 | -| publicInputHash | bytes32 | 252 | 0 | 32 | MainnetTaikoL2 | -| parentGasExcess | uint64 | 253 | 0 | 8 | MainnetTaikoL2 | -| lastSyncedBlock | uint64 | 253 | 8 | 8 | MainnetTaikoL2 | -| parentTimestamp | uint64 | 253 | 16 | 8 | MainnetTaikoL2 | -| parentGasTarget | uint64 | 253 | 24 | 8 | MainnetTaikoL2 | -| l1ChainId | uint64 | 254 | 0 | 8 | MainnetTaikoL2 | -| \_\_gap | uint256[46] | 255 | 0 | 1472 | MainnetTaikoL2 | From 637d193fbdca4a6689adf6ddbb71b4f486ebecba Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 2 Dec 2024 10:51:30 +0100 Subject: [PATCH 78/79] solved gh errors --- .../trailblazer/trailblazers-badges/sol/Deploy.s.sol | 4 ---- .../trailblazer/trailblazers-badges/sol/UpgradeV2.sol | 4 ---- packages/nfts/script/trailblazers-badges/Deploy.s.sol | 5 ----- .../nfts/script/trailblazers-badges/UpgradeS1.sol | 5 ----- packages/nfts/script/trailblazers-badges/Utils.s.sol | 11 +---------- 5 files changed, 1 insertion(+), 28 deletions(-) diff --git a/packages/nfts/script/trailblazer/trailblazers-badges/sol/Deploy.s.sol b/packages/nfts/script/trailblazer/trailblazers-badges/sol/Deploy.s.sol index fd30fad4826..278128c9659 100644 --- a/packages/nfts/script/trailblazer/trailblazers-badges/sol/Deploy.s.sol +++ b/packages/nfts/script/trailblazer/trailblazers-badges/sol/Deploy.s.sol @@ -5,12 +5,8 @@ import { UtilsScript, MockBlacklist } 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"; -<<<<<<<< HEAD:packages/nfts/script/trailblazers-badges/Deploy.s.sol -import { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; -======== import { TrailblazersBadges } from "../../../../contracts/trailblazers-badges/TrailblazersBadges.sol"; ->>>>>>>> main:packages/nfts/script/trailblazer/trailblazers-badges/sol/Deploy.s.sol import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; contract DeployScript is Script { diff --git a/packages/nfts/script/trailblazer/trailblazers-badges/sol/UpgradeV2.sol b/packages/nfts/script/trailblazer/trailblazers-badges/sol/UpgradeV2.sol index d2be00f11ef..976afe77915 100644 --- a/packages/nfts/script/trailblazer/trailblazers-badges/sol/UpgradeV2.sol +++ b/packages/nfts/script/trailblazer/trailblazers-badges/sol/UpgradeV2.sol @@ -5,12 +5,8 @@ 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"; -<<<<<<<< HEAD:packages/nfts/script/trailblazers-badges/UpgradeS1.sol -import { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; -======== import { TrailblazersBadges } from "../../../../contracts/trailblazers-badges/TrailblazersBadges.sol"; ->>>>>>>> main:packages/nfts/script/trailblazer/trailblazers-badges/sol/UpgradeV2.sol import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; contract UpgradeV2 is Script { diff --git a/packages/nfts/script/trailblazers-badges/Deploy.s.sol b/packages/nfts/script/trailblazers-badges/Deploy.s.sol index fd30fad4826..a48ce45cdc8 100644 --- a/packages/nfts/script/trailblazers-badges/Deploy.s.sol +++ b/packages/nfts/script/trailblazers-badges/Deploy.s.sol @@ -5,12 +5,7 @@ import { UtilsScript, MockBlacklist } 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"; -<<<<<<<< HEAD:packages/nfts/script/trailblazers-badges/Deploy.s.sol import { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; -======== -import { TrailblazersBadges } from - "../../../../contracts/trailblazers-badges/TrailblazersBadges.sol"; ->>>>>>>> main:packages/nfts/script/trailblazer/trailblazers-badges/sol/Deploy.s.sol import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; contract DeployScript is Script { diff --git a/packages/nfts/script/trailblazers-badges/UpgradeS1.sol b/packages/nfts/script/trailblazers-badges/UpgradeS1.sol index d2be00f11ef..3fd1ea77341 100644 --- a/packages/nfts/script/trailblazers-badges/UpgradeS1.sol +++ b/packages/nfts/script/trailblazers-badges/UpgradeS1.sol @@ -5,12 +5,7 @@ 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"; -<<<<<<<< HEAD:packages/nfts/script/trailblazers-badges/UpgradeS1.sol import { TrailblazersBadges } from "../../contracts/trailblazers-badges/TrailblazersBadges.sol"; -======== -import { TrailblazersBadges } from - "../../../../contracts/trailblazers-badges/TrailblazersBadges.sol"; ->>>>>>>> main:packages/nfts/script/trailblazer/trailblazers-badges/sol/UpgradeV2.sol import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; contract UpgradeV2 is Script { diff --git a/packages/nfts/script/trailblazers-badges/Utils.s.sol b/packages/nfts/script/trailblazers-badges/Utils.s.sol index 92f9042acd3..747c9ac3eae 100644 --- a/packages/nfts/script/trailblazers-badges/Utils.s.sol +++ b/packages/nfts/script/trailblazers-badges/Utils.s.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.24; import { Script, console } from "forge-std/src/Script.sol"; import "forge-std/src/StdJson.sol"; -import { MockBlacklist } from "../../../test/util/Blacklist.sol"; +import { MockBlacklist } from "../../test/util/Blacklist.sol"; import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; contract UtilsScript is Script { @@ -78,12 +78,3 @@ contract UtilsScript is Script { function run() public { } } - -contract MockBlacklist is IMinimalBlacklist { - function isBlacklisted(address _account) external pure returns (bool) { - if (_account == address(0)) { - return true; - } - return false; - } -} From 258333d2b2299828d79de2480ae12ae736f6b630 Mon Sep 17 00:00:00 2001 From: bearni95 Date: Mon, 2 Dec 2024 10:55:16 +0100 Subject: [PATCH 79/79] refactored folders --- .../trailblazers-badges/Deploy.s.sol | 2 +- .../trailblazers-badges/UpgradeS1.sol | 2 +- .../trailblazers-badges/UpgradeV3.s.sol | 5 +- .../trailblazers-badges/UpgradeV3.sol | 5 +- .../trailblazers-badges/UpgradeV4.s.sol | 7 +- .../trailblazers-badges/Utils.s.sol | 2 +- .../trailblazers-badges/sol/Deploy.s.sol | 84 ------------------- .../trailblazers-badges/sol/UpgradeV2.sol | 42 ---------- .../trailblazers-badges/sol/UpgradeV3.sol | 45 ---------- .../trailblazers-badges/sol/Utils.s.sol | 78 ----------------- 10 files changed, 13 insertions(+), 259 deletions(-) rename packages/nfts/script/{ => trailblazer}/trailblazers-badges/Deploy.s.sol (96%) rename packages/nfts/script/{ => trailblazer}/trailblazers-badges/UpgradeS1.sol (92%) rename packages/nfts/script/{ => trailblazer}/trailblazers-badges/UpgradeV3.s.sol (86%) rename packages/nfts/script/{ => trailblazer}/trailblazers-badges/UpgradeV3.sol (86%) rename packages/nfts/script/{ => trailblazer}/trailblazers-badges/UpgradeV4.s.sol (85%) rename packages/nfts/script/{ => trailblazer}/trailblazers-badges/Utils.s.sol (97%) delete mode 100644 packages/nfts/script/trailblazer/trailblazers-badges/sol/Deploy.s.sol delete mode 100644 packages/nfts/script/trailblazer/trailblazers-badges/sol/UpgradeV2.sol delete mode 100644 packages/nfts/script/trailblazer/trailblazers-badges/sol/UpgradeV3.sol delete mode 100644 packages/nfts/script/trailblazer/trailblazers-badges/sol/Utils.s.sol diff --git a/packages/nfts/script/trailblazers-badges/Deploy.s.sol b/packages/nfts/script/trailblazer/trailblazers-badges/Deploy.s.sol similarity index 96% rename from packages/nfts/script/trailblazers-badges/Deploy.s.sol rename to packages/nfts/script/trailblazer/trailblazers-badges/Deploy.s.sol index a48ce45cdc8..932321e9237 100644 --- a/packages/nfts/script/trailblazers-badges/Deploy.s.sol +++ b/packages/nfts/script/trailblazer/trailblazers-badges/Deploy.s.sol @@ -5,7 +5,7 @@ import { UtilsScript, MockBlacklist } 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 { TrailblazersBadges } from "../../../contracts/trailblazers-badges/TrailblazersBadges.sol"; import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; contract DeployScript is Script { diff --git a/packages/nfts/script/trailblazers-badges/UpgradeS1.sol b/packages/nfts/script/trailblazer/trailblazers-badges/UpgradeS1.sol similarity index 92% rename from packages/nfts/script/trailblazers-badges/UpgradeS1.sol rename to packages/nfts/script/trailblazer/trailblazers-badges/UpgradeS1.sol index 3fd1ea77341..662a98a3561 100644 --- a/packages/nfts/script/trailblazers-badges/UpgradeS1.sol +++ b/packages/nfts/script/trailblazer/trailblazers-badges/UpgradeS1.sol @@ -5,7 +5,7 @@ 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 { TrailblazersBadges } from "../../../contracts/trailblazers-badges/TrailblazersBadges.sol"; import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; contract UpgradeV2 is Script { diff --git a/packages/nfts/script/trailblazers-badges/UpgradeV3.s.sol b/packages/nfts/script/trailblazer/trailblazers-badges/UpgradeV3.s.sol similarity index 86% rename from packages/nfts/script/trailblazers-badges/UpgradeV3.s.sol rename to packages/nfts/script/trailblazer/trailblazers-badges/UpgradeV3.s.sol index fe09f5a74c8..e212f866987 100644 --- a/packages/nfts/script/trailblazers-badges/UpgradeV3.s.sol +++ b/packages/nfts/script/trailblazer/trailblazers-badges/UpgradeV3.s.sol @@ -5,9 +5,10 @@ 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 { TrailblazersBadges } from "../../../contracts/trailblazers-badges/TrailblazersBadges.sol"; import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; -import { TrailblazersBadgesV3 } from "../../contracts/trailblazers-badges/TrailblazersBadgesV3.sol"; +import { TrailblazersBadgesV3 } from + "../../../contracts/trailblazers-badges/TrailblazersBadgesV3.sol"; contract UpgradeV3 is Script { UtilsScript public utils; diff --git a/packages/nfts/script/trailblazers-badges/UpgradeV3.sol b/packages/nfts/script/trailblazer/trailblazers-badges/UpgradeV3.sol similarity index 86% rename from packages/nfts/script/trailblazers-badges/UpgradeV3.sol rename to packages/nfts/script/trailblazer/trailblazers-badges/UpgradeV3.sol index fe09f5a74c8..e212f866987 100644 --- a/packages/nfts/script/trailblazers-badges/UpgradeV3.sol +++ b/packages/nfts/script/trailblazer/trailblazers-badges/UpgradeV3.sol @@ -5,9 +5,10 @@ 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 { TrailblazersBadges } from "../../../contracts/trailblazers-badges/TrailblazersBadges.sol"; import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; -import { TrailblazersBadgesV3 } from "../../contracts/trailblazers-badges/TrailblazersBadgesV3.sol"; +import { TrailblazersBadgesV3 } from + "../../../contracts/trailblazers-badges/TrailblazersBadgesV3.sol"; contract UpgradeV3 is Script { UtilsScript public utils; diff --git a/packages/nfts/script/trailblazers-badges/UpgradeV4.s.sol b/packages/nfts/script/trailblazer/trailblazers-badges/UpgradeV4.s.sol similarity index 85% rename from packages/nfts/script/trailblazers-badges/UpgradeV4.s.sol rename to packages/nfts/script/trailblazer/trailblazers-badges/UpgradeV4.s.sol index 6627496ba66..d49ad9cb55a 100644 --- a/packages/nfts/script/trailblazers-badges/UpgradeV4.s.sol +++ b/packages/nfts/script/trailblazer/trailblazers-badges/UpgradeV4.s.sol @@ -5,11 +5,12 @@ 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 { TrailblazersBadges } from "../../../contracts/trailblazers-badges/TrailblazersBadges.sol"; import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; -import { TrailblazersBadgesV3 } from "../../contracts/trailblazers-badges/TrailblazersBadgesV3.sol"; +import { TrailblazersBadgesV3 } from + "../../../contracts/trailblazers-badges/TrailblazersBadgesV3.sol"; import { TrailblazersBadgesV4 } from - "../../contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol"; + "../../../contracts/trailblazers-season-2/TrailblazersS1BadgesV4.sol"; contract UpgradeV4 is Script { UtilsScript public utils; diff --git a/packages/nfts/script/trailblazers-badges/Utils.s.sol b/packages/nfts/script/trailblazer/trailblazers-badges/Utils.s.sol similarity index 97% rename from packages/nfts/script/trailblazers-badges/Utils.s.sol rename to packages/nfts/script/trailblazer/trailblazers-badges/Utils.s.sol index 747c9ac3eae..3a0dc45a5c6 100644 --- a/packages/nfts/script/trailblazers-badges/Utils.s.sol +++ b/packages/nfts/script/trailblazer/trailblazers-badges/Utils.s.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.24; import { Script, console } from "forge-std/src/Script.sol"; import "forge-std/src/StdJson.sol"; -import { MockBlacklist } from "../../test/util/Blacklist.sol"; +import { MockBlacklist } from "../../../test/util/Blacklist.sol"; import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; contract UtilsScript is Script { diff --git a/packages/nfts/script/trailblazer/trailblazers-badges/sol/Deploy.s.sol b/packages/nfts/script/trailblazer/trailblazers-badges/sol/Deploy.s.sol deleted file mode 100644 index 278128c9659..00000000000 --- a/packages/nfts/script/trailblazer/trailblazers-badges/sol/Deploy.s.sol +++ /dev/null @@ -1,84 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.24; - -import { UtilsScript, MockBlacklist } 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"; - -contract DeployScript is Script { - UtilsScript public utils; - string public jsonLocation; - uint256 public deployerPrivateKey; - address public deployerAddress; - - // Taiko Mainnet Values - //address owner = 0xf8ff2AF0DC1D5BA4811f22aCb02936A1529fd2Be; - //bytes32 root = 0xa7e510d5aed347e65609cf6f0e0738cdd752ffdf5980749057c634489fd09fc3; - // string baseURI = "bafybeiebmvj6roz4iuoinackb5c6eeshvppctkydrckqrnxexdnzh6odq4"; - // IMinimalBlacklist blacklist = IMinimalBlacklist(0xfA5EA6f9A13532cd64e805996a941F101CCaAc9a); - - // Holesky Testnet Values - // address owner = 0xf8ff2AF0DC1D5BA4811f22aCb02936A1529fd2Be; - // bytes32 root = 0xf1359c4c4ba41a72025f2534ea8ad23c6b941b55a715838ebdc71202a78c6c87; - // string baseURI = "bafybeiebmvj6roz4iuoinackb5c6eeshvppctkydrckqrnxexdnzh6odq4"; - // IMinimalBlacklist blacklist = IMinimalBlacklist(0xe61E9034b5633977eC98E302b33e321e8140F105); - - // Hardhat Testnet Values - address owner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; - address mintSigner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; - string baseURI = - "https://taikonfts.4everland.link/ipfs/bafybeiebmvj6roz4iuoinackb5c6eeshvppctkydrckqrnxexdnzh6odq4"; - IMinimalBlacklist blacklist = IMinimalBlacklist(0xe61E9034b5633977eC98E302b33e321e8140F105); - - function setUp() public { - utils = new UtilsScript(); - utils.setUp(); - - jsonLocation = utils.getContractJsonLocation(); - deployerPrivateKey = utils.getPrivateKey(); - deployerAddress = utils.getAddress(); - } - - function run() public { - string memory jsonRoot = "root"; - - require(owner != address(0), "Owner must be specified"); - - vm.startBroadcast(deployerPrivateKey); - - if (block.chainid == 167_000) { - // mainnet, use existing blacklist - } else { - blacklist = new MockBlacklist(); - } - - // deploy token with empty root - address impl = address(new TrailblazersBadges()); - address proxy = address( - new ERC1967Proxy( - impl, - abi.encodeCall( - TrailblazersBadges.initialize, (owner, baseURI, mintSigner, blacklist) - ) - ) - ); - - TrailblazersBadges token = TrailblazersBadges(proxy); - - console.log("Token Base URI:", baseURI); - console.log("Deployed TrailblazersBadges to:", address(token)); - - vm.serializeAddress(jsonRoot, "Owner", token.owner()); - vm.serializeAddress(jsonRoot, "MintSigner", token.mintSigner()); - - string memory finalJson = - vm.serializeAddress(jsonRoot, "TrailblazersBadges", address(token)); - vm.writeJson(finalJson, jsonLocation); - - vm.stopBroadcast(); - } -} diff --git a/packages/nfts/script/trailblazer/trailblazers-badges/sol/UpgradeV2.sol b/packages/nfts/script/trailblazer/trailblazers-badges/sol/UpgradeV2.sol deleted file mode 100644 index 976afe77915..00000000000 --- a/packages/nfts/script/trailblazer/trailblazers-badges/sol/UpgradeV2.sol +++ /dev/null @@ -1,42 +0,0 @@ -// 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"; - -contract UpgradeV2 is Script { - UtilsScript public utils; - string public jsonLocation; - uint256 public deployerPrivateKey; - address public deployerAddress; - - address s1Token = 0xa20a8856e00F5ad024a55A663F06DCc419FFc4d5; - TrailblazersBadges public token; - - function setUp() public { - utils = new UtilsScript(); - utils.setUp(); - - jsonLocation = utils.getContractJsonLocation(); - deployerPrivateKey = utils.getPrivateKey(); - deployerAddress = utils.getAddress(); - } - - function run() public { - token = TrailblazersBadges(s1Token); - vm.startBroadcast(deployerPrivateKey); - - token.upgradeToAndCall( - address(new TrailblazersBadges()), abi.encodeCall(TrailblazersBadges.baseURI, ()) - ); - - token = TrailblazersBadges(token); - - console.log("Upgraded TrailblazersBadges to:", address(token)); - } -} diff --git a/packages/nfts/script/trailblazer/trailblazers-badges/sol/UpgradeV3.sol b/packages/nfts/script/trailblazer/trailblazers-badges/sol/UpgradeV3.sol deleted file mode 100644 index 472192164cd..00000000000 --- a/packages/nfts/script/trailblazer/trailblazers-badges/sol/UpgradeV3.sol +++ /dev/null @@ -1,45 +0,0 @@ -// 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 { TrailblazersBadgesV3 } from - "../../../../contracts/trailblazers-badges/TrailblazersBadgesV3.sol"; - -contract UpgradeV2 is Script { - UtilsScript public utils; - string public jsonLocation; - uint256 public deployerPrivateKey; - address public deployerAddress; - - address tokenV2Address = 0xa20a8856e00F5ad024a55A663F06DCc419FFc4d5; - TrailblazersBadges public tokenV2; - TrailblazersBadgesV3 public tokenV3; - - function setUp() public { - utils = new UtilsScript(); - utils.setUp(); - - jsonLocation = utils.getContractJsonLocation(); - deployerPrivateKey = utils.getPrivateKey(); - deployerAddress = utils.getAddress(); - } - - function run() public { - vm.startBroadcast(deployerPrivateKey); - tokenV2 = TrailblazersBadges(tokenV2Address); - - tokenV2.upgradeToAndCall( - address(new TrailblazersBadgesV3()), abi.encodeCall(TrailblazersBadgesV3.version, ()) - ); - - tokenV3 = TrailblazersBadgesV3(tokenV3); - - console.log("Upgraded TrailblazersBadgesV3 to:", address(tokenV3)); - } -} diff --git a/packages/nfts/script/trailblazer/trailblazers-badges/sol/Utils.s.sol b/packages/nfts/script/trailblazer/trailblazers-badges/sol/Utils.s.sol deleted file mode 100644 index 3af584af2bb..00000000000 --- a/packages/nfts/script/trailblazer/trailblazers-badges/sol/Utils.s.sol +++ /dev/null @@ -1,78 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.24; - -import { Script, console } from "forge-std/src/Script.sol"; -import "forge-std/src/StdJson.sol"; -import { IMinimalBlacklist } from "@taiko/blacklist/IMinimalBlacklist.sol"; -import { MockBlacklist } from "../../../../test/util/Blacklist.sol"; - -contract UtilsScript is Script { - using stdJson for string; - - address public nounsTokenAddress; - - uint256 public chainId; - - string public lowercaseNetworkKey; - string public uppercaseNetworkKey; - - function setUp() public { - // load all network configs - chainId = block.chainid; - - if (chainId == 31_337) { - lowercaseNetworkKey = "localhost"; - uppercaseNetworkKey = "LOCALHOST"; - } else if (chainId == 17_000) { - lowercaseNetworkKey = "holesky"; - uppercaseNetworkKey = "HOLESKY"; - } else if (chainId == 167_001) { - lowercaseNetworkKey = "devnet"; - uppercaseNetworkKey = "DEVNET"; - } else if (chainId == 11_155_111) { - lowercaseNetworkKey = "sepolia"; - uppercaseNetworkKey = "SEPOLIA"; - } else if (chainId == 167_008) { - lowercaseNetworkKey = "katla"; - uppercaseNetworkKey = "KATLA"; - } else if (chainId == 167_000) { - lowercaseNetworkKey = "mainnet"; - uppercaseNetworkKey = "MAINNET"; - } else if (chainId == 167_009) { - lowercaseNetworkKey = "hekla"; - uppercaseNetworkKey = "HEKLA"; - } else { - revert("Unsupported chainId"); - } - } - - function getPrivateKey() public view returns (uint256) { - string memory lookupKey = string.concat(uppercaseNetworkKey, "_PRIVATE_KEY"); - return vm.envUint(lookupKey); - } - - function getAddress() public view returns (address) { - string memory lookupKey = string.concat(uppercaseNetworkKey, "_ADDRESS"); - return vm.envAddress(lookupKey); - } - - function getContractJsonLocation() public view returns (string memory) { - string memory root = vm.projectRoot(); - return - string.concat(root, "/deployments/trailblazers-badges/", lowercaseNetworkKey, ".json"); - } - - function getBlacklist() public view returns (IMinimalBlacklist blacklistAddress) { - if (block.chainid == 167_000) { - // mainnet blacklist address - blacklistAddress = IMinimalBlacklist(vm.envAddress("BLACKLIST_ADDRESS")); - } else { - // deploy a mock blacklist otherwise - blacklistAddress = IMinimalBlacklist(0xbdEd0D2bf404bdcBa897a74E6657f1f12e5C6fb6); - } - - return blacklistAddress; - } - - function run() public { } -}