@@ -15,15 +15,19 @@ contract ShutterRegistry is Ownable {
15
15
// Custom error for when a provided timestamp is in the past.
16
16
error TimestampInThePast ();
17
17
18
+ struct RegsitrationData {
19
+ uint64 eon;
20
+ uint64 timestamp;
21
+ }
18
22
/**
19
23
* @dev Mapping to store registration timestamps for each identity.
20
24
* The identity is represented as a `bytes32` hash and mapped to a uint64 timestamp.
21
25
*/
22
- mapping (bytes32 identity = > uint64 timestamp ) public registrations;
26
+ mapping (bytes32 identity = > RegsitrationData ) public registrations;
23
27
24
28
/**
25
29
* @dev Emitted when a new identity is successfully registered.
26
- * @param eon The eon associated with the identity.
30
+ * @param eon The eon associated with the identity.
27
31
* @param identityPrefix The raw prefix input used to derive the registered identity hash.
28
32
* @param sender The address of the account that performed the registration.
29
33
* @param timestamp The timestamp associated with the registered identity.
@@ -55,19 +59,20 @@ contract ShutterRegistry is Ownable {
55
59
bytes32 identityPrefix ,
56
60
uint64 timestamp
57
61
) external {
62
+ // Ensure the timestamp is not in the past.
63
+ require (timestamp >= block .timestamp , TimestampInThePast ());
64
+
58
65
// Generate the identity hash from the provided prefix and the sender's address.
59
66
bytes32 identity = keccak256 (
60
67
abi.encodePacked (identityPrefix, msg .sender )
61
68
);
62
-
69
+ RegsitrationData storage registrationData = registrations[identity];
63
70
// Ensure the identity is not already registered.
64
- require (registrations[identity] == uint64 (0 ), AlreadyRegistered ());
65
-
66
- // Ensure the timestamp is not in the past.
67
- require (timestamp >= block .timestamp , TimestampInThePast ());
71
+ require (registrationData.timestamp == 0 , AlreadyRegistered ());
68
72
69
73
// Store the registration timestamp.
70
- registrations[identity] = timestamp;
74
+ registrationData.eon = eon;
75
+ registrationData.timestamp = timestamp;
71
76
72
77
// Emit the IdentityRegistered event.
73
78
emit IdentityRegistered (eon, identityPrefix, msg .sender , timestamp);
0 commit comments