From 71224f096e406c3366f754ad91d533f752d35d57 Mon Sep 17 00:00:00 2001 From: Lorenz Herzberger Date: Thu, 25 Jul 2024 10:11:06 +0200 Subject: [PATCH] fix: use correct key to store activated ta counter on migration Signed-off-by: Lorenz Herzberger --- x/machine/keeper/migrations.go | 2 +- x/machine/migrations/v3/migrate.go | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/x/machine/keeper/migrations.go b/x/machine/keeper/migrations.go index 668d453..cd45a3d 100644 --- a/x/machine/keeper/migrations.go +++ b/x/machine/keeper/migrations.go @@ -22,5 +22,5 @@ func (m Migrator) Migrate1to2(ctx sdk.Context) error { } func (m Migrator) Migrate2to3(ctx sdk.Context) error { - return v3.MigrateStore(ctx, m.keeper.taStoreKey, m.keeper.cdc) + return v3.MigrateStore(ctx, m.keeper.taStoreKey, m.keeper.storeKey) } diff --git a/x/machine/migrations/v3/migrate.go b/x/machine/migrations/v3/migrate.go index 7cb67d5..8cc6fbc 100644 --- a/x/machine/migrations/v3/migrate.go +++ b/x/machine/migrations/v3/migrate.go @@ -3,18 +3,17 @@ package v3 import ( "encoding/binary" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/planetmint/planetmint-go/x/machine/types" ) -func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, _ codec.BinaryCodec) error { - store := prefix.NewStore(ctx.KVStore(storeKey), types.KeyPrefix(types.TrustAnchorKey)) +func MigrateStore(ctx sdk.Context, taStoreKey storetypes.StoreKey, storeKey storetypes.StoreKey) error { + store := ctx.KVStore(taStoreKey) count := uint64(0) - iterator := store.Iterator(nil, nil) + iterator := sdk.KVStorePrefixIterator(store, []byte(types.TrustAnchorKey)) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { if iterator.Value()[0] == 1 {