From b204135f8b8a7286f5c2a10e5008d9713dc654c2 Mon Sep 17 00:00:00 2001 From: Brandon Roberts Date: Fri, 21 Jun 2024 10:06:15 -0500 Subject: [PATCH] Add input type for hodl quest backend --- backend/quests/inputs.go | 10 ++++++++++ backend/quests/status.go | 8 ++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/backend/quests/inputs.go b/backend/quests/inputs.go index d5d0097a..4406d59b 100644 --- a/backend/quests/inputs.go +++ b/backend/quests/inputs.go @@ -12,6 +12,10 @@ type VoteQuestInputs struct { DayIndex uint32 } +type HodlQuestInputs struct { + Amount int +} + func NewPixelQuestInputs(encodedInputs []int) *PixelQuestInputs { return &PixelQuestInputs{ PixelsNeeded: uint32(encodedInputs[0]), @@ -27,3 +31,9 @@ func NewVoteQuestInputs(encodedInputs []int) *VoteQuestInputs { DayIndex: uint32(encodedInputs[0]), } } + +func NewHodlQuestInputs(encodedInputs []int) *HodlQuestInputs { + return &HodlQuestInputs{ + Amount: encodedInputs[0], + } +} diff --git a/backend/quests/status.go b/backend/quests/status.go index 165837ec..ca012b22 100644 --- a/backend/quests/status.go +++ b/backend/quests/status.go @@ -29,13 +29,13 @@ func CheckAuthorityStatus(q *Quest, user string) (progress int, needed int) { } func CheckHodlStatus(q *Quest, user string) (progress int, needed int) { - needed = q.GetInputData()[0] - available_amount, err := core.PostgresQueryOne[int]("SELECT available FROM ExtraPixels WHERE address = $1", user) + hodlQuestInputs := NewHodlQuestInputs(q.InputData) + available, err := core.PostgresQueryOne[int]("SELECT available FROM ExtraPixels WHERE address = $1", user) if err != nil { - return 0, needed + return 0, hodlQuestInputs.Amount } - return *available_amount, needed + return *available, hodlQuestInputs.Amount } func CheckNftStatus(q *Quest, user string) (progress int, needed int) {