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

render.gno

1.36 Kb · 49 lines
 1package community_pool
 2
 3import (
 4	prbac "gno.land/p/gnoswap/rbac/v1"
 5	"gno.land/p/moul/md/v0"
 6	"gno.land/p/moul/mdtable/v0"
 7	ufmt "gno.land/p/nt/ufmt/v0"
 8
 9	"gno.land/r/gnoswap/access/v1"
10	"gno.land/r/gnoswap/halt/v1"
11)
12
13// Render shows the authorities and withdrawal gate used by treasury transfers.
14func Render(path string) string {
15	if path != "" {
16		return "404\n"
17	}
18
19	out := md.H1("Gnoswap Community Pool") +
20		"\n" +
21		md.Paragraph(
22			"The community treasury holds tokens for ecosystem funding.\n"+
23				"Balances are queried per token; this page does not report a total treasury value.",
24		) +
25		md.H2("Transfers") +
26		"\n" +
27		md.Paragraph("Transfers require the admin or governance role and are blocked when withdrawals are halted.")
28
29	statusTable := mdtable.Table{
30		Headers: []string{"Restriction", "Enabled"},
31		Rows: [][]string{
32			{"Withdrawals halted", ufmt.Sprintf("%t", halt.IsHaltedWithdraw())},
33		},
34	}
35	out += statusTable.String() + "\n"
36
37	out += md.H2("Transfer authorities") + "\n"
38	authorityTable := mdtable.Table{
39		Headers: []string{"Role", "Address"},
40	}
41	for _, role := range []prbac.SystemRole{prbac.ROLE_ADMIN, prbac.ROLE_GOVERNANCE} {
42		value := "Unassigned"
43		if addr, ok := access.GetAddress(role.String()); ok {
44			value = md.InlineCode(addr.String())
45		}
46		authorityTable.Append([]string{role.String(), value})
47	}
48	return out + authorityTable.String()
49}