From 864c3be5ee974e287357b12f2351cd733ebc1c57 Mon Sep 17 00:00:00 2001 From: asim Date: Wed, 14 Dec 2022 10:05:47 +0000 Subject: [PATCH] fix opensea handler --- nft/handler/opensea.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/nft/handler/opensea.go b/nft/handler/opensea.go index f3530d8d97..5230980655 100644 --- a/nft/handler/opensea.go +++ b/nft/handler/opensea.go @@ -321,17 +321,26 @@ func (o *OpenSea) Collections(ctx context.Context, req *pb.CollectionsRequest, r params += fmt.Sprintf("limit=%d&offset=%d", limit, offset) + var colls []*domain.Collection + + var err error + if len(req.Owner) > 0 { params += "&asset_owner=" + req.Owner + err = api.Get(uri+params, &colls) + } else { + var resp domain.CollectionsResponse + err = api.Get(uri+params, &resp) + if err == nil { + colls = resp.Collections + } } - var resp domain.CollectionsResponse - - if err := api.Get(uri+params, &resp); err != nil { + if err != nil { return errors.InternalServerError("nft.collections", "failed to get collections: %v", err) } - for _, collection := range resp.Collections { + for _, collection := range colls { rsp.Collections = append(rsp.Collections, collectionToPb(collection)) }