lfglabs-dev / api.starknet.quest

starknet.quest rust backend
7 stars 28 forks source link

fix: add missing fields to UserTask struct #304

Closed suhas-sensei closed 2 weeks ago

suhas-sensei commented 2 weeks ago

fixes Add missing tasks fields #288

Changes

  1. Updated the UserTask struct in src/endpoints/get_tasks.rs:
    calls: Option<Vec<String>>,
    contracts: Option<Vec<String>>,
    api_url: Option<String>,
    regex: Option<String>,
  2. Ensured the $project stage includes the required fields :
    "calls": 1,
    "contracts": 1,
    "api_url": 1,
    "regex": 1
  3. Database setup and testing.
    
    # Connecting to MongoDB
    docker exec -it <container_id> mongosh

Authoring db in mongodb:

use admin db.auth("quests", "password")

Inserting test quest

db.quests.insertOne({ id: 1, name: "Starknet Introduction", disabled: false })

Inserting test task

db.tasks.insertOne({ id: 1, quest_id: 1, name: "Deploy Your First Contract", href: "https://starknet.io/docs/hello_starknet/", cta: "Deploy Contract", verify_endpoint: "/verify/deploy", verify_endpoint_type: "default", verify_redirect: null, desc: "Learn to deploy your first Starknet smart contract", completed: [], quiz_name: null, calls: ["write_greeting", "get_greeting"], contracts: ["0x123456789"], api_url: "https://api.starknet.io/verify", regex: "^0x[a-fA-F0-9]{64}$", overwrite_order: 1 })

4. API Call
```powershell
Invoke-WebRequest "http://localhost:8080/get_tasks?quest_id=1&addr=0x0000000000000000000000000000000000000000000000000000000000000000" | Select-Object -ExpandProperty Content | ConvertFrom-Json | ConvertTo-Json
  1. Output
    {
    "value": [{
        "id": 1,
        "quest_id": 1,
        "name": "Deploy Your First Contract",
        "href": "https://starknet.io/docs/hello_starknet/",
        "cta": "Deploy Contract",
        "verify_endpoint": "/verify/deploy",
        "verify_endpoint_type": "default",
        "verify_redirect": null,
        "desc": "Learn to deploy your first Starknet smart contract",
        "completed": false,
        "quiz_name": null,
        "calls": ["write_greeting", "get_greeting"],
        "contracts": ["0x123456789"],
        "api_url": "https://api.starknet.io/verify",
        "regex": "^0x[a-fA-F0-9]{64}$"
    }],
    "Count": 1
    }