Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add host cli to generate ica packet data #2297

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
22d9e1b
wip: adding command to display json value for interchain packet data
chatton Sep 14, 2022
3ecdc1d
tests: adding tests for generatePacketData
chatton Sep 15, 2022
1f12260
Merge branch 'main' into cian/issue#2243-add-a-ics27-host-cli-to-gene…
chatton Sep 15, 2022
fe4880a
chore: adding changelog entry
chatton Sep 15, 2022
4f3ef30
chore: fix useless assignment to local var
chatton Sep 15, 2022
4e6ed4e
chore: fix typo
chatton Sep 15, 2022
47abc0b
Merge branch 'main' into cian/issue#2243-add-a-ics27-host-cli-to-gene…
chatton Sep 19, 2022
96f1f24
Merge branch 'main' into cian/issue#2243-add-a-ics27-host-cli-to-gene…
chatton Sep 20, 2022
e067218
Merge branch 'main' into cian/issue#2243-add-a-ics27-host-cli-to-gene…
chatton Sep 21, 2022
8645a8b
chore: addressing PR feedback
chatton Sep 21, 2022
d520833
Merge branch 'main' into cian/issue#2243-add-a-ics27-host-cli-to-gene…
chatton Sep 21, 2022
2a43f5c
chore: merge main
chatton Sep 22, 2022
c5f7fdd
Merge branch 'main' into cian/issue#2243-add-a-ics27-host-cli-to-gene…
chatton Sep 22, 2022
cf2179f
chore: bumping imports
chatton Sep 22, 2022
d477702
Merge branch 'cian/issue#2243-add-a-ics27-host-cli-to-generate-ica-pa…
chatton Sep 22, 2022
5ae13d3
feat: adding support for both single and multiple messages
chatton Sep 23, 2022
e306637
chore: addressing PR feedback
chatton Sep 26, 2022
7411b53
Update modules/apps/27-interchain-accounts/host/client/cli/cli.go
chatton Sep 26, 2022
5076fbd
Merge branch 'main' into cian/issue#2243-add-a-ics27-host-cli-to-gene…
chatton Sep 27, 2022
30b7907
chore: use version AppName variable
chatton Sep 27, 2022
8bfbf57
Merge branch 'main' into cian/issue#2243-add-a-ics27-host-cli-to-gene…
chatton Sep 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
wip: adding command to display json value for interchain packet data
  • Loading branch information
chatton committed Sep 14, 2022
commit 22d9e1b341b79b131893cd1ad85f1dfe8362fc02
1 change: 1 addition & 0 deletions modules/apps/27-interchain-accounts/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func NewTxCmd() *cobra.Command {

icaTxCmd.AddCommand(
controllercli.NewTxCmd(),
hostcli.NewTxCmd(),
)

return icaTxCmd
Expand Down
18 changes: 18 additions & 0 deletions modules/apps/27-interchain-accounts/host/client/cli/cli.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cli

import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/spf13/cobra"
)

Expand All @@ -20,3 +21,20 @@ func GetQueryCmd() *cobra.Command {

return queryCmd
}

// NewTxCmd creates and returns the tx command
func NewTxCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "host",
Short: "interchain-accounts host subcommands",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Short: "interchain-accounts host subcommands",
Short: "IBC interchain accounts host transaction subcommands",

See this PR.

DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}

cmd.AddCommand(
generatePacketData(),
)

return cmd
}
61 changes: 61 additions & 0 deletions modules/apps/27-interchain-accounts/host/client/cli/tx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package cli

import (
"strings"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/spf13/cobra"

icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types"
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
)

func generatePacketData() *cobra.Command {
cmd := &cobra.Command{
Use: "generate-packet-data [message]",
Short: "Generate ICA packet data.",
Long: strings.TrimSpace(`Generate ICA packet data.`), // TODO write more here
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry)

var msg sdk.Msg
if err := cdc.UnmarshalInterfaceJSON([]byte(args[0]), &msg); err != nil {
return err
}

icaPacketDataBytes, err := icatypes.SerializeCosmosTx(cdc, []sdk.Msg{msg})
if err != nil {
return err
}

memo, err := cmd.Flags().GetString("memo")
if err != nil {
return err
}

icaPacketData := icatypes.InterchainAccountPacketData{
Type: icatypes.EXECUTE_TX,
Data: icaPacketDataBytes,
Memo: memo,
}

if err := icaPacketData.ValidateBasic(); err != nil {
return err
}

jsonBytes := cdc.MustMarshalJSON(&icaPacketData)
cmd.Println(string(jsonBytes))
return nil
},
}

cmd.Flags().String("memo", "", "")
return cmd
}