diff --git a/app/app.go b/app/app.go index eac0fed470..b2d94186b3 100644 --- a/app/app.go +++ b/app/app.go @@ -113,11 +113,6 @@ import ( "go.opentelemetry.io/otel" ) -const ( - AccountAddressPrefix = "cosmos" - Name = "sei-chain" -) - // this line is used by starport scaffolding # stargate/wasm/app/enabledProposals func getGovProposalHandlers() []govclient.ProposalHandler { @@ -191,7 +186,7 @@ func init() { panic(err) } - DefaultNodeHome = filepath.Join(userHomeDir, "."+Name) + DefaultNodeHome = filepath.Join(userHomeDir, "."+AppName) } // App extends an ABCI application, but with most of its parameters exported. @@ -245,7 +240,8 @@ type App struct { // sm is the simulation manager sm *module.SimulationManager - tracingInfo *tracing.TracingInfo + configurator module.Configurator + tracingInfo *tracing.TracingInfo } // New returns a reference to an initialized blockchain app @@ -267,7 +263,7 @@ func New( cdc := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry - bApp := baseapp.NewBaseApp(Name, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...) + bApp := baseapp.NewBaseApp(AppName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) bApp.SetVersion(version.Version) bApp.SetInterfaceRegistry(interfaceRegistry) @@ -571,7 +567,8 @@ func New( app.mm.RegisterInvariants(&app.CrisisKeeper) app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) - app.mm.RegisterServices(module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())) + app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) + app.mm.RegisterServices(app.configurator) // create the simulation manager and define the order of the modules for deterministic simulations app.sm = module.NewSimulationManager( @@ -594,6 +591,7 @@ func New( // this line is used by starport scaffolding # stargate/app/appModule ) app.sm.RegisterStoreDecoders() + app.RegisterUpgradeHandlers() // initialize stores app.MountKVStores(keys) @@ -644,7 +642,7 @@ func New( return app } -// Name returns the name of the App +// AppName returns the name of the App func (app *App) Name() string { return app.BaseApp.Name() } // GetBaseApp returns the base app of the application @@ -757,7 +755,7 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig // register app's OpenAPI routes. apiSvr.Router.Handle("/static/openapi.yml", http.FileServer(http.FS(docs.Docs))) - apiSvr.Router.HandleFunc("/", openapiconsole.Handler(Name, "/static/openapi.yml")) + apiSvr.Router.HandleFunc("/", openapiconsole.Handler(AppName, "/static/openapi.yml")) } // RegisterTxService implements the Application.RegisterTxService method. diff --git a/app/const.go b/app/const.go new file mode 100644 index 0000000000..76b690fe71 --- /dev/null +++ b/app/const.go @@ -0,0 +1,8 @@ +package app + +const ( + // Prefix of bech32 encoded address + AccountAddressPrefix = "cosmos" + // Application name + AppName = "sei-chain" +) diff --git a/app/upgrades.go b/app/upgrades.go new file mode 100644 index 0000000000..09463fe7ae --- /dev/null +++ b/app/upgrades.go @@ -0,0 +1,22 @@ +package app + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +// Set this to the name of your upgrade +const UpgradeName = "upgrade-1.0.0" + +func (app App) RegisterUpgradeHandlers() { + app.UpgradeKeeper.SetUpgradeHandler(UpgradeName, func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + // Upgrade specific logic goes here + // For now, remove dex, epoch and oracle from the version map since + // they do not yet have upgrade logic + delete(fromVM, "dex") + delete(fromVM, "epoch") + delete(fromVM, "oracle") + return app.mm.RunMigrations(ctx, app.configurator, fromVM) + }) +} diff --git a/cmd/sei-chaind/main.go b/cmd/sei-chaind/main.go index f1f94ff16c..1b52ffbafd 100644 --- a/cmd/sei-chaind/main.go +++ b/cmd/sei-chaind/main.go @@ -9,10 +9,10 @@ import ( func main() { rootCmd, _ := NewRootCmd( - app.Name, + app.AppName, app.AccountAddressPrefix, app.DefaultNodeHome, - app.Name, + app.AppName, app.ModuleBasics, app.New, // this line is used by starport scaffolding # root/arguments diff --git a/cmd/sei-chaind/root.go b/cmd/sei-chaind/root.go index 59c88cbf4c..04572c870a 100644 --- a/cmd/sei-chaind/root.go +++ b/cmd/sei-chaind/root.go @@ -131,8 +131,8 @@ func NewRootCmd( WithViper(rootOptions.envPrefix) rootCmd := &cobra.Command{ - Use: appName + "d", - Short: "Stargate CosmosHub App", + Use: "seid", + Short: "Stargate Sei App", PersistentPreRunE: func(cmd *cobra.Command, _ []string) error { // set the default command outputs cmd.SetOut(cmd.OutOrStdout())