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

render.gno

2.66 Kb · 71 lines
 1package launchpad
 2
 3import (
 4	"chain"
 5	"strings"
 6
 7	prbac "gno.land/p/gnoswap/rbac/v1"
 8	"gno.land/p/moul/md/v0"
 9	"gno.land/p/moul/mdtable/v0"
10	ufmt "gno.land/p/nt/ufmt/v0"
11
12	"gno.land/r/gnoswap/access/v1"
13	"gno.land/r/gnoswap/halt/v1"
14	launchpadRoot "gno.land/r/gnoswap/launchpad"
15)
16
17func (l *launchpadV1) Render(path string) string {
18	if path != "" {
19		return "404\n"
20	}
21
22	implementation := launchpadRoot.GetImplementationPackagePath()
23
24	out := md.H1("Gnoswap Launchpad")
25	out += md.Paragraph(
26		"All GNS amounts use the token's six-decimal base units. Project reward amounts\n" +
27			"use the project token's own base units.",
28	)
29
30	out += md.H2("Implementation and access")
31	implementationTable := mdtable.Table{
32		Headers: []string{"Field", "Value"},
33		Rows: [][]string{
34			{"Realm address", md.InlineCode(chain.PackageAddress("gno.land/r/gnoswap/launchpad").String())},
35			{"Active implementation", md.Link(implementation, strings.TrimPrefix(implementation, "gno.land"))},
36			{"Launchpad operations halted", ufmt.Sprintf("%t", halt.IsHaltedLaunchpad())},
37			{"Withdrawal operations halted", ufmt.Sprintf("%t", halt.IsHaltedWithdraw())},
38			{"Project creation role (admin)", renderLaunchpadRole(prbac.ROLE_ADMIN)},
39			{"Project creation role (governance)", renderLaunchpadRole(prbac.ROLE_GOVERNANCE)},
40		},
41	}
42	out += implementationTable.String()
43
44	out += md.H2("Deposit accounting and configuration")
45	accountingTable := mdtable.Table{
46		Headers: []string{"Field", "Value"},
47		Rows: [][]string{
48			{"Stored project records", ufmt.Sprintf("%d", l.store.GetProjects().Size())},
49			{"Stored unique project-recipient records", ufmt.Sprintf("%d", l.store.GetProjectRecipients().Size())},
50			{"Stored project-tier reward-manager records", ufmt.Sprintf("%d", l.store.GetProjectTierRewardManagers().Size())},
51			{"Stored deposit records (including withdrawn)", ufmt.Sprintf("%d", l.store.GetDeposits().Size())},
52			{"Deposit ID counter (allocated IDs)", ufmt.Sprintf("%d", l.store.GetDepositCounter().Get())},
53			{"Current GNS staked amount (base units; 6 decimals)", ufmt.Sprintf("%d", l.store.GetTotalGNSStakedAmount())},
54			{"Minimum GNS deposit (base units; 6 decimals)", ufmt.Sprintf("%d", minimumDepositAmount)},
55			{"Minimum project start delay (seconds)", ufmt.Sprintf("%d", projectMinimumStartDelayTime)},
56			{"Project tiers (days)", "30 / 90 / 180"},
57			{"Reward claimable duration (seconds)", ufmt.Sprintf("%d", projectTierRewardCollectableDuration[projectTier30])},
58		},
59	}
60	out += accountingTable.String()
61
62	return out
63}
64
65func renderLaunchpadRole(role prbac.SystemRole) string {
66	addr, ok := access.GetAddress(role.String())
67	if !ok || addr == address("") {
68		return "Unassigned"
69	}
70	return md.InlineCode(addr.String())
71}