From 61a7c6e95f34adb73c8253b6e3fe1b52a5e6288e Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Thu, 1 Aug 2024 17:53:42 +0530 Subject: [PATCH] Refactor LookupAuthorities method --- gql/resolver.go | 20 +------------------- gql/util.go | 6 +----- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/gql/resolver.go b/gql/resolver.go index ef1bdc52..76f3571f 100644 --- a/gql/resolver.go +++ b/gql/resolver.go @@ -82,29 +82,11 @@ func (q queryResolver) LookupAuthorities(ctx context.Context, names []string) ([ } nameAuthority := res.GetNameAuthority() - gqlNameAuthorityRecord, err := GetGQLNameAuthorityRecord(&nameAuthority) + gqlNameAuthorityRecord, err := getAuthorityRecord(nameAuthority, auctionQueryClient) if err != nil { return nil, err } - if nameAuthority.AuctionId != "" { - auctionResp, err := auctionQueryClient.GetAuction(context.Background(), &auctiontypes.QueryGetAuctionRequest{Id: nameAuthority.GetAuctionId()}) - if err != nil { - return nil, err - } - bidsResp, err := auctionQueryClient.GetBids(context.Background(), &auctiontypes.QueryGetBidsRequest{AuctionId: nameAuthority.GetAuctionId()}) - if err != nil { - return nil, err - } - - gqlAuctionRecord, err := GetGQLAuction(auctionResp.GetAuction(), bidsResp.GetBids()) - if err != nil { - return nil, err - } - - gqlNameAuthorityRecord.Auction = gqlAuctionRecord - } - gqlResponse = append(gqlResponse, gqlNameAuthorityRecord) } diff --git a/gql/util.go b/gql/util.go index 914a2d30..b978264f 100644 --- a/gql/util.go +++ b/gql/util.go @@ -305,8 +305,6 @@ func toRPCAttributes(attrs []*KeyValueInput) []*registrytypes.QueryRecordsReques } func getAuthorityRecord(nameAuthority registrytypes.NameAuthority, auctionQueryClient auctiontypes.QueryClient) (*AuthorityRecord, error) { - gqlResponse := &AuthorityRecord{} - gqlNameAuthorityRecord, err := GetGQLNameAuthorityRecord(&nameAuthority) if err != nil { return nil, err @@ -330,7 +328,5 @@ func getAuthorityRecord(nameAuthority registrytypes.NameAuthority, auctionQueryC gqlNameAuthorityRecord.Auction = gqlAuctionRecord } - *gqlResponse = *gqlNameAuthorityRecord - - return gqlResponse, nil + return gqlNameAuthorityRecord, nil }