Skip to content

Commit b811738

Browse files
committed
emit logs via state-changes in the storage
1 parent c4732ca commit b811738

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/automata_pccs/shared/AutomataDaoStorage.sol

+17-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ contract AutomataDaoStorage is AutomataTCBManager, IDaoAttestationResolver, Paus
1717
mapping(address => bool) _authorized_readers;
1818
mapping(bytes32 attId => bytes collateral) _db;
1919

20+
event SetAuthorizedWriter(address caller, bool authorized);
21+
event SetAuthorizedReader(address caller, bool authorized);
22+
2023
modifier onlyDao(address dao) {
2124
require(_authorized_writers[dao], "FORBIDDEN");
2225
_;
@@ -26,15 +29,15 @@ contract AutomataDaoStorage is AutomataTCBManager, IDaoAttestationResolver, Paus
2629
_initializeOwner(msg.sender);
2730

2831
// adding address(0) as an authorized_reader to allow eth_call
29-
_authorized_readers[address(0)] = true;
32+
_setAuthorizedReader(address(0), true);
3033
}
3134

3235
function isAuthorizedCaller(address caller) external view returns (bool) {
3336
return _authorized_readers[caller];
3437
}
3538

3639
function setCallerAuthorization(address caller, bool authorized) external onlyOwner {
37-
_authorized_readers[caller] = authorized;
40+
_setAuthorizedReader(caller, authorized);
3841
}
3942

4043
function pauseCallerRestriction() external onlyOwner whenNotPaused {
@@ -46,11 +49,11 @@ contract AutomataDaoStorage is AutomataTCBManager, IDaoAttestationResolver, Paus
4649
}
4750

4851
function grantDao(address granted) external onlyOwner {
49-
_authorized_writers[granted] = true;
52+
_setAuthorizedWriter(granted, true);
5053
}
5154

5255
function revokeDao(address revoked) external onlyOwner {
53-
_authorized_writers[revoked] = false;
56+
_setAuthorizedWriter(revoked, false);
5457
}
5558

5659
function collateralPointer(bytes32 key) external pure override returns (bytes32 collateralAttId) {
@@ -99,6 +102,16 @@ contract AutomataDaoStorage is AutomataTCBManager, IDaoAttestationResolver, Paus
99102
attestationId = keccak256(abi.encodePacked(magic, key));
100103
}
101104

105+
function _setAuthorizedWriter(address caller, bool authorized) private {
106+
_authorized_writers[caller] = authorized;
107+
emit SetAuthorizedWriter(caller, authorized);
108+
}
109+
110+
function _setAuthorizedReader(address caller, bool authorized) private {
111+
_authorized_readers[caller] = authorized;
112+
emit SetAuthorizedReader(caller, authorized);
113+
}
114+
102115
/// TCB Management
103116
using EnumerableSet for EnumerableSet.Bytes32Set;
104117

0 commit comments

Comments
 (0)