-
Notifications
You must be signed in to change notification settings - Fork 32
withdraw escrow #110
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
withdraw escrow #110
Conversation
|
@Abeeujah please check |
Abeeujah
left a comment
There was a problem hiding this 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", | ||
| )) | ||
| } | ||
| } |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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 👍
src/http/transaction/withdraw.rs
Outdated
|
|
||
| // First check if balance is sufficient | ||
| let current_balance = sqlx::query!( | ||
| r#"SELECT balance FROM escrow_users WHERE wallet_address = $1"#, |
There was a problem hiding this comment.
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.
src/http/transaction/withdraw.rs
Outdated
| }; | ||
|
|
||
| if current_balance < payload.amount { | ||
| return Err(Error::Conflict); |
There was a problem hiding this comment.
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#" |
There was a problem hiding this comment.
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) | ||
| } |
There was a problem hiding this comment.
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); | ||
| } |
There was a problem hiding this comment.
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. 👍
|
thank you . |
ONEONUORA
left a comment
There was a problem hiding this 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
closes #66