github.com/Finschia/finschia-sdk@v0.49.1/x/token/keeper/keeper.go (about)

     1  package keeper
     2  
     3  import (
     4  	"github.com/Finschia/finschia-sdk/codec"
     5  	sdk "github.com/Finschia/finschia-sdk/types"
     6  	"github.com/Finschia/finschia-sdk/x/token"
     7  	"github.com/Finschia/finschia-sdk/x/token/class"
     8  )
     9  
    10  // Keeper defines the token module Keeper
    11  type Keeper struct {
    12  	classKeeper token.ClassKeeper
    13  
    14  	// The (unexposed) keys used to access the stores from the Context.
    15  	storeKey sdk.StoreKey
    16  
    17  	// The codec for binary encoding/decoding.
    18  	cdc codec.Codec
    19  }
    20  
    21  // NewKeeper returns a token keeper
    22  func NewKeeper(
    23  	cdc codec.Codec,
    24  	key sdk.StoreKey,
    25  	ck token.ClassKeeper,
    26  ) Keeper {
    27  	return Keeper{
    28  		classKeeper: ck,
    29  		storeKey:    key,
    30  		cdc:         cdc,
    31  	}
    32  }
    33  
    34  func ValidateLegacyContract(k Keeper, ctx sdk.Context, contractID string) error {
    35  	if !k.classKeeper.HasID(ctx, contractID) {
    36  		return class.ErrContractNotExist.Wrap(contractID)
    37  	}
    38  
    39  	if _, err := k.GetClass(ctx, contractID); err != nil {
    40  		return err
    41  	}
    42  
    43  	return nil
    44  }