Skip to content

feat(contract): Implement Quest Metadata and Description System (#104)#142

Merged
RUKAYAT-CODER merged 2 commits intoEarnQuestOne:mainfrom
David-patrick-chuks:issue-104-quest-metadata
Feb 25, 2026
Merged

feat(contract): Implement Quest Metadata and Description System (#104)#142
RUKAYAT-CODER merged 2 commits intoEarnQuestOne:mainfrom
David-patrick-chuks:issue-104-quest-metadata

Conversation

@David-patrick-chuks
Copy link
Contributor

Overview

This PR implements quest metadata support for the Soroban contract, including creation-time metadata, metadata updates, and metadata query functions.
It supports both inline descriptions and hash-based references for larger content.

Related Issue

Closes #104

Changes

🧱 Contract Types

  • [MODIFY] contracts/earn-quest/src/types.rs
    • Added MetadataDescription enum:
      • Inline(String)
      • Hash(BytesN<32>)
    • Added QuestMetadata struct with:
      • title
      • description
      • requirements
      • category
      • tags

🗄️ Storage Layer

  • [MODIFY] contracts/earn-quest/src/storage.rs
    • Added DataKey::QuestMetadata(Symbol)
    • Added helpers:
      • has_quest_metadata
      • get_quest_metadata
      • set_quest_metadata
    • Updated delete_quest to remove associated metadata.

⚙️ Quest Logic

  • [MODIFY] contracts/earn-quest/src/quest.rs
    • Added register_quest_with_metadata(...)
    • Added update_quest_metadata(...) (authorized for quest creator or admin)
    • Added metadata validation and size limits for gas safety:
      • title/category/tag/requirement length checks
      • max tags/requirements count
      • max inline description length

🌐 Contract Interface

  • [MODIFY] contracts/earn-quest/src/lib.rs
    • Added public contract methods:
      • register_quest_with_metadata
      • update_quest_metadata
      • get_quest_metadata
      • has_quest_metadata

❗ Errors

  • [MODIFY] contracts/earn-quest/src/errors.rs
    • Added MetadataNotFound

🧪 Tests

  • [NEW] contracts/earn-quest/tests/test_metadata.rs
    • Added tests for:
      • metadata on quest creation
      • metadata retrieval
      • creator update authorization
      • admin update authorization
      • unauthorized update rejection
      • hash-reference metadata support
      • large inline description rejection
  • [MODIFY] contracts/earn-quest/tests/test_batch.rs
    • Fixed compatibility issues with current Soroban test APIs.
    • Updated batch size test to avoid budget overflow while preserving size-limit behavior.

🛠️ Cleanup Fix

  • [MODIFY] contracts/earn-quest/src/submission.rs
    • Removed duplicate use crate::storage; import causing compile failure.

Verification Results

Acceptance Criteria Status
Metadata can be set during quest creation
Metadata is retrievable via queries
Authorized users can update metadata
Gas costs remain reasonable ✅ (bounded metadata sizes + hash reference support)
Support for different metadata formats ✅ (Inline + Hash)
All metadata operations tested
Full contract test suite passes

How to Test

# 1. Run full contract test suite
cd contracts/earn-quest
cargo test

# 2. (Optional) Run metadata tests only
cargo test --test test_metadata
image

@RUKAYAT-CODER
Copy link
Contributor

RUKAYAT-CODER commented Feb 25, 2026

please resolve conflict

@David-patrick-chuks
Copy link
Contributor Author

please resolve conflict

DONE ✅.

kindly review and merge

@RUKAYAT-CODER RUKAYAT-CODER merged commit 9e6726b into EarnQuestOne:main Feb 25, 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.

Implement Quest Metadata and Description System

2 participants