Skip to content

Commit

Permalink
Merge PR cosmos#6426: Migrate API Server
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez authored Jun 15, 2020
1 parent 87aafc5 commit 9290415
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
11 changes: 11 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ import (
dbm "github.com/tendermint/tm-db"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/testdata"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/std"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
"github.com/cosmos/cosmos-sdk/x/bank"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand Down Expand Up @@ -499,6 +502,14 @@ func (app *SimApp) SimulationManager() *module.SimulationManager {
return app.sm
}

// RegisterAPIRoutes registers all application module routes with the provided
// API server.
func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server) {
rpc.RegisterRoutes(apiSvr.ClientCtx, apiSvr.Router)
authrest.RegisterTxRoutes(apiSvr.ClientCtx, apiSvr.Router)
ModuleBasics.RegisterRESTRoutes(apiSvr.ClientCtx, apiSvr.Router)
}

// GetMaccPerms returns a copy of the module account permissions
func GetMaccPerms() map[string][]string {
dupMaccPerms := make(map[string][]string)
Expand Down
11 changes: 0 additions & 11 deletions cmd/simcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/client/lcd"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
"github.com/cosmos/cosmos-sdk/x/auth/types"
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
)
Expand Down Expand Up @@ -65,7 +63,6 @@ func main() {
queryCmd(cdc),
txCmd(cdc),
flags.LineBreak,
lcd.ServeCommand(cdc, registerRoutes),
flags.LineBreak,
keys.Commands(),
flags.LineBreak,
Expand Down Expand Up @@ -148,14 +145,6 @@ func txCmd(cdc *codec.Codec) *cobra.Command {
return txCmd
}

// registerRoutes registers the routes from the different modules for the REST client.
// NOTE: details on the routes added for each module are in the module documentation
func registerRoutes(rs *lcd.RestServer) {
rpc.RegisterRoutes(rs.ClientCtx, rs.Mux)
authrest.RegisterTxRoutes(rs.ClientCtx, rs.Mux)
simapp.ModuleBasics.RegisterRESTRoutes(rs.ClientCtx, rs.Mux)
}

func initConfig(cmd *cobra.Command) error {
home, err := cmd.PersistentFlags().GetString(cli.HomeFlag)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/simd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func main() {
}
}

func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer) abci.Application {
func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer) server.Application {
var cache sdk.MultiStorePersistentCache

if viper.GetBool(server.FlagInterBlockCache) {
Expand Down
1 change: 1 addition & 0 deletions cmd/simd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func InitTestnet(

simappConfig := srvconfig.DefaultConfig()
simappConfig.MinGasPrices = minGasPrices
simappConfig.API.Enable = true

var (
genAccounts []authtypes.GenesisAccount
Expand Down

0 comments on commit 9290415

Please sign in to comment.