events.gno
1.14 Kb · 38 lines
1package nslogic
2
3import (
4 "strconv"
5
6 "chain"
7)
8
9/*
10EVERY ADMIN ACTION EMITS AdminAction, with the signer and the call.
11
12There was no event anywhere in this realm, so a stolen admin key's
13treasury change, rate change or deletion was invisible until its effects
14showed up somewhere else (audit M-4/M-6). The vault now says what changed
15(nsdata/events.gno); this says who asked, through which call, with which
16arguments — the line a monitor alerts on. A failed call emits nothing:
17an aborted transaction keeps no events.
18
19One event type, "AdminAction", with "fn" naming the call, so a monitor
20subscribes once and a new admin call is covered without anybody updating
21a list. Profile values replayed by a restore are not repeated here, only
22their keys, for the reason given in nsdata/events.gno.
23*/
24func emitAdmin(cur realm, fn string, kv ...string) {
25 attrs := []string{"fn", fn, "by", cur.Previous().Address().String()}
26 chain.Emit("AdminAction", append(attrs, kv...)...)
27}
28
29func fmtInt(n int64) string { return strconv.FormatInt(n, 10) }
30
31func fmtI(n int) string { return strconv.Itoa(n) }
32
33func fmtBool(b bool) string {
34 if b {
35 return "true"
36 }
37 return "false"
38}