lfglabs-dev / api.starknet.quest

starknet.quest rust backend
7 stars 28 forks source link

Advanced `contract` task type #265

Closed Marchand-Nicolas closed 1 month ago

Marchand-Nicolas commented 1 month ago

Description

Advanced contract task type: the aim of this PR is to add a new verify_contract route in src\endpoints\quests.

PROPOSED TODO

martinvibes commented 1 month ago

Hey @Marchand-Nicolas let me work on this

onlydustapp[bot] commented 1 month 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.

onlydustapp[bot] commented 1 month ago

Hi @vickiddev! 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.

MPSxDev commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello, I am Manuel, a process engineer and web3 developer. I have participated in Starknet Bootcamps and am an Elite winner of Speedrunstark. I have a high capacity to solve problems. I am a member of the DojoCoding community. I hope this issue is assigned to me. I am available to work immediately to achieve what is required in the shortest time possible.

How I plan on tackling this issue

To address the requirements of the issue, I will:

  1. Add an optional calls field to QuestTaskDocument in src\models.rs, defining it as an array of Call objects.
  2. Create a Call type with fields: contract, call_data, entry_point, and regex.
  3. Implement the verify_contract route in src\endpoints\quests, reusing code from verify_balance.
  4. Execute each call and validate the output against the corresponding regex.
  5. Ensure thorough testing and update documentation for the new route and its usage.
Ugo-X commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a Full Stack blockchain Developer with expertise in Next.js, Nest.js, TypeScript, JavaScript, React, Node.js, Three.js, Solidity and rust. My journey with OnlyDust hackathons began at Edition 1, and I've since made 69 contributions across 14 projects. With my extensive experience on the OnlyDust platform (profile: https://app.onlydust.com/u/Ugo-X), I've honed my skills in delivering quality solutions under pressure.

I bring a unique blend of technical proficiency and user-focused design to every project, whether it's crafting immersive 3D experiences or developing smart contracts. My track record shows I can adapt quickly and contribute effectively to diverse challenges.

As we surf through Edition 8, I'm excited to leverage my skills and hackathon experience to push the boundaries of blockchain development. I'm confident in my ability to tackle new challenges and drive innovation in this space.

How I plan on tackling this issue

I will approach this issue in the following manner:

  1. Create a new file verify_contract.rs in src\endpoints\quests.

  2. Define a new struct Call in src\models.rs with fields: contract, call_data, entry_point, and regex.

  3. Add a calls field of type Option<Vec<Call>> to the QuestTaskDocument struct.

  4. Implement the verify_contract route handler:

    a. Retrieve the task document from the database.

    b. For each Call in calls:

    • Use the Starknet provider to make a contract call with the given parameters.

    • Parse the call result using the parse_string function (to be implemented).

    • Check if the parsed result matches the regex pattern.

    c. If all calls pass their regex checks, mark the task as completed.

    d. Otherwise, return an error response.

  5. Reuse error handling and response formatting from the verify_balance route.

  6. Add appropriate error handling for contract call failures and regex mismatches.

PoulavBhowmick03 commented 1 month 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 ecosystem.

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 calls field to the QuestTaskDocument type in src/models.rs if it doesn't already exist. This field will be an array of Call objects. Each Call will have the properties: contract (string), call_data (string array), entry_point (string), and regex (string). If necessary, I will create a new Call type to maintain clarity and structure. Create verify_contract Route:

I'll implement a new verify_contract route in src/endpoints/quests. This route will loop through each Call in the calls array, interact with the specified smart contract at the given entry_point, and pass the provided call_data. Check Outputs with Regex:

After executing each contract call, I'll validate the output using the corresponding regex field to ensure the results meet the specified criteria. If the regex matches the output, the task will proceed; otherwise, an error will be thrown. Reuse Existing Code:

To ensure consistency and efficiency, I will reuse code from the verify_balance route where applicable, adapting it to handle the advanced contract task logic. I'll make sure to thoroughly test the verify_contract route with different Call configurations and regex patterns to ensure it functions correctly.

ETA - 2 days

thesledge04 commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have experience in Rust programming, particularly in web development or smart contract interactions, this knowledge will be critical in implementing the new route and handling contract calls efficiently. Familiarity with blockchain concepts and contract calls will aid in ensuring that the new route functions as intended and meets user requirements.

How I plan on tackling this issue

Approach to Adding the verify_contract Route Modify QuestTaskDocument:

In src/models.rs, check if the calls field is present in QuestTaskDocument. If not, add it as an array of Call type. Define the Call type if it doesn't exist:

[derive(Deserialize, Serialize)]

struct Call { contract: String, call_data: Vec, entry_point: String, regex: String, } Create the verify_contract Route:

In src/endpoints/quests, create a new route for verify_contract. Use existing code from the verify_balance route as a reference for structure and implementation. Implement Call Execution Logic:

Iterate through the calls array, executing each call with the specified entry_point and call_data. Capture the output of each call. Regex Validation:

After executing each call, apply the corresponding regex to validate the output. If the output matches, proceed; otherwise, handle the mismatch accordingly (e.g., log an error or return a failure response). Testing:

Write unit tests for the new route, ensuring it correctly handles various scenarios, including regex matches and mismatches. Documentation:

Update any relevant API documentation to reflect the new verify_contract route and its usage. Create a Pull Request (PR):

Push changes to a new branch and create a PR for review, detailing the implementation and any tests added.

onlydustapp[bot] commented 1 month ago

The maintainer Marchand-Nicolas has assigned Ugo-X to this issue via OnlyDust Platform. Good luck!

Ugo-X commented 1 month ago

Thank you ser, will get to it.