diff --git a/changelog.md b/changelog.md index ae8c61bf7f..029baea432 100644 --- a/changelog.md +++ b/changelog.md @@ -5,8 +5,9 @@ ### Fixes - [#3878](https://github.com/ignite/cli/pull/3878) Support local forks of Cosmos SDK in scaffolded chain. -- [#3867](https://github.com/ignite/cli/pull/3867) Fix genesis export for ibc modules. - [#3869](https://github.com/ignite/cli/pull/3869) Fix .git in parent dir +- [#3867](https://github.com/ignite/cli/pull/3867) Fix genesis export for ibc modules. +- [#3850](https://github.com/ignite/cli/pull/3871) Fix app.go file detection in apps scaffolded before v28.0.0 ### Changes diff --git a/ignite/pkg/cosmosanalysis/cosmosanalysis.go b/ignite/pkg/cosmosanalysis/cosmosanalysis.go index 470dbab256..868d5aa63a 100644 --- a/ignite/pkg/cosmosanalysis/cosmosanalysis.go +++ b/ignite/pkg/cosmosanalysis/cosmosanalysis.go @@ -27,7 +27,6 @@ var AppImplementation = []string{ "AppCodec", "GetKey", "GetMemKey", - "kvStoreKeys", "RegisterAPIRoutes", } diff --git a/ignite/pkg/cosmosanalysis/cosmosanalysis_test.go b/ignite/pkg/cosmosanalysis/cosmosanalysis_test.go index 8b3fbae93a..ae6f8c24c4 100644 --- a/ignite/pkg/cosmosanalysis/cosmosanalysis_test.go +++ b/ignite/pkg/cosmosanalysis/cosmosanalysis_test.go @@ -108,6 +108,24 @@ func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.R func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { return app.mm.EndBlock(ctx, req) } +`) + appFileSDKv47 = []byte(` +package app +type App struct {} +func (app *App) Name() string { return app.BaseApp.Name() } +func (app *App) RegisterAPIRoutes() {} +func (app *App) RegisterTxService() {} +func (app *App) AppCodec() codec.Codec { return app.appCodec } +func (app *App) GetKey(storeKey string) *storetypes.KVStoreKey { return nil } +func (app *App) GetMemKey(storeKey string) *storetypes.MemoryStoreKey { return nil } +func (app *App) GetSubspace(moduleName string) paramstypes.Subspace { return subspace } +func (app *App) TxConfig() client.TxConfig { return nil } +func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { + return app.mm.BeginBlock(ctx, req) +} +func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { + return app.mm.EndBlock(ctx, req) +} `) ) @@ -177,50 +195,62 @@ func TestFindImplementationNotFound(t *testing.T) { } func TestFindAppFilePath(t *testing.T) { - tmpDir := t.TempDir() + tmpDir1 := t.TempDir() + tmpDir2 := t.TempDir() - appFolder := filepath.Join(tmpDir, "app") - secondaryAppFolder := filepath.Join(tmpDir, "myOwnAppDir") - err := os.Mkdir(appFolder, 0o700) + appFolder1 := filepath.Join(tmpDir1, "app") + appFolder2 := filepath.Join(tmpDir1, "myOwnAppDir") + appFolder3 := filepath.Join(tmpDir2, "sdk47AppDir") + err := os.Mkdir(appFolder1, 0o700) + require.NoError(t, err) + err = os.Mkdir(appFolder2, 0o700) require.NoError(t, err) - err = os.Mkdir(secondaryAppFolder, 0o700) + err = os.Mkdir(appFolder3, 0o700) require.NoError(t, err) // No file - _, err = cosmosanalysis.FindAppFilePath(tmpDir) + _, err = cosmosanalysis.FindAppFilePath(tmpDir1) require.Equal(t, "app.go file cannot be found", err.Error()) // Only one file with app implementation - myOwnAppFilePath := filepath.Join(secondaryAppFolder, "my_own_app.go") + myOwnAppFilePath := filepath.Join(appFolder2, "my_own_app.go") err = os.WriteFile(myOwnAppFilePath, appFile, 0o644) require.NoError(t, err) - pathFound, err := cosmosanalysis.FindAppFilePath(tmpDir) + pathFound, err := cosmosanalysis.FindAppFilePath(tmpDir1) require.NoError(t, err) require.Equal(t, myOwnAppFilePath, pathFound) // With a test file added - appTestFilePath := filepath.Join(secondaryAppFolder, "my_own_app_test.go") + appTestFilePath := filepath.Join(appFolder2, "my_own_app_test.go") err = os.WriteFile(appTestFilePath, appTestFile, 0o644) require.NoError(t, err) - _, err = cosmosanalysis.FindAppFilePath(tmpDir) + _, err = cosmosanalysis.FindAppFilePath(tmpDir1) require.Error(t, err) require.Contains(t, err.Error(), "cannot locate your app.go") // With an additional app file (that is app.go) - appFilePath := filepath.Join(appFolder, "app.go") + appFilePath := filepath.Join(appFolder1, "app.go") err = os.WriteFile(appFilePath, appFile, 0o644) require.NoError(t, err) - pathFound, err = cosmosanalysis.FindAppFilePath(tmpDir) + pathFound, err = cosmosanalysis.FindAppFilePath(tmpDir1) require.NoError(t, err) require.Equal(t, appFilePath, pathFound) // With two app.go files - extraAppFilePath := filepath.Join(secondaryAppFolder, "app.go") + extraAppFilePath := filepath.Join(appFolder2, "app.go") err = os.WriteFile(extraAppFilePath, appFile, 0o644) require.NoError(t, err) - pathFound, err = cosmosanalysis.FindAppFilePath(tmpDir) + pathFound, err = cosmosanalysis.FindAppFilePath(tmpDir1) + require.NoError(t, err) + require.Equal(t, filepath.Join(appFolder1, "app.go"), pathFound) + + // With an app.go file from a Cosmos SDK v0.47 app + sdk47AppFilePath := filepath.Join(appFolder3, "app_sdk_47.go") + err = os.WriteFile(sdk47AppFilePath, appFileSDKv47, 0o644) + require.NoError(t, err) + pathFound, err = cosmosanalysis.FindAppFilePath(tmpDir2) require.NoError(t, err) - require.Equal(t, filepath.Join(appFolder, "app.go"), pathFound) + require.Equal(t, sdk47AppFilePath, pathFound) } func TestIsChainPath(t *testing.T) {