lfglabs-dev / api.starknet.quest

starknet.quest rust backend
2 stars 17 forks source link

Advanced custom api task type: `custom_api` #263

Open Marchand-Nicolas opened 6 days ago

Marchand-Nicolas commented 6 days ago

Description

Advanced custom api task type: custom_api: the aim of this PR is to add a new verify_custom_api route in src\endpoints\quests.

PROPOSED TODO

Oshioke-Salaki commented 6 days ago

Can I do this?

onlydustapp[bot] commented 6 days ago

Hi @Oshioke-Salaki! Maintainers during the ODHack # 8.0 will be tracking applications via OnlyDust. Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

martinvibes commented 3 days ago

Hello @Marchand-Nicolas I would love to work on this

onlydustapp[bot] commented 3 days ago

Hi @martinvibes! Maintainers during the ODHack # 8.0 will be tracking applications via OnlyDust. Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

PoulavBhowmick03 commented 1 day ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I'm Poulav Bhowmick, a software engineer at Invisible Studios with a robust background in TypeScript, Rust, Solidity Cairo, fullstack development and blockchain technology. My experience includes building robust applications, optimizing functionalities and blockchain integration. I have actively participated in events and open source contributions, enhancing my capability to tackle real-world tech challenges. My projects can be viewed on my GitHub Profile and OnlyDust Profile. Plus I´m active member of Starknet, Ethereum exosystem. I have also previously contributed to Starknet Quest

How I plan on tackling this issue

I will address this issue by implementing the following steps:

Update QuestTaskDocument Type:

I'll start by adding the api_url (string) and regex (string) as optional fields to the QuestTaskDocument type in src/models.rs if they aren't already present. Create verify_custom_api Route:

Next, I'll create the new route verify_custom_api.rs under src/endpoints/quests. Within this route, I'll handle HTTP requests to the specified API URL (e.g., api.carmine.finance). Validate API Response with Regex:

After calling the API, I'll extract and check the response against the provided regex. If the response matches the regex pattern, I will mark the task as completed in the database or task management system. If the regex doesn't match, I'll ensure that an appropriate error is thrown. Reuse Existing Code:

To maintain consistency and efficiency, I'll reuse parts of the verify_balance route code for API calls and response handling, adapting them as needed for this custom verification process. Once completed, I will test the new verify_custom_api route to ensure it functions correctly with various API responses and regex patterns.

ETA-2 days

Dprof-in-tech commented 1 day ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello, i am Dprof-in-tech, an experienced Full Stack Blockchain Developer and I am excited to contribute my skills to this project in this ODHACK 8. With a strong background in Next.js, TypeScript, JavaScript, React, Node.js, Rust and Cairo, I've honed my technical skills across the blockchain development landscape. My journey with OnlyDust began at Edition 2, and I've since made 34 contributions across 11 projects. This extensive experience on the platform has allowed me to develop a keen understanding of delivering high-quality solutions under tight deadlines. I bring a unique blend of technical prowess and user-centric design to every project, whether I'm crafting immersive 3D experiences or developing innovative smart contracts. My track record demonstrates my ability to adapt quickly and contribute effectively to diverse challenges. I'm confident in my capacity to tackle new problems and drive innovation in the blockchain space. As we begin ODHACK 8, I'm eager to leverage my hackathon experience and technical skills to push the boundaries of what's possible in blockchain development. Below is a link to my OnlyDust public profile. https://app.onlydust.com/u/Dprof-in-tech

How I plan on tackling this issue

  1. Review the Existing System

I will begin by reviewing the existing codebase, particularly the verify_balance route located in the src/endpoints/quests/verify_balance.rs. This will give me insight into the current validation mechanism used and how it can be reused for the new verify_custom_api route.

I will examine how the QuestTaskDocument type is defined in src/models.rs, and determine if it already has the necessary fields for this task, specifically api_url and regex.

  1. Update QuestTaskDocument with New Fields

I will add two optional fields to the QuestTaskDocument type: api_url: A string that represents the URL of the external API to be called. regex: A string that represents the regular expression that will be used to validate the API response.

These fields will be marked as optional (Option), allowing for flexibility when creating quest tasks. These will be crucial for customizing API-based tasks.

  1. Create verify_custom_api Route

I will create a new route named verify_custom_api.rs under the src/endpoints/quests directory. This route will handle custom API-based quest tasks.

This route will: Accept a request containing the api_url and the regex that need to be validated. Call the external API at the provided api_url using the reqwest crate to send the HTTP request. Parse the response body and use Rust's regex crate to validate it against the provided regular expression.

  1. API Call and Regex Validation

I will implement a function that: Sends an HTTP GET request to the provided api_url using the reqwest crate.

If the API call is successful, it retrieves the response as text. Uses the regex::Regex::new() function to compile and match the provided regular expression against the API response.

If the API response passes the regex check, I will mark the quest task as completed by updating the task state. If the regex check fails or the API call fails, I will return an appropriate error message indicating the failure.

  1. Error Handling I will ensure that proper error handling is in place: If the API call fails (e.g., network error or invalid URL), an error will be returned to the user.

If the regex validation fails, I will throw a meaningful error stating that the API response did not meet the expected format. In case of any unexpected behavior, such as invalid task configuration (missing api_url or regex), a validation error will be returned to the user.

  1. Test the Implementation I will create unit and integration tests to verify the functionality of the verify_custom_api route. These tests will include:

Successful cases: Where the API returns valid responses that pass the regex check. Failure cases: Where either the API call fails or the response doesn’t pass the regex validation. Edge cases: Such as handling missing or malformed api_url and regex inputs.

  1. Reuse Code from verify_balance Route I will reuse the logic from the existing verify_balance route wherever applicable: Specifically, the task verification process and any database interactions. Ensuring that the architecture is consistent across verification routes.

  2. Update Documentation I will update any relevant documentation to include the new verify_custom_api route and the functionality it provides. I will provide instructions for creating tasks that use the api_url and regex fields, explaining how to set up custom API-based verifications for future developers.

  3. Submit the Changes for Review Once the development and testing phases are complete, I will submit a pull request with the following: Updated QuestTaskDocument in src/models.rs. The newly implemented verify_custom_api route. Associated tests for validating the functionality. Any relevant documentation updates. I will request feedback from the team and address any necessary changes.

  4. Estimated Timeline Start Date: Immediately upon assignment. Estimated Completion Date: 2-3 days from the start date.

JoE11-y commented 1 day ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

With over four years in blockchain and backend development, I’ve worked across different ecosystems, handling everything from smart contract design to on-chain interactions and protocol integration. I focus on building secure, scalable, and reliable blockchain applications, managing both on-chain and off-chain infrastructure.

How I plan on tackling this issue

Begin by studying the codebase to ensure design consistency, then proceed to work on the task.

Benjtalkshow commented 1 day ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hi @Marchand-Nicolas,

I’m Benjamin, a Full Stack JavaScript developer with four years of experience, mainly in backend development using Next.js and TypeScript. I’ve made 18 contributions on the OnlyDust platform, and you can check my work here: https://app.onlydust.com/u/Benjtalkshow. I enjoy solving problems and delivering good solutions, especially when under pressure.

How I plan on tackling this issue

  1. Review the Existing Code I will start by looking at the current code, especially the verify_balance route in src/endpoints/quests. This will help me understand how it works and see what I can reuse.

  2. Update the QuestTaskDocument I will add api_url and regex as optional fields to the QuestTaskDocument type in src/models.rs. This will give us more flexibility for our custom API tasks.

  3. Create the verify_custom_api Route I will create a new file called verify_custom_api.rs in src/endpoints/quests. This route will:

  4. Handle requests with the api_url and regex. Use a HTTP client like reqwest to call the API. Check the API response against the regex. If it matches, I will mark the task as complete; if not, I will return an error message. Implement Error Handling I want to make sure users get helpful messages if something goes wrong. If the API call fails, they will see a clear error message. If the regex doesn’t match, I will explain what happened. I will also handle any issues with missing task information.

  5. Testing I will write unit and integration tests to ensure everything works well. I will test: Successful API responses that match the regex. Failures due to API issues or regex mismatches. Edge cases, like missing or incorrect inputs. Reuse Existing Code a. I will reuse code from the verify_balance route to keep things consistent. b. I will update the documentation to include the new route and explain how to use the new fields.

onlydustapp[bot] commented 1 day ago

The maintainer Marchand-Nicolas has assigned Dprof-in-tech to this issue via OnlyDust Platform. Good luck!