Impl api get batch(es)

This commit is contained in:
Arnau B
2020-10-26 10:43:34 +01:00
parent 7c8f380637
commit 28c0164525
15 changed files with 599 additions and 136 deletions

View File

@@ -178,49 +178,6 @@ func getExit(c *gin.Context) {
c.JSON(http.StatusOK, apiExits[0])
}
func getHistoryTxs(c *gin.Context) {
// Get query parameters
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
}
// TxType
txType, err := parseQueryTxType(c)
if err != nil {
retBadReq(err, c)
return
}
// Pagination
fromItem, order, limit, err := parsePagination(c)
if err != nil {
retBadReq(err, c)
return
}
// Fetch txs from historyDB
txs, pagination, err := h.GetHistoryTxs(
addr, bjj, tokenID, idx, batchNum, txType, fromItem, limit, order,
)
if err != nil {
retSQLErr(err, c)
return
}
// Build succesfull response
apiTxs := historyTxsToAPI(txs)
c.JSON(http.StatusOK, &historyTxsAPI{
Txs: apiTxs,
Pagination: pagination,
})
}
func getHistoryTx(c *gin.Context) {
// Get TxID
txID, err := parseParamTxID(c)
@@ -239,18 +196,6 @@ func getHistoryTx(c *gin.Context) {
c.JSON(http.StatusOK, apiTxs[0])
}
func getBatches(c *gin.Context) {
}
func getBatch(c *gin.Context) {
}
func getFullBatch(c *gin.Context) {
}
func getSlots(c *gin.Context) {
}
@@ -349,7 +294,7 @@ func getCoordinators(c *gin.Context) {
func getCoordinator(c *gin.Context) {
// Get bidderAddr
const name = "bidderAddr"
bidderAddr, err := parseEthAddr(c, name)
bidderAddr, err := parseParamEthAddr(name, c)
if err != nil {
retBadReq(err, c)