query: pending bids for auction

master
michael 2022-08-30 21:47:39 +00:00
parent e5abd3c1d8
commit 11e2c9e819
4 changed files with 98 additions and 62 deletions

View File

@ -20316,6 +20316,13 @@ paths:
type: object type: object
properties: properties:
bids: bids:
type: array
items:
type: object
properties:
owner:
type: string
amount:
type: string type: string
default: default:
description: An unexpected error response. description: An unexpected error response.
@ -47523,6 +47530,13 @@ definitions:
type: object type: object
properties: properties:
bids: bids:
type: array
items:
type: object
properties:
owner:
type: string
amount:
type: string type: string
cosmostest.cosmostest.QueryGetAuctionResponse: cosmostest.cosmostest.QueryGetAuctionResponse:
type: object type: object

View File

@ -7,6 +7,7 @@ import "cosmos/base/query/v1beta1/pagination.proto";
import "cosmostest/params.proto"; import "cosmostest/params.proto";
import "cosmostest/next_auction.proto"; import "cosmostest/next_auction.proto";
import "cosmostest/auction.proto"; import "cosmostest/auction.proto";
import "cosmostest/bid.proto";
// this line is used by starport scaffolding # 1 // this line is used by starport scaffolding # 1
option go_package = "cosmos-test/x/cosmostest/types"; option go_package = "cosmos-test/x/cosmostest/types";
@ -76,7 +77,7 @@ message QueryAuctionBidsRequest {
} }
message QueryAuctionBidsResponse { message QueryAuctionBidsResponse {
string bids = 1; repeated Bid bids = 1;
} }
// this line is used by starport scaffolding # 3 // this line is used by starport scaffolding # 3

View File

@ -2,8 +2,11 @@ package keeper
import ( import (
"context" "context"
"fmt"
"cosmos-test/x/cosmostest/memdb"
"cosmos-test/x/cosmostest/types" "cosmos-test/x/cosmostest/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
@ -16,8 +19,15 @@ func (k Keeper) AuctionBids(goCtx context.Context, req *types.QueryAuctionBidsRe
ctx := sdk.UnwrapSDKContext(goCtx) ctx := sdk.UnwrapSDKContext(goCtx)
// TODO: Process the query auction, found := k.GetAuction(ctx, req.Index)
_ = ctx if !found {
return nil, fmt.Errorf("auction %s not found", req.Index)
return &types.QueryAuctionBidsResponse{}, nil }
bids, err := memdb.BidDB.GetBids(auction.Index)
if err != nil {
return nil, fmt.Errorf("failed to get bids for auction %s:", err)
}
return &types.QueryAuctionBidsResponse{Bids: bids}, nil
} }

View File

@ -422,7 +422,7 @@ func (m *QueryAuctionBidsRequest) GetIndex() string {
} }
type QueryAuctionBidsResponse struct { type QueryAuctionBidsResponse struct {
Bids string `protobuf:"bytes,1,opt,name=bids,proto3" json:"bids,omitempty"` Bids []*Bid `protobuf:"bytes,1,rep,name=bids,proto3" json:"bids,omitempty"`
} }
func (m *QueryAuctionBidsResponse) Reset() { *m = QueryAuctionBidsResponse{} } func (m *QueryAuctionBidsResponse) Reset() { *m = QueryAuctionBidsResponse{} }
@ -458,11 +458,11 @@ func (m *QueryAuctionBidsResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_QueryAuctionBidsResponse proto.InternalMessageInfo var xxx_messageInfo_QueryAuctionBidsResponse proto.InternalMessageInfo
func (m *QueryAuctionBidsResponse) GetBids() string { func (m *QueryAuctionBidsResponse) GetBids() []*Bid {
if m != nil { if m != nil {
return m.Bids return m.Bids
} }
return "" return nil
} }
func init() { func init() {
@ -481,45 +481,45 @@ func init() {
func init() { proto.RegisterFile("cosmostest/query.proto", fileDescriptor_540d26b2788a5d10) } func init() { proto.RegisterFile("cosmostest/query.proto", fileDescriptor_540d26b2788a5d10) }
var fileDescriptor_540d26b2788a5d10 = []byte{ var fileDescriptor_540d26b2788a5d10 = []byte{
// 593 bytes of a gzipped FileDescriptorProto // 605 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x95, 0xcf, 0x4f, 0x13, 0x4f, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x95, 0xc1, 0x6b, 0x13, 0x41,
0x18, 0xc6, 0x3b, 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x91, 0x0b, 0x2e, 0xc7, 0x6e, 0xe9, 0x66, 0xec, 0x96, 0x7e, 0x8f, 0xdd, 0xd2,
0x7e, 0x39, 0x9e, 0xfc, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xfc, 0x95, 0x2a, 0x26, 0x1c, 0x07, 0x00, 0x7b, 0xd7, 0x6e, 0x33, 0xb4, 0x1b, 0xc9, 0x8b, 0x98, 0x89, 0x4e, 0x59, 0xfd, 0xab, 0x3c, 0xfb,
0x00, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xd5, 0x23, 0xd8, 0xc6, 0x4e, 0x07, 0x00, 0x00,
} }
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
@ -1066,12 +1066,19 @@ func (m *QueryAuctionBidsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error
var l int var l int
_ = l _ = l
if len(m.Bids) > 0 { if len(m.Bids) > 0 {
i -= len(m.Bids) for iNdEx := len(m.Bids) - 1; iNdEx >= 0; iNdEx-- {
copy(dAtA[i:], m.Bids) {
i = encodeVarintQuery(dAtA, i, uint64(len(m.Bids))) size, err := m.Bids[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
}
i-- i--
dAtA[i] = 0xa dAtA[i] = 0xa
} }
}
return len(dAtA) - i, nil return len(dAtA) - i, nil
} }
@ -1201,10 +1208,12 @@ func (m *QueryAuctionBidsResponse) Size() (n int) {
} }
var l int var l int
_ = l _ = l
l = len(m.Bids) if len(m.Bids) > 0 {
if l > 0 { for _, e := range m.Bids {
l = e.Size()
n += 1 + l + sovQuery(uint64(l)) n += 1 + l + sovQuery(uint64(l))
} }
}
return n return n
} }
@ -1966,7 +1975,7 @@ func (m *QueryAuctionBidsResponse) Unmarshal(dAtA []byte) error {
if wireType != 2 { if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Bids", wireType) return fmt.Errorf("proto: wrong wireType = %d for field Bids", wireType)
} }
var stringLen uint64 var msglen int
for shift := uint(0); ; shift += 7 { for shift := uint(0); ; shift += 7 {
if shift >= 64 { if shift >= 64 {
return ErrIntOverflowQuery return ErrIntOverflowQuery
@ -1976,23 +1985,25 @@ func (m *QueryAuctionBidsResponse) Unmarshal(dAtA []byte) error {
} }
b := dAtA[iNdEx] b := dAtA[iNdEx]
iNdEx++ iNdEx++
stringLen |= uint64(b&0x7F) << shift msglen |= int(b&0x7F) << shift
if b < 0x80 { if b < 0x80 {
break break
} }
} }
intStringLen := int(stringLen) if msglen < 0 {
if intStringLen < 0 {
return ErrInvalidLengthQuery return ErrInvalidLengthQuery
} }
postIndex := iNdEx + intStringLen postIndex := iNdEx + msglen
if postIndex < 0 { if postIndex < 0 {
return ErrInvalidLengthQuery return ErrInvalidLengthQuery
} }
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.Bids = string(dAtA[iNdEx:postIndex]) m.Bids = append(m.Bids, &Bid{})
if err := m.Bids[len(m.Bids)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex iNdEx = postIndex
default: default:
iNdEx = preIndex iNdEx = preIndex