mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 19:36:44 +01:00
Refactor api exits
This commit is contained in:
@@ -36,67 +36,6 @@ func getAccount(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func getExits(c *gin.Context) {
|
||||
// Get query parameters
|
||||
// Account filters
|
||||
tokenID, addr, bjj, idx, err := parseAccountFilters(c)
|
||||
if err != nil {
|
||||
retBadReq(err, c)
|
||||
return
|
||||
}
|
||||
// BatchNum
|
||||
batchNum, err := parseQueryUint("batchNum", nil, 0, maxUint32, c)
|
||||
if err != nil {
|
||||
retBadReq(err, c)
|
||||
return
|
||||
}
|
||||
// Pagination
|
||||
fromItem, order, limit, err := parsePagination(c)
|
||||
if err != nil {
|
||||
retBadReq(err, c)
|
||||
return
|
||||
}
|
||||
|
||||
// Fetch exits from historyDB
|
||||
exits, pagination, err := h.GetExits(
|
||||
addr, bjj, tokenID, idx, batchNum, fromItem, limit, order,
|
||||
)
|
||||
if err != nil {
|
||||
retSQLErr(err, c)
|
||||
return
|
||||
}
|
||||
|
||||
// Build succesfull response
|
||||
apiExits := historyExitsToAPI(exits)
|
||||
c.JSON(http.StatusOK, &exitsAPI{
|
||||
Exits: apiExits,
|
||||
Pagination: pagination,
|
||||
})
|
||||
}
|
||||
|
||||
func getExit(c *gin.Context) {
|
||||
// Get batchNum and accountIndex
|
||||
batchNum, err := parseParamUint("batchNum", nil, 0, maxUint32, c)
|
||||
if err != nil {
|
||||
retBadReq(err, c)
|
||||
return
|
||||
}
|
||||
idx, err := parseParamIdx(c)
|
||||
if err != nil {
|
||||
retBadReq(err, c)
|
||||
return
|
||||
}
|
||||
// Fetch tx from historyDB
|
||||
exit, err := h.GetExit(batchNum, idx)
|
||||
if err != nil {
|
||||
retSQLErr(err, c)
|
||||
return
|
||||
}
|
||||
apiExits := historyExitsToAPI([]historydb.HistoryExit{*exit})
|
||||
// Build succesfull response
|
||||
c.JSON(http.StatusOK, apiExits[0])
|
||||
}
|
||||
|
||||
func getSlots(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user