Skip to content

Commit

Permalink
Fix: transfers last ID
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Feb 4, 2021
1 parent b28cc9c commit a20158d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/api/handlers/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ func TransferFromElasticModel(model transfer.Transfer) (t Transfer) {
type TransferResponse struct {
Transfers []Transfer `json:"transfers"`
Total int64 `json:"total"`
LastID string `json:"last_id,omitempty"`
}

// ConfigResponse -
Expand Down
2 changes: 1 addition & 1 deletion cmd/api/handlers/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (ctx *Context) GetFA12OperationsForAddress(c *gin.Context) {
return
}

response, err := ctx.transfersPostprocessing(transfers)
response, err := ctx.transfersPostprocessing(transfers, true)
if ctx.handleError(c, err, 0) {
return
}
Expand Down
7 changes: 5 additions & 2 deletions cmd/api/handlers/transfers.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (ctx *Context) GetContractTransfers(c *gin.Context) {
if ctx.handleError(c, err, 0) {
return
}
response, err := ctx.transfersPostprocessing(transfers)
response, err := ctx.transfersPostprocessing(transfers, false)
if ctx.handleError(c, err, 0) {
return
}
Expand All @@ -60,9 +60,12 @@ type tokenKey struct {
TokenID int64
}

func (ctx *Context) transfersPostprocessing(transfers transfer.Pageable) (response TransferResponse, err error) {
func (ctx *Context) transfersPostprocessing(transfers transfer.Pageable, withLastID bool) (response TransferResponse, err error) {
response.Total = transfers.Total
response.Transfers = make([]Transfer, len(transfers.Transfers))
if withLastID {
response.LastID = transfers.LastID
}

mapTokens := make(map[tokenKey]*TokenMetadata)
tokens, err := ctx.TokenMetadata.Get(tokenmetadata.GetContext{
Expand Down

0 comments on commit a20158d

Please sign in to comment.