events.gno
1.83 Kb · 68 lines
1package access
2
3import (
4 "chain"
5 "strconv"
6
7 "gno.land/p/onbloc/access/manager"
8)
9
10func emitRoleLabelEvent(role manager.RoleId, label string) {
11 chain.Emit(
12 manager.EventTypeRoleLabel,
13 manager.AttributeKeyRoleID, role.String(),
14 manager.AttributeKeyLabel, label,
15 )
16}
17
18func emitRoleGrantedEvent(role manager.RoleId, account address, since manager.TimePoint, newMember bool) {
19 chain.Emit(
20 manager.EventTypeRoleGranted,
21 manager.AttributeKeyRoleID, role.String(),
22 manager.AttributeKeyAccount, account.String(),
23 manager.AttributeKeySince, since.String(),
24 manager.AttributeKeyNewMember, strconv.FormatBool(newMember),
25 )
26}
27
28func emitRoleRevokedEvent(role manager.RoleId, account address) {
29 chain.Emit(
30 manager.EventTypeRoleRevoked,
31 manager.AttributeKeyRoleID, role.String(),
32 manager.AttributeKeyAccount, account.String(),
33 )
34}
35
36func emitRoleAdminChangedEvent(role manager.RoleId, admin manager.RoleId) {
37 chain.Emit(
38 manager.EventTypeRoleAdminChanged,
39 manager.AttributeKeyRoleID, role.String(),
40 manager.AttributeKeyAdmin, admin.String(),
41 )
42}
43
44func emitRoleGrantDelayChangedEvent(role manager.RoleId, delay manager.Delay, since manager.TimePoint) {
45 chain.Emit(
46 manager.EventTypeRoleGrantDelayChanged,
47 manager.AttributeKeyRoleID, role.String(),
48 manager.AttributeKeyDelay, delay.String(),
49 manager.AttributeKeySince, since.String(),
50 )
51}
52
53func emitTargetClosedEvent(target string, closed bool) {
54 chain.Emit(
55 manager.EventTypeTargetClosed,
56 manager.AttributeKeyTarget, target,
57 manager.AttributeKeyClosed, strconv.FormatBool(closed),
58 )
59}
60
61func emitTargetFunctionRoleUpdatedEvent(target string, selector manager.Selector, role manager.RoleId) {
62 chain.Emit(
63 manager.EventTypeTargetFunctionRoleUpdated,
64 manager.AttributeKeyTarget, target,
65 manager.AttributeKeySelector, string(selector),
66 manager.AttributeKeyRoleID, role.String(),
67 )
68}