-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from starknet-id/feat/add_new_quizzes
feat: add more quizzes & read some twitter tasks
- Loading branch information
Showing
16 changed files
with
445 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod claimable; | ||
pub mod discord_fw_callback; | ||
pub mod verify_quiz; | ||
pub mod verify_swap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use std::sync::Arc; | ||
|
||
use crate::{ | ||
common::verify_quiz::verify_quiz, | ||
models::{AppState, VerifyQuizQuery}, | ||
utils::{get_error, CompletedTasksTrait}, | ||
}; | ||
use axum::{extract::State, http::StatusCode, response::IntoResponse, Json}; | ||
use serde_json::json; | ||
use starknet::core::types::FieldElement; | ||
|
||
pub async fn handler( | ||
State(state): State<Arc<AppState>>, | ||
body: Json<VerifyQuizQuery>, | ||
) -> impl IntoResponse { | ||
let task_id = 54; | ||
if body.addr == FieldElement::ZERO { | ||
return get_error("Please connect your wallet first".to_string()); | ||
} | ||
|
||
let user_answers_numbers: Result<Vec<Vec<usize>>, _> = body | ||
.user_answers_list | ||
.iter() | ||
.map(|inner_list| { | ||
inner_list | ||
.iter() | ||
.map(|s| s.parse::<usize>()) | ||
.collect::<Result<Vec<_>, _>>() | ||
}) | ||
.collect(); | ||
|
||
match user_answers_numbers { | ||
Ok(responses) => match verify_quiz(&state.conf, body.addr, &body.quiz_name, &responses) { | ||
true => match state.upsert_completed_task(body.addr, task_id).await { | ||
Ok(_) => (StatusCode::OK, Json(json!({"res": true}))).into_response(), | ||
Err(e) => get_error(format!("{}", e)), | ||
}, | ||
false => get_error("Incorrect answers".to_string()), | ||
}, | ||
Err(e) => get_error(format!("{}", e)), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
pub mod claimable; | ||
pub mod verify_added_liquidity; | ||
pub mod verify_quiz; | ||
pub mod verify_twitter_fw; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use std::sync::Arc; | ||
|
||
use crate::{ | ||
common::verify_quiz::verify_quiz, | ||
models::{AppState, VerifyQuizQuery}, | ||
utils::{get_error, CompletedTasksTrait}, | ||
}; | ||
use axum::{extract::State, http::StatusCode, response::IntoResponse, Json}; | ||
use serde_json::json; | ||
use starknet::core::types::FieldElement; | ||
|
||
pub async fn handler( | ||
State(state): State<Arc<AppState>>, | ||
body: Json<VerifyQuizQuery>, | ||
) -> impl IntoResponse { | ||
let task_id = 55; | ||
if body.addr == FieldElement::ZERO { | ||
return get_error("Please connect your wallet first".to_string()); | ||
} | ||
|
||
let user_answers_numbers: Result<Vec<Vec<usize>>, _> = body | ||
.user_answers_list | ||
.iter() | ||
.map(|inner_list| { | ||
inner_list | ||
.iter() | ||
.map(|s| s.parse::<usize>()) | ||
.collect::<Result<Vec<_>, _>>() | ||
}) | ||
.collect(); | ||
|
||
match user_answers_numbers { | ||
Ok(responses) => match verify_quiz(&state.conf, body.addr, &body.quiz_name, &responses) { | ||
true => match state.upsert_completed_task(body.addr, task_id).await { | ||
Ok(_) => (StatusCode::OK, Json(json!({"res": true}))).into_response(), | ||
Err(e) => get_error(format!("{}", e)), | ||
}, | ||
false => get_error("Incorrect answers".to_string()), | ||
}, | ||
Err(e) => get_error(format!("{}", e)), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use std::sync::Arc; | ||
|
||
use crate::{ | ||
models::{AppState, VerifyQuery}, | ||
utils::{get_error, CompletedTasksTrait}, | ||
}; | ||
use axum::{ | ||
extract::{Query, State}, | ||
http::StatusCode, | ||
response::IntoResponse, | ||
Json, | ||
}; | ||
use serde_json::json; | ||
use starknet::core::types::FieldElement; | ||
|
||
pub async fn handler( | ||
State(state): State<Arc<AppState>>, | ||
Query(query): Query<VerifyQuery>, | ||
) -> impl IntoResponse { | ||
let task_id = 21; | ||
if query.addr == FieldElement::ZERO { | ||
return get_error("Please connect your wallet first".to_string()); | ||
} | ||
match state.upsert_completed_task(query.addr, task_id).await { | ||
Ok(_) => (StatusCode::OK, Json(json!({"res": true}))).into_response(), | ||
Err(e) => get_error(format!("{}", e)), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod verify_twitter_fw; | ||
pub mod claimable; | ||
pub mod verify_has_domain; | ||
pub mod verify_has_root_domain; | ||
pub mod verify_quiz; | ||
pub mod verify_socials; | ||
pub mod claimable; | ||
pub mod verify_twitter_fw; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use std::sync::Arc; | ||
|
||
use crate::{ | ||
common::verify_quiz::verify_quiz, | ||
models::{AppState, VerifyQuizQuery}, | ||
utils::{get_error, CompletedTasksTrait}, | ||
}; | ||
use axum::{extract::State, http::StatusCode, response::IntoResponse, Json}; | ||
use serde_json::json; | ||
use starknet::core::types::FieldElement; | ||
|
||
pub async fn handler( | ||
State(state): State<Arc<AppState>>, | ||
body: Json<VerifyQuizQuery>, | ||
) -> impl IntoResponse { | ||
let task_id = 56; | ||
if body.addr == FieldElement::ZERO { | ||
return get_error("Please connect your wallet first".to_string()); | ||
} | ||
|
||
let user_answers_numbers: Result<Vec<Vec<usize>>, _> = body | ||
.user_answers_list | ||
.iter() | ||
.map(|inner_list| { | ||
inner_list | ||
.iter() | ||
.map(|s| s.parse::<usize>()) | ||
.collect::<Result<Vec<_>, _>>() | ||
}) | ||
.collect(); | ||
|
||
match user_answers_numbers { | ||
Ok(responses) => match verify_quiz(&state.conf, body.addr, &body.quiz_name, &responses) { | ||
true => match state.upsert_completed_task(body.addr, task_id).await { | ||
Ok(_) => (StatusCode::OK, Json(json!({"res": true}))).into_response(), | ||
Err(e) => get_error(format!("{}", e)), | ||
}, | ||
false => get_error("Incorrect answers".to_string()), | ||
}, | ||
Err(e) => get_error(format!("{}", e)), | ||
} | ||
} |
Oops, something went wrong.