auction creation msg

master
michael 2022-08-28 02:48:00 +00:00
parent e33adb1dbf
commit ac5e2637cb
1 changed files with 23 additions and 3 deletions

View File

@ -2,16 +2,36 @@ package keeper
import (
"context"
"errors"
"strconv"
"cosmos-test/x/cosmostest/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
func (k msgServer) NewAuction(goCtx context.Context, msg *types.MsgNewAuction) (*types.MsgNewAuctionResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
// TODO: Handling the message
_ = ctx
next, found := k.Keeper.GetNextAuction(ctx)
if !found {
return nil, errors.New("Auction not found")
}
index := strconv.FormatUint(next.AuctionId, 10)
return &types.MsgNewAuctionResponse{}, nil
auction := types.Auction{
Index: index,
Name: msg.Name,
Description: msg.Description,
Bids: []*types.Bid{},
}
k.Keeper.SetAuction(ctx, auction)
next.AuctionId++
k.Keeper.SetNextAuction(ctx, types.NextAuction{next.AuctionId})
return &types.MsgNewAuctionResponse{
AuctionId: strconv.FormatUint(next.AuctionId, 10),
}, nil
}