Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

emits.gno

1.61 Kb · 60 lines
 1package keeper
 2
 3import (
 4	"chain"
 5	"strconv"
 6
 7	"gno.land/p/gnoswap/order/access/manager/v0"
 8)
 9
10func emitRoleLabel(role manager.RoleId, label string) {
11	chain.Emit(
12		manager.EventTypeRoleLabel,
13		manager.AttributeKeyRoleID, role.String(),
14		manager.AttributeKeyLabel, label,
15	)
16}
17
18func emitRoleGranted(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 emitRoleRevoked(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 emitRoleGrantDelayChanged(role manager.RoleId, delay uint32, since manager.TimePoint) {
37	chain.Emit(
38		manager.EventTypeRoleGrantDelayChanged,
39		manager.AttributeKeyRoleID, role.String(),
40		manager.AttributeKeyDelay, strconv.FormatUint(uint64(delay), 10),
41		manager.AttributeKeySince, since.String(),
42	)
43}
44
45func emitTargetClosed(target string, closed bool) {
46	chain.Emit(
47		manager.EventTypeTargetClosed,
48		manager.AttributeKeyTarget, target,
49		manager.AttributeKeyClosed, strconv.FormatBool(closed),
50	)
51}
52
53func emitTargetFunctionRoleUpdated(target string, selector manager.Selector, role manager.RoleId) {
54	chain.Emit(
55		manager.EventTypeTargetFunctionRoleUpdated,
56		manager.AttributeKeyTarget, target,
57		manager.AttributeKeySelector, string(selector),
58		manager.AttributeKeyRoleID, role.String(),
59	)
60}