-
Notifications
You must be signed in to change notification settings - Fork 55
/
genesis.go
43 lines (38 loc) · 1.35 KB
/
genesis.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
package keeper
import (
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/crescent-network/crescent/v5/x/liquidamm/types"
)
// InitGenesis initializes the capability module's state from a provided genesis state.
func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) {
k.SetParams(ctx, genState.Params)
if genState.LastPublicPositionId > 0 {
k.SetLastPublicPositionId(ctx, genState.LastPublicPositionId)
}
for _, publicPosition := range genState.PublicPositions {
k.SetPublicPosition(ctx, publicPosition)
k.SetPublicPositionByParamsIndex(ctx, publicPosition)
k.SetPublicPositionsByPoolIndex(ctx, publicPosition)
}
for _, auction := range genState.RewardsAuctions {
k.SetRewardsAuction(ctx, auction)
}
for _, bid := range genState.Bids {
k.SetBid(ctx, bid)
}
if genState.NextRewardsAuctionEndTime != nil {
k.SetNextRewardsAuctionEndTime(ctx, *genState.NextRewardsAuctionEndTime)
}
}
// ExportGenesis returns the module's exported genesis.
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
var nextAuctionEndTime *time.Time
if t, found := k.GetNextRewardsAuctionEndTime(ctx); found {
nextAuctionEndTime = &t
}
return types.NewGenesisState(
k.GetParams(ctx), k.GetLastPublicPositionId(ctx),
k.GetAllPublicPositions(ctx), k.GetAllRewardsAuctions(ctx),
k.GetAllBids(ctx), nextAuctionEndTime)
}