Skip to content

Commit

Permalink
set mission method and mission count to genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani committed Aug 9, 2024
1 parent 48aba69 commit 45ac24a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions x/claim/keeper/mission.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@ func (k Keeper) ClaimMission(
return claimed, nil
}

// SetMission add a mission id and store the Mission.
func (k Keeper) SetMission(ctx context.Context, mission types.Mission) (uint64, error) {
missionID, err := k.MissionSeq.Next(ctx)
if err != nil {
return 0, err
}
mission.MissionID = missionID
return missionID, k.Mission.Set(ctx, missionID, mission)
}

// Missions returns all missions.
func (k Keeper) Missions(ctx context.Context) ([]types.Mission, error) {
missions := make([]types.Mission, 0)
err := k.IterateMissions(ctx, func(_ uint64, mission types.Mission) (bool, error) {
Expand All @@ -149,6 +160,7 @@ func (k Keeper) Missions(ctx context.Context) ([]types.Mission, error) {
return missions, err
}

// ClaimRecords returns all claim records.
func (k Keeper) ClaimRecords(ctx context.Context) ([]types.ClaimRecord, error) {
claimRecords := make([]types.ClaimRecord, 0)
err := k.IterateClaimRecords(ctx, func(_ string, claimRecord types.ClaimRecord) (bool, error) {
Expand Down
1 change: 1 addition & 0 deletions x/claim/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func DefaultGenesis() *GenesisState {
return &GenesisState{
AirdropSupply: AirdropSupply{Supply: sdk.NewCoin("utest", sdkmath.ZeroInt())},
ClaimRecordList: []ClaimRecord{},
MissionCount: 0,
MissionList: []Mission{},
InitialClaim: InitialClaim{},
// this line is used by starport scaffolding # genesis/types/default
Expand Down

0 comments on commit 45ac24a

Please sign in to comment.