mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-27 00:35:18 +00:00
31 lines
710 B
Go
31 lines
710 B
Go
|
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 {
|
||
|
|
||
|
err := keeper.PlaceBid(ctx, msg.AuctionID, msg.Bidder, msg.Bid, msg.Lot)
|
||
|
if err != nil {
|
||
|
return err.Result()
|
||
|
}
|
||
|
|
||
|
return sdk.Result{}
|
||
|
}
|