From 40ece271d0271c1c2ca968575ce242c458444e2b Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 24 Sep 2024 11:58:52 +0530 Subject: [PATCH] Fix auction funds release check --- api/cerc/auction/v1/auction.pulsar.go | 6 ++++-- proto/cerc/auction/v1/auction.proto | 2 ++ x/auction/auction.pb.go | 6 ++++-- x/auction/keeper/keeper.go | 4 ++-- x/auction/types.go | 3 --- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/api/cerc/auction/v1/auction.pulsar.go b/api/cerc/auction/v1/auction.pulsar.go index d7851989..97ccb909 100644 --- a/api/cerc/auction/v1/auction.pulsar.go +++ b/api/cerc/auction/v1/auction.pulsar.go @@ -3563,8 +3563,10 @@ type Auction struct { MaxPrice *v1beta1.Coin `protobuf:"bytes,14,opt,name=max_price,json=maxPrice,proto3" json:"max_price,omitempty"` // Number of desired providers (num of auction winners) // Only applicable in provider auctions - NumProviders int32 `protobuf:"varint,15,opt,name=num_providers,json=numProviders,proto3" json:"num_providers,omitempty"` - FundsReleased bool `protobuf:"varint,16,opt,name=funds_released,json=fundsReleased,proto3" json:"funds_released,omitempty"` + NumProviders int32 `protobuf:"varint,15,opt,name=num_providers,json=numProviders,proto3" json:"num_providers,omitempty"` + // Whether funds have been released to providers + // Only applicable in provider auctions + FundsReleased bool `protobuf:"varint,16,opt,name=funds_released,json=fundsReleased,proto3" json:"funds_released,omitempty"` } func (x *Auction) Reset() { diff --git a/proto/cerc/auction/v1/auction.proto b/proto/cerc/auction/v1/auction.proto index 9aea35fa..76e7ac29 100644 --- a/proto/cerc/auction/v1/auction.proto +++ b/proto/cerc/auction/v1/auction.proto @@ -95,6 +95,8 @@ message Auction { // Only applicable in provider auctions int32 num_providers = 15; + // Whether funds have been released to providers + // Only applicable in provider auctions bool funds_released = 16 [ (gogoproto.moretags) = "json:\"funds_released\" yaml:\"funds_released\"" ]; diff --git a/x/auction/auction.pb.go b/x/auction/auction.pb.go index 21a05dfa..65bda830 100644 --- a/x/auction/auction.pb.go +++ b/x/auction/auction.pb.go @@ -102,8 +102,10 @@ type Auction struct { MaxPrice types.Coin `protobuf:"bytes,14,opt,name=max_price,json=maxPrice,proto3" json:"max_price" json:"max_price" yaml:"max_price"` // Number of desired providers (num of auction winners) // Only applicable in provider auctions - NumProviders int32 `protobuf:"varint,15,opt,name=num_providers,json=numProviders,proto3" json:"num_providers,omitempty"` - FundsReleased bool `protobuf:"varint,16,opt,name=funds_released,json=fundsReleased,proto3" json:"funds_released,omitempty" json:"funds_released" yaml:"funds_released"` + NumProviders int32 `protobuf:"varint,15,opt,name=num_providers,json=numProviders,proto3" json:"num_providers,omitempty"` + // Whether funds have been released to providers + // Only applicable in provider auctions + FundsReleased bool `protobuf:"varint,16,opt,name=funds_released,json=fundsReleased,proto3" json:"funds_released,omitempty" json:"funds_released" yaml:"funds_released"` } func (m *Auction) Reset() { *m = Auction{} } diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index 040517d4..e7d038f4 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -931,14 +931,14 @@ func (k Keeper) ReleaseFunds(ctx sdk.Context, msg auctiontypes.MsgReleaseFunds) // Only the auction owner can release funds. if msg.Signer != auction.OwnerAddress { - return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Auction owner mismatch.") + return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Only auction owner can release funds.") } if auction.Status != auctiontypes.AuctionStatusCompleted { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction is not completed.") } - if auction.Status == auctiontypes.AuctionStatusFundsReleased { + if auction.FundsReleased { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Auction funds already released.") } diff --git a/x/auction/types.go b/x/auction/types.go index 17eaef2a..266f0c32 100644 --- a/x/auction/types.go +++ b/x/auction/types.go @@ -21,9 +21,6 @@ const ( // Auction has completed (winner selected). AuctionStatusCompleted = "completed" - - // Auction has completed (winner selected). - AuctionStatusFundsReleased = "funds_released" ) // Bid status values.