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

R4R: Address gov cli ux issues and add additional input validation for better errors #2938

Merged
merged 12 commits into from
Dec 3, 2018
22 changes: 9 additions & 13 deletions cmd/gaia/cli_test/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,22 +359,20 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
fooAcc = executeGetAccount(t, fmt.Sprintf("gaiacli query account %s %v", fooAddr, flags))
require.Equal(t, int64(45), fooAcc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom).Int64())

proposal1 := executeGetProposal(t, fmt.Sprintf("gaiacli query gov proposal --proposal-id=1 --output=json %v", flags))
proposal1 := executeGetProposal(t, fmt.Sprintf("gaiacli query gov proposal 1 --output=json %v", flags))
require.Equal(t, uint64(1), proposal1.GetProposalID())
require.Equal(t, gov.StatusDepositPeriod, proposal1.GetStatus())

proposalsQuery, _ = tests.ExecuteT(t, fmt.Sprintf("gaiacli query gov proposals %v", flags), "")
require.Equal(t, " 1 - Test", proposalsQuery)

deposit := executeGetDeposit(t,
fmt.Sprintf("gaiacli query gov deposit --proposal-id=1 --depositor=%s --output=json %v",
fmt.Sprintf("gaiacli query gov deposit 1 %s --output=json %v",
jackzampolin marked this conversation as resolved.
Show resolved Hide resolved
fooAddr, flags))
require.Equal(t, int64(5), deposit.Amount.AmountOf(stakeTypes.DefaultBondDenom).Int64())

depositStr := fmt.Sprintf("gaiacli tx gov deposit %v", flags)
depositStr := fmt.Sprintf("gaiacli tx gov deposit 1 %s %v", fmt.Sprintf("10%s", stakeTypes.DefaultBondDenom), flags)
depositStr += fmt.Sprintf(" --from=%s", "foo")
depositStr += fmt.Sprintf(" --deposit=%s", fmt.Sprintf("10%s", stakeTypes.DefaultBondDenom))
depositStr += fmt.Sprintf(" --proposal-id=%s", "1")

// Test generate only
success, stdout, stderr = executeWriteRetStdStreams(t, depositStr+" --generate-only", app.DefaultKeyPass)
Expand All @@ -391,12 +389,12 @@ func TestGaiaCLISubmitProposal(t *testing.T) {

// test query deposit
deposits := executeGetDeposits(t,
fmt.Sprintf("gaiacli query gov deposits --proposal-id=1 --output=json %v", flags))
fmt.Sprintf("gaiacli query gov deposits 1 --output=json %v", flags))
require.Len(t, deposits, 1)
require.Equal(t, int64(15), deposits[0].Amount.AmountOf(stakeTypes.DefaultBondDenom).Int64())

deposit = executeGetDeposit(t,
fmt.Sprintf("gaiacli query gov deposit --proposal-id=1 --depositor=%s --output=json %v",
fmt.Sprintf("gaiacli query gov deposit 1 %s --output=json %v",
fooAddr, flags))
require.Equal(t, int64(15), deposit.Amount.AmountOf(stakeTypes.DefaultBondDenom).Int64())

Expand All @@ -406,14 +404,12 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
fooAcc = executeGetAccount(t, fmt.Sprintf("gaiacli query account %s %v", fooAddr, flags))

require.Equal(t, int64(35), fooAcc.GetCoins().AmountOf(stakeTypes.DefaultBondDenom).Int64())
proposal1 = executeGetProposal(t, fmt.Sprintf("gaiacli query gov proposal --proposal-id=1 --output=json %v", flags))
proposal1 = executeGetProposal(t, fmt.Sprintf("gaiacli query gov proposal 1 --output=json %v", flags))
require.Equal(t, uint64(1), proposal1.GetProposalID())
require.Equal(t, gov.StatusVotingPeriod, proposal1.GetStatus())

voteStr := fmt.Sprintf("gaiacli tx gov vote %v", flags)
voteStr := fmt.Sprintf("gaiacli tx gov vote 1 Yes %v", flags)
jackzampolin marked this conversation as resolved.
Show resolved Hide resolved
voteStr += fmt.Sprintf(" --from=%s", "foo")
voteStr += fmt.Sprintf(" --proposal-id=%s", "1")
voteStr += fmt.Sprintf(" --option=%s", "Yes")

// Test generate only
success, stdout, stderr = executeWriteRetStdStreams(t, voteStr+" --generate-only", app.DefaultKeyPass)
Expand All @@ -428,11 +424,11 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
executeWrite(t, voteStr, app.DefaultKeyPass)
tests.WaitForNextNBlocksTM(1, port)

vote := executeGetVote(t, fmt.Sprintf("gaiacli query gov vote --proposal-id=1 --voter=%s --output=json %v", fooAddr, flags))
vote := executeGetVote(t, fmt.Sprintf("gaiacli query gov vote 1 %s --output=json %v", fooAddr, flags))
require.Equal(t, uint64(1), vote.ProposalID)
require.Equal(t, gov.OptionYes, vote.Option)

votes := executeGetVotes(t, fmt.Sprintf("gaiacli query gov votes --proposal-id=1 --output=json %v", flags))
votes := executeGetVotes(t, fmt.Sprintf("gaiacli query gov votes 1 --output=json %v", flags))
require.Len(t, votes, 1)
require.Equal(t, uint64(1), votes[0].ProposalID)
require.Equal(t, gov.OptionYes, votes[0].Option)
Expand Down
36 changes: 19 additions & 17 deletions docs/gaia/gaiacli.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ gaiacli query txs --tags='<tag1>:<value1>&<tag2>:<value2>'

::: tip Note

The action tag always equals the message type returned by the `Type()` function of the relevant message.
The action tag always equals the message type returned by the `Type()` function of the relevant message.

You can find a list of available `tags` on each of the SDK modules:

Expand Down Expand Up @@ -461,7 +461,7 @@ gaiacli tx gov submit-proposal \
Once created, you can now query information of the proposal:

```bash
gaiacli query gov proposal --proposal-id=<proposal_id>
gaiacli query gov proposal <proposal_id>
```

Or query all available proposals:
Expand All @@ -477,9 +477,7 @@ You can also query proposals filtered by `voter` or `depositor` by using the cor
In order for a proposal to be broadcasted to the network, the amount deposited must be above a `minDeposit` value (default: `10 steak`). If the proposal you previously created didn't meet this requirement, you can still increase the total amount deposited to activate it. Once the minimum deposit is reached, the proposal enters voting period:

```bash
gaiacli tx gov deposit \
--proposal-id=<proposal_id> \
--deposit=<200steak> \
gaiacli tx gov deposit <proposal_id> <200steak> \
--from=<name> \
--chain-id=<chain_id>
```
Expand All @@ -491,25 +489,21 @@ gaiacli tx gov deposit \
Once a new proposal is created, you can query all the deposits submitted to it:

```bash
gaiacli query gov deposits --proposal-id=<proposal_id>
gaiacli query gov deposits <proposal_id>
```

You can also query a deposit submitted by a specific address:

```bash
gaiacli query gov deposit \
--proposal-id=<proposal_id> \
--depositor=<account_cosmos>
gaiacli query gov deposit <proposal_id> <depositor_address>
```

#### Vote on a proposal

After a proposal's deposit reaches the `MinDeposit` value, the voting period opens. Bonded `Atom` holders can then cast vote on it:

```bash
gaiacli tx gov vote \
--proposal-id=<proposal_id> \
--option=<Yes/No/NoWithVeto/Abstain> \
gaiacli tx gov vote <proposal_id> <Yes/No/NoWithVeto/Abstain> \
--from=<name> \
--chain-id=<chain_id>
```
Expand All @@ -519,21 +513,29 @@ gaiacli tx gov vote \
Check the vote with the option you just submitted:

```bash
gaiacli query gov vote \
--proposal-id=<proposal_id> \
--voter=<account_cosmos>
gaiacli query gov vote <proposal_id> <voter_address>
```

You can also get all the previous votes submitted to the proposal with:

```bash
gaiacli query gov votes --proposal-id=<proposal_id>
gaiacli query gov votes <proposal_id>
```

#### Query proposal tally results

To check the current tally of a given proposal you can use the `tally` command:

```bash
gaiacli query gov tally --proposal-id=<proposal_id>
gaiacli query gov tally <proposal_id>
```

#### Query governance parameters
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ thanks !

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d'accord!


To check the current governance parameters run:

```bash
gaiacli query gov param voting
gaiacli query gov param tallying
gaiacli query gov param deposit
```
Loading