From 97b2d0c47ededf4aa22975a86be991c864932577 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Sat, 24 Sep 2022 13:49:11 +0200 Subject: [PATCH] refactor: move `simapp.App` to `runtime.AppI` (#13378) * refactor: move `simapp.App` to `runtime.AppI` * add changelog * `go mod tidy` * fix app legacy build --- app.go | 5 ++++- app_legacy.go | 6 +++++- types.go | 41 ----------------------------------------- utils.go | 5 +++-- 4 files changed, 12 insertions(+), 45 deletions(-) delete mode 100644 types.go diff --git a/app.go b/app.go index 5c8e3a4f8947..e6e3d3a87482 100644 --- a/app.go +++ b/app.go @@ -89,6 +89,9 @@ import ( ) var ( + // App is deprecated, use runtime.AppI instead + App runtime.AppI + // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string @@ -124,7 +127,7 @@ var ( ) var ( - _ App = (*SimApp)(nil) + _ runtime.AppI = (*SimApp)(nil) _ servertypes.Application = (*SimApp)(nil) ) diff --git a/app_legacy.go b/app_legacy.go index 0ec41fc412ca..ba664d41f225 100644 --- a/app_legacy.go +++ b/app_legacy.go @@ -21,6 +21,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/api" "github.com/cosmos/cosmos-sdk/server/config" @@ -99,6 +100,9 @@ import ( const appName = "SimApp" var ( + // App is deprecated, use runtime.AppI instead + App runtime.AppI + // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string @@ -145,7 +149,7 @@ var ( ) var ( - _ App = (*SimApp)(nil) + _ runtime.AppI = (*SimApp)(nil) _ servertypes.Application = (*SimApp)(nil) ) diff --git a/types.go b/types.go deleted file mode 100644 index 1b434ea67141..000000000000 --- a/types.go +++ /dev/null @@ -1,41 +0,0 @@ -package simapp - -import ( - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/server/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" -) - -// App implements the common methods for a Cosmos SDK-based application -// specific blockchain. -type App interface { - // The assigned name of the app. - Name() string - - // The application types codec. - // NOTE: This shoult be sealed before being returned. - LegacyAmino() *codec.LegacyAmino - - // Application updates every begin block. - BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock - - // Application updates every end block. - EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock - - // Application update at chain (i.e app) initialization. - InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain - - // Loads the app at a given height. - LoadHeight(height int64) error - - // Exports the state of the application for a genesis file. - ExportAppStateAndValidators( - forZeroHeight bool, jailAllowedAddrs []string, - ) (types.ExportedApp, error) - - // Helper for the simulation framework. - SimulationManager() *module.SimulationManager -} diff --git a/utils.go b/utils.go index b18ff77dbeb9..4c2e7de0f470 100644 --- a/utils.go +++ b/utils.go @@ -9,6 +9,7 @@ import ( dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/runtime" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" @@ -49,7 +50,7 @@ func SetupSimulation(dirPrefix, dbName string) (simtypes.Config, dbm.DB, string, // SimulationOperations retrieves the simulation params from the provided file path // and returns all the modules weighted operations -func SimulationOperations(app App, cdc codec.JSONCodec, config simtypes.Config) []simtypes.WeightedOperation { +func SimulationOperations(app runtime.AppI, cdc codec.JSONCodec, config simtypes.Config) []simtypes.WeightedOperation { simState := module.SimulationState{ AppParams: make(simtypes.AppParams), Cdc: cdc, @@ -74,7 +75,7 @@ func SimulationOperations(app App, cdc codec.JSONCodec, config simtypes.Config) // CheckExportSimulation exports the app state and simulation parameters to JSON // if the export paths are defined. func CheckExportSimulation( - app App, config simtypes.Config, params simtypes.Params, + app runtime.AppI, config simtypes.Config, params simtypes.Params, ) error { if config.ExportStatePath != "" { fmt.Println("exporting app state...")