1+ // SPDX-License-Identifier: MIT
2+ pragma solidity ^ 0.8.22 ;
3+
4+ contract PrivateEvents {
5+ // Public events with string parameters
6+ event PublicEvent1 (string message );
7+ event PublicEvent2 (string data );
8+
9+ // Private events (these will be wrapped in PrivateEvent by the Silent Data rollup)
10+ event PrivateEvent1 (string secretMessage );
11+ event PrivateEvent2 (string privateData );
12+
13+ // The PrivateEvent wrapper that Silent Data uses
14+ event PrivateEvent (
15+ address [] allowedViewers ,
16+ bytes32 indexed eventType ,
17+ bytes payload
18+ );
19+
20+ // Event type constants for private events
21+ bytes32 public constant EVENT_TYPE_PRIVATE_1 = keccak256 ("PrivateEvent1(string) " );
22+ bytes32 public constant EVENT_TYPE_PRIVATE_2 = keccak256 ("PrivateEvent2(string) " );
23+
24+ // Function to trigger all events in one transaction
25+ function triggerEvents (
26+ string memory publicMessage1 ,
27+ string memory publicMessage2 ,
28+ string memory privateMessage1 ,
29+ string memory privateMessage2 ,
30+ address [] memory allowedViewers
31+ ) external {
32+ // Emit public events
33+ emit PublicEvent1 (publicMessage1);
34+ emit PublicEvent2 (publicMessage2);
35+
36+ // Emit private events wrapped in PrivateEvent
37+ emit PrivateEvent (
38+ allowedViewers,
39+ EVENT_TYPE_PRIVATE_1,
40+ abi.encode (privateMessage1)
41+ );
42+
43+ emit PrivateEvent (
44+ allowedViewers,
45+ EVENT_TYPE_PRIVATE_2,
46+ abi.encode (privateMessage2)
47+ );
48+ }
49+ }
0 commit comments