Skip to content
Cosmopediaby Unity Nodes
DiscussionsCosmos-SDKCosmos-SDK simple governance applicationForum ↗

Cosmos-SDK simple governance application

Cosmos-SDK5 posts1,169 views1 likesLast activity Dec 2018
HA
happygopherOP
Nov 2018

Hi guys! I need your help! I’m following the docs to build a simple governance application ( https://cosmos.network/docs/sdk/sdk-by-examples/simple-governance/simple-gov-module.html ) I know that the docs are a little out of date and Cosmos SDK API has changed a little, but I almost made it work by looking at a more fresh example at https://github.com/cosmos/sdk-application-tutorial . When I try to cast a vote I get an error: “Delegator does not contain this delegation”. The error occurs at the following line: github.com cosmos/cosmos-sdk/blob/bf5aa434bb623270a410b4d0011edfbdcc85b9d8/examples/simpleGov/x/simple_governance/handler.go#L129 ``` proposal, err := k.GetProposal(ctx, msg.ProposalID) if err != nil { return err.Result() } if ctx.BlockHeight() > proposal.SubmitBlock+votingPeriod || !proposal.IsOpen() { return ErrVotingPeriodClosed().Result() } delegatedTo := k.sm.GetDelegations(ctx, msg.Voter, 10) if len(delegatedTo) <= 0 { return stake.ErrNoDelegatorForAddress(stake.DefaultCodespace).Result() } // Check if address already voted voterOption, err := k.GetVote(ctx, msg.ProposalID, msg.Voter) if voterOption == "" && err…

Excerpt (1197 of 1618 characters). Read the whole post on the forum ↗

JA
jack
Nov 2018

Hey @happygopher! The simple_goverance application is pretty out of date. We are, however, maintaining the sdk-application-tutorial does that one work for you?

HA
happygopher
Nov 2018

Yeah, I know As I mentioned it in my message, I’m trying to build the simple governance application using the sdk-application-tutorial as a skeleton. I hacked it a little and almost made it work, the only thing I’m struggling is that I don’t know how to make delegations work The thing is that the delegation part is not covered by sdk-application-tutorial Btw, I’ve committed everything I’ve done so far in my own repo. So to be more precise, I don’t know how to prevent the error at the following line from happening: github.com screwyprof/testgov/blob/e9f1279518af918dc634d9244038d3829aaef496/x/testgov/handler.go#L67 ``` if err != nil { return err.Result() } if !proposal.IsOpen() || ctx.BlockHeight() > proposal.SubmitBlock+votingPeriod { return ErrVotingPeriodClosed().Result() } delegatedTo := k.stakeKeeper.GetDelegatorDelegations(ctx, msg.Voter, 10) if len(delegatedTo) <= 0 { return stake.ErrNoDelegatorForAddress(stake.DefaultCodespace).Result() // TODO: Find it out how to prevent this error // see https://forum.cosmos.network/t/cosmos-sdk-simple-governance-application/1325 // Magic //valPriv := ed25519.GenPrivKey() //valAddress,…

Excerpt (1199 of 1546 characters). Read the whole post on the forum ↗

HA
happygopher
Nov 2018 1

I’ve finally made it work :slight_smile: All really needed is to create a validator. I’ve committed the changes and updated the docs. Current version is available on GitHub screwyprof/testgov (the forum doesn’t allow posting a link for some reason)

09
09qw123
Dec 2018
happygopher:

crewyprof/testgov

link to repo mentioned above

← Back to Discussions