1package validators23import (4 "strings"56 "gno.land/p/nt/ufmt/v0"7 "gno.land/p/sys/validators/v0"8 "gno.land/r/gov/dao"9)1011// NewPropRequest creates a new proposal request that wraps a changes closure12// proposal. This wrapper is required to ensure the GovDAO Realm actually13// executed the callback.14func NewPropRequest(cur realm, changesFn func() []validators.Validator, title, description string) dao.ProposalRequest {15 if changesFn == nil {16 panic("no set changes proposed")17 }1819 title = strings.TrimSpace(title)20 if title == "" {21 panic("proposal title is empty")22 }2324 // Get the list of validators now to make sure the list25 // doesn't change during the lifetime of the proposal26 changes := changesFn()2728 // Limit the number of validators to keep the description within a limit29 // that makes sense because there is not pagination of validators30 if len(changes) > 40 {31 panic("max number of allowed validators per proposal is 40")32 } else if len(changes) == 0 {33 panic("proposal requires at least one validator")34 }3536 // List the validator addresses and the action to be taken for each one37 var desc strings.Builder38 desc.WriteString(description)39 if len(description) > 0 {40 desc.WriteString("\n\n")41 }4243 desc.WriteString("## Validator Updates\n")44 for _, change := range changes {45 if change.VotingPower == 0 {46 desc.WriteString(ufmt.Sprintf("- %s: remove\n", change.Address))47 } else {48 desc.WriteString(ufmt.Sprintf("- %s: add\n", change.Address))49 }50 }5152 callback := func(cur realm) error {53 for _, change := range changes {54 if change.VotingPower == 0 {55 // This change request is to remove the validator56 removeValidator(change.Address)5758 continue59 }6061 // This change request is to add the validator62 addValidator(change)63 }6465 return nil66 }6768 e := dao.NewSimpleExecutor(0, cur, callback, "")6970 return dao.NewProposalRequest(title, desc.String(), e)71}7273// IsValidator returns a flag indicating if the given bech32 address74// is part of the validator set75func IsValidator(addr address) bool {76 return vp.IsValidator(addr)77}7879// GetValidator returns the typed validator80func GetValidator(addr address) validators.Validator {81 if validator, err := vp.GetValidator(addr); err == nil {82 return validator83 }8485 panic("validator not found")86}8788// GetValidators returns the typed validator set89func GetValidators() []validators.Validator {90 return vp.GetValidators()91}92GetChanges(from int64, to int64) []gno.land/p/sys/validators/v0.Validator
GetValidator(addr string) struct{Address .uverse.address; PubKey string; VotingPower uint64}
GetValidators() []gno.land/p/sys/validators/v0.Validator
IsValidator(addr string) bool
NewPropRequest(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, changesFn func() []gno.land/p/sys/validators/v0.Validator, title string, description string) struct{title string; description string; executor gno.land/r/gov/dao.Executor; filter gno.land/r/gov/dao.Filter}
Render(string) string
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.
vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.