Skip to content

Commit

Permalink
migrate icq params in upgrade handler
Browse files Browse the repository at this point in the history
  • Loading branch information
dimiandre committed Jul 5, 2024
1 parent 18621fb commit 8509891
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions app/upgrades/v23/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,55 @@ package v23
import (
"fmt"

"github.com/CosmosContracts/juno/v23/app/keepers"

Check failure on line 6 in app/upgrades/v23/upgrades.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos) -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/CosmosContracts/juno) --custom-order (gci)
"github.com/CosmosContracts/juno/v23/app/upgrades"
"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/CosmosContracts/juno/v23/app/keepers"
"github.com/CosmosContracts/juno/v23/app/upgrades"
icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v7/types"

Check failure on line 13 in app/upgrades/v23/upgrades.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos) -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/CosmosContracts/juno) --custom-order (gci)
)

func CreateV23UpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
_ *keepers.AppKeepers,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := ctx.Logger().With("upgrade", UpgradeName)

nativeDenom := upgrades.GetChainsDenomToken(ctx.ChainID())
logger.Info(fmt.Sprintf("With native denom %s", nativeDenom))

// migrate ICQ params
for _, subspace := range keepers.ParamsKeeper.GetSubspaces() {
subspace := subspace

var keyTable paramstypes.KeyTable
if subspace.Name() == icqtypes.ModuleName {
keyTable = icqtypes.ParamKeyTable()
} else {
continue
}

if !subspace.HasKeyTable() {
subspace.WithKeyTable(keyTable)
}
}

// Migrate Tendermint consensus parameters from x/params module to a deprecated x/consensus module.
// The old params module is required to still be imported in your app.go in order to handle this migration.
baseAppLegacySS := keepers.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
baseapp.MigrateParams(ctx, baseAppLegacySS, &keepers.ConsensusParamsKeeper)

// Run migrations
logger.Info(fmt.Sprintf("pre migrate version map: %v", vm))
versionMap, err := mm.RunMigrations(ctx, cfg, vm)
if err != nil {
return nil, err
}

Check failure on line 54 in app/upgrades/v23/upgrades.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos) -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/CosmosContracts/juno) --custom-order (gci)
logger.Info(fmt.Sprintf("post migrate version map: %v", versionMap))

return versionMap, err
Expand Down

0 comments on commit 8509891

Please sign in to comment.