Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
366 changes: 218 additions & 148 deletions contracts/Cargo.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ members = [
resolver = "2"

[workspace.dependencies]
soroban-sdk = "23"
soroban-sdk = "23.0.0"

[profile.release]
overflow-checks = true


21 changes: 18 additions & 3 deletions contracts/quest-engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ impl QuestEngineContract {
/// * If admin does not match stored admin
/// * If quest is not found
/// * If quest type is not Explore
/// * If learner has already been verified for this quest
/// * If contract is not initialized
pub fn verify_explore_quest(env: Env, admin: Address, learner: Address, quest_id: u32) {
// 1. admin.require_auth()
Expand All @@ -605,22 +606,31 @@ impl QuestEngineContract {
"Not an Explore quest"
);

// 5. Get reward pool address and create client
// 5. NEW: Check if learner was already verified for this quest
let verification_key = DataKey::ExploreVerification(learner.clone(), quest_id);
if env.storage().persistent().has(&verification_key) {
panic!("Learner already verified for this quest");
}

// 6. Get reward pool address and create client
let reward_pool_address: Address = env
.storage()
.instance()
.get(&DataKey::RewardPool)
.expect("Not initialized");
let reward_pool_client = RewardPoolClient::new(&env, &reward_pool_address);

// 6. Distribute reward from RewardPool
// 7. Distribute reward from RewardPool
reward_pool_client.distribute_reward(
&env.current_contract_address(),
&learner,
&quest.reward_amount,
);

// 7. Emit ExploreQuestVerified event
// 8. NEW: Persist the verification marker after successful payout
env.storage().persistent().set(&verification_key, &true);

// 9. Emit ExploreQuestVerified event
ExploreQuestVerified {
admin,
learner,
Expand All @@ -629,6 +639,11 @@ impl QuestEngineContract {
}
.publish(&env);
}

pub fn is_explore_verified(env: Env, learner: Address, quest_id: u32) -> bool {
let key = DataKey::ExploreVerification(learner, quest_id);
env.storage().persistent().get(&key).unwrap_or(false)
}
}

#[cfg(test)]
Expand Down
Loading
Loading