-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add CreateTransaction endpoint #334
base: main
Are you sure you want to change the base?
Conversation
var req CreateTransactionRequest | ||
if err := c.Bind(&req); err != nil { | ||
return v1_common.Fail(c, http.StatusBadRequest, "Invalid request body", err) | ||
} | ||
|
||
// Validate request | ||
if err := c.Validate(&req); err != nil { | ||
return v1_common.Fail(c, http.StatusBadRequest, "Validation failed", err) | ||
} | ||
|
||
// Validate project ID format | ||
if _, err := uuid.Parse(req.ProjectID); err != nil { | ||
return v1_common.Fail(c, http.StatusBadRequest, "Invalid project ID format", err) | ||
} |
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.
Why are we not taking advantage of the validate tags and the request validator middleware?
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.
also we have helpers functions that simplify some of this logic
ProjectID string `json:"project_id" validate:"required,uuid4"` | ||
TxHash string `json:"tx_hash" validate:"required"` | ||
FromAddress string `json:"from_address" validate:"required"` | ||
ToAddress string `json:"to_address" validate:"required"` | ||
ValueAmount string `json:"value_amount" validate:"required,numeric"` | ||
} | ||
|
||
type TransactionResponse struct { | ||
ID string `json:"id"` | ||
ProjectID string `json:"project_id"` | ||
CompanyID string `json:"company_id"` | ||
TxHash string `json:"tx_hash"` | ||
FromAddress string `json:"from_address"` | ||
ToAddress string `json:"to_address"` | ||
ValueAmount string `json:"value_amount"` |
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.
We can add validate tags here so that request objects can be validated using the request validator
Description
Adds a new endpoint for recording blockchain transactions associated with specific projects.
Linked Issues
Testing
backend/internal/tests/transactions_test.go
Checklist
Before opening this PR, make sure the PR:
Additionally, make sure that: