diff --git a/config.template.toml b/config.template.toml index a88007bb..8ecb5461 100644 --- a/config.template.toml +++ b/config.template.toml @@ -11,7 +11,7 @@ private_key = "1" [starknetid_contracts] naming_contract = "0xXXXXXXXXXXXX" -verifier_contract = "0xXXXXXXXXXXXX" +verifier_contracts = [ "0xXXXXXXXXXXXX" ] identity_contract = "0xXXXXXXXXXXXX" [quests] diff --git a/src/config.rs b/src/config.rs index 7db958d6..2d07b633 100644 --- a/src/config.rs +++ b/src/config.rs @@ -26,7 +26,7 @@ pub_struct!(Clone, Deserialize; Variables { pub_struct!(Clone, Deserialize; StarknetIdContracts { naming_contract: FieldElement, - verifier_contract: FieldElement, + verifier_contracts: Vec, identity_contract: FieldElement, }); diff --git a/src/endpoints/quests/starknetid/verify_socials.rs b/src/endpoints/quests/starknetid/verify_socials.rs index 337f5220..be30f861 100644 --- a/src/endpoints/quests/starknetid/verify_socials.rs +++ b/src/endpoints/quests/starknetid/verify_socials.rs @@ -63,38 +63,50 @@ pub async fn handler( ) .await?; - let twitter_verifier_data = call_contract_helper( - &state, - state.conf.starknetid_contracts.identity_contract, - selector!("get_verifier_data"), - vec![ - id_res[0], - short_string!("twitter"), - state.conf.starknetid_contracts.verifier_contract, - FieldElement::ZERO, - ], - ) - .await?; + let mut twitter = false; + let mut discord = false; + for verifier_contract in &state.conf.starknetid_contracts.verifier_contracts { - let discord_verifier_data = call_contract_helper( - &state, - state.conf.starknetid_contracts.identity_contract, - selector!("get_verifier_data"), - vec![ - id_res[0], - short_string!("discord"), - state.conf.starknetid_contracts.verifier_contract, - FieldElement::ZERO, - ], - ) - .await?; + let twitter_verifier_data = call_contract_helper( + &state, + state.conf.starknetid_contracts.identity_contract, + selector!("get_verifier_data"), + vec![ + id_res[0], + short_string!("twitter"), + *verifier_contract, + FieldElement::ZERO, + ], + ) + .await?; + if twitter_verifier_data[0] != felt!("0") { + twitter = true; + } + + let discord_verifier_data = call_contract_helper( + &state, + state.conf.starknetid_contracts.identity_contract, + selector!("get_verifier_data"), + vec![ + id_res[0], + short_string!("discord"), + *verifier_contract, + FieldElement::ZERO, + ], + ) + .await?; + if discord_verifier_data[0] != felt!("0") { + discord = true; + } + } + - if twitter_verifier_data[0] != felt!("0") && discord_verifier_data[0] != felt!("0") { + if twitter && discord{ match state.upsert_completed_task(query.addr, task_id).await { Ok(_) => Ok((StatusCode::OK, Json(json!({"res": true})))), Err(e) => Err(e.to_string()), } - } else if twitter_verifier_data[0] == felt!("0") { + } else if !twitter{ Err("You have not verified your Twitter account".to_string()) } else { Err("You have not verified your Discord account".to_string())