-
Notifications
You must be signed in to change notification settings - Fork 28
/
params.go
55 lines (46 loc) · 1.59 KB
/
params.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
45
46
47
48
49
50
51
52
53
54
55
package keeper
import (
"time"
"github.com/OmniFlix/omniflixhub/v2/x/marketplace/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// GetParams gets the parameters for the marketplace module.
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.ParamsKey)
if bz == nil {
return params
}
k.cdc.MustUnmarshal(bz, ¶ms)
return params
}
// SetParams sets the parameters for the marketplace module.
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error {
if err := params.ValidateBasic(); err != nil {
return err
}
store := ctx.KVStore(k.storeKey)
bz := k.cdc.MustMarshal(¶ms)
store.Set(types.ParamsKey, bz)
return nil
}
// GetSaleCommission returns the current sale commission of marketplace.
func (k Keeper) GetSaleCommission(ctx sdk.Context) (percent sdk.Dec) {
params := k.GetParams(ctx)
return params.SaleCommission
}
// GetMarketplaceDistributionParams returns the current distribution of marketplace commission.
func (k Keeper) GetMarketplaceDistributionParams(ctx sdk.Context) (distParams types.Distribution) {
params := k.GetParams(ctx)
return params.Distribution
}
// GetBidCloseDuration returns the closing duration for bid for auctions.
func (k Keeper) GetBidCloseDuration(ctx sdk.Context) (duration time.Duration) {
params := k.GetParams(ctx)
return params.BidCloseDuration
}
// GetMaxAuctionDuration returns the maximum duration for auctions.
func (k Keeper) GetMaxAuctionDuration(ctx sdk.Context) (duration time.Duration) {
params := k.GetParams(ctx)
return params.MaxAuctionDuration
}