Closed Marchand-Nicolas closed 2 months ago
MorninG folks, these seem right within my alley, not too complex, can I please take it up ?
I am applying to this issue via OnlyDust platform.
I am front end developer with 6 years experience. i have worked with microsoft on several projects, this will be my first time contributing to the hackathon and i am ready to work
I would approach this issue with following steps Update the QuestTaskDocument struct in models.rs to include a new total_amount field of type FieldElement. Modify the verify_balance function in verify_balance.rs to use the total_amount field from the QuestTaskDocument. If total_amount is None, use the fallback static value. Update the usage of verify_balance to ensure the QuestTaskDocument instance includes the total_amount field. Document the changes, including the new total_amount field and the fallback behavior.
I am applying to this issue via OnlyDust platform.
I am a Full Stack blockchain Developer with expertise in Next.js, Nest.js, TypeScript, JavaScript, React, Node.js, Three.js, and Solidity. My journey with OnlyDust hackathons began at Edition 1, and I've since made 47 contributions across 11 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 7, 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.
I will address the issue in these steps:
Model Update:
QuestTaskDocument
struct in models.rs
to include a new field named total_amount
.Option<FieldElement>
, allowing it to be either present (containing a value) or absent (empty).Code Update:
src\endpoints\quests\verify_balance.rs
, replace the static value with a check on the total_amount
field.Dynamic Amount Handling:
total_amount
is present in the task
document:
result[0]
) with the extracted total_amount
value.total_amount
is absent:
3000000000000000
) for comparison.Testing and Refinement:
total_amount
fails to parse as a FieldElement
.This approach provides flexibility in specifying the required balance for verification tasks while maintaining a fallback for missing values.
I am applying to this issue via OnlyDust platform.
As an experienced Full Stack Blockchain Developer, I'm excited to contribute my expertise to Edition 7 of the OnlyDust hackathons. With a strong background in Next.js, TypeScript, JavaScript, React, Node.js, Solidity, 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 28 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 embark on Edition 7, I'm eager to leverage my hackathon experience and technical skills to push the boundaries of what's possible in blockchain development. With a passion for creating cutting-edge solutions, I'm excited to collaborate with the OnlyDust community and contribute to the advancement of the blockchain ecosystem.
i would first update the task document to include a total amount field, then i am going to retrieve this total amount value in the code as requested and use optional chaining method to display the dummy text when total amount is undefined or empty
I am applying to this issue via OnlyDust platform.
I am more commonly a Python developer but I have extensive knowledge in lots of field of programming as I have dabbled in Javascript, Java, Rust, Cairo, C, Typescript. I am good with solving problems, it's just about changing syntax to solve the problem for a particular programming language being used.
I would employ the concept of variables to replace the defined static quantity so that as the variable( using mut keyword for changes), so would the specified or static number change.
I am applying to this issue via OnlyDust platform.
I have substantial experience in Rust programming, particularly with structuring and manipulating data within Rust applications. My expertise includes updating and managing data models, handling optional fields, and working with various data types like FieldElement.
Specific Skills and Approach: Experience with Rust and Data Models:
I have experience working with Rust’s strong type system and managing complex data structures. This includes defining and updating structs to support new fields and ensuring compatibility with existing code. Handling Optional Fields:
I’ve implemented optional fields in Rust, ensuring that default values are used when an optional field is not set. This involves using Option
I’m familiar with the FieldElement type and its use cases, including parsing and comparing large numbers. This experience is crucial for ensuring that the dynamic total_amount field is correctly handled. Approach to the Task: Update QuestTaskDocument Struct:
Add a new total_amount field to the QuestTaskDocument struct in models.rs. This field should be of type Option
rust Copy code use some_crate::FieldElement;
pub struct QuestTaskDocument { // Existing fields...
pub total_amount: Option<FieldElement>,
} Modify verify_balance.rs to Use total_amount:
Update the logic in verify_balance.rs to check if the total_amount field is set. Use this value if available, otherwise fall back to the static value. Example Update to verify_balance.rs:
rust Copy code use crate::models::QuestTaskDocument; use some_crate::FieldElement;
// Assuming task
is an instance of QuestTaskDocument
let static_amount = FieldElement::from_dec_str("3000000000000000").unwrap();
let amount_to_check = task.total_amount.unwrap_or(static_amount);
if result[0] < amount_to_check { // Handle the case where the balance is less than the amount to check } Testing:
Test the updated functionality to ensure that the total_amount field is correctly handled and that the fallback to the static value works as expected. Write unit tests to cover scenarios where total_amount is set and not set. Documentation:
Update any relevant documentation or comments to reflect the changes made to the QuestTaskDocument struct and how the dynamic total_amount field is used.
Update the QuestTaskDocument struct to include a new optional field total_amount of type Option
rust Copy code use some_crate::FieldElement; // Import FieldElement type
pub struct QuestTaskDocument { // Existing fields...
pub total_amount: Option<FieldElement>,
}
Retrieve the total_amount field from the QuestTaskDocument. Use this value for comparison if it exists; otherwise, fall back to the static value. Update the Logic:
Replace the static value with the dynamic total_amount in the verify_balance.rs file. Example Update in verify_balance.rs:
rust Copy code use crate::models::QuestTaskDocument; use some_crate::FieldElement;
pub fn verify_balance(task: &QuestTaskDocument, result: &[FieldElement]) { // Static amount let static_amount = FieldElement::from_dec_str("3000000000000000").unwrap();
// Determine the amount to check
let amount_to_check = task.total_amount.as_ref().unwrap_or(&static_amount);
// Compare the result with the amount to check
if result[0] < *amount_to_check {
// Handle the case where the balance is less than the amount to check
}
}
Write unit tests to ensure that the total_amount field is correctly used when present and that the static value is used as a fallback when it is not set. Example Unit Test:
rust Copy code
mod tests { use super::*; use some_crate::FieldElement;
#[test]
fn test_verify_balance_with_dynamic_amount() {
let dynamic_amount = FieldElement::from_dec_str("4000000000000000").unwrap();
let task = QuestTaskDocument { total_amount: Some(dynamic_amount.clone()) };
let result = [FieldElement::from_dec_str("3000000000000000").unwrap()];
verify_balance(&task, &result);
// Add assertions based on expected behavior
}
#[test]
fn test_verify_balance_with_static_amount() {
let task = QuestTaskDocument { total_amount: None };
let result = [FieldElement::from_dec_str("3000000000000000").unwrap()];
verify_balance(&task, &result);
// Add assertions based on expected behavior
}
} Integration Testing:
Test the entire application to confirm that the total_amount field is integrated correctly and does not cause issues with other parts of the system.
I am applying to this issue via OnlyDust platform.
I am ready to work on improving the verify_balance
route. My name is Benjamin, and I have extensive experience in backend development and API design. I have worked on updating and optimizing routes to handle dynamic data and improve flexibility.
The current implementation of the verify_balance
route in src/endpoints/quests/verify_balance.rs
uses a static value "3000000000000000"
for balance checking:
I am applying to this issue via OnlyDust platform.
How would you approach the problem:
Update Data Model: Modify QuestTaskDocument
in models.rs
to include an optional total_amount
field of type FieldElement
.
Modify Endpoint Logic: In verify_balance.rs
, replace the static value with the total_amount
field. Check if total_amount
is None
and fallback to the static value if not set.
Testing: Ensure that both scenarios (with and without total_amount
) are covered in the tests to validate correct behavior.
Update Data Model: Add an optional total_amount
field of type FieldElement
to QuestTaskDocument
in models.rs
.
Modify Endpoint Logic: In verify_balance.rs
, replace the static value with the total_amount
field. If total_amount
is None
, use the static value as a fallback.
Test: Validate that both scenarios (with and without total_amount
) work correctly by updating and running relevant tests.
The maintainer Marchand-Nicolas has assigned Dprof-in-tech to this issue via OnlyDust Platform. Good luck!
Update
src\endpoints\quests\verify_balance.rs
to support a dynamic total amount.The aim is to replace the static value "3000000000000000" here
(line 71)
by a "total_amount" field from the "task" document.
You'll need to update the
QuestTaskDocument
struct in models.rs to support this new field.I suggest using the
FieldElement
type.This issue would allow us to precise the amount we want for balance checking taks, rather than a static amount which corresponded to approximatively 10$ worth of ETH. This is even more important when we want to call contracts that use different currencies.
Also could be cool to make this field optional for balance tasks, and to use the static value when the "total_amount" field is not set.