Skip to content

Commit

Permalink
Updates roles base to check for data if removing entitlement (#1219)
Browse files Browse the repository at this point in the history
  • Loading branch information
giuseppecrj authored Oct 4, 2024
1 parent 1ea5ba0 commit 93280c6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
14 changes: 10 additions & 4 deletions contracts/src/spaces/facets/roles/RolesBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,16 @@ abstract contract RolesBase is IRolesBase {

// loop through old entitlements and remove them
for (uint256 i = 0; i < currentEntitlementsLen; ) {
EntitlementsManagerService.proxyRemoveRoleFromEntitlement(
address(currentEntitlements[i]),
roleId
);
// fetch entitlement data and if it's not empty, remove it
bytes memory entitlementData = IEntitlement(currentEntitlements[i])
.getEntitlementDataByRoleId(roleId);

if (entitlementData.length > 0) {
EntitlementsManagerService.proxyRemoveRoleFromEntitlement(
address(currentEntitlements[i]),
roleId
);
}

unchecked {
i++;
Expand Down
14 changes: 7 additions & 7 deletions contracts/test/crosschain/RuleEntitlementUtil.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ library RuleEntitlementUtil {
returns (IRuleEntitlementBase.RuleDataV2 memory data)
{
data = IRuleEntitlementBase.RuleDataV2({
operations: new IRuleEntitlementBase.Operation[](1),
operations: new IRuleEntitlementBase.Operation[](0),
checkOperations: new IRuleEntitlementBase.CheckOperationV2[](0),
logicalOperations: new IRuleEntitlementBase.LogicalOperation[](0)
});
IRuleEntitlementBase.Operation memory noop = IRuleEntitlementBase
.Operation({
opType: IRuleEntitlementBase.CombinedOperationType.NONE,
index: 0
});
// IRuleEntitlementBase.Operation memory noop = IRuleEntitlementBase
// .Operation({
// opType: IRuleEntitlementBase.CombinedOperationType.NONE,
// index: 0
// });

data.operations[0] = noop;
// data.operations[0] = noop;
}

function getMockERC721RuleData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,6 @@ contract IntegrationCreateSpace is
spaceArchitect.createSpace(spaceInfo);

MockERC721(mock).mint(user, 1);

// TODO: Add asserts for the entitlements
// assertTrue(
// IEntitlementsManager(newSpace).isEntitledToSpace(
// user,
// Permissions.JoinSpace
// )
// );
}

// =============================================================
Expand Down

0 comments on commit 93280c6

Please sign in to comment.