From 897d0cac8fefd843077a6ab1cc64b4f91eca65c4 Mon Sep 17 00:00:00 2001 From: spengrah Date: Thu, 5 Sep 2024 17:18:29 -0500 Subject: [PATCH 1/4] use HatsModuleFactory 0.7.0 --- .gitmodules | 1 - lib/forge-std | 2 +- lib/hats-module | 2 +- test/AllowlistEligibility.t.sol | 22 ++++++++++------------ 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/.gitmodules b/.gitmodules index bab5b6f..c255e1c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,6 @@ [submodule "lib/forge-std"] path = lib/forge-std url = https://github.com/foundry-rs/forge-std - [submodule "lib/hats-module"] path = lib/hats-module url = https://github.com/hats-protocol/hats-module diff --git a/lib/forge-std b/lib/forge-std index 74cfb77..1714bee 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 74cfb77e308dd188d2f58864aaf44963ae6b88b1 +Subproject commit 1714bee72e286e73f76e320d110e0eaf5c4e649d diff --git a/lib/hats-module b/lib/hats-module index 5a69da3..e83bd72 160000 --- a/lib/hats-module +++ b/lib/hats-module @@ -1 +1 @@ -Subproject commit 5a69da357e70cc2e3727d6ec02097711439ec32b +Subproject commit e83bd72cb3eebdbeadabcb63e3c6f69ab61a5562 diff --git a/test/AllowlistEligibility.t.sol b/test/AllowlistEligibility.t.sol index f9a6b11..9653f20 100644 --- a/test/AllowlistEligibility.t.sol +++ b/test/AllowlistEligibility.t.sol @@ -24,9 +24,10 @@ contract AllowlistEligibilityTest is Deploy, Test { // bytes32 public SALT; uint256 public fork; - uint256 public BLOCK_NUMBER = 17_671_864; // deployment block for Hats.sol + uint256 public BLOCK_NUMBER = 19_467_227; // deployment block for HatsModuleFactory IHats public HATS = IHats(0x3bc1A0Ad72417f2d411118085256fC53CBdDd137); // v1.hatsprotocol.eth - HatsModuleFactory public factory; + HatsModuleFactory public factory = HatsModuleFactory(0x0a3f85fa597B6a967271286aA0724811acDF5CD9); + uint256 public SALT_NONCE = 1; AllowlistEligibility public instance; bytes public otherImmutableArgs; bytes public initArgs; @@ -73,9 +74,6 @@ contract AllowlistEligibilityTest is Deploy, Test { // deploy implementation via the script prepare(false, MODULE_VERSION); run(); - - // deploy the hats module factory - factory = deployModuleFactory(HATS, SALT, "test factory"); } } @@ -101,7 +99,7 @@ contract WithInstanceTest is AllowlistEligibilityTest { // deploy an instance of the module instance = AllowlistEligibility( - deployModuleInstance(factory, address(implementation), hatToClaim, otherImmutableArgs, initArgs) + deployModuleInstance(factory, address(implementation), hatToClaim, otherImmutableArgs, initArgs, SALT_NONCE) ); // set the instance as the hatToClaim's eligibility @@ -139,27 +137,27 @@ contract Deployment is WithInstanceTest { instance.setUp(abi.encode(ownerHat, arbitratorHat, alloweds)); } - function test_version() public { + function test_version() public view { assertEq(instance.version(), MODULE_VERSION); } - function test_implementation() public { + function test_implementation() public view { assertEq(address(instance.IMPLEMENTATION()), address(implementation)); } - function test_hats() public { + function test_hats() public view { assertEq(address(instance.HATS()), address(HATS)); } - function test_hatId() public { + function test_hatId() public view { assertEq(instance.hatId(), hatToClaim); } - function test_ownerHat() public { + function test_ownerHat() public view { assertEq(instance.ownerHat(), ownerHat); } - function test_arbitratorHat() public { + function test_arbitratorHat() public view { assertEq(instance.arbitratorHat(), arbitratorHat); } } From 102aa2c02e8be637fdd95b3c51ca4780daf99b1d Mon Sep 17 00:00:00 2001 From: spengrah Date: Thu, 5 Sep 2024 17:19:14 -0500 Subject: [PATCH 2/4] use checkHatWearerStatus instead of setHatWearerStatus --- src/AllowlistEligibility.sol | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/AllowlistEligibility.sol b/src/AllowlistEligibility.sol index a2f56d4..bd13772 100644 --- a/src/AllowlistEligibility.sol +++ b/src/AllowlistEligibility.sol @@ -233,8 +233,9 @@ contract AllowlistEligibility is HatsEligibilityModule { emit AccountRemoved(_account); - // burn the hat by setting their eligibility to with the account's current standing - HATS().setHatWearerStatus(hatId(), _account, false, !eligibility.badStanding); + // Check their eligibility and burn the hat if they are not eligible. We use this pull pattern instead of the push + // pattern — i.e. setHatWearerStatus — for compatibility with chained modules. + HATS().checkHatWearerStatus(hatId(), _account); /** * @dev Hats.sol will emit the following events: From a5fcc64ab8e9b99cf325efcddd080458c42a4a12 Mon Sep 17 00:00:00 2001 From: spengrah Date: Mon, 9 Sep 2024 11:25:36 -0500 Subject: [PATCH 3/4] add hats-protocol dep --- .gitmodules | 3 +++ lib/hats-protocol | 1 + 2 files changed, 4 insertions(+) create mode 160000 lib/hats-protocol diff --git a/.gitmodules b/.gitmodules index c255e1c..470718e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "lib/hats-module"] path = lib/hats-module url = https://github.com/hats-protocol/hats-module +[submodule "lib/hats-protocol"] + path = lib/hats-protocol + url = https://github.com/hats-protocol/hats-protocol diff --git a/lib/hats-protocol b/lib/hats-protocol new file mode 160000 index 0000000..cccb71a --- /dev/null +++ b/lib/hats-protocol @@ -0,0 +1 @@ +Subproject commit cccb71a061cdb9095af7d11dfdb47026993d8c4e From da27c8a4f1bfa434403ce2aadd3054bc5142a698 Mon Sep 17 00:00:00 2001 From: spengrah Date: Mon, 9 Sep 2024 11:27:09 -0500 Subject: [PATCH 4/4] replace missed setHatWearerStatus --- src/AllowlistEligibility.sol | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/AllowlistEligibility.sol b/src/AllowlistEligibility.sol index bd13772..9c87c9e 100644 --- a/src/AllowlistEligibility.sol +++ b/src/AllowlistEligibility.sol @@ -288,8 +288,9 @@ contract AllowlistEligibility is HatsEligibilityModule { emit AccountStandingChanged(_account, false); - // burn the account's hat by setting their eligibility and standing to false - HATS().setHatWearerStatus(hatId(), _account, false, false); + // have Hats.sol check the account's hat wearer status to burn their hat. We use this pull pattern instead of the + // push pattern — i.e. setHatWearerStatus — for compatibility with chained modules. + HATS().checkHatWearerStatus(hatId(), _account); /** * @dev Hats.sol will emit the following events: