Skip to content

Commit

Permalink
v0.37.0 rc2 cherry picks
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez authored Aug 21, 2019
2 parents a6f265c + 8d1f9bb commit 87067e4
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 15 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

## [v0.37.0] - 2019-08-16
## [v0.37.0] - TBD

### Bug Fixes

Expand All @@ -45,6 +45,17 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Update `handleQueryStore` to resemble `handleQueryCustom`
* (simulation) [\#4912](https://github.com/cosmos/cosmos-sdk/issues/4912) Fix SimApp ModuleAccountAddrs
to properly return black listed addresses for bank keeper initialization.
* (cli) [\#4919](https://github.com/cosmos/cosmos-sdk/pull/4919) Don't crash CLI
if user doesn't answer y/n confirmation request.
* (cli) [\#4927](https://github.com/cosmos/cosmos-sdk/issues/4927) Fix the `q gov vote`
command to handle empty (pruned) votes correctly.

### Improvements

* (rest) [\#4924](https://github.com/cosmos/cosmos-sdk/pull/4924) Return response
height even upon error as it may be useful for the downstream caller and have
`/auth/accounts/{address}` return a 200 with an empty account upon error when
that error is that the account doesn't exist.

## [v0.36.0] - 2019-08-13

Expand Down
4 changes: 2 additions & 2 deletions client/context/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (ctx CLIContext) query(path string, key cmn.HexBytes) (res []byte, height i

resp := result.Response
if !resp.IsOK() {
return res, height, errors.New(resp.Log)
return res, resp.Height, errors.New(resp.Log)
}

// data from trusted node or subspace query doesn't need verification
Expand All @@ -105,7 +105,7 @@ func (ctx CLIContext) query(path string, key cmn.HexBytes) (res []byte, height i

err = ctx.verifyProof(path, resp)
if err != nil {
return res, height, err
return res, resp.Height, err
}

return resp.Value, resp.Height, nil
Expand Down
7 changes: 6 additions & 1 deletion client/input/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ func GetConfirmation(prompt string, buf *bufio.Reader) (bool, error) {
return false, err
}

response = strings.ToLower(strings.TrimSpace(response))
response = strings.TrimSpace(response)
if len(response) == 0 {
return false, nil
}

response = strings.ToLower(response)
if response[0] == 'y' {
return true, nil
}
Expand Down
13 changes: 8 additions & 5 deletions x/auth/client/rest/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ func QueryAccountRequestHandlerFn(storeName string, cliCtx context.CLIContext) h
}

accGetter := types.NewAccountRetriever(cliCtx)
// the query will return empty account if there is no data
if err := accGetter.EnsureExists(addr); err != nil {
rest.PostProcessResponse(w, cliCtx, types.BaseAccount{})
return
}

account, height, err := accGetter.GetAccountWithHeight(addr)
if err != nil {
// TODO: Handle more appropriately based on the error type.
// Ref: https://github.com/cosmos/cosmos-sdk/issues/4923
if err := accGetter.EnsureExists(addr); err != nil {
cliCtx = cliCtx.WithHeight(height)
rest.PostProcessResponse(w, cliCtx, types.BaseAccount{})
return
}

rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
Expand Down
4 changes: 2 additions & 2 deletions x/auth/types/account_retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ func (ar AccountRetriever) GetAccountWithHeight(addr sdk.AccAddress) (exported.A

res, height, err := ar.querier.QueryWithData(fmt.Sprintf("custom/%s/%s", QuerierRoute, QueryAccount), bs)
if err != nil {
return nil, 0, err
return nil, height, err
}

var account exported.Account
if err := ModuleCdc.UnmarshalJSON(res, &account); err != nil {
return nil, 0, err
return nil, height, err
}

return account, height, nil
Expand Down
11 changes: 7 additions & 4 deletions x/gov/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,21 +215,24 @@ $ %s query gov vote 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
}

var vote types.Vote
if err := cdc.UnmarshalJSON(res, &vote); err != nil {
return err
}

// XXX: Allow the decoding to potentially fail as the vote may have been
// pruned from state. If so, decoding will fail and so we need to check the
// Empty() case. Consider updating Vote JSON decoding to not fail when empty.
_ = cdc.UnmarshalJSON(res, &vote)

if vote.Empty() {
res, err = gcutils.QueryVoteByTxQuery(cliCtx, params)
if err != nil {
return err
}

if err := cdc.UnmarshalJSON(res, &vote); err != nil {
return err
}
}

return cliCtx.PrintOutput(vote) //nolint:errcheck
return cliCtx.PrintOutput(vote)
},
}
}
Expand Down

0 comments on commit 87067e4

Please sign in to comment.