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