Skip to content

Commit

Permalink
Add logic to create drop
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Dusek committed Apr 19, 2024
1 parent 191babb commit 09d63b1
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions x/market/keeper/msg_server_create_drop.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,44 @@ package keeper

import (
"context"

"onex/x/market/types"
"sort"
"strings"

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
)

func (k msgServer) CreateDrop(goCtx context.Context, msg *types.MsgCreateDrop) (*types.MsgCreateDropResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

// TODO: Handling the message
_ = ctx
pairMsg := strings.Split(msg.Pair, ",")
sort.Strings(pairMsg)

denomA := pairMsg[0]
denomB := pairMsg[1]

pool, found := k.GetPool(ctx, denomA, denomB)
if !found {
return nil, types.ErrPoolNotFound
}

if pool.Drops.Equal(math.ZeroInt()) {
return nil, types.ErrPoolInactive
}

memberA, found := k.GetMember(ctx, denomB, denomA)
if !found {
return nil, types.ErrMemberNotFound
}

memberB, found := k.GetMember(ctx, denomA, denomB)
if !found {
return nil, types.ErrMemberNotFound
}

_ = memberA
_ = memberB

return &types.MsgCreateDropResponse{}, nil
}

0 comments on commit 09d63b1

Please sign in to comment.