Skip to content

Commit

Permalink
Add in first section of create-pool msg logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Dusek committed Apr 18, 2024
1 parent 3ab4ee5 commit fa11df4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion x/market/keeper/msg_server_create_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,34 @@ import (
"context"

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

sdk "github.com/cosmos/cosmos-sdk/types"
)

func (k msgServer) CreatePool(goCtx context.Context, msg *types.MsgCreatePool) (*types.MsgCreatePoolResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

// TODO: Handling the message
// CoinAmsg and CoinBmsg pre-sort from raw msg
coinA, err := sdk.ParseCoinNormalized(msg.CoinA)
if err != nil {
panic(err)
}

coinB, err := sdk.ParseCoinNormalized(msg.CoinB)
if err != nil {
panic(err)
}

coinPair := sdk.NewCoins(coinA, coinB)

// NewCoins sorts denoms.
// The sorted pair joined by "," is used as the key for the pool.
denom1 := coinPair.GetDenomByIndex(0)
denom2 := coinPair.GetDenomByIndex(1)
pair := strings.Join([]string{denom1, denom2}, ",")

_ = pair
_ = ctx

return &types.MsgCreatePoolResponse{}, nil
Expand Down

0 comments on commit fa11df4

Please sign in to comment.