From 0c9322f0968c32d61e92d7044ccefd6b4eb67006 Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Mon, 25 Sep 2023 00:29:37 -0500 Subject: [PATCH] Fixing cancel order bug --- x/market/keeper/msg_server_cancel_order.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/x/market/keeper/msg_server_cancel_order.go b/x/market/keeper/msg_server_cancel_order.go index cf75a4f9..742e9a57 100644 --- a/x/market/keeper/msg_server_cancel_order.go +++ b/x/market/keeper/msg_server_cancel_order.go @@ -85,6 +85,15 @@ func (k msgServer) CancelOrder(goCtx context.Context, msg *types.MsgCancelOrder) } } + coinBid := sdk.NewCoin(order.DenomBid, order.Amount) + coinsBid := sdk.NewCoins(coinBid) + + // Transfer order amount to module + sdkError := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sdk.AccAddress(msg.Creator), coinsBid) + if sdkError != nil { + return nil, sdkError + } + order.Status = "canceled" order.UpdTime = ctx.BlockHeader().Time.Unix() k.RemoveOrderOwner(ctx, order.Owner, order.Uid)