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

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

events.gno

1.43 Kb · 47 lines
 1package nsdata
 2
 3import (
 4	"strconv"
 5
 6	"chain"
 7)
 8
 9/*
10EVERY RECORD AND CONFIG CHANGE EMITS, FROM THE VAULT.
11
12There were no events here outside governance, and none in the logic realm
13at all, so the audit's stolen-admin attacks were invisible until the
14ledger's Burn and Mint showed the result (audit M-6). PREFLIGHT.md and
15MAINNET.md make monitoring the mitigation — "a timelock is worthless if
16nobody watches it" — and there was nothing to watch.
17
18They are emitted here rather than in nslogic so the coverage survives a
19logic swap: whatever realm writes, the vault says what changed. Each one
20carries `by`, the realm that made the write. For record writes that is a
21trusted logic realm, which is the point — a write from a realm a monitor
22did not expect IS the incident. nslogic adds its own AdminAction event with
23the signer and the call.
24
25Profile writes name the field and never the value: the value is in the
26transaction already, and an event index is not the place to collect
27people's addresses a second time.
28*/
29
30func emitBy(cur realm, typ string, kv ...string) {
31	kv = append(kv, "by", cur.Previous().Address().String())
32	chain.Emit(typ, kv...)
33}
34
35func i64(n int64) string { return strconv.FormatInt(n, 10) }
36
37func boolStr(b bool) string {
38	if b {
39		return "true"
40	}
41	return "false"
42}
43
44// emitConfig is the one event for every typed vault setting.
45func emitConfig(cur realm, key, value string) {
46	emitBy(cur, "ConfigSet", "key", key, "value", value)
47}