Skip to content

Commit

Permalink
fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
dan13ram committed Feb 20, 2024
1 parent 6b63c37 commit 14c6033
Show file tree
Hide file tree
Showing 14 changed files with 12 additions and 48 deletions.
21 changes: 11 additions & 10 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ CharacterSheetsTest:testTransferFrom() (gas: 446036)
CharacterSheetsTest:testUnequipItemFromCharacter() (gas: 306485)
CharacterSheetsTest:testUpdateCharacterMetadata() (gas: 98384)
CharacterSheetsTest:testUpdateContractImplementation() (gas: 5065067)
ClassLevelAdaptorTest:testLevelRequirementsMet() (gas: 304432)
ClassLevelAdaptorTest:testLevelRequirementsMet() (gas: 304494)
ClassLevelAdaptorTest:testSupportsInterface() (gas: 10602)
ClassesTest:testAssignClass() (gas: 253854)
ClassesTest:testClaimClass() (gas: 135793)
ClassesTest:testCreateClass() (gas: 131486)
ClassesTest:testFuzz_DeLevelClass(uint256) (runs: 256, μ: 390385, ~: 376747)
ClassesTest:testLevelClass() (gas: 282184)
ClassesTest:testFuzz_DeLevelClass(uint256) (runs: 256, μ: 390478, ~: 376809)
ClassesTest:testLevelClass() (gas: 282246)
ClassesTest:testRenounceClass() (gas: 215536)
ClassesTest:testRevokeClass() (gas: 187712)
ClassesTest:testTransferClass() (gas: 722170)
Expand All @@ -57,13 +57,14 @@ HatsAdaptorTest:testIsGameMaster() (gas: 59545)
HatsAdaptorTest:testIsPlayer() (gas: 81923)
HatsAdaptorTest:testMintCharacterHat() (gas: 170310)
HatsAdaptorTest:testMintPlayerHat() (gas: 683403)
HatsEligibilityModulesTest:testAddClassToElderModule() (gas: 1765612)
HatsEligibilityModulesTest:testAddNewAdmin() (gas: 2684753)
HatsEligibilityModulesTest:testAddNewGameMaster() (gas: 2708790)
HatsEligibilityModulesTest:testCharacterSheetsLevelEligibilityModule() (gas: 1987871)
HatsEligibilityModulesTest:testNewModuleSetup() (gas: 2627447)
HatsEligibilityModulesTest:testRemoveAdmin() (gas: 2682981)
HatsEligibilityModulesTest:testRemoveGameMaster() (gas: 2710992)
HatsEligibilityModulesTest:testAddClassToElderModule() (gas: 1799436)
HatsEligibilityModulesTest:testAddNewAdmin() (gas: 2684775)
HatsEligibilityModulesTest:testAddNewGameMaster() (gas: 2708812)
HatsEligibilityModulesTest:testCharacterSheetsLevelEligibilityModule() (gas: 2029996)
HatsEligibilityModulesTest:testElderModuleNoCharacter() (gas: 1808523)
HatsEligibilityModulesTest:testNewModuleSetup() (gas: 2627469)
HatsEligibilityModulesTest:testRemoveAdmin() (gas: 2682915)
HatsEligibilityModulesTest:testRemoveGameMaster() (gas: 2710925)
ItemsTest:testClaimItem() (gas: 922291)
ItemsTest:testClaimItemRevert() (gas: 1358494)
ItemsTest:testCraftItem() (gas: 517103)
Expand Down
1 change: 1 addition & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"rules": {
"compiler-version": ["error", "^0.8.0"],
"func-visibility": ["warn", { "ignoreConstructors": true }],
"one-contract-per-file": "off",
"ordering": "error"
}
}
1 change: 0 additions & 1 deletion src/CharacterAccount.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {Errors} from "./lib/Errors.sol";
* @author Mr DeadCe11
* @notice This is a simple ERC6551 account implementation that can hold ERC1155 tokens
*/

contract CharacterAccount is IERC165, IERC1271, IERC6551Account, IERC6551Executable, ERC1155Holder {
uint256 public state;

Expand Down
1 change: 0 additions & 1 deletion src/CharacterSheetsFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ contract CharacterSheetsFactory is Initializable, OwnableUpgradeable {
* @dev check notes on the initializeContracts function to see what needs to be
* in the encoded hatsStrings and the encoded sheets strings
*/

function createAndInitialize(
address dao,
address[] calldata admins,
Expand Down
1 change: 0 additions & 1 deletion src/adaptors/ClassLevelAdaptor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {IHatsAdaptor} from "../interfaces/IHatsAdaptor.sol";
* @notice This is an adaptor that allows the classesImplementation to check the requirements to level a class
* @dev any variation to this contract must implement the levelRequirementsMet and getExperienceForNextLevel functions
*/

contract ClassLevelAdaptor is ERC165, Initializable, UUPSUpgradeable {
/**
* @notice erc651 interfaceId
Expand Down
4 changes: 0 additions & 4 deletions src/adaptors/HatsAdaptor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {HatsData} from "../lib/Structs.sol";
* character sheets contacts. It also allows the minting of hats to players and characters
* and checks if any address is wearing the player or character hat.
*/

struct InitStruct {
address _owner;
bytes hatsAddresses;
Expand All @@ -40,7 +39,6 @@ contract HatsAdaptor is Initializable, OwnableUpgradeable, UUPSUpgradeable, ERC1
* @notice these are the addresses of the eligibility modules after they are created by
* the hats module factory during contract initialization.
*/

ImplementationAddressStorage public implementations;
IClonesAddressStorage public clones;

Expand Down Expand Up @@ -98,7 +96,6 @@ contract HatsAdaptor is Initializable, OwnableUpgradeable, UUPSUpgradeable, ERC1
* 9. string characterUri
* 10. string characterDescription
*/

function initialize(address _owner, bytes calldata hatsAddresses, bytes calldata hatsStrings)
external
initializer
Expand All @@ -115,7 +112,6 @@ contract HatsAdaptor is Initializable, OwnableUpgradeable, UUPSUpgradeable, ERC1
* 3. player admin hats eligibility Module
* 4. character admin hats eligibility Module
*/

function initialize(
address _owner,
bytes calldata hatsAddresses,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {ICharacterSheets} from "../../interfaces/ICharacterSheets.sol";
* @notice A Hats Protocol eligibility module that checks if a player owns a character sheet with desired number
* of class Levels of any particular class tokenId
*/

contract CharacterSheetsLevelEligibilityModule is HatsEligibilityModule {
event ElderEligibilityDeployed(address);
event ClassesAdded(uint256[], uint256[]);
Expand Down
10 changes: 0 additions & 10 deletions src/implementations/CharacterSheetsImplementation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {Errors} from "../lib/Errors.sol";
* a rpg themed reputation system with experience points awarded by a centralized authority the "GAME_MASTER" and items and classes that can be owned and equipped
* by the base character account.
*/

contract CharacterSheetsImplementation is ERC721URIStorageUpgradeable, UUPSUpgradeable {
string public baseTokenURI;
string public metadataURI;
Expand Down Expand Up @@ -133,7 +132,6 @@ contract CharacterSheetsImplementation is ERC721URIStorageUpgradeable, UUPSUpgra
* - address itemsImplementation: this is the address of the ERC1155 items contract associated
* with this contract. this is assigned at contract creation.
*/

function initialize(bytes calldata _encodedParameters) external initializer {
__ERC721_init_unchained("CharacterSheet", "CHAS");
__UUPSUpgradeable_init();
Expand All @@ -153,7 +151,6 @@ contract CharacterSheetsImplementation is ERC721URIStorageUpgradeable, UUPSUpgra
* @param _tokenURI the uri of the character sheet metadata
* if no uri is stored then it will revert to the base uri of the contract
*/

function rollCharacterSheet(string calldata _tokenURI) external returns (uint256) {
if (erc6551CharacterAccount == address(0) || erc6551Registry == address(0)) {
revert Errors.NotInitialized();
Expand Down Expand Up @@ -216,7 +213,6 @@ contract CharacterSheetsImplementation is ERC721URIStorageUpgradeable, UUPSUpgra
* @param characterId the player to have the item type from their inventory
* @param characterId the erc1155 token id of the item to be unequipped
*/

function unequipItemFromCharacter(uint256 characterId, uint256 itemId) external onlyCharacter {
if (msg.sender != _sheets[characterId].accountAddress) {
revert Errors.OwnershipError();
Expand Down Expand Up @@ -260,7 +256,6 @@ contract CharacterSheetsImplementation is ERC721URIStorageUpgradeable, UUPSUpgra
* @param characterId the id of the player receiving the item
* @param itemId the itemId of the item
*/

function equipItemToCharacter(uint256 characterId, uint256 itemId) external onlyCharacter {
if (msg.sender != _sheets[characterId].accountAddress) {
revert Errors.OwnershipError();
Expand All @@ -281,7 +276,6 @@ contract CharacterSheetsImplementation is ERC721URIStorageUpgradeable, UUPSUpgra
/**
* this will burn the nft of the player. only a player can burn their own token.
*/

function renounceSheet() external onlyPlayer {
uint256 _characterId = _playerSheets[msg.sender];

Expand All @@ -298,7 +292,6 @@ contract CharacterSheetsImplementation is ERC721URIStorageUpgradeable, UUPSUpgra
* restores a previously renounced sheet if called by the wrong player and incorrect address will be created that does not control any assets
* @return the ERC6551 account address
*/

function restoreSheet() external returns (address) {
uint256 characterId = _playerSheets[msg.sender];

Expand Down Expand Up @@ -337,7 +330,6 @@ contract CharacterSheetsImplementation is ERC721URIStorageUpgradeable, UUPSUpgra
* Burns a players characterSheet. can only be done if there is a passing guild kick proposal
* @param characterId the characterId of the player to be removed.
*/

function removeSheet(uint256 characterId) external onlyGameMaster {
address playerAddress = _ownerOf(characterId);
if (playerAddress == address(0)) {
Expand Down Expand Up @@ -408,7 +400,6 @@ contract CharacterSheetsImplementation is ERC721URIStorageUpgradeable, UUPSUpgra
/**
* @dev See {IERC721-approve}.
*/

function approve(address to, uint256 characterId) public virtual override(ERC721Upgradeable, IERC721) {
return super.approve(to, characterId);
}
Expand Down Expand Up @@ -436,7 +427,6 @@ contract CharacterSheetsImplementation is ERC721URIStorageUpgradeable, UUPSUpgra
/**
* @dev See {IERC721-safeTransferFrom}.
*/

function safeTransferFrom(address from, address to, uint256 characterId, bytes memory)
public
virtual
Expand Down
5 changes: 0 additions & 5 deletions src/implementations/ClassesImplementation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ contract ClassesImplementation is ERC1155HolderUpgradeable, ERC1155Upgradeable,
* - string cid
* @return tokenId the ERC1155 token id
*/

function createClassType(bytes calldata classData) external onlyGameMaster returns (uint256 tokenId) {
uint256 _tokenId = totalClasses;

Expand All @@ -145,7 +144,6 @@ contract ClassesImplementation is ERC1155HolderUpgradeable, ERC1155Upgradeable,
* @param character the tokenId of the player
* @param classId the classId of the class to be assigned
*/

function assignClass(address character, uint256 classId) public onlyGameMaster {
if (character == address(0x0)) {
revert Errors.CharacterError();
Expand All @@ -169,7 +167,6 @@ contract ClassesImplementation is ERC1155HolderUpgradeable, ERC1155Upgradeable,
* @param character the token Id of the player who needs a class removed
* @param classId the class to be removed
*/

function revokeClass(address character, uint256 classId) public onlyGameMaster returns (bool success) {
return _revokeClass(character, classId);
}
Expand Down Expand Up @@ -251,7 +248,6 @@ contract ClassesImplementation is ERC1155HolderUpgradeable, ERC1155Upgradeable,
/**
* @return an array of all Class structs stored in the _classes mapping
*/

function getAllClasses() public view returns (Class[] memory) {
Class[] memory allClasses = new Class[](totalClasses);
for (uint256 i = 1; i <= totalClasses; i++) {
Expand Down Expand Up @@ -291,7 +287,6 @@ contract ClassesImplementation is ERC1155HolderUpgradeable, ERC1155Upgradeable,
* - if `_tokenURIs[tokenId]` is NOT set, and if the parents do not have a
* uri value set, then the result is empty.
*/

function uri(uint256 tokenId) public view override returns (string memory) {
string memory tokenURI = _classURIs[tokenId];
// If token URI is set, concatenate base URI and tokenURI (via abi.encodePacked).
Expand Down
2 changes: 0 additions & 2 deletions src/implementations/ExperienceImplementation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ contract ExperienceImplementation is ERC20Upgradeable, UUPSUpgradeable {
* @notice Called by game master or an authorized contract to give experience to a character
* @param to the address of the character that will receive the exp
*/

function dropExp(address to, uint256 amount) public {
if (!_isAuthorized(msg.sender)) {
revert Errors.CallerNotApproved();
Expand Down Expand Up @@ -82,7 +81,6 @@ contract ExperienceImplementation is ERC20Upgradeable, UUPSUpgradeable {
/**
* @notice 0 decimals. 1 exp = 1 exp
*/

function decimals() public pure override returns (uint8) {
return 0;
}
Expand Down
10 changes: 0 additions & 10 deletions src/implementations/ItemsImplementation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {IHatsAdaptor} from "../interfaces/IHatsAdaptor.sol";
* Each item and class is an 1155 token that can soulbound or not to the erc6551 wallet of each player nft
* in the characterSheets contract.
*/

contract ItemsImplementation is
ERC1155HolderUpgradeable,
ERC1155Upgradeable,
Expand Down Expand Up @@ -99,7 +98,6 @@ contract ItemsImplementation is
* @param itemIds the item Id's of the loot to be dropped exp is allways Item Id 0;
* @param amounts the amounts of each item to be dropped this must be in sync with the item ids
*/

function dropLoot(address[] calldata characterAccounts, uint256[][] calldata itemIds, uint256[][] calldata amounts)
external
onlyGameMaster
Expand Down Expand Up @@ -127,7 +125,6 @@ contract ItemsImplementation is
* must be in same order as item ids and amounts
* if claimable of the item is bytes32(0) the proof can be just an empty array.
*/

function claimItems(uint256[] calldata itemIds, uint256[] calldata amounts, bytes32[][] calldata proofs)
external
onlyCharacter
Expand Down Expand Up @@ -168,7 +165,6 @@ contract ItemsImplementation is
* @param amount the number of new items to be created
* @return success bool if crafting is a success return true, else return false
*/

function craftItem(uint256 itemId, uint256 amount) external onlyCharacter returns (bool success) {
if (!itemsManager.checkRequirements(msg.sender, itemId, amount)) {
revert Errors.RequirementNotMet();
Expand Down Expand Up @@ -211,7 +207,6 @@ contract ItemsImplementation is
* - uint256[] memory requiredAssetAmounts;
* @return _itemId the ERC1155 tokenId
*/

function createItemType(bytes calldata _itemData) external onlyGameMaster returns (uint256 _itemId) {
_itemId = totalItemTypes;

Expand All @@ -229,7 +224,6 @@ contract ItemsImplementation is
* @param itemId the item id of the item to be updated
* @param merkleRoot the merkle root of the addresses and amounts that can be claimed of this item
*/

function updateItemClaimable(uint256 itemId, bytes32 merkleRoot, uint256 newDistribution) external onlyGameMaster {
if (_items[itemId].supply == 0) {
revert Errors.ItemError();
Expand All @@ -251,7 +245,6 @@ contract ItemsImplementation is
/**
* @notice this item will delete the Item Struct from the items mapping and burn the remaining supply it will also set the enabled bool to false;
*/

function deleteItem(uint256 itemId) external onlyGameMaster {
// cannot delete an Item that has been supplied to anyone.
if (_items[itemId].supplied != 0) {
Expand All @@ -270,7 +263,6 @@ contract ItemsImplementation is
/**
* @dev Sets `tokenURI` as the tokenURI of `tokenId`.
*/

function setURI(uint256 tokenId, string memory tokenURI) external onlyGameMaster {
_itemURIs[tokenId] = tokenURI;
emit URI(uri(tokenId), tokenId);
Expand Down Expand Up @@ -334,7 +326,6 @@ contract ItemsImplementation is
* - if `_tokenURI` is NOT set, and if the parents do not have a
* uri value set, then the result is empty.
*/

function uri(uint256 _itemId) public view override returns (string memory) {
string memory _tokenURI = _itemURIs[_itemId];

Expand Down Expand Up @@ -428,7 +419,6 @@ contract ItemsImplementation is
* @param itemId the erc1155 Id of the item to be transfered
* @param amount the number of items to be transfered
*/

function _transferItem(address characterAccount, uint256 itemId, uint256 amount) internal returns (bool success) {
if (!IHatsAdaptor(clones.hatsAdaptor()).isCharacter(characterAccount)) {
revert Errors.CharacterOnly();
Expand Down
1 change: 0 additions & 1 deletion src/implementations/ItemsManagerImplementation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ contract ItemsManagerImplementation is UUPSUpgradeable, ERC1155HolderUpgradeable
* @param amount the number of new items to be created
* @return success bool if crafting is a success return true, else return false
*/

function craftItem(Item memory item, uint256 itemId, uint256 amount, address caller)
public
onlyItemsContract
Expand Down
1 change: 0 additions & 1 deletion src/interfaces/IHatsAdaptor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pragma solidity ^0.8.20;
* @notice This is an adaptor interface that allows contracts to mint hats to players and characters
* and check which accounts are wearing which hats.
*/

interface IHatsAdaptor {
function updateHatsAddress(address newHatsAddress) external;

Expand Down
1 change: 0 additions & 1 deletion src/mocks/AddressHatsEligibilityModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {HatsEligibilityModule, HatsModule} from "hats-module/HatsEligibilityModu
* @notice A Hats Protocol eligibility module that allows admin's of a hat to whitelist eligible addresses for that hat
* this is set so the admin will be the Top Hat and all admins will be set be that top hat. Ideally this will be A guild or multisig.
*/

contract AddressHatsEligibilityModule is HatsEligibilityModule {
/*//////////////////////////////////////////////////////////////
CUSTOM ERRORS
Expand Down

0 comments on commit 14c6033

Please sign in to comment.