diff --git a/bech32-migration/auth/auth.go b/bech32-migration/auth/auth.go index ece741c43b..72b6d429f9 100644 --- a/bech32-migration/auth/auth.go +++ b/bech32-migration/auth/auth.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/likecoin/likechain/bech32-migration/utils" ) @@ -12,6 +13,7 @@ import ( func MigrateAddressBech32(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.BinaryCodec) { ctx.Logger().Info("Migration of address bech32 for auth module begin") migratedAccountCount := uint64(0) + migratedAccountTypesStat := map[string]uint64{} utils.IterateStoreByPrefix(ctx, storeKey, types.AddressStoreKeyPrefix, func(bz []byte) []byte { var accountI types.AccountI err := cdc.UnmarshalInterface(bz, &accountI) @@ -22,9 +24,31 @@ func MigrateAddressBech32(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.Bina case *types.BaseAccount: acc := accountI.(*types.BaseAccount) acc.Address = utils.ConvertAccAddr(acc.Address) + migratedAccountTypesStat["BaseAccount"]++ case *types.ModuleAccount: acc := accountI.(*types.ModuleAccount) acc.Address = utils.ConvertAccAddr(acc.Address) + migratedAccountTypesStat["ModuleAccount"]++ + case *vestingtypes.BaseVestingAccount: + acc := accountI.(*vestingtypes.BaseVestingAccount) + acc.Address = utils.ConvertAccAddr(acc.Address) + migratedAccountTypesStat["BaseVestingAccount"]++ + case *vestingtypes.ContinuousVestingAccount: + acc := accountI.(*vestingtypes.ContinuousVestingAccount) + acc.Address = utils.ConvertAccAddr(acc.Address) + migratedAccountTypesStat["ContinuousVestingAccount"]++ + case *vestingtypes.DelayedVestingAccount: + acc := accountI.(*vestingtypes.DelayedVestingAccount) + acc.Address = utils.ConvertAccAddr(acc.Address) + migratedAccountTypesStat["DelayedVestingAccount"]++ + case *vestingtypes.PeriodicVestingAccount: + acc := accountI.(*vestingtypes.PeriodicVestingAccount) + acc.Address = utils.ConvertAccAddr(acc.Address) + migratedAccountTypesStat["PeriodicVestingAccount"]++ + case *vestingtypes.PermanentLockedAccount: + acc := accountI.(*vestingtypes.PermanentLockedAccount) + acc.Address = utils.ConvertAccAddr(acc.Address) + migratedAccountTypesStat["PermanentLockedAccount"]++ default: ctx.Logger().Info( "Warning: unknown account type, skipping migration", @@ -45,5 +69,6 @@ func MigrateAddressBech32(ctx sdk.Context, storeKey sdk.StoreKey, cdc codec.Bina ctx.Logger().Info( "Migration of address bech32 for auth module done", "migrated_account_count", migratedAccountCount, + "migrated_account_types_stat", migratedAccountTypesStat, ) }