Skip to content

Commit a090c62

Browse files
committed
Ⓜ️ Event with unique ID (fix #19)
1 parent 5b94e3c commit a090c62

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mina/HumanIDv1.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ const readSignature = (bytes: Uint8Array) => new Signature(
3737
readField(bytes.subarray(32))
3838
);
3939

40+
const encoder = new TextEncoder();
41+
const encodedEventInit = encoder.encode("KimlikDAO-init");
42+
const encodedEventCreate = encoder.encode("KimlikDAO-add-HumanIDv1");
43+
4044
class HumanIDv1 extends Struct({
4145
id: Field,
4246
commitmentR: Field,
@@ -108,7 +112,7 @@ class PerHumanIDv1Contract extends SmartContract {
108112
"KimlikDAO-init",
109113
new EventStruct(
110114
{
111-
uid: Poseidon.hash([Field("KimlikDAO-init")]),
115+
uid: Poseidon.hash([readField(encodedEventInit)]),
112116
humanIDv1: Field(32)
113117
}
114118
)
@@ -127,7 +131,7 @@ class PerHumanIDv1Contract extends SmartContract {
127131
"KimlikDAO-add-HumanIDv1",
128132
new EventStruct(
129133
{
130-
uid: Poseidon.hash([Field("KimlikDAO-add-HumanIDv1")]),
134+
uid: Poseidon.hash([readField(encodedEventCreate)]),
131135
humanIDv1: humanIDv1.id
132136
}
133137
));

0 commit comments

Comments
 (0)