Skip to content

Conversation

@blurbeast
Copy link
Contributor

closes #66

@blurbeast
Copy link
Contributor Author

@Abeeujah please check

Copy link
Contributor

@Abeeujah Abeeujah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great Job here compared to previous times.

"Withdrawal amount must be greater than zero",
))
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great Job here with the Domain modelling and Validation man 👍

Router::new().route("/deposit", post(deposit::deposit_handler))
Router::new()
.route("/deposit", post(deposit::deposit_handler))
.route("/withdraw", post(withdraw::withdraw_handler))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is looking good 👍


// First check if balance is sufficient
let current_balance = sqlx::query!(
r#"SELECT balance FROM escrow_users WHERE wallet_address = $1"#,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For cases where a query macro is used such as here sqlx::query! you'd want to cache the queries that this particular macro can hit against, to verify your SQL query.

};

if current_balance < payload.amount {
return Err(Error::Conflict);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think Conflict is the right choice of Response here though, Don't you think an InvalidRequest would be better?


// Perform the withdrawal transaction atomically
sqlx::query!(
r#"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can cache your query using cargo sqlx prepare


tx.commit().await?;
Ok(StatusCode::CREATED)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a well done implementation, great job man 👍


let res = app.request(request).await;
assert_eq!(res.status(), StatusCode::BAD_REQUEST);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are good, pretty detailed and decent too. 👍

@blurbeast
Copy link
Contributor Author

thank you .

Copy link
Contributor

@ONEONUORA ONEONUORA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice implementation @blurbeast Keep up the good work

@ONEONUORA ONEONUORA merged commit 4b53187 into skill-mind:master Jul 30, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Withdraw from Escrow

3 participants