Skip to content

Commit

Permalink
Make cosmwasmpool's create pool cli generic (#6388) (#6472)
Browse files Browse the repository at this point in the history
* make create pool generic

* update changelog

(cherry picked from commit ebb31b6)

Co-authored-by: Supanat <[email protected]>
  • Loading branch information
mergify[bot] and iboss-ptk authored Sep 20, 2023
1 parent 16e7593 commit f69fd8c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* [#6371](https://github.com/osmosis-labs/osmosis/pull/6371) Change PoolI.SpotPrice API from Dec (18 decimals) to BigDec (36 decimals), maintain state-compatibility.

### Client Breaks
* [#6388](https://github.com/osmosis-labs/osmosis/pull/6388) Make cosmwasmpool's create pool cli generic

## v19.0.0

### Features
Expand Down
18 changes: 9 additions & 9 deletions x/cosmwasmpool/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/spf13/pflag"

"github.com/osmosis-labs/osmosis/osmoutils/osmocli"
"github.com/osmosis-labs/osmosis/v19/x/cosmwasmpool/cosmwasm/msg"
"github.com/osmosis-labs/osmosis/v19/x/cosmwasmpool/model"
"github.com/osmosis-labs/osmosis/v19/x/cosmwasmpool/types"
)
Expand All @@ -32,7 +31,7 @@ func NewCreateCWPoolCmd() (*osmocli.TxCliDesc, *model.MsgCreateCosmWasmPool) {
return &osmocli.TxCliDesc{
Use: "create-pool",
Short: "create a cosmwasm pool",
Example: "osmosisd tx cosmwasmpool create-pool 1 uion,uosmo --from lo-test1 --keyring-backend test --chain-id localosmosis --fees 875uosmo -b=block",
Example: "osmosisd tx cosmwasmpool create-pool 1 '{\"pool_assets_denom\":[\"uion\",\"uosmo\"]}' --from lo-test1 --keyring-backend test --chain-id localosmosis --fees 875uosmo -b=block",
NumArgs: 2,
ParseAndBuildMsg: BuildCreatePoolMsg,
}, &model.MsgCreateCosmWasmPool{}
Expand All @@ -44,17 +43,18 @@ func BuildCreatePoolMsg(clientCtx client.Context, args []string, flags *pflag.Fl
return nil, err
}

denoms := strings.Split(args[1], ",")
instantiateMsg := args[1]

// Construct instantiate msg
instantiateMsg := &msg.InstantiateMsg{
PoolAssetDenoms: denoms,
}
msgBz, err := json.Marshal(instantiateMsg)
// Check JSON format for instantiateMsg
var jsonCheck map[string]interface{}
err = json.Unmarshal([]byte(instantiateMsg), &jsonCheck)
if err != nil {
return nil, err
return nil, fmt.Errorf("invalid JSON format for instantiateMsg: %v", err)
}

// Turn instantiateMsg to bytes
msgBz := []byte(instantiateMsg)

return &model.MsgCreateCosmWasmPool{
CodeId: codeId,
InstantiateMsg: msgBz,
Expand Down

0 comments on commit f69fd8c

Please sign in to comment.