From 2b4067433172f8994c25bd57356f99cb73acb8bd Mon Sep 17 00:00:00 2001 From: spengrah Date: Wed, 7 Dec 2022 17:25:28 -0600 Subject: [PATCH 1/3] remove `isActive` & `isMutable` for contract size --- src/Hats.sol | 20 ++++++++++---------- src/Interfaces/IHats.sol | 2 +- test/Hats.t.sol | 27 ++++++++++++++++++--------- test/HatsTestSetup.t.sol | 3 +++ 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/Hats.sol b/src/Hats.sol index 70f04d4..45313bb 100644 --- a/src/Hats.sol +++ b/src/Hats.sol @@ -733,13 +733,13 @@ contract Hats is IHats, ERC1155, HatsIdUtilities { } } - /// @notice Checks the active status of a hat - /// @dev Use `_isActive` for internal calls that can take a Hat as a param - /// @param _hatId The id of the hat - /// @return bool The active status of the hat - function isActive(uint256 _hatId) public view returns (bool) { - return _isActive(_hats[_hatId], _hatId); - } + // /// @notice Checks the active status of a hat + // /// @dev Use `_isActive` for internal calls that can take a Hat as a param + // /// @param _hatId The id of the hat + // /// @return bool The active status of the hat + // function isActive(uint256 _hatId) public view returns (bool) { + // return _isActive(_hats[_hatId], _hatId); + // } function _getHatStatus(Hat memory _hat) internal view returns (bool) { return (_hat.config >> 95 != 0); @@ -757,9 +757,9 @@ contract Hats is IHats, ERC1155, HatsIdUtilities { return (_hat.config & uint96(1 << 94) != 0); } - function isMutable(uint256 _hatId) public view returns (bool) { - return _isMutable(_hats[_hatId]); - } + // function isMutable(uint256 _hatId) public view returns (bool) { + // return _isMutable(_hats[_hatId]); + // } /// @notice Checks whether a wearer of a Hat is in good standing /// @dev Public function for use when pa ssing a Hat object is not possible or preferable diff --git a/src/Interfaces/IHats.sol b/src/Interfaces/IHats.sol index 9c80066..1110deb 100644 --- a/src/Interfaces/IHats.sol +++ b/src/Interfaces/IHats.sol @@ -137,7 +137,7 @@ interface IHats is IHatsIdUtilities, HatsErrors, HatsEvents { view returns (bool); - function isActive(uint256 _hatId) external view returns (bool); + // function isActive(uint256 _hatId) external view returns (bool); function isInGoodStanding(address _wearer, uint256 _hatId) external diff --git a/test/Hats.t.sol b/test/Hats.t.sol index 36fe12b..49659cd 100644 --- a/test/Hats.t.sol +++ b/test/Hats.t.sol @@ -1103,7 +1103,8 @@ contract RenounceHatsTest is TestSetup2 { contract ToggleSetHatsTest is TestSetup2 { function testDeactivateHat() public { // confirm second hat is active - assertTrue(hats.isActive(secondHatId)); + (, , , , , , , , active_) = hats.viewHat(secondHatId); + assertTrue(active_); assertTrue(hats.isWearerOfHat(secondWearer, secondHatId)); // expectEmit HatStatusChanged to false @@ -1113,7 +1114,8 @@ contract ToggleSetHatsTest is TestSetup2 { // 7-2. change Hat Status true->false via setHatStatus vm.prank(address(_toggle)); hats.setHatStatus(secondHatId, false); - assertFalse(hats.isActive(secondHatId)); + (, , , , , , , mutable_, ) = hats.viewHat(secondHatId); + assertFalse(mutable_); assertFalse(hats.isWearerOfHat(secondWearer, secondHatId)); } @@ -1140,7 +1142,8 @@ contract ToggleSetHatsTest is TestSetup2 { // changeHatStatus false->true via setHatStatus vm.prank(address(_toggle)); hats.setHatStatus(secondHatId, true); - assertTrue(hats.isActive(secondHatId)); + (, , , , , , , , active_) = hats.viewHat(secondHatId); + assertTrue(active_); assertTrue(hats.isWearerOfHat(secondWearer, secondHatId)); } @@ -1185,7 +1188,8 @@ contract ToggleGetHatsTest is TestSetup2 { // call mocked function within checkHatStatus to deactivate hats.checkHatStatus(secondHatId); - assertFalse(hats.isActive(secondHatId)); + (, , , , , , , mutable_, ) = hats.viewHat(secondHatId); + assertFalse(mutable_); assertFalse(hats.isWearerOfHat(secondWearer, secondHatId)); } @@ -1207,7 +1211,8 @@ contract ToggleGetHatsTest is TestSetup2 { // call mocked function within checkHatStatus to reactivate hats.checkHatStatus(secondHatId); - assertTrue(hats.isActive(secondHatId)); + (, , , , , , , , active_) = hats.viewHat(secondHatId); + assertTrue(active_); assertTrue(hats.isWearerOfHat(secondWearer, secondHatId)); } } @@ -1230,7 +1235,8 @@ contract MutabilityTests is TestSetup { } function testAdminCanMakeMutableHatImmutable() public { - assertTrue(hats.isMutable(secondHatId)); + (, , , , , , , mutable_, ) = hats.viewHat(secondHatId); + assertTrue(mutable_); vm.expectEmit(false, false, false, true); emit HatMutabilityChanged(secondHatId); @@ -1238,7 +1244,8 @@ contract MutabilityTests is TestSetup { vm.prank(topHatWearer); hats.makeHatImmutable(secondHatId); - assertFalse(hats.isMutable(secondHatId)); + (, , , , , , , mutable_, ) = hats.viewHat(secondHatId); + assertFalse(mutable_); } function testCannotChangeImmutableHatMutability() public { @@ -1254,7 +1261,8 @@ contract MutabilityTests is TestSetup { secondHatImageURI ); - assertFalse(hats.isMutable(thirdHatId)); + (, , , , , , , mutable_, ) = hats.viewHat(thirdHatId); + assertFalse(mutable_); vm.expectRevert(abi.encodeWithSelector(HatsErrors.Immutable.selector)); @@ -1286,7 +1294,8 @@ contract MutabilityTests is TestSetup { secondHatImageURI ); - assertFalse(hats.isMutable(thirdHatId)); + (, , , , , , , mutable_, ) = hats.viewHat(thirdHatId); + assertFalse(mutable_); vm.expectRevert(abi.encodeWithSelector(HatsErrors.Immutable.selector)); hats.changeHatDetails(thirdHatId, "should not work"); diff --git a/test/HatsTestSetup.t.sol b/test/HatsTestSetup.t.sol index d9ce2ec..d1d2bec 100644 --- a/test/HatsTestSetup.t.sol +++ b/test/HatsTestSetup.t.sol @@ -50,6 +50,9 @@ abstract contract TestVariables is HatsEvents, HatsErrors { bool retmutable; bool retactive; + bool active_; + bool mutable_; + event TransferSingle( address indexed operator, address indexed from, From d94f1df941b057f80d92b7e41426276f9b30a6aa Mon Sep 17 00:00:00 2001 From: spengrah Date: Wed, 7 Dec 2022 17:26:15 -0600 Subject: [PATCH 2/3] apply ci to develop branch --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 01c3849..2c0074f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ on: push: branches: - main - - beta + - develop pull_request: jobs: From d518a80efbe609a4aef108215a9cf2d3492864cb Mon Sep 17 00:00:00 2001 From: spengrah Date: Wed, 7 Dec 2022 17:40:25 -0600 Subject: [PATCH 3/3] update readme to refer to Releases --- README.md | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 6fa5696..d40ac15 100644 --- a/README.md +++ b/README.md @@ -18,16 +18,15 @@ [![Stargazers][stars-shield]][stars-url] [![Issues][issues-shield]][issues-url] [![Twitter][twitter-shield]][twitter-url] -
- Logo + Hats Hat -

Hats Protocol

+

Hats Protocol

How DAOs get things done @@ -48,7 +47,7 @@

  • About The Project
  • Getting Started
  • @@ -67,17 +66,9 @@ Hats Protocol is a protocol for DAO-native roles and credentials that support de Hats are represented on-chain by ERC1155 tokens. An address with a balance of a given Hat token "wears" that hat, granting them the responsibilities and authorities that have been assigned to the Hat by the DAO. -### Latest Deployments +### Deployments -#### Beta 3 - -- Gnosis Chain (chain id #100) — `0x245e5B56C18B18aC2d72F94C5F7bE1D52497A8aD` - -#### Beta 4 - -- Goerli Testnet (chain id #4) — `0x2923469a33bd2fa2ab33c877db81d35a9d8d60c6` -- Gnosis Chain (chain id #100) — `0x72c89eb08444bc16396dd9432b3e82d956c412ec` -- Polygon (chain id #137) — `0xe81597289a249ae725c2d80e7848dbfa9708c22d` +For information on Hats Protocol versions and deployments, see [Releases](https://github.com/Hats-Protocol/hats-protocol/releases). ## Getting Started @@ -399,15 +390,12 @@ Since batch Hats transfers can be made from and to multiple wearers, batch trans The wearer of a Hat can "take off" their Hat via `Hats.renounceHat`. This burns the token and revokes any associated authorities and responsibilities from the now-former wearer, but does not put the wearer in bad standing.

    (back to contents)

    -

    (back to top)

    - ## Contact