diff --git a/api/cerc/auction/v1/auction.pulsar.go b/api/cerc/auction/v1/auction.pulsar.go index 43b54561..d18f396d 100644 --- a/api/cerc/auction/v1/auction.pulsar.go +++ b/api/cerc/auction/v1/auction.pulsar.go @@ -3915,7 +3915,7 @@ type Auction struct { unknownFields protoimpl.UnknownFields Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - // Auction's kind (vickrey | service_provider) + // Auction's kind (vickrey | provider) Kind string `protobuf:"bytes,2,opt,name=kind,proto3" json:"kind,omitempty"` Status string `protobuf:"bytes,3,opt,name=status,proto3" json:"status,omitempty"` // Address of the creator of the auction @@ -3932,7 +3932,7 @@ type Auction struct { RevealFee *v1beta1.Coin `protobuf:"bytes,9,opt,name=reveal_fee,json=revealFee,proto3" json:"reveal_fee,omitempty"` // Minimum acceptable bid amount for a valid commit MinimumBid *v1beta1.Coin `protobuf:"bytes,10,opt,name=minimum_bid,json=minimumBid,proto3" json:"minimum_bid,omitempty"` - // Addresses of the winners (one for vickrey and can be multiple for service_provider) + // Addresses of the winners (one for vickrey auctions and can be multiple for provider auctions) WinnerAddresses []string `protobuf:"bytes,11,rep,name=winner_addresses,json=winnerAddresses,proto3" json:"winner_addresses,omitempty"` // Winning bids, i.e., the best bids WinningBids []*v1beta1.Coin `protobuf:"bytes,12,rep,name=winning_bids,json=winningBids,proto3" json:"winning_bids,omitempty"` diff --git a/api/cerc/auction/v1/tx.pulsar.go b/api/cerc/auction/v1/tx.pulsar.go index 0d4bb11e..9db13ab4 100644 --- a/api/cerc/auction/v1/tx.pulsar.go +++ b/api/cerc/auction/v1/tx.pulsar.go @@ -4311,7 +4311,7 @@ type MsgCreateAuction struct { MinimumBid *v1beta1.Coin `protobuf:"bytes,5,opt,name=minimum_bid,json=minimumBid,proto3" json:"minimum_bid,omitempty"` // Address of the signer Signer string `protobuf:"bytes,6,opt,name=signer,proto3" json:"signer,omitempty"` - // Auction's kind (vickrey | service_provider) + // Auction's kind (vickrey | provider) Kind string `protobuf:"bytes,7,opt,name=kind,proto3" json:"kind,omitempty"` // Maximum acceptable bid amount (for service provider auctions) MaxPrice *v1beta1.Coin `protobuf:"bytes,8,opt,name=max_price,json=maxPrice,proto3" json:"max_price,omitempty"` diff --git a/proto/cerc/auction/v1/auction.proto b/proto/cerc/auction/v1/auction.proto index 7de86476..c4ad059a 100644 --- a/proto/cerc/auction/v1/auction.proto +++ b/proto/cerc/auction/v1/auction.proto @@ -53,7 +53,7 @@ message Auction { string id = 1; - // Auction's kind (vickrey | service_provider) + // Auction's kind (vickrey | provider) string kind = 2 [ (gogoproto.moretags) = "json:\"kind\" yaml:\"kind\"" ]; @@ -101,7 +101,7 @@ message Auction { (gogoproto.moretags) = "json:\"minimum_bid\" yaml:\"minimum_bid\"" ]; - // Addresses of the winners (one for vickrey and can be multiple for service_provider) + // Addresses of the winners (one for vickrey auctions and can be multiple for provider auctions) repeated string winner_addresses = 11; // Winning bids, i.e., the best bids @@ -110,7 +110,7 @@ message Auction { (gogoproto.moretags) = "json:\"winning_bids\" yaml:\"winning_bids\"" ]; - // Amount the winner pays, i.e. the second best bid + // Amount the winner pays (vickrey auction) or gets paid (provider auction), i.e. the second best bid cosmos.base.v1beta1.Coin winning_price = 13 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "json:\"winning_price\" yaml:\"winning_price\"" diff --git a/proto/cerc/auction/v1/tx.proto b/proto/cerc/auction/v1/tx.proto index ec02f771..b4545513 100644 --- a/proto/cerc/auction/v1/tx.proto +++ b/proto/cerc/auction/v1/tx.proto @@ -77,7 +77,7 @@ message MsgCreateAuction { string signer = 6 [ (gogoproto.moretags) = "json:\"signer\" yaml:\"signer\"" ]; - // Auction's kind (vickrey | service_provider) + // Auction's kind (vickrey | provider) string kind = 7 [ (gogoproto.moretags) = "json:\"kind\" yaml:\"kind\"" ]; diff --git a/x/auction/auction.pb.go b/x/auction/auction.pb.go index 5f93c3c5..fc50802a 100644 --- a/x/auction/auction.pb.go +++ b/x/auction/auction.pb.go @@ -113,7 +113,7 @@ func (m *Params) GetMinimumBid() types.Coin { // Auction represents a sealed-bid on-chain auction type Auction struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - // Auction's kind (vickrey | service_provider) + // Auction's kind (vickrey | provider) Kind string `protobuf:"bytes,2,opt,name=kind,proto3" json:"kind,omitempty" json:"kind" yaml:"kind"` Status string `protobuf:"bytes,3,opt,name=status,proto3" json:"status,omitempty"` // Address of the creator of the auction @@ -130,7 +130,7 @@ type Auction struct { RevealFee types.Coin `protobuf:"bytes,9,opt,name=reveal_fee,json=revealFee,proto3" json:"reveal_fee" json:"reveal_fee" yaml:"reveal_fee"` // Minimum acceptable bid amount for a valid commit MinimumBid types.Coin `protobuf:"bytes,10,opt,name=minimum_bid,json=minimumBid,proto3" json:"minimum_bid" json:"minimum_bid" yaml:"minimum_bid"` - // Addresses of the winners (one for vickrey and can be multiple for service_provider) + // Addresses of the winners (one for vickrey auctions and can be multiple for provider auctions) WinnerAddresses []string `protobuf:"bytes,11,rep,name=winner_addresses,json=winnerAddresses,proto3" json:"winner_addresses,omitempty"` // Winning bids, i.e., the best bids WinningBids []types.Coin `protobuf:"bytes,12,rep,name=winning_bids,json=winningBids,proto3" json:"winning_bids" json:"winning_bids" yaml:"winning_bids"` diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index a884bfbe..dfd0ecec 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -341,12 +341,12 @@ func (k Keeper) CreateAuction(ctx sdk.Context, msg auctiontypes.MsgCreateAuction commitsEndTime := now.Add(msg.CommitsDuration) revealsEndTime := now.Add(msg.CommitsDuration + msg.RevealsDuration) - if msg.Kind == auctiontypes.AuctionKindServiceProvider { + if msg.Kind == auctiontypes.AuctionKindProvider { totalLockedAmount := sdk.NewCoin(msg.MaxPrice.Denom, msg.MaxPrice.Amount.MulRaw(int64(msg.NumProviders))) sdkErr := k.bankKeeper.SendCoinsFromAccountToModule(ctx, signerAddress, auctiontypes.ModuleName, sdk.NewCoins(totalLockedAmount)) if sdkErr != nil { - k.Logger(ctx).Error(fmt.Sprintf("Auction error transferring maximum_bid amount: %v", sdkErr)) + k.Logger(ctx).Error(fmt.Sprintf("Auction error transferring maximum price amount: %v", sdkErr)) panic(sdkErr) } } @@ -531,12 +531,12 @@ func (k Keeper) RevealBid(ctx sdk.Context, msg auctiontypes.MsgRevealBid) (*auct return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal bid amount.") } - if auction.Kind == "vickrey" && bidAmount.IsLT(auction.MinimumBid) { + if auction.Kind == auctiontypes.AuctionKindVickrey && bidAmount.IsLT(auction.MinimumBid) { return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bid is lower than minimum bid.") } - if auction.Kind == "service_provider" && bidAmount.IsGTE(auction.MaxPrice) { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bid is lower than minimum bid.") + if auction.Kind == auctiontypes.AuctionKindProvider && bidAmount.IsGTE(auction.MaxPrice) { + return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Bid is higher than maximum price.") } // Lock bid amount. @@ -630,7 +630,7 @@ func (k Keeper) processAuctionPhases(ctx sdk.Context) error { return err } } else { - if err = k.pickServiceProviderAuctionWinners(ctx, auction); err != nil { + if err = k.pickProviderAuctionWinners(ctx, auction); err != nil { return err } } @@ -754,8 +754,8 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *auctiontypes.Auction } } - // Process winner accounts (if nobody bids, there won't be a winner). - if len(auction.WinnerAddresses) == 0 { + // Process winner account (if nobody bids, there won't be a winner). + if len(auction.WinnerAddresses) == 1 { winnerAddress, err := sdk.AccAddressFromBech32(auction.WinnerAddresses[0]) if err != nil { k.Logger(ctx).Error(fmt.Sprintf("Invalid winner address. %v", err)) @@ -799,8 +799,8 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *auctiontypes.Auction return nil } -// Pick winner for service_provider auction -func (k Keeper) pickServiceProviderAuctionWinners(ctx sdk.Context, auction *auctiontypes.Auction) error { +// Pick winner for provider auction +func (k Keeper) pickProviderAuctionWinners(ctx sdk.Context, auction *auctiontypes.Auction) error { k.Logger(ctx).Info(fmt.Sprintf("Picking auction %s winners.", auction.Id)) bids, err := k.GetBids(ctx, auction.Id) @@ -848,7 +848,6 @@ func (k Keeper) pickServiceProviderAuctionWinners(ctx sdk.Context, auction *auct } auction.WinnerAddresses = winnerAddresses auction.WinningBids = winningBids - auction.WinningPrice = winnerBids[0].BidAmount if len(winnerBids) > 0 { // The last best bid is the winning price diff --git a/x/auction/msgs.go b/x/auction/msgs.go index db8888ea..2ed0cc69 100644 --- a/x/auction/msgs.go +++ b/x/auction/msgs.go @@ -68,7 +68,7 @@ func (msg MsgCreateAuction) ValidateBasic() error { return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "minimum bid should be greater than zero.") } - if msg.Kind == AuctionKindServiceProvider && !msg.MaxPrice.IsPositive() { + if msg.Kind == AuctionKindProvider && !msg.MaxPrice.IsPositive() { return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "maximum price should be greater than zero.") } diff --git a/x/auction/tx.pb.go b/x/auction/tx.pb.go index d5217415..d7df6dda 100644 --- a/x/auction/tx.pb.go +++ b/x/auction/tx.pb.go @@ -50,7 +50,7 @@ type MsgCreateAuction struct { MinimumBid types.Coin `protobuf:"bytes,5,opt,name=minimum_bid,json=minimumBid,proto3" json:"minimum_bid" json:"minimum_bid" yaml:"minimum_bid"` // Address of the signer Signer string `protobuf:"bytes,6,opt,name=signer,proto3" json:"signer,omitempty" json:"signer" yaml:"signer"` - // Auction's kind (vickrey | service_provider) + // Auction's kind (vickrey | provider) Kind string `protobuf:"bytes,7,opt,name=kind,proto3" json:"kind,omitempty" json:"kind" yaml:"kind"` // Maximum acceptable bid amount (for service provider auctions) MaxPrice types.Coin `protobuf:"bytes,8,opt,name=max_price,json=maxPrice,proto3" json:"max_price" json:"max_price" yaml:"max_price"` diff --git a/x/auction/types.go b/x/auction/types.go index 02ac8b38..266f0c32 100644 --- a/x/auction/types.go +++ b/x/auction/types.go @@ -31,8 +31,8 @@ const ( // Auction kinds const ( - AuctionKindVickrey = "vickrey" - AuctionKindServiceProvider = "service_provider" + AuctionKindVickrey = "vickrey" + AuctionKindProvider = "provider" ) // AuctionId simplifies generation of auction ids.