Skip to content

Advanced contract task type #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks
Marchand-Nicolas opened this issue Sep 21, 2024 · 9 comments · Fixed by #273
Closed
3 tasks

Advanced contract task type #265

Marchand-Nicolas opened this issue Sep 21, 2024 · 9 comments · Fixed by #273
Assignees
Labels
🍒 Nice to have Nice to have but not a priority

Comments

@Marchand-Nicolas
Copy link
Collaborator

Description

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

PROPOSED TODO

  • Add the calls optional field to the QuestTaskDocument type in src\models.rs if it is not already present. This is an array of Call. Each Call is an object with the following fields: contract (string), call_data (string array), entry_point (string), regex (string). If it doesn't already exist, I suggest you to create a Call type that you can then use to type the Calls field.
  • Reuse the code from the verify_balance route.
  • After each call, check the output using the regex field corresponding to field.
@martinvibes
Copy link

Hey @Marchand-Nicolas let me work on this

Copy link

onlydustapp bot commented Sep 24, 2024

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.

@vickiddev
Copy link

hello @dmirgaleev i am a frontend dev and blockchain developer
please can i work on this issue :) and would love to be a contributor

Copy link

onlydustapp bot commented Sep 25, 2024

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
Copy link

MPSxDev commented Sep 26, 2024

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
Copy link
Contributor

Ugo-X commented Sep 26, 2024

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
Copy link
Contributor

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
Copy link

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.

Copy link

onlydustapp bot commented Sep 26, 2024

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

@Ugo-X
Copy link
Contributor

Ugo-X commented Sep 27, 2024

Thank you ser, will get to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 Nice to have Nice to have but not a priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants