Skip to content

Commit

Permalink
ref: verify_quiz
Browse files Browse the repository at this point in the history
  • Loading branch information
irisdv committed Oct 16, 2023
1 parent ca20940 commit fc4ed52
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 241 deletions.
1 change: 1 addition & 0 deletions src/endpoints/quests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ pub mod starknet;
pub mod starknetid;
pub mod tribe;
pub mod uri;
pub mod verify_quiz;
pub mod zklend;
3 changes: 0 additions & 3 deletions src/endpoints/quests/starknet/aa_mastery/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
pub mod claimable;
pub mod verify_quiz_1;
pub mod verify_quiz_2;
pub mod verify_quiz_3;
42 changes: 0 additions & 42 deletions src/endpoints/quests/starknet/aa_mastery/verify_quiz_2.rs

This file was deleted.

42 changes: 0 additions & 42 deletions src/endpoints/quests/starknet/aa_mastery/verify_quiz_3.rs

This file was deleted.

3 changes: 0 additions & 3 deletions src/endpoints/quests/starknet/gigabrain/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
pub mod claimable;
pub mod verify_quiz_1;
pub mod verify_quiz_2;
pub mod verify_quiz_3;
42 changes: 0 additions & 42 deletions src/endpoints/quests/starknet/gigabrain/verify_quiz_1.rs

This file was deleted.

42 changes: 0 additions & 42 deletions src/endpoints/quests/starknet/gigabrain/verify_quiz_2.rs

This file was deleted.

42 changes: 0 additions & 42 deletions src/endpoints/quests/starknet/gigabrain/verify_quiz_3.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,32 @@ use axum::{extract::State, http::StatusCode, response::IntoResponse, Json};
use serde_json::json;
use starknet::core::types::FieldElement;

fn get_task_id(quiz_name: &str) -> Option<u32> {
match quiz_name {
"gigabrain_1" => Some(51),
"gigabrain_2" => Some(57),
"gigabrain_3" => Some(58),
"aa_mastery_1" => Some(52),
"aa_mastery_2" => Some(59),
"aa_mastery_3" => Some(60),
"focustree" => Some(61),
_ => None,
}
}

pub async fn handler(
State(state): State<Arc<AppState>>,
body: Json<VerifyQuizQuery>,
) -> impl IntoResponse {
let task_id = 52;
if body.addr == FieldElement::ZERO {
return get_error("Please connect your wallet first".to_string());
}

let task_id = match get_task_id(&body.quiz_name) {
Some(id) => id,
None => return get_error("Quiz name does not match".to_string()),
};

let user_answers_numbers: Result<Vec<Vec<usize>>, _> = body
.user_answers_list
.iter()
Expand Down
28 changes: 4 additions & 24 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ async fn main() {
get(endpoints::get_trending_quests::handler),
)
.route("/get_tasks", get(endpoints::get_tasks::handler))
.route(
"/quests/verify_quiz",
post(endpoints::quests::verify_quiz::handler),
)
.route(
"/quests/starknetid/verify_has_domain",
get(endpoints::quests::starknetid::verify_has_domain::handler),
Expand Down Expand Up @@ -242,34 +246,10 @@ async fn main() {
"/quests/myswap/claimable",
get(endpoints::quests::myswap::claimable::handler),
)
.route(
"/quests/starknet/gigabrain/verify_quiz_1",
post(endpoints::quests::starknet::gigabrain::verify_quiz_1::handler),
)
.route(
"/quests/starknet/gigabrain/verify_quiz_2",
post(endpoints::quests::starknet::gigabrain::verify_quiz_2::handler),
)
.route(
"/quests/starknet/gigabrain/verify_quiz_3",
post(endpoints::quests::starknet::gigabrain::verify_quiz_3::handler),
)
.route(
"/quests/starknet/gigabrain/claimable",
get(endpoints::quests::starknet::gigabrain::claimable::handler),
)
.route(
"/quests/starknet/aa_mastery/verify_quiz_1",
post(endpoints::quests::starknet::aa_mastery::verify_quiz_1::handler),
)
.route(
"/quests/starknet/aa_mastery/verify_quiz_2",
post(endpoints::quests::starknet::aa_mastery::verify_quiz_2::handler),
)
.route(
"/quests/starknet/aa_mastery/verify_quiz_3",
post(endpoints::quests::starknet::aa_mastery::verify_quiz_3::handler),
)
.route(
"/quests/starknet/aa_mastery/claimable",
get(endpoints::quests::starknet::aa_mastery::claimable::handler),
Expand Down

0 comments on commit fc4ed52

Please sign in to comment.