Skip to content

Commit

Permalink
Merge PR #1949: Fixed delegations endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
faboweb authored and cwgoes committed Aug 10, 2018
1 parent 831435c commit 1479a35
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions x/stake/client/rest/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,16 @@ func delegatorHandlerFn(cliCtx context.CLIContext, cdc *wire.Codec) http.Handler
if statusCode != http.StatusNoContent {
delegationSummary.Redelegations = append(delegationSummary.Redelegations, redelegations)
}
}

output, err := cdc.MarshalJSON(delegationSummary)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
return
}

// success
w.Write(output) // write
output, err := cdc.MarshalJSON(delegationSummary)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
return
}

w.Write(output)
}
}

Expand Down Expand Up @@ -218,14 +217,13 @@ func delegatorTxsHandlerFn(cliCtx context.CLIContext, cdc *wire.Codec) http.Hand
txs = append(txs, foundTxs...)
}

// success
output, err = cdc.MarshalJSON(txs)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
return
}
w.Write(output) // write
w.Write(output)
}
}

Expand Down Expand Up @@ -402,14 +400,13 @@ func delegatorValidatorsHandlerFn(cliCtx context.CLIContext, cdc *wire.Codec) ht

bondedValidators = append(bondedValidators, validator)
}
// success
output, err := cdc.MarshalJSON(bondedValidators)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
return
}
w.Write(output) // write
w.Write(output)
}
}

Expand Down Expand Up @@ -441,7 +438,6 @@ func delegatorValidatorHandlerFn(cliCtx context.CLIContext, cdc *wire.Codec) htt
w.WriteHeader(statusCode)
return
}
// success
output, err = cdc.MarshalJSON(validator)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
Expand Down

0 comments on commit 1479a35

Please sign in to comment.