2019-11-25 19:46:02 +00:00
|
|
|
package auction
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
// NewHandler returns a function to handle all "auction" type messages.
|
|
|
|
func NewHandler(keeper Keeper) sdk.Handler {
|
|
|
|
return func(ctx sdk.Context, msg sdk.Msg) sdk.Result {
|
|
|
|
switch msg := msg.(type) {
|
|
|
|
case MsgPlaceBid:
|
|
|
|
return handleMsgPlaceBid(ctx, keeper, msg)
|
|
|
|
default:
|
|
|
|
errMsg := fmt.Sprintf("Unrecognized auction msg type: %T", msg)
|
|
|
|
return sdk.ErrUnknownRequest(errMsg).Result()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func handleMsgPlaceBid(ctx sdk.Context, keeper Keeper, msg MsgPlaceBid) sdk.Result {
|
|
|
|
|
2020-01-09 14:58:47 +00:00
|
|
|
err := keeper.PlaceBid(ctx, msg.AuctionID, msg.Bidder, msg.Amount)
|
2019-11-25 19:46:02 +00:00
|
|
|
if err != nil {
|
|
|
|
return err.Result()
|
|
|
|
}
|
|
|
|
|
|
|
|
return sdk.Result{}
|
|
|
|
}
|