Skip to content

Commit 41acc96

Browse files
committed
shutter-service: update storage
1 parent 33e7d08 commit 41acc96

File tree

3 files changed

+41
-20
lines changed

3 files changed

+41
-20
lines changed

bindings/shutterregistry/shutterregistry.go

Lines changed: 27 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen_bindings.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CONTRACTS=(
88
"EonKeyPublish"
99
"KeyBroadcastContract"
1010
"Inbox"
11+
"ShutterRegistry"
1112
)
1213
OUTPUT_DIR="bindings"
1314
PACKAGE_NAME="bindings"

src/shutter-service/ShutterRegistry.sol

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ contract ShutterRegistry is Ownable {
1515
// Custom error for when a provided timestamp is in the past.
1616
error TimestampInThePast();
1717

18+
struct RegsitrationData {
19+
uint64 eon;
20+
uint64 timestamp;
21+
}
1822
/**
1923
* @dev Mapping to store registration timestamps for each identity.
2024
* The identity is represented as a `bytes32` hash and mapped to a uint64 timestamp.
2125
*/
22-
mapping(bytes32 identity => uint64 timestamp) public registrations;
26+
mapping(bytes32 identity => RegsitrationData) public registrations;
2327

2428
/**
2529
* @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.
2731
* @param identityPrefix The raw prefix input used to derive the registered identity hash.
2832
* @param sender The address of the account that performed the registration.
2933
* @param timestamp The timestamp associated with the registered identity.
@@ -55,19 +59,20 @@ contract ShutterRegistry is Ownable {
5559
bytes32 identityPrefix,
5660
uint64 timestamp
5761
) external {
62+
// Ensure the timestamp is not in the past.
63+
require(timestamp >= block.timestamp, TimestampInThePast());
64+
5865
// Generate the identity hash from the provided prefix and the sender's address.
5966
bytes32 identity = keccak256(
6067
abi.encodePacked(identityPrefix, msg.sender)
6168
);
62-
69+
RegsitrationData storage registrationData = registrations[identity];
6370
// 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());
6872

6973
// Store the registration timestamp.
70-
registrations[identity] = timestamp;
74+
registrationData.eon = eon;
75+
registrationData.timestamp = timestamp;
7176

7277
// Emit the IdentityRegistered event.
7378
emit IdentityRegistered(eon, identityPrefix, msg.sender, timestamp);

0 commit comments

Comments
 (0)