mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-15 20:44:46 +00:00
cursors for nft/assets (#400)
This commit is contained in:
@@ -49,7 +49,6 @@ func (o *OpenSea) Assets(ctx context.Context, req *pb.AssetsRequest, rsp *pb.Ass
|
||||
params := "?"
|
||||
|
||||
limit := int32(20)
|
||||
offset := int32(0)
|
||||
order := "desc"
|
||||
orderBy := ""
|
||||
|
||||
@@ -57,10 +56,6 @@ func (o *OpenSea) Assets(ctx context.Context, req *pb.AssetsRequest, rsp *pb.Ass
|
||||
limit = req.Limit
|
||||
}
|
||||
|
||||
if req.Offset > 0 {
|
||||
offset = req.Offset
|
||||
}
|
||||
|
||||
if req.Order == "asc" {
|
||||
order = "asc"
|
||||
}
|
||||
@@ -70,8 +65,11 @@ func (o *OpenSea) Assets(ctx context.Context, req *pb.AssetsRequest, rsp *pb.Ass
|
||||
orderBy = req.OrderBy
|
||||
}
|
||||
|
||||
params += fmt.Sprintf("limit=%d&offset=%d&order_direction=%s",
|
||||
limit, offset, order)
|
||||
params += fmt.Sprintf("limit=%d&order_direction=%s", limit, order)
|
||||
|
||||
if len(req.Cursor) > 0 {
|
||||
params += fmt.Sprintf("&cursor=%s", req.Cursor)
|
||||
}
|
||||
|
||||
if len(orderBy) > 0 {
|
||||
params += "&order_by=" + orderBy
|
||||
@@ -90,6 +88,8 @@ func (o *OpenSea) Assets(ctx context.Context, req *pb.AssetsRequest, rsp *pb.Ass
|
||||
for _, asset := range resp.Assets {
|
||||
rsp.Assets = append(rsp.Assets, assetToPb(asset))
|
||||
}
|
||||
rsp.Next = resp.Next
|
||||
rsp.Previous = resp.Previous
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user