-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unimplemented gaiacli init command (#3156)
- Loading branch information
1 parent
f32286d
commit 0360b12
Showing
7 changed files
with
28 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,44 @@ | ||
package rpc | ||
|
||
import ( | ||
"github.com/gorilla/mux" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/spf13/viper" | ||
"github.com/gorilla/mux" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"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 | ||
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("/syncing", NodeSyncingRequestHandlerFn(cliCtx)).Methods("GET") | ||
r.HandleFunc("/blocks/latest", LatestBlockRequestHandlerFn(cliCtx)).Methods("GET") | ||
r.HandleFunc("/blocks/{height}", BlockRequestHandlerFn(cliCtx)).Methods("GET") | ||
r.HandleFunc("/validatorsets/latest", LatestValidatorSetRequestHandlerFn(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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters