* A few godoc updates * More minor tweaks and reformatting * Implement initial minting querier * Implement stringer interface for minting params * Minor cleanup * Add minting CLI commands * Implement inflation query command * Implement annual provisions query and CLI command * Update x/mint/client/module_client.go Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Update x/mint/client/module_client.go Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Update x/mint/client/module_client.go Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Update x/mint/querier.go Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Add minting REST client routes/handlers * Fix build issues * Implement querier unit tests * Update gaiacli docs * Implement LCD tests * Update Swagger docs * Add pending log entry * add examples Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * revert adding examples Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com>
72 lines
1.9 KiB
Go
72 lines
1.9 KiB
Go
package rest
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client/context"
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
"github.com/cosmos/cosmos-sdk/types/rest"
|
|
"github.com/cosmos/cosmos-sdk/x/mint"
|
|
"github.com/gorilla/mux"
|
|
)
|
|
|
|
func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec) {
|
|
r.HandleFunc(
|
|
"/minting/parameters",
|
|
queryParamsHandlerFn(cdc, cliCtx),
|
|
).Methods("GET")
|
|
|
|
r.HandleFunc(
|
|
"/minting/inflation",
|
|
queryInflationHandlerFn(cdc, cliCtx),
|
|
).Methods("GET")
|
|
|
|
r.HandleFunc(
|
|
"/minting/annual-provisions",
|
|
queryAnnualProvisionsHandlerFn(cdc, cliCtx),
|
|
).Methods("GET")
|
|
}
|
|
|
|
func queryParamsHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
route := fmt.Sprintf("custom/%s/%s", mint.QuerierRoute, mint.QueryParameters)
|
|
|
|
res, err := cliCtx.QueryWithData(route, nil)
|
|
if err != nil {
|
|
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
|
return
|
|
}
|
|
|
|
rest.PostProcessResponse(w, cdc, res, cliCtx.Indent)
|
|
}
|
|
}
|
|
|
|
func queryInflationHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
route := fmt.Sprintf("custom/%s/%s", mint.QuerierRoute, mint.QueryInflation)
|
|
|
|
res, err := cliCtx.QueryWithData(route, nil)
|
|
if err != nil {
|
|
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
|
return
|
|
}
|
|
|
|
rest.PostProcessResponse(w, cdc, res, cliCtx.Indent)
|
|
}
|
|
}
|
|
|
|
func queryAnnualProvisionsHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
route := fmt.Sprintf("custom/%s/%s", mint.QuerierRoute, mint.QueryAnnualProvisions)
|
|
|
|
res, err := cliCtx.QueryWithData(route, nil)
|
|
if err != nil {
|
|
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
|
return
|
|
}
|
|
|
|
rest.PostProcessResponse(w, cdc, res, cliCtx.Indent)
|
|
}
|
|
}
|