Skip to content

Commit

Permalink
Merge PR cosmos#7191: Fix Legacy API Server Client Context
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez authored Aug 28, 2020
1 parent f652ba4 commit 4de5e28
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions server/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func (s *Server) Start(cfg config.Config) error {
return tmrpcserver.Serve(s.listener, allowAllCORS(h), s.logger, tmCfg)
}

s.logger.Info("starting API server...")
return tmrpcserver.Serve(s.listener, s.Router, s.logger, tmCfg)
}

Expand Down
9 changes: 3 additions & 6 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servergrpc "github.com/cosmos/cosmos-sdk/server/grpc"
Expand Down Expand Up @@ -108,7 +107,7 @@ which accepts a path for the resulting pprof file.
serverCtx.Logger.Info("starting ABCI with Tendermint")

// amino is needed here for backwards compatibility of REST routes
err := startInProcess(serverCtx, clientCtx.LegacyAmino, appCreator)
err := startInProcess(serverCtx, clientCtx, appCreator)
return err
},
}
Expand Down Expand Up @@ -180,7 +179,7 @@ func startStandAlone(ctx *Context, appCreator types.AppCreator) error {
}

// legacyAminoCdc is used for the legacy REST API
func startInProcess(ctx *Context, legacyAminoCdc *codec.LegacyAmino, appCreator types.AppCreator) error {
func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.AppCreator) error {
cfg := ctx.Config
home := cfg.RootDir

Expand Down Expand Up @@ -230,11 +229,9 @@ func startInProcess(ctx *Context, legacyAminoCdc *codec.LegacyAmino, appCreator
return err
}

clientCtx := client.Context{}.
clientCtx := clientCtx.
WithHomeDir(home).
WithChainID(genDoc.ChainID).
// amino is needed here for backwards compatibility of REST routes
WithLegacyAmino(legacyAminoCdc).
WithClient(local.New(tmNode))

apiSrv = api.New(clientCtx, ctx.Logger.With("module", "api-server"))
Expand Down

0 comments on commit 4de5e28

Please sign in to comment.