Add service provider auctions #59

Merged
nabarun merged 29 commits from deep-stack/laconicd:iv-service-provider-auction into main 2024-09-25 12:38:50 +00:00
2 changed files with 10 additions and 5 deletions
Showing only changes of commit fb66b9aed5 - Show all commits

View File

@ -233,7 +233,8 @@ func GetGQLAuction(auction *auctiontypes.Auction, bids []*auctiontypes.Bid) (*Au
} }
winnerAddresses := make([]*string, len(auction.WinnerAddresses)) winnerAddresses := make([]*string, len(auction.WinnerAddresses))
for i, addr := range auction.WinnerAddresses { for i := range auction.WinnerAddresses {
addr := auction.WinnerAddresses[i]
winnerAddresses[i] = &addr winnerAddresses[i] = &addr
} }

View File

@ -16,7 +16,6 @@ import (
"cosmossdk.io/math" "cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper" auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
@ -805,7 +804,7 @@ func (k Keeper) pickServiceProviderAuctionWinner(ctx sdk.Context, auction *aucti
return err return err
} }
var revealedBids []*auctiontypes.Bid revealedBids := make([]*auctiontypes.Bid, 0, len(bids))
for _, bid := range bids { for _, bid := range bids {
k.Logger(ctx).Info(fmt.Sprintf("Processing bid %s %s", bid.BidderAddress, bid.BidAmount.String())) k.Logger(ctx).Info(fmt.Sprintf("Processing bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
@ -838,7 +837,7 @@ func (k Keeper) pickServiceProviderAuctionWinner(ctx sdk.Context, auction *aucti
if len(winnerBids) > 0 { if len(winnerBids) > 0 {
winnerAddresses := make([]string, len(winnerBids)) winnerAddresses := make([]string, len(winnerBids))
winningBids := make([]types.Coin, len(winnerBids)) winningBids := make([]sdk.Coin, len(winnerBids))
for i, bid := range winnerBids { for i, bid := range winnerBids {
winnerAddresses[i] = bid.BidderAddress winnerAddresses[i] = bid.BidderAddress
winningBids[i] = bid.BidAmount winningBids[i] = bid.BidAmount
@ -904,7 +903,12 @@ func (k Keeper) pickServiceProviderAuctionWinner(ctx sdk.Context, auction *aucti
extraAmountCoin := sdk.NewCoin(auction.MaxPrice.Denom, totalMaxBidAmount.Sub(totalAmountPaid)) extraAmountCoin := sdk.NewCoin(auction.MaxPrice.Denom, totalMaxBidAmount.Sub(totalAmountPaid))
sdkErrCreator := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, auctiontypes.ModuleName, sdk.AccAddress(auction.OwnerAddress), sdk.NewCoins(extraAmountCoin)) sdkErrCreator := k.bankKeeper.SendCoinsFromModuleToAccount(
ctx,
auctiontypes.ModuleName,
sdk.AccAddress(auction.OwnerAddress),
sdk.NewCoins(extraAmountCoin),
)
if sdkErrCreator != nil { if sdkErrCreator != nil {
k.Logger(ctx).Error(fmt.Sprintf("Auction error returning bid amount: %v", sdkErrCreator)) k.Logger(ctx).Error(fmt.Sprintf("Auction error returning bid amount: %v", sdkErrCreator))
panic(sdkErrCreator) panic(sdkErrCreator)