settings.gno
2.84 Kb · 81 lines
1package bolo
2
3import "gno.land/p/nt/avl/v0"
4
5// Phase 0's values (API §2.2): placeholders for the deposit, the minimum donation and
6// the escrow cap, whose launch values API §2.2 proposes, and the three durations it
7// proposes. All are settled before Phase 1 (README), and only the admin changes them
8// afterwards.
9const (
10 launchDeposit int64 = 1_000_000 // ugnot
11 launchDormancy int64 = 90 * secondsPerDay
12 launchExitDelay int64 = 60 * secondsPerDay
13 launchBondHold int64 = 30 * secondsPerDay
14 launchMinDonation int64 = 1_000_000 // ugnot, a placeholder
15 launchEscrowCap int64 = 1_000_000_000 // ugnot (1,000 GNOT), a placeholder
16
17 // maxCategories keeps the list GetSettings returns to one bounded read (INV-9).
18 maxCategories = 50
19)
20
21// The admin and the settings only it changes (API §2.2, §3.6). Package state, all
22// unexported (C6).
23var (
24 admin address = adminAddr // a realm once a DAO accepts the role (ADR D11)
25 pendingAdmin address // the proposed admin until it accepts; "" for none
26
27 params = Params{ // for campaigns created from now on (INV-5)
28 CreationDeposit: launchDeposit,
29 DormancyPeriod: launchDormancy,
30 ExitDelay: launchExitDelay,
31 BondHold: launchBondHold,
32 }
33
34 presets = [4]int64{5_000_000, 10_000_000, 20_000_000, 50_000_000}
35 minDonation = launchMinDonation
36 escrowCap = launchEscrowCap // 0: no cap
37 tipRecipient address = adminAddr
38 paused bool
39 sunset bool
40
41 // The categories: a tree to look one up, and the codes in the order they were
42 // added, for GetSettings. init fills the tree from the launch set (API §2.1).
43 categories avl.Tree // code → true
44 categoryOrder = []string{
45 "medical", "emergency", "disaster", "humanitarian", "water", "food",
46 "education", "orphans", "animals", "funeral", "worship", "community",
47 "sport", "celebration", "personal", "other",
48 }
49)
50
51// SettingsView is the live settings (API §2.4): a copy, holding nothing of the
52// realm's state.
53type SettingsView struct {
54 Version string // "v0"
55 Presets [4]int64
56 MaxEscrowBalance int64 // 0 = no cap
57 Categories []string
58 TipRecipient address
59 MinDonation int64
60 Paused, Sunset bool
61}
62
63// GetParams returns the Params a campaign created now would get (API §4).
64func GetParams() Params { return params }
65
66// GetSettings returns the live settings (API §4).
67func GetSettings() SettingsView {
68 return SettingsView{
69 Version: "v0",
70 Presets: presets,
71 MaxEscrowBalance: escrowCap,
72 Categories: append([]string(nil), categoryOrder...),
73 TipRecipient: tipRecipient,
74 MinDonation: minDonation,
75 Paused: paused,
76 Sunset: sunset,
77 }
78}
79
80// GetAdmin returns the admin and the proposed admin, "" when there is none (API §4).
81func GetAdmin() (address, address) { return admin, pendingAdmin }