Skip to content

Verify explore quest implementation#81

Merged
Kaylahray merged 3 commits into
learnault:mainfrom
Birdmannn:feat-#56
Jun 3, 2026
Merged

Verify explore quest implementation#81
Kaylahray merged 3 commits into
learnault:mainfrom
Birdmannn:feat-#56

Conversation

@Birdmannn
Copy link
Copy Markdown
Contributor

Quest Engine: Explore Quest Implementation

Overview

Implemented Explore Quest functionality that allows the admin to verify off-chain actions and trigger payouts from the RewardPool.

Changes

1. Contract Implementation

File: contracts/quest-engine/src/lib.rs

Added:

  • RewardPoolClient interface to interact with RewardPool contract
  • ExploreQuestVerified event for tracking verified quests
  • create_explore_quest() function - Admin creates Explore Quests (no escrow)
  • verify_explore_quest() function - Admin verifies completion and triggers RewardPool payout

Key Functions:

create_explore_quest(admin, reward_amount, metadata_hash) -> u32

  • Only admin can create Explore Quests
  • No tokens are escrowed (unlike Build Quests)
  • Quest type set to QuestType::Explore
  • Returns quest ID

verify_explore_quest(admin, learner, quest_id)

  • Only admin can verify
  • Validates quest type is Explore
  • Calls RewardPool.distribute_reward() to pay learner
  • Emits ExploreQuestVerified event

Validation:

  • Admin authentication required
  • Quest must exist
  • Quest type must be Explore
  • RewardPool must have sufficient funds

2. Events

New Event: ExploreQuestVerified

pub struct ExploreQuestVerified {
    pub admin: Address,
    pub learner: Address,
    pub quest_id: u32,
    pub amount: i128,
}

3. Tests

File: contracts/quest-engine/src/test.rs

Added 9 new tests:

  • test_create_explore_quest_success - Creates Explore Quest
  • test_create_explore_quest_unauthorized - Rejects non-admin
  • test_create_explore_quest_increments_ids - Verifies ID counter
  • test_verify_explore_quest_success - Successful verification
  • test_verify_explore_quest_unauthorized - Rejects non-admin
  • test_verify_explore_quest_nonexistent - Handles missing quest
  • test_verify_explore_quest_wrong_type - Rejects Build Quests
  • test_explore_quest_emits_event - Verifies event emission
  • test_mixed_quest_types - Tests Build + Explore coexistence

4. Quest Types Comparison

Feature Build Quest Explore Quest
Creator Employer Admin
Funding Escrowed in QuestEngine Paid from RewardPool
Verification Employer reviews submission Admin verifies off-chain action
Use Case On-chain deliverables Off-chain actions (social, etc.)

Usage Flow

Creating Explore Quest

let quest_id = quest_engine.create_explore_quest(
    &admin,
    &500,  // reward amount
    &metadata_hash
);

Verifying Completion

quest_engine.verify_explore_quest(
    &admin,
    &learner,
    &quest_id
);
// Triggers: RewardPool.distribute_reward(quest_engine, learner, 500)

Verification

✅ All tests pass (129 total across all contracts)
✅ Clippy clean
✅ Formatting correct
✅ Wasm builds successfully
✅ Quest Engine now exports 10 functions (was 8)
✅ CI ready

Integration Requirements

  • RewardPool must be funded with sufficient tokens
  • QuestEngine must be added as approved spender in RewardPool
  • Admin backend/oracle must call verify_explore_quest() after off-chain verification
    Closes [QuestEngine] Verify explore quest #56

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Jun 1, 2026

@Birdmannn Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Kaylahray Kaylahray merged commit d8a4fcf into learnault:main Jun 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[QuestEngine] Verify explore quest

2 participants