func (k Keeper) IteratePendingAccounts(ctx sdk.Context, process func(info types.PendingAccount) (stop bool)) {
	store := ctx.KVStore(k.storeKey)
	iter := sdk.KVStorePrefixIterator(store, types.PendingAccountPrefix)
	defer iter.Close()
	for {
		if !iter.Valid() {
			return
		}
		val := iter.Value()
		var pendAcc types.PendingAccount
		k.cdc.MustUnmarshalBinaryBare(val, &pendAcc)
		if process(pendAcc) {
			return
		}
		iter.Next()
	}
}
Iterate over all Pending Accounts.
package keeper
import (
	"github.com/cosmos/cosmos-sdk/codec"
	sdk "github.com/cosmos/cosmos-sdk/types"
	"github.com/zigbee-alliance/distributed-compliance-ledger/x/auth/internal/types"
)
type Keeper struct {
	storeKey sdk.StoreKey
	cdc *codec.Codec
}
func NewKeeper(storeKey sdk.StoreKey, cdc *codec.Codec) Keeper {
	return Keeper{storeKey: storeKey, cdc: cdc}
}
func (k Keeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) (acc types.Account) {
	store := ctx.KVStore(k.storeKey)
	bz := store.Get(types.GetAccountKey(addr))
	if bz == nil {
		panic("Account does not exist")
	}
	err := k.cdc.UnmarshalBinaryBare(bz, &acc)
	if err != nil {
		panic(err)
	}
	return
}
func (k Keeper) GetAllAccounts(ctx sdk.Context) (accounts []types.Account) {
	appendAccount := func(acc types.Account) (stop bool) {
		accounts = append(accounts, acc)
		return false
	}
	k.IterateAccounts(ctx, appendAccount)
	return accounts
}
func (k Keeper) SetAccount(ctx sdk.Context, acc types.Account) {
	store := ctx.KVStore(k.storeKey)
	bz := k.cdc.MustMarshalBinaryBare(acc)
	store.Set(types.GetAccountKey(acc.Address), bz)
}
func (k Keeper) IsAccountPresent(ctx sdk.Context, acc sdk.AccAddress) bool {
	store := ctx.KVStore(k.storeKey)
	return store.Has(types.GetAccountKey(acc))
}
func (k Keeper) IterateAccounts(ctx sdk.Context, process func(types.Account) (stop bool)) {
	store := ctx.KVStore(k.storeKey)
	iter := sdk.KVStorePrefixIterator(store, types.AccountPrefix)
	defer iter.Close()
	for {
		if !iter.Valid() {
			return
		}
		val := iter.Value()
		var account types.Account
		k.cdc.MustUnmarshalBinaryBare(val, &account)
		if process(account) {
			return
		}
		iter.Next()
	}
}
func (k Keeper) HasRole(ctx sdk.Context, addr sdk.AccAddress, roleToCheck types.AccountRole) bool {
	account := k.GetAccount(ctx, addr)
	for _, role := range account.Roles {
		if role == roleToCheck {
			return true
		}
	}
	return false
}
func (k Keeper) CountAccountsWithRole(ctx sdk.Context, roleToCount types.AccountRole) int {
	res := 0
	k.IterateAccounts(ctx, func(account types.Account) (stop bool) {
		for _, role := range account.Roles {
			if role == roleToCount {
				res++
				return false
			}
		}
		return false
	})
	return res
}
func (k Keeper) DeleteAccount(ctx sdk.Context, address sdk.AccAddress) {
	if !k.IsAccountPresent(ctx, address) {
		panic("Account does not exist")
	}
	store := ctx.KVStore(k.storeKey)
	store.Delete(types.GetAccountKey(address))
}
func (k Keeper) GetPendingAccount(ctx sdk.Context, address sdk.AccAddress) types.PendingAccount {
	store := ctx.KVStore(k.storeKey)
	bz := store.Get(types.GetPendingAccountKey(address))
	if bz == nil {
		panic("Pending Account does not exist")
	}
	var pendAcc types.PendingAccount
	k.cdc.MustUnmarshalBinaryBare(bz, &pendAcc)
	return pendAcc
}
func (k Keeper) SetPendingAccount(ctx sdk.Context, pendAcc types.PendingAccount) {
	store := ctx.KVStore(k.storeKey)
	store.Set(types.GetPendingAccountKey(pendAcc.Address), k.cdc.MustMarshalBinaryBare(pendAcc))
}
func (k Keeper) IsPendingAccountPresent(ctx sdk.Context, address sdk.AccAddress) bool {
	store := ctx.KVStore(k.storeKey)
	return store.Has(types.GetPendingAccountKey(address))
}