-
Notifications
You must be signed in to change notification settings - Fork 48
/
parameters.go
38 lines (31 loc) · 1.51 KB
/
parameters.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
package keeper
import (
"cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/desmos-labs/desmos/v7/x/reactions/types"
)
// SaveSubspaceReactionsParams stores the given reactions params inside the store
func (k Keeper) SaveSubspaceReactionsParams(ctx sdk.Context, params types.SubspaceReactionsParams) {
store := ctx.KVStore(k.storeKey)
store.Set(types.SubspaceReactionsParamsStoreKey(params.SubspaceID), k.cdc.MustMarshal(¶ms))
}
// HasSubspaceReactionsParams tells whether the params for the given subspace exist or not
func (k Keeper) HasSubspaceReactionsParams(ctx sdk.Context, subspaceID uint64) bool {
store := ctx.KVStore(k.storeKey)
return store.Has(types.SubspaceReactionsParamsStoreKey(subspaceID))
}
// GetSubspaceReactionsParams returns the reactions params for the given subspace
func (k Keeper) GetSubspaceReactionsParams(ctx sdk.Context, subspaceID uint64) (params types.SubspaceReactionsParams, err error) {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.SubspaceReactionsParamsStoreKey(subspaceID))
if bz == nil {
return types.SubspaceReactionsParams{}, errors.Wrapf(types.ErrInvalidGenesis, "reactions params are not set for subspace %d", subspaceID)
}
k.cdc.MustUnmarshal(bz, ¶ms)
return params, nil
}
// DeleteSubspaceReactionsParams deletes the reactions params for the given subspace
func (k Keeper) DeleteSubspaceReactionsParams(ctx sdk.Context, subspaceID uint64) {
store := ctx.KVStore(k.storeKey)
store.Delete(types.SubspaceReactionsParamsStoreKey(subspaceID))
}