Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve r/gnoland/valopers implementation #2509

Merged
merged 11 commits into from
Jul 6, 2024
18 changes: 11 additions & 7 deletions examples/gno.land/r/gnoland/valopers/valopers.gno
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const (
errValoperExists = "valoper already exists"
errValoperMissing = "valoper does not exist"
errInvalidAddressUpdate = "valoper updated address exists"
errValoperInactive = "valoper is not active"
errValoperNotCaller = "valoper is not the caller"
)

Expand Down Expand Up @@ -141,22 +140,27 @@ func isValoper(address std.Address) bool {
// This function is meant to serve as a helper
// for generating the govdao proposal
func GovDAOProposal(address std.Address) {
moul marked this conversation as resolved.
Show resolved Hide resolved
moul marked this conversation as resolved.
Show resolved Hide resolved
valoper := GetByAddr(address)
if !valoper.Active {
panic(errValoperInactive)
}
var (
valoper = GetByAddr(address)
votingPower = uint64(1)
)

// Make sure the valoper is the caller
if std.GetOrigCaller() != address {
zivkovicmilos marked this conversation as resolved.
Show resolved Hide resolved
panic(errValoperInactive)
panic(errValoperNotCaller)
}

// Determine the voting power
if !valoper.Active {
votingPower = uint64(0)
}

changesFn := func() []pVals.Validator {
return []pVals.Validator{
{
Address: valoper.Address,
PubKey: valoper.PubKey,
VotingPower: 10,
VotingPower: votingPower,
},
}
}
Expand Down
Loading