Skip to content

Commit

Permalink
feat: add events to ACL
Browse files Browse the repository at this point in the history
chore: prettier

test: forge test new event
  • Loading branch information
jatZama committed Jan 22, 2025
1 parent 8ec37eb commit 839b4d1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions contracts/contracts/ACL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ contract ACL is UUPSUpgradeable, Ownable2StepUpgradeable {
error SenderNotAllowed(address sender);

/// @notice Emitted when a list of handles is allowed for decryption.
/// @param caller account calling the allowForDecryption function.
/// @param handlesList List of handles allowed for decryption.
event AllowedForDecryption(uint256[] handlesList);
event AllowedForDecryption(address indexed caller, uint256[] handlesList);

/// @notice Emitted when a handle is allowed.
/// @param caller account calling the allow function.
/// @param account account being allowed for the handle.
/// @param handle handle being allowed.
event Allowed(address indexed caller, address indexed account, uint256 handle);

/// @notice Emitted when a new delegate address is added.
/// @param sender Sender address
Expand Down Expand Up @@ -76,6 +83,7 @@ contract ACL is UUPSUpgradeable, Ownable2StepUpgradeable {
revert SenderNotAllowed(msg.sender);
}
$.persistedAllowedPairs[handle][account] = true;
emit Allowed(msg.sender, account, handle);
}

/**
Expand All @@ -92,7 +100,7 @@ contract ACL is UUPSUpgradeable, Ownable2StepUpgradeable {
}
$.allowedForDecryption[handle] = true;
}
emit AllowedForDecryption(handlesList);
emit AllowedForDecryption(msg.sender, handlesList);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/acl/acl.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ contract ACLTest is Test {
uint256[] memory handlesList = new uint256[](0);
vm.prank(sender);
vm.expectEmit(address(acl));
emit ACL.AllowedForDecryption(handlesList);
emit ACL.AllowedForDecryption(address(sender), handlesList);
acl.allowForDecryption(handlesList);
}

Expand All @@ -184,7 +184,7 @@ contract ACLTest is Test {

vm.prank(sender);
vm.expectEmit(address(acl));
emit ACL.AllowedForDecryption(handlesList);
emit ACL.AllowedForDecryption(address(sender), handlesList);
acl.allowForDecryption(handlesList);

assertTrue(acl.isAllowedForDecryption(handle0));
Expand Down

0 comments on commit 839b4d1

Please sign in to comment.