Skip to content

Commit

Permalink
Merge pull request #6 from Hats-Protocol/evm/chaining-compatibility
Browse files Browse the repository at this point in the history
Chaining compatibility
  • Loading branch information
spengrah authored Sep 10, 2024
2 parents 07b0594 + b8090c3 commit 4f5066a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 22 deletions.
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[submodule "lib/hats-module"]
path = lib/hats-module
url = https://github.com/hats-protocol/hats-module
[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
[submodule "lib/multi-claims-hatter"]
path = lib/multi-claims-hatter
url = https://github.com/Hats-Protocol/multi-claims-hatter
url = https://github.com/hats-protocol/multi-claims-hatter
9 changes: 6 additions & 3 deletions src/AgreementEligibility.sol
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,9 @@ contract AgreementEligibility is HatsEligibilityModule {
// set bad standing in this contract
_badStandings[_wearer] = true;

// revoke _wearer's hat and set their standing to false in Hats.sol
HATS().setHatWearerStatus(hatId(), _wearer, false, false);
// revoke _wearer's hat and set their standing to false in Hats.sol. We use the pull pattern (checkHatWearerStatus)
// rather than the push pattern (setHatWearerStatus) for compatibility with module chains.
HATS().checkHatWearerStatus(hatId(), _wearer);

/**
* @dev Hats.sol will emit the following events:
Expand All @@ -236,7 +237,9 @@ contract AgreementEligibility is HatsEligibilityModule {
function forgive(address _wearer) public onlyArbitrator {
_badStandings[_wearer] = false;

HATS().setHatWearerStatus(hatId(), _wearer, true, true);
// return the wearer to good standing in Hats.sol. We use the pull pattern (checkHatWearerStatus) rather than the
// push pattern (setHatWearerStatus) for compatibility with module chains.
HATS().checkHatWearerStatus(hatId(), _wearer);

/// @dev Hats.sol will emit a Hats.WearerStandingChanged event
}
Expand Down
27 changes: 15 additions & 12 deletions test/AgreementEligibility.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract AgreementEligibilityTest is Deploy, Test {
// bytes32 public SALT;

uint256 public fork;
uint256 public BLOCK_NUMBER = 18_265_713;
uint256 public BLOCK_NUMBER = 19_467_227; // deployment block for HatsModuleFactory v0.7.0
IHats public constant HATS = IHats(0x3bc1A0Ad72417f2d411118085256fC53CBdDd137); // v1.hatsprotocol.eth

string public FACTORY_VERSION = "factory test version";
Expand Down Expand Up @@ -54,7 +54,8 @@ contract WithInstanceTest is AgreementEligibilityTest {
ClaimableFor
}

HatsModuleFactory public factory;
HatsModuleFactory public factory = HatsModuleFactory(0x0a3f85fa597B6a967271286aA0724811acDF5CD9);
uint256 public constant SALT_NONCE = 1;
AgreementEligibility public instance;
MultiClaimsHatter public claimsHatter;

Expand Down Expand Up @@ -90,7 +91,7 @@ contract WithInstanceTest is AgreementEligibilityTest {
initData = abi.encode(_ownerHat, _arbitratorHat, _agreement);
// deploy the instance
return AgreementEligibility(
deployModuleInstance(factory, address(implementation), _claimableHat, otherImmutableArgs, initData)
deployModuleInstance(factory, address(implementation), _claimableHat, otherImmutableArgs, initData, SALT_NONCE)
);
}

Expand All @@ -103,7 +104,9 @@ contract WithInstanceTest is AgreementEligibilityTest {
initData = abi.encode(_claimableHats, _claimTypes);
// deploy the instance
return MultiClaimsHatter(
deployModuleInstance(factory, address(0xB985eA1be961f7c4A4C45504444C02c88c4fdEF9), _hatId, "", initData)
deployModuleInstance(
factory, address(0xB985eA1be961f7c4A4C45504444C02c88c4fdEF9), _hatId, "", initData, SALT_NONCE
)
);
}

Expand Down Expand Up @@ -145,35 +148,35 @@ contract WithInstanceTest is AgreementEligibilityTest {
}

contract Deployment is WithInstanceTest {
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_claimableHat() public {
function test_claimableHat() public view {
assertEq(instance.hatId(), claimableHat);
}

function test_ownerHat() public {
function test_ownerHat() public view {
assertEq(instance.ownerHat(), tophat);
}

function test_arbitratorHat() public {
function test_arbitratorHat() public view {
assertEq(instance.arbitratorHat(), arbitratorHat);
}

function test_agreement() public {
function test_agreement() public view {
assertEq(instance.currentAgreement(), agreement);
}

function test_agreementId() public {
function test_agreementId() public view {
assertEq(instance.currentAgreementId(), 1);
}
}
Expand Down

0 comments on commit 4f5066a

Please sign in to comment.