Skip to content

Commit 5ea007f

Browse files
committed
improve auction status proto
1 parent fb729a6 commit 5ea007f

File tree

7 files changed

+153
-126
lines changed

7 files changed

+153
-126
lines changed

api/side/auction/auction.pulsar.go

Lines changed: 58 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/side/auction/query.pulsar.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/side/auction/auction.proto

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,19 @@ message Auction {
3939
}
4040

4141
enum AssetType {
42-
Bitcoin = 0;
42+
ASSET_TYPE_BITCOIN = 0;
4343
}
4444

4545
enum AuctionStatus {
46-
AuctionOpen = 0;
47-
AuctionClose = 1;
46+
AUCTION_STATUS_UNSPECIFIED = 0;
47+
AUCTION_STATUS_OPEN = 1;
48+
AUCTION_STATUS_CLOSED = 2;
4849
}
4950

5051
enum BidStatus {
51-
Bidding = 0;
52-
Accepted = 1;
53-
Rejected = 2;
54-
Cancelled = 3;
52+
BID_STATUS_UNSPECIFIED = 0;
53+
BID_STATUS_BIDDING = 1;
54+
BID_STATUS_ACCEPTED = 2;
55+
BID_STATUS_REJECTED = 3;
56+
BID_STATUS_CANCELLED = 4;
5557
}

x/auction/keeper/bid.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func (k Keeper) HandleBid(ctx sdk.Context, sender string, auctionId uint64, pric
1515
}
1616

1717
auction := k.GetAuction(ctx, auctionId)
18-
if auction.Status == types.AuctionStatus_AuctionClose {
18+
if auction.Status == types.AuctionStatus_AUCTION_STATUS_CLOSED {
1919
return nil, types.ErrAuctionClosed
2020
}
2121

@@ -34,7 +34,7 @@ func (k Keeper) HandleBid(ctx sdk.Context, sender string, auctionId uint64, pric
3434
AuctionId: auctionId,
3535
BidPrice: price,
3636
BidAmount: amount,
37-
Status: types.BidStatus_Bidding,
37+
Status: types.BidStatus_BID_STATUS_BIDDING,
3838
}
3939

4040
k.SetBid(ctx, bid)
@@ -54,11 +54,11 @@ func (k Keeper) CancelBid(ctx sdk.Context, sender string, id uint64) error {
5454
return errorsmod.Wrap(types.ErrUnauthorized, "sender is not the bidder")
5555
}
5656

57-
if bid.Status != types.BidStatus_Bidding {
57+
if bid.Status != types.BidStatus_BID_STATUS_BIDDING {
5858
return types.ErrInvalidBidStatus
5959
}
6060

61-
bid.Status = types.BidStatus_Cancelled
61+
bid.Status = types.BidStatus_BID_STATUS_CANCELLED
6262
k.SetBid(ctx, bid)
6363

6464
return nil

x/auction/module/abci.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func EndBlocker(ctx sdk.Context, k keeper.Keeper) {
1717
// handlePendingAuctions handles the pending auctions
1818
func handlePendingAuctions(ctx sdk.Context, k keeper.Keeper) {
1919
// get pending auctions
20-
pendingAuctions := k.GetAuctions(ctx, types.AuctionStatus_AuctionOpen)
20+
pendingAuctions := k.GetAuctions(ctx, types.AuctionStatus_AUCTION_STATUS_OPEN)
2121

2222
for _, auction := range pendingAuctions {
2323
// get pending bids
@@ -41,7 +41,7 @@ func handlePendingAuctions(ctx sdk.Context, k keeper.Keeper) {
4141
auction.BiddedValue += bidValue
4242

4343
bid.BiddedAmount = bid.BidAmount
44-
bid.Status = types.BidStatus_Accepted
44+
bid.Status = types.BidStatus_BID_STATUS_ACCEPTED
4545

4646
// update bid
4747
k.SetBid(ctx, bid)
@@ -53,7 +53,7 @@ func handlePendingAuctions(ctx sdk.Context, k keeper.Keeper) {
5353

5454
// close auction if bidded value >= expected value
5555
if auction.BiddedValue >= auction.ExpectedValue {
56-
auction.Status = types.AuctionStatus_AuctionClose
56+
auction.Status = types.AuctionStatus_AUCTION_STATUS_CLOSED
5757
}
5858

5959
// update auction
@@ -66,7 +66,7 @@ func handlePendingAuctions(ctx sdk.Context, k keeper.Keeper) {
6666
// handleCompletedAuctions handles the completed auctions
6767
func handleCompletedAuctions(ctx sdk.Context, k keeper.Keeper) {
6868
// get completed auctions
69-
completedAuctions := k.GetAuctions(ctx, types.AuctionStatus_AuctionClose)
69+
completedAuctions := k.GetAuctions(ctx, types.AuctionStatus_AUCTION_STATUS_CLOSED)
7070

7171
for _, auction := range completedAuctions {
7272
// get pending bids

0 commit comments

Comments
 (0)