Skip to content
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

Admin routes for contract tasks #267

Closed
4 tasks
Marchand-Nicolas opened this issue Sep 21, 2024 · 11 comments · Fixed by #276
Closed
4 tasks

Admin routes for contract tasks #267

Marchand-Nicolas opened this issue Sep 21, 2024 · 11 comments · Fixed by #276
Assignees
Labels
Good first issue Good for newcomers 🍒 Nice to have Nice to have but not a priority

Comments

@Marchand-Nicolas
Copy link
Collaborator

Description

Implement the necessary admin routes to create and edit a new contract task type.

PROPOSED TODO

  • Create a contract folder in src\endpoints\admin containing a create_contract and an update_contract route (such as in src\endpoints\admin\balance), which are dedicated to creating & updating contract tasks.
  • It should take a calls (Array of Call) field as an argument in the body (among the other default fields such as the task name), and store it in the task document in the db (as we are doing for other task types, such as in src\endpoints\admin\balance.).
    Each Call is an object with the following fields contract (string), call_data (string array), entry_point (string), regex (string).
  • Add the calls optional field to the QuestTaskDocument type in src\models.rs if it is not already present. If it doesn't already exist, I suggest you to create a Call type that you can then use to type the Calls field.
  • The new document should look something like that:
    let new_document = QuestTaskDocument {
        name: body.name.clone(),
        desc: body.desc.clone(),
        verify_redirect: None,
        href: body.href.clone(),
        total_amount: None,
        quest_id: body.quest_id,
        id: next_id,
        cta: body.cta.clone(),
        verify_endpoint: "quests/verify_contract".to_string(),
        verify_endpoint_type: "default".to_string(),
        task_type: Some("contract".to_string()),
        discord_guild_id: None,
        quiz_name: None,
        contracts: None,
        calls: Some(body.calls),
    };
@Marchand-Nicolas Marchand-Nicolas added 🍒 Nice to have Nice to have but not a priority Good first issue Good for newcomers OD Hack 8 labels Sep 21, 2024
@Luluameh
Copy link

Hello @Marchand-Nicolas
I can handle this
I will love to fix this issue

Copy link

onlydustapp bot commented Sep 24, 2024

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

@MatiasAchucarro
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a passionate and results-driven web developer, currently deepening my knowledge in web3 technologies, Cairo, and open-source development through Dojo Coding. My skill set includes expertise in JavaScript, React, HTML, CSS, and C# with .NET Entity Framework, among others. I also have experience with tools like Git, GitHub, SQL Server, and Postman. My focus has been on building solid web applications, from task lists to full-fledged CRUD systems, with front-end, back-end, and database integration. I have already made a contribution to Starknet Quest, and I am eager to take on more opportunities

How I plan on tackling this issue

To implement the admin routes for creating and editing contract tasks, I first create the src/endpoints/admin folder and within it, the create_contract.js and update_contract.js files. In create_contract.js, I define a POST route that receives an object with the calls field and uses it to create a new QuestTaskDocument, ensuring the calls field is included as a vector of Call.

The Call type is defined in src/models.rs, with the fields contract, call_data, entry_point, and regex. Then, in update_contract.js, I set up a PUT route that updates an existing document, allowing the modification of fields, including calls.

Finally, I perform tests to verify that the create and update operations work correctly and that the documents are stored properly in the database.

@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 implement the admin routes for contract tasks by following these steps:

Create Contract Folder and Routes:
I will create a contract folder under src/endpoints/admin.
Inside this folder, I'll add create_contract.rs and update_contract.rs routes, similar to how it's structured for balance in src/endpoints/admin/balance.

Handle Calls Field in Routes:
The create_contract and update_contract routes will accept a calls field (an array of Call objects) in the request body, along with other fields like task name.
Each Call object will include contract (string), call_data (string array), entry_point (string), and regex (string).

Update QuestTaskDocument Type:
I'll add the calls field to the QuestTaskDocument type in src/models.rs if it doesn't already exist.
If the Call type isn't defined yet, I'll create it to ensure a clear and structured data model.

Store the New Document:
I will construct the new document as specified
I'll ensure that the document structure matches the existing patterns for consistency.
Testing and Validation:

I'll thoroughly test both create_contract and update_contract routes to verify they handle the calls data correctly and store it in the database without issues.
Let me know if there are any other specifics you'd like me to include!

ETA - 3 days

@mubarak23
Copy link
Contributor

mubarak23 commented Sep 26, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a Experience Cairo smart contract developer with experience working on projects such as Just Art Peace, Dojo, Kart, TBA, and Shinigami. Before transitioning to Cairo development, I was a backend developer specializing in Rust.

My recent work with cairo starknet

My recent work with rust

How I plan on tackling this issue

I have read the description

This issue, am going to create two endpoints

  • CREATE CONTRACT TASK
    - The body of create contract will take body that has CALL data object which has the following field, contact name, call_data, entry point and regex and also make the call field an option field inside the QuestTaskDocument,
  1. collect the request body
  2. validate the request body
  3. save in the db
  4. return error if save fail
  5. return successful response after saving the data
  • EDIT CONTRACT TASK
    1. collect the id of the contract we are going to edit
    2. find the contract task
    3. if it's does not exist, return error
    4. if its's exist update the record
    5. if update is successful, return the correct response
    6. if update fail, return the right error response.

ETA : 16HRS

@JoE11-y
Copy link
Contributor

JoE11-y commented Sep 26, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

With over 3 years of experience in blockchain and backend development, I have worked across multiple blockchain ecosystems. My expertise spans the entire development lifecycle—from project conceptualization and smart contract design to managing on-chain interactions, seamless protocol integration, and implementing strong security practices.

This enables me to handle both on-chain and off-chain infrastructure, ensuring the development of reliable, scalable blockchain applications.

How I plan on tackling this issue

Study the codebase to ensure design consitency, then implement the assigned tasks.

@aji70
Copy link

aji70 commented Sep 26, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

i'm a solidity and cairo smart contract developer with over 2 years experience and belive i have the skill set for the task

@GideonBature
Copy link
Contributor

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a Software Engineer with experience in building backend using Rust, I am quite good with Rust and other programming languages including JavaScript, TypeScript, Cairo and NodeJS. I am also an open source contributor and made my first contribution in the ODHack #7.0 which was successfully merged.

How I plan on tackling this issue

First is to look at how the existing routes are been structured, that would give me an idea on how to structure my code, next I will look closely at what is to be implemented by following the PROPOSED TODO, as I build I will keep testing to make sure it's working the way it is supposed to.

Copy link

onlydustapp bot commented Sep 26, 2024

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

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

Successfully merging a pull request may close this issue.

9 participants