Skip to content

Commit

Permalink
Add a boolean to AccessManager.GrantGroup (#4569)
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx authored Sep 5, 2023
1 parent 33cab7c commit ff9d089
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion contracts/access/manager/AccessManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ contract AccessManager is Context, Multicall, IAccessManager {
_groups[groupId].members[account] = Access({since: since, delay: executionDelay.toDelay()});
}

emit GroupGranted(groupId, account, executionDelay, since);
emit GroupGranted(groupId, account, executionDelay, since, !inGroup);
return !inGroup;
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/access/manager/IAccessManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface IAccessManager {
event OperationCanceled(bytes32 indexed operationId, uint32 indexed nonce);

event GroupLabel(uint64 indexed groupId, string label);
event GroupGranted(uint64 indexed groupId, address indexed account, uint32 delay, uint48 since);
event GroupGranted(uint64 indexed groupId, address indexed account, uint32 delay, uint48 since, bool newMember);
event GroupRevoked(uint64 indexed groupId, address indexed account);
event GroupAdminChanged(uint64 indexed groupId, uint64 indexed admin);
event GroupGuardianChanged(uint64 indexed groupId, uint64 indexed guardian);
Expand Down
16 changes: 14 additions & 2 deletions test/access/manager/AccessManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ contract('AccessManager', function (accounts) {

const { receipt } = await this.manager.grantGroup(GROUPS.SOME, user, 0, { from: manager });
const timestamp = await clockFromReceipt.timestamp(receipt).then(web3.utils.toBN);
expectEvent(receipt, 'GroupGranted', { groupId: GROUPS.SOME, account: user, since: timestamp, delay: '0' });
expectEvent(receipt, 'GroupGranted', {
groupId: GROUPS.SOME,
account: user,
since: timestamp,
delay: '0',
newMember: true,
});

expect(await this.manager.hasGroup(GROUPS.SOME, user).then(formatAccess)).to.be.deep.equal([true, '0']);

Expand All @@ -127,6 +133,7 @@ contract('AccessManager', function (accounts) {
account: user,
since: timestamp,
delay: executeDelay,
newMember: true,
});

expect(await this.manager.hasGroup(GROUPS.SOME, user).then(formatAccess)).to.be.deep.equal([
Expand Down Expand Up @@ -169,14 +176,15 @@ contract('AccessManager', function (accounts) {
await time.increase(MINSETBACK);
});

it('granted group is not active immediatly', async function () {
it('granted group is not active immediately', async function () {
const { receipt } = await this.manager.grantGroup(GROUPS.SOME, user, 0, { from: manager });
const timestamp = await clockFromReceipt.timestamp(receipt).then(web3.utils.toBN);
expectEvent(receipt, 'GroupGranted', {
groupId: GROUPS.SOME,
account: user,
since: timestamp.add(grantDelay),
delay: '0',
newMember: true,
});

expect(await this.manager.hasGroup(GROUPS.SOME, user).then(formatAccess)).to.be.deep.equal([false, '0']);
Expand All @@ -196,6 +204,7 @@ contract('AccessManager', function (accounts) {
account: user,
since: timestamp.add(grantDelay),
delay: '0',
newMember: true,
});

await time.increase(grantDelay);
Expand Down Expand Up @@ -374,6 +383,7 @@ contract('AccessManager', function (accounts) {
account: member,
since: timestamp,
delay: newDelay,
newMember: false,
});

// immediate effect
Expand Down Expand Up @@ -406,6 +416,7 @@ contract('AccessManager', function (accounts) {
account: member,
since: timestamp.add(setback),
delay: newDelay,
newMember: false,
});

// no immediate effect
Expand Down Expand Up @@ -435,6 +446,7 @@ contract('AccessManager', function (accounts) {
account: other,
since: timestamp,
delay: executeDelay,
newMember: false,
});
});
});
Expand Down

0 comments on commit ff9d089

Please sign in to comment.