Skip to content

Commit

Permalink
🐛 Fix "no RPC client is defined in offline mode" in REST API
Browse files Browse the repository at this point in the history
  • Loading branch information
nnkken authored and williamchong committed Nov 30, 2022
1 parent 051a77b commit 4a832af
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cmd/liked/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/cosmos/cosmos-sdk/store"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
"github.com/cosmos/cosmos-sdk/client/debug"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/keys"
Expand Down Expand Up @@ -156,19 +157,30 @@ func NewRootCmd() (*cobra.Command, app.EncodingConfig) {
encodingConfig := app.MakeEncodingConfig()

initClientCtx := client.Context{}.
WithJSONCodec(encodingConfig.Marshaler).
WithCodec(encodingConfig.Marshaler).
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
WithTxConfig(encodingConfig.TxConfig).
WithLegacyAmino(encodingConfig.Amino).
WithInput(os.Stdin).
WithAccountRetriever(types.AccountRetriever{}).
WithBroadcastMode(flags.BroadcastBlock).
WithHomeDir(app.DefaultNodeHome)
WithHomeDir(app.DefaultNodeHome).
WithViper("LIKE")

rootCmd := &cobra.Command{
Use: "liked",
Short: "LikeCoin chain App",
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
initClientCtx, err := client.ReadPersistentCommandFlags(initClientCtx, cmd.Flags())
if err != nil {
return err
}

initClientCtx, err = config.ReadFromClientConfig(initClientCtx)
if err != nil {
return err
}

if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil {
return err
}
Expand Down

0 comments on commit 4a832af

Please sign in to comment.