fix: use correct key to store activated ta counter on migration

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
Lorenz Herzberger 2024-07-25 10:11:06 +02:00
parent c4b5dfb0ad
commit 71224f096e
No known key found for this signature in database
GPG Key ID: FA5EE906EB55316A
2 changed files with 4 additions and 5 deletions

View File

@ -22,5 +22,5 @@ func (m Migrator) Migrate1to2(ctx sdk.Context) error {
} }
func (m Migrator) Migrate2to3(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)
} }

View File

@ -3,18 +3,17 @@ package v3
import ( import (
"encoding/binary" "encoding/binary"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/store/prefix" "github.com/cosmos/cosmos-sdk/store/prefix"
storetypes "github.com/cosmos/cosmos-sdk/store/types" storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/planetmint/planetmint-go/x/machine/types" "github.com/planetmint/planetmint-go/x/machine/types"
) )
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, _ codec.BinaryCodec) error { func MigrateStore(ctx sdk.Context, taStoreKey storetypes.StoreKey, storeKey storetypes.StoreKey) error {
store := prefix.NewStore(ctx.KVStore(storeKey), types.KeyPrefix(types.TrustAnchorKey)) store := ctx.KVStore(taStoreKey)
count := uint64(0) count := uint64(0)
iterator := store.Iterator(nil, nil) iterator := sdk.KVStorePrefixIterator(store, []byte(types.TrustAnchorKey))
defer iterator.Close() defer iterator.Close()
for ; iterator.Valid(); iterator.Next() { for ; iterator.Valid(); iterator.Next() {
if iterator.Value()[0] == 1 { if iterator.Value()[0] == 1 {