Skip to content
Cosmopediaby Unity Nodes
Documentationcosmos/cosmos-sdk-migration-mcpcosmos/cosmos-sdk-migration-mcp › src › cosmos_migration_mcp › migration_spec › v50-to-v54View on cosmos/cosmos-sdk-migration-mcp ↗

── verification ────────────────────────────────────────────────────────────

id: gov-keeper-migration title: x/gov NewKeeper signature change version: v50+ -> v54 description: | The signature of govkeeper.NewKeeper changed in v54:

v53: govkeeper.NewKeeper(cdc, storeService, acctKeeper, bankKeeper,
       stakingKeeper, distrKeeper, router, config, authority, ...initOptions)

v54: govkeeper.NewKeeper(cdc, storeService, acctKeeper, bankKeeper,
       distrKeeper, router, config, authority,
       govkeeper.NewDefaultCalculateVoteResultsAndVotingPower(stakingKeeper))

Changes:

  • StakingKeeper (pos 4) is removed from the direct arg list.
  • Variadic InitOption args are removed.
  • A new final arg wraps the staking keeper: govkeeper.NewDefaultCalculateVoteResultsAndVotingPower(stakingKeeper)

This transformation is AST-based and cannot be expressed as a simple text replacement because the package alias for govkeeper varies by chain (some use "govkeeper", others "keeper", etc.). The migration tool resolves the actual alias from the file's import block and injects it correctly.

upstream_sources:

  • docs://upgrading/v0.54
  • docs://changelog/v0.54-breaking

depends_on:

  • core-sdk-migration

manual_steps_policy: only_when_unresolved

detection: sdk_version: max_exclusive: v0.54.0-0 imports: - github.com/cosmos/cosmos-sdk/x/gov/keeper patterns: - govkeeper.NewKeeper( - keeper.NewKeeper( # alias may vary

changes: special_cases: - gov_new_keeper

manual_steps:

  • id: gov-keeper-new-keeper description: | Find all calls to govkeeper.NewKeeper (or whatever alias your project uses for "github.com/cosmos/cosmos-sdk/x/gov/keeper") and rewrite them.

    Before: app.GovKeeper = govkeeper.NewKeeper( appCodec, runtime.NewKVStoreService(keys[govtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, // <-- remove this app.DistrKeeper, app.MsgServiceRouter(), govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String(), // any ...initOptions <-- remove these )

    After: app.GovKeeper = govkeeper.NewKeeper( appCodec, runtime.NewKVStoreService(keys[govtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.MsgServiceRouter(), govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String(), govkeeper.NewDefaultCalculateVoteResultsAndVotingPower(app.StakingKeeper), )

    Key rules:

    • Save the StakingKeeper argument (originally at position 4, 0-indexed).
    • Drop all variadic InitOption arguments at the end.
    • Append govkeeper.NewDefaultCalculateVoteResultsAndVotingPower(<saved_staking_keeper>).
    • Use whatever alias your file uses for the gov/keeper package — do NOT hardcode "govkeeper".

── verification ────────────────────────────────────────────────────────────

verification:

We want NewDefaultCalculateVoteResultsAndVotingPower to be PRESENT after

migration — its appearance confirms the surgery succeeded.

must_contain: - pattern: NewDefaultCalculateVoteResultsAndVotingPower