From 909bbafc22c7dbaaa7d26dcd7c385468b53705fa Mon Sep 17 00:00:00 2001 From: turtlebasket Date: Sat, 17 Sep 2022 21:35:46 +0000 Subject: [PATCH] finish ongoing auction info q implementation --- docs/static/openapi.yml | 36 ++++++++++++------- go.mod | 1 - go.sum | 2 -- .../client/cli/query_auction_info.go | 1 + .../keeper/grpc_query_auction_info.go | 27 ++++++++++++-- 5 files changed, 49 insertions(+), 18 deletions(-) diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 3dbd277..5997c3e 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -15,7 +15,18 @@ paths: type: object properties: bids: - type: string + type: array + items: + type: object + properties: + owner: + type: string + amount: + type: string + verifiedProviders: + type: array + items: + type: string default: description: An unexpected error response. schema: @@ -252,16 +263,6 @@ paths: in: query required: false type: boolean - - name: pagination.reverse - description: >- - reverse is set to true if results are to be returned in the - descending order. - - - Since: cosmos-sdk 0.43 - in: query - required: false - type: boolean tags: - Query '/colinearcore/colinearcore/auction/{index}': @@ -30967,7 +30968,18 @@ definitions: type: object properties: bids: - type: string + type: array + items: + type: object + properties: + owner: + type: string + amount: + type: string + verifiedProviders: + type: array + items: + type: string colinear.colinearcore.QueryGetAuctionResponse: type: object properties: diff --git a/go.mod b/go.mod index 30cc3b9..4774928 100644 --- a/go.mod +++ b/go.mod @@ -88,7 +88,6 @@ require ( github.com/gorilla/handlers v1.5.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/gtank/merlin v0.1.1 // indirect github.com/gtank/ristretto255 v0.1.2 // indirect diff --git a/go.sum b/go.sum index ad897ba..07b1083 100644 --- a/go.sum +++ b/go.sum @@ -734,8 +734,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 h1:lLT7ZLSzGLI08vc9cpd+tYmNWjdKDqyr/2L+f6U12Fk= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= diff --git a/x/colinearcore/client/cli/query_auction_info.go b/x/colinearcore/client/cli/query_auction_info.go index 16a0b12..55ce74c 100644 --- a/x/colinearcore/client/cli/query_auction_info.go +++ b/x/colinearcore/client/cli/query_auction_info.go @@ -4,6 +4,7 @@ import ( "strconv" "colinear/x/colinearcore/types" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" diff --git a/x/colinearcore/keeper/grpc_query_auction_info.go b/x/colinearcore/keeper/grpc_query_auction_info.go index 033a871..ff929ab 100644 --- a/x/colinearcore/keeper/grpc_query_auction_info.go +++ b/x/colinearcore/keeper/grpc_query_auction_info.go @@ -2,8 +2,11 @@ package keeper import ( "context" + "fmt" + "colinear/x/colinearcore/memdb" "colinear/x/colinearcore/types" + sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -16,8 +19,26 @@ func (k Keeper) AuctionInfo(goCtx context.Context, req *types.QueryAuctionInfoRe ctx := sdk.UnwrapSDKContext(goCtx) - // TODO: Process the query - _ = ctx + if exp, err := k.AuctionIsExpired(ctx, req.AuctionId); err != nil { + return nil, fmt.Errorf("unable to check auction expiry status: %s", err) + } else { + if exp { + return nil, fmt.Errorf("auction %s is finalized", req.AuctionId) + } + } - return &types.QueryAuctionInfoResponse{}, nil + bids, err := memdb.AuctionDB.GetBids(req.AuctionId) + if err != nil { + return nil, fmt.Errorf("unable to get bids for auction %s: %s", req.AuctionId, err) + } + + vProviders, err := memdb.AuctionDB.GetVerifiedProviders(req.AuctionId) + if err != nil { + return nil, fmt.Errorf("unable to get verified providers for auction %s: %s", req.AuctionId, err) + } + + return &types.QueryAuctionInfoResponse{ + Bids: bids, + VerifiedProviders: vProviders, + }, nil }