Skip to content

Commit

Permalink
Auction v2 Param migration
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrit committed Oct 8, 2024
1 parent b921658 commit 86c08b6
Show file tree
Hide file tree
Showing 8 changed files with 3,216 additions and 1 deletion.
21 changes: 21 additions & 0 deletions x/auction/keeper/migrations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
v1 "github.com/peggyjv/sommelier/v7/x/auction/migrations/v1"
)

// Migrator is a struct for handling in-place store migrations.
type Migrator struct {
keeper Keeper
}

// NewMigrator returns a new Migrator.
func NewMigrator(keeper Keeper) Migrator {
return Migrator{keeper: keeper}
}

// Migrate1to2 migrates from consensus version 1 to 2.
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return v1.MigrateParamStore(ctx, m.keeper.paramSpace)
}
18 changes: 18 additions & 0 deletions x/auction/migrations/v1/store.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v1

import (
sdk "github.com/cosmos/cosmos-sdk/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/peggyjv/sommelier/v7/x/auction/types"
)

func MigrateParamStore(ctx sdk.Context, subspace paramstypes.Subspace) error {
ctx.Logger().Info("auction v1 to v2: Migrating params")

if !subspace.Has(ctx, types.KeyAuctionBurnRate) {
subspace.Set(ctx, types.KeyAuctionBurnRate, types.DefaultParams().AuctionBurnRate)
}

ctx.Logger().Info("auction v1 to v2: Params migration complete")
return nil
}
Loading

0 comments on commit 86c08b6

Please sign in to comment.