Remove unimplemented gaiacli init command (#3156)
This commit is contained in:
parent
f32286d5ff
commit
0360b12075
|
@ -8,6 +8,7 @@ BREAKING CHANGES
|
||||||
* [\#810](https://github.com/cosmos/cosmos-sdk/issues/810) Don't fallback to any default values for chain ID.
|
* [\#810](https://github.com/cosmos/cosmos-sdk/issues/810) Don't fallback to any default values for chain ID.
|
||||||
- Users need to supply chain ID either via config file or the `--chain-id` flag.
|
- Users need to supply chain ID either via config file or the `--chain-id` flag.
|
||||||
- Change `chain_id` and `trust_node` in `gaiacli` configuration to `chain-id` and `trust-node` respectively.
|
- Change `chain_id` and `trust_node` in `gaiacli` configuration to `chain-id` and `trust-node` respectively.
|
||||||
|
* [\#3156](https://github.com/cosmos/cosmos-sdk/pull/3156) Remove unimplemented `gaiacli init` command
|
||||||
|
|
||||||
* Gaia
|
* Gaia
|
||||||
|
|
||||||
|
|
|
@ -41,11 +41,6 @@ type RestServer struct {
|
||||||
func NewRestServer(cdc *codec.Codec) *RestServer {
|
func NewRestServer(cdc *codec.Codec) *RestServer {
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
cliCtx := context.NewCLIContext().WithCodec(cdc).WithAccountDecoder(cdc)
|
cliCtx := context.NewCLIContext().WithCodec(cdc).WithAccountDecoder(cdc)
|
||||||
|
|
||||||
// Register version methods on the router
|
|
||||||
r.HandleFunc("/version", CLIVersionRequestHandler).Methods("GET")
|
|
||||||
r.HandleFunc("/node_version", NodeVersionRequestHandler(cliCtx)).Methods("GET")
|
|
||||||
|
|
||||||
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "rest-server")
|
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "rest-server")
|
||||||
|
|
||||||
return &RestServer{
|
return &RestServer{
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
package lcd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/utils"
|
|
||||||
"github.com/cosmos/cosmos-sdk/version"
|
|
||||||
)
|
|
||||||
|
|
||||||
// cli version REST handler endpoint
|
|
||||||
func CLIVersionRequestHandler(w http.ResponseWriter, r *http.Request) {
|
|
||||||
v := version.GetVersion()
|
|
||||||
w.Write([]byte(v))
|
|
||||||
}
|
|
||||||
|
|
||||||
// connected node version REST handler endpoint
|
|
||||||
func NodeVersionRequestHandler(cliCtx context.CLIContext) http.HandlerFunc {
|
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
version, err := cliCtx.Query("/app/version", nil)
|
|
||||||
if err != nil {
|
|
||||||
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
|
||||||
w.Write(version)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,48 +1,20 @@
|
||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
|
"github.com/cosmos/cosmos-sdk/client/utils"
|
||||||
|
"github.com/cosmos/cosmos-sdk/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
// one of the following should be provided to verify the connection
|
|
||||||
flagGenesis = "genesis"
|
|
||||||
flagCommit = "commit"
|
|
||||||
flagValHash = "validator-set"
|
|
||||||
)
|
|
||||||
|
|
||||||
// XXX: remove this when not needed
|
|
||||||
func todoNotImplemented(_ *cobra.Command, _ []string) error {
|
|
||||||
return errors.New("todo: Command not yet implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
// InitClientCommand initializes client commands
|
|
||||||
func InitClientCommand() *cobra.Command {
|
|
||||||
cmd := &cobra.Command{
|
|
||||||
Use: "init",
|
|
||||||
Short: "Initialize light client",
|
|
||||||
RunE: todoNotImplemented,
|
|
||||||
}
|
|
||||||
cmd.Flags().StringP(client.FlagChainID, "c", "", "ID of chain we connect to")
|
|
||||||
cmd.Flags().StringP(client.FlagNode, "n", "tcp://localhost:26657", "Node to connect to")
|
|
||||||
cmd.Flags().String(flagGenesis, "", "Genesis file to verify header validity")
|
|
||||||
cmd.Flags().String(flagCommit, "", "File with trusted and signed header")
|
|
||||||
cmd.Flags().String(flagValHash, "", "Hash of trusted validator set (hex-encoded)")
|
|
||||||
viper.BindPFlag(client.FlagChainID, cmd.Flags().Lookup(client.FlagChainID))
|
|
||||||
viper.BindPFlag(client.FlagNode, cmd.Flags().Lookup(client.FlagNode))
|
|
||||||
|
|
||||||
return cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register REST endpoints
|
// Register REST endpoints
|
||||||
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router) {
|
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router) {
|
||||||
|
r.HandleFunc("/version", CLIVersionRequestHandler).Methods("GET")
|
||||||
|
r.HandleFunc("/node_version", NodeVersionRequestHandler(cliCtx)).Methods("GET")
|
||||||
r.HandleFunc("/node_info", NodeInfoRequestHandlerFn(cliCtx)).Methods("GET")
|
r.HandleFunc("/node_info", NodeInfoRequestHandlerFn(cliCtx)).Methods("GET")
|
||||||
r.HandleFunc("/syncing", NodeSyncingRequestHandlerFn(cliCtx)).Methods("GET")
|
r.HandleFunc("/syncing", NodeSyncingRequestHandlerFn(cliCtx)).Methods("GET")
|
||||||
r.HandleFunc("/blocks/latest", LatestBlockRequestHandlerFn(cliCtx)).Methods("GET")
|
r.HandleFunc("/blocks/latest", LatestBlockRequestHandlerFn(cliCtx)).Methods("GET")
|
||||||
|
@ -50,3 +22,23 @@ func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router) {
|
||||||
r.HandleFunc("/validatorsets/latest", LatestValidatorSetRequestHandlerFn(cliCtx)).Methods("GET")
|
r.HandleFunc("/validatorsets/latest", LatestValidatorSetRequestHandlerFn(cliCtx)).Methods("GET")
|
||||||
r.HandleFunc("/validatorsets/{height}", ValidatorSetRequestHandlerFn(cliCtx)).Methods("GET")
|
r.HandleFunc("/validatorsets/{height}", ValidatorSetRequestHandlerFn(cliCtx)).Methods("GET")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cli version REST handler endpoint
|
||||||
|
func CLIVersionRequestHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
w.Write([]byte(fmt.Sprintf("{\"version\": \"%s\"}", version.GetVersion())))
|
||||||
|
}
|
||||||
|
|
||||||
|
// connected node version REST handler endpoint
|
||||||
|
func NodeVersionRequestHandler(cliCtx context.CLIContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
version, err := cliCtx.Query("/app/version", nil)
|
||||||
|
if err != nil {
|
||||||
|
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
w.Write(version)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -80,7 +80,6 @@ func main() {
|
||||||
|
|
||||||
// Construct Root Command
|
// Construct Root Command
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
rpc.InitClientCommand(),
|
|
||||||
rpc.StatusCommand(),
|
rpc.StatusCommand(),
|
||||||
client.ConfigCmd(),
|
client.ConfigCmd(),
|
||||||
queryCmd(cdc, mc),
|
queryCmd(cdc, mc),
|
||||||
|
|
|
@ -59,7 +59,6 @@ func main() {
|
||||||
|
|
||||||
// add standard rpc, and tx commands
|
// add standard rpc, and tx commands
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
rpc.InitClientCommand(),
|
|
||||||
rpc.StatusCommand(),
|
rpc.StatusCommand(),
|
||||||
client.LineBreak,
|
client.LineBreak,
|
||||||
tx.SearchTxCmd(cdc),
|
tx.SearchTxCmd(cdc),
|
||||||
|
|
|
@ -55,7 +55,6 @@ func main() {
|
||||||
// add standard rpc, and tx commands
|
// add standard rpc, and tx commands
|
||||||
|
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
rpc.InitClientCommand(),
|
|
||||||
rpc.StatusCommand(),
|
rpc.StatusCommand(),
|
||||||
client.LineBreak,
|
client.LineBreak,
|
||||||
tx.SearchTxCmd(cdc),
|
tx.SearchTxCmd(cdc),
|
||||||
|
|
Loading…
Reference in New Issue