Skip to content

Commit

Permalink
update cli
Browse files Browse the repository at this point in the history
  • Loading branch information
vuong177 committed Jun 19, 2023
1 parent 26fd667 commit 5a6b26e
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 3 deletions.
71 changes: 71 additions & 0 deletions x/transfermiddleware/client/cli/tx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package cli

import (
"fmt"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/version"
"github.com/notional-labs/centauri/v3/x/transfermiddleware/types"
"github.com/spf13/cobra"
)

// GetTxCmd returns the tx commands for router
func GetTxCmd() *cobra.Command {
txCmd := &cobra.Command{
Use: "transfermiddleware",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
Short: "Registry and remove IBC dotsama chain infomation",
Long: "Registry and remove IBC dotsama chain infomation",
}

txCmd.AddCommand(
RegistryDotSamaChain(),
)

return txCmd
}

// RegistryDotSamaChain returns the command handler for registry dotsame token info.
func RegistryDotSamaChain() *cobra.Command {
cmd := &cobra.Command{
Use: "registry",
Short: "registry dotsama chain infomation",
Long: "registry dotsama chain infomation",
Args: cobra.MatchAll(cobra.ExactArgs(4), cobra.OnlyValidArgs),
Example: fmt.Sprintf("%s tx transfermiddleware registry [ibc_denom] [native_denom] [asset_id] [channel_id]", version.AppName),
RunE: func(cmd *cobra.Command, args []string) error {
ibcDenom := args[0]
nativeDenom := args[1]
assetID := args[2]
channelID := args[3]

clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

fromAddress := clientCtx.GetFromAddress().String()

msg := types.NewMsgAddParachainIBCTokenInfo(
fromAddress,
ibcDenom,
nativeDenom,
assetID,
channelID,
)

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

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}
2 changes: 1 addition & 1 deletion x/transfermiddleware/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r

// GetTxCmd implements AppModuleBasic interface
func (AppModuleBasic) GetTxCmd() *cobra.Command {
return cli.NewTxCmd()
return cli.GetTxCmd()
}

// GetQueryCmd implements AppModuleBasic interface
Expand Down
6 changes: 4 additions & 2 deletions x/transfermiddleware/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ var _ sdk.Msg = &MsgAddParachainIBCTokenInfo{}
func NewMsgAddParachainIBCTokenInfo(
authority string,
ibcDenom string,
channelID string,
nativeDenom string,
assetID string,
channelID string,
) *MsgAddParachainIBCTokenInfo {
return &MsgAddParachainIBCTokenInfo{
Authority: authority,
IbcDenom: ibcDenom,
ChannelId: channelID,
NativeDenom: nativeDenom,
AssetId: assetID,
ChannelId: channelID,
}
}

Expand Down

0 comments on commit 5a6b26e

Please sign in to comment.