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]: add swagger-ui for gov, stake and slashing #2462

Merged
merged 28 commits into from
Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
126dc8a
Add swagger-ui for gov, stake and slashing
Oct 9, 2018
d8852d7
Add json consume
Oct 9, 2018
eadaf43
Add json to response header
Oct 10, 2018
1774658
Fix some bugs in stake APIs
Oct 10, 2018
da7dc49
Refactor swagger.ymal, remove definitions which are only referenced once
Oct 10, 2018
e529488
Remove duplicated json header
Oct 10, 2018
66eb6f9
Merge branch 'develop' of https://github.com/cosmos/cosmos-sdk into i…
Oct 10, 2018
4ba59c7
refactor query validator set response
Oct 10, 2018
6e1a4d1
Refactor swagger.yaml according code reviewer feedback
Oct 10, 2018
ba4eadd
Add response model
Oct 11, 2018
cde3db1
Merge with develop
Oct 18, 2018
4c08aed
Merge branch 'develop' of https://github.com/cosmos/cosmos-sdk into i…
Oct 19, 2018
e050d89
Fix lcd test failure: TestUnjail
Oct 19, 2018
9db8dc2
Add response mode and add error code for all query endpoints
Oct 19, 2018
5270da6
fix ci test failure
Oct 19, 2018
6ec2d88
Resolve some spell error, add missing gov endpoint and modify swagger…
Oct 19, 2018
9136254
Fix wrong response body
Oct 19, 2018
131e0ca
Resolve inconsistence between swagger.yaml and code implementation
Oct 19, 2018
2f09cd7
Merge with develop
Oct 20, 2018
eb7d3df
Update swagger.yaml to accommodate handler implementation changes
Oct 20, 2018
2b267fc
Fix bug in normalize gov parameters
Oct 20, 2018
8363685
Add example value to proposal type and vote option
Oct 20, 2018
88b4c66
Improve error handler in delete and update key
Oct 20, 2018
4631c0b
Merge branch 'develop' of https://github.com/cosmos/cosmos-sdk into i…
Oct 22, 2018
8045d49
Implement error type in key base
Oct 23, 2018
d88a213
Add /stake/validators/{validatorAddr}/unbonding_delegations and /stak…
Oct 23, 2018
6d6b58a
Merge branch 'develop' of https://github.com/cosmos/cosmos-sdk into i…
Oct 24, 2018
fb04cfb
Add change to about split issue 2258 to swagger.yaml
Oct 24, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ FEATURES
* [gaia-lite] [\#966](https://github.com/cosmos/cosmos-sdk/issues/966) Add support for `generate_only=true` query argument to generate offline unsigned transactions
* [gaia-lite] [\#1953](https://github.com/cosmos/cosmos-sdk/issues/1953) Add /sign endpoint to sign transactions generated with `generate_only=true`.
* [gaia-lite] [\#1954](https://github.com/cosmos/cosmos-sdk/issues/1954) Add /broadcast endpoint to broadcast transactions signed by the /sign endpoint.
* [gaia-lite] [\#2113](https://github.com/cosmos/cosmos-sdk/issues/2113) Rename `/accounts/{address}/send` to `/bank/accounts/{address}/transfers`, rename `/accounts/{address}` to `/auth/accounts/{address}`
* [gaia-lite] [\#2113](https://github.com/cosmos/cosmos-sdk/issues/2113) Rename `/accounts/{address}/send` to `/bank/accounts/{address}/transfers`, rename `/accounts/{address}` to `/auth/accounts/{address}`, replace `proposal-id` with `proposalId` in all gov endpoints
* [gaia-lite] [\#2478](https://github.com/cosmos/cosmos-sdk/issues/2478) Add query gov proposal's deposits endpoint
* [gaia-lite] [\#2477](https://github.com/cosmos/cosmos-sdk/issues/2477) Add query validator's outgoing redelegations and unbonding delegations endpoints

Expand Down
12 changes: 10 additions & 2 deletions client/keys/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/cosmos/cosmos-sdk/client"
keys "github.com/cosmos/cosmos-sdk/crypto/keys"
keyerror "github.com/cosmos/cosmos-sdk/crypto/keys/keyerror"
"github.com/gorilla/mux"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -80,9 +81,16 @@ func DeleteKeyRequestHandler(w http.ResponseWriter, r *http.Request) {
return
}

// TODO handle error if key is not available or pass is wrong
err = kb.Delete(name, m.Password)
if err != nil {
if keyerror.IsErrKeyNotFound(err) {
w.WriteHeader(http.StatusNotFound)
w.Write([]byte(err.Error()))
return
} else if keyerror.IsErrWrongPassword(err) {
w.WriteHeader(http.StatusUnauthorized)
w.Write([]byte(err.Error()))
return
} else if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
return
Expand Down
9 changes: 6 additions & 3 deletions client/keys/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/tendermint/tendermint/libs/cli"
"github.com/cosmos/cosmos-sdk/crypto/keys/keyerror"
)

const (
Expand Down Expand Up @@ -108,12 +109,14 @@ func GetKeyRequestHandler(indent bool) http.HandlerFunc {
}

info, err := GetKeyInfo(name)
// TODO: check for the error if key actually does not exist, instead of
// assuming this as the reason
if err != nil {
if keyerror.IsErrKeyNotFound(err) {
w.WriteHeader(http.StatusNotFound)
w.Write([]byte(err.Error()))
return
} else if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
return
}

keyOutput, err := bechKeyOut(info)
Expand Down
12 changes: 10 additions & 2 deletions client/keys/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/gorilla/mux"

"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/crypto/keys/keyerror"
)

func updateKeyCommand() *cobra.Command {
Expand Down Expand Up @@ -83,12 +84,19 @@ func UpdateKeyRequestHandler(w http.ResponseWriter, r *http.Request) {

getNewpass := func() (string, error) { return m.NewPassword, nil }

// TODO check if account exists and if password is correct
err = kb.Update(name, m.OldPassword, getNewpass)
if err != nil {
if keyerror.IsErrKeyNotFound(err) {
w.WriteHeader(http.StatusNotFound)
w.Write([]byte(err.Error()))
return
} else if keyerror.IsErrWrongPassword(err) {
w.WriteHeader(http.StatusUnauthorized)
w.Write([]byte(err.Error()))
return
} else if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
return
}

w.Header().Set("Content-Type", "application/json")
Expand Down
2 changes: 1 addition & 1 deletion client/lcd/lcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ func doIBCTransfer(t *testing.T, port, seed, name, password string, addr sdk.Acc
}

func getSigningInfo(t *testing.T, port string, validatorPubKey string) slashing.ValidatorSigningInfo {
res, body := Request(t, port, "GET", fmt.Sprintf("/slashing/signing_info/%s", validatorPubKey), nil)
res, body := Request(t, port, "GET", fmt.Sprintf("/slashing/validators/%s/signing_info", validatorPubKey), nil)
require.Equal(t, http.StatusOK, res.StatusCode, body)

var signingInfo slashing.ValidatorSigningInfo
Expand Down
Loading