Skip to content

Commit

Permalink
added migration function to upgrades.go
Browse files Browse the repository at this point in the history
  • Loading branch information
stackman27 committed May 23, 2023
1 parent 179fbcb commit 97a6ea8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
7 changes: 5 additions & 2 deletions app/upgrades/v16/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/osmosis-labs/osmosis/v15/app/keepers"
"github.com/osmosis-labs/osmosis/v15/app/upgrades"
protorevtypes "github.com/osmosis-labs/osmosis/v15/x/protorev/types"

tokenfactorykeeper "github.com/osmosis-labs/osmosis/v15/x/tokenfactory/keeper"
tokenfactorytypes "github.com/osmosis-labs/osmosis/v15/x/tokenfactory/types"
Expand Down Expand Up @@ -67,7 +66,7 @@ func CreateUpgradeHandler(
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// Added since when testing the fromVersion was set to 2
// and therefore did not run the migration for protorev
fromVM[protorevtypes.ModuleName] = 1
// fromVM[protorevtypes.ModuleName] = 1

// Run migrations before applying any other state changes.
// NOTE: DO NOT PUT ANY STATE CHANGES BEFORE RunMigrations().
Expand All @@ -91,6 +90,10 @@ func CreateUpgradeHandler(

updateTokenFactoryParams(ctx, keepers.TokenFactoryKeeper)

if err := keepers.ProtoRevKeeper.SendDeveloperFeesToDeveloperAccount(ctx); err != nil {
return nil, err
}

return migrations, nil
}
}
Expand Down
22 changes: 11 additions & 11 deletions x/protorev/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerier(am.keeper))
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.keeper))

if err := cfg.RegisterMigration(types.ModuleName, 1, am.Upgrade1to2); err != nil {
panic(fmt.Sprintf("failed to migrate x/protorev from version 1 to 2: %v", err))
}
// if err := cfg.RegisterMigration(types.ModuleName, 1, am.Upgrade1to2); err != nil {
// panic(fmt.Sprintf("failed to migrate x/protorev from version 1 to 2: %v", err))
// }
}

func (a AppModuleBasic) RegisterRESTRoutes(ctx client.Context, r *mux.Router) {
Expand All @@ -167,7 +167,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}

// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1
func (AppModule) ConsensusVersion() uint64 { return 2 }
func (AppModule) ConsensusVersion() uint64 { return 1 }

// BeginBlock contains the logic that is automatically triggered at the beginning of each block
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
Expand All @@ -181,11 +181,11 @@ func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.Valid
// Upgrades
// ----------------------------------------------------------------------------

func (am AppModule) Upgrade1to2(ctx sdk.Context) error {
err := am.keeper.SendDeveloperFeesToDeveloperAccount(ctx)
if err != nil {
return err
}
// func (am AppModule) Upgrade1to2(ctx sdk.Context) error {
// err := am.keeper.SendDeveloperFeesToDeveloperAccount(ctx)
// if err != nil {
// return err
// }

return nil
}
// return nil
// }

0 comments on commit 97a6ea8

Please sign in to comment.