From 22e46c5e701a12eb8c536ce217f8b1cc202ed899 Mon Sep 17 00:00:00 2001 From: Alexander Bezobchuk Date: Wed, 5 Jun 2019 20:58:44 -0400 Subject: [PATCH] Merge PR #37: Revert removal of auth/bank commands from root --- .../breaking/gaiacli/Bank-and-Auth-module | 3 --- cli_test/test_helpers.go | 8 +++---- cmd/gaiacli/main.go | 24 +++++++++++++++++-- 3 files changed, 26 insertions(+), 9 deletions(-) delete mode 100644 .pending/breaking/gaiacli/Bank-and-Auth-module diff --git a/.pending/breaking/gaiacli/Bank-and-Auth-module b/.pending/breaking/gaiacli/Bank-and-Auth-module deleted file mode 100644 index 5130770de..000000000 --- a/.pending/breaking/gaiacli/Bank-and-Auth-module +++ /dev/null @@ -1,3 +0,0 @@ -Bank and Auth module commands are now mounted under their respective module: - * `sign` and `multisign` are under `gaiacli tx auth` - * `send` is under `gaiacli tx bank` diff --git a/cli_test/test_helpers.go b/cli_test/test_helpers.go index 6877da46a..5b926a41f 100644 --- a/cli_test/test_helpers.go +++ b/cli_test/test_helpers.go @@ -309,7 +309,7 @@ func (f *Fixtures) CLIConfig(key, value string, flags ...string) { // TxSend is gaiacli tx send func (f *Fixtures) TxSend(from string, to sdk.AccAddress, amount sdk.Coin, flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("%s tx bank send %s %s %s %v", f.GaiacliBinary, from, to, amount, f.Flags()) + cmd := fmt.Sprintf("%s tx send %s %s %s %v", f.GaiacliBinary, from, to, amount, f.Flags()) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), client.DefaultKeyPass) } @@ -317,13 +317,13 @@ func (f *Fixtures) txSendWithConfirm( from string, to sdk.AccAddress, amount sdk.Coin, confirm string, flags ...string, ) (bool, string, string) { - cmd := fmt.Sprintf("%s tx bank send %s %s %s %v", f.GaiacliBinary, from, to, amount, f.Flags()) + cmd := fmt.Sprintf("%s tx send %s %s %s %v", f.GaiacliBinary, from, to, amount, f.Flags()) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), confirm, client.DefaultKeyPass) } // TxSign is gaiacli tx sign func (f *Fixtures) TxSign(signer, fileName string, flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("%s tx auth sign %v --from=%s %v", f.GaiacliBinary, f.Flags(), signer, fileName) + cmd := fmt.Sprintf("%s tx sign %v --from=%s %v", f.GaiacliBinary, f.Flags(), signer, fileName) return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), client.DefaultKeyPass) } @@ -343,7 +343,7 @@ func (f *Fixtures) TxEncode(fileName string, flags ...string) (bool, string, str func (f *Fixtures) TxMultisign(fileName, name string, signaturesFiles []string, flags ...string) (bool, string, string) { - cmd := fmt.Sprintf("%s tx auth multisign %v %s %s %s", f.GaiacliBinary, f.Flags(), + cmd := fmt.Sprintf("%s tx multisign %v %s %s %s", f.GaiacliBinary, f.Flags(), fileName, name, strings.Join(signaturesFiles, " "), ) return executeWriteRetStdStreams(f.T, cmd) diff --git a/cmd/gaiacli/main.go b/cmd/gaiacli/main.go index 7d6243f90..6581121d3 100644 --- a/cmd/gaiacli/main.go +++ b/cmd/gaiacli/main.go @@ -5,8 +5,6 @@ import ( "os" "path" - "github.com/cosmos/gaia/app" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/client/lcd" @@ -14,12 +12,18 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" + "github.com/cosmos/cosmos-sdk/x/auth" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" + "github.com/cosmos/cosmos-sdk/x/bank" + bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli" + "github.com/spf13/cobra" "github.com/spf13/viper" "github.com/tendermint/go-amino" "github.com/tendermint/tendermint/libs/cli" + + "github.com/cosmos/gaia/app" ) func main() { @@ -106,6 +110,11 @@ func txCmd(cdc *amino.Codec) *cobra.Command { } txCmd.AddCommand( + bankcmd.SendTxCmd(cdc), + client.LineBreak, + authcmd.GetSignCommand(cdc), + authcmd.GetMultiSignCommand(cdc), + client.LineBreak, tx.GetBroadcastCommand(cdc), tx.GetEncodeCommand(cdc), client.LineBreak, @@ -114,6 +123,17 @@ func txCmd(cdc *amino.Codec) *cobra.Command { // add modules' tx commands app.ModuleBasics.AddTxCommands(txCmd, cdc) + // remove auth and bank commands as they're mounted under the root tx command + var cmdsToRemove []*cobra.Command + + for _, cmd := range txCmd.Commands() { + if cmd.Use == auth.ModuleName || cmd.Use == bank.ModuleName { + cmdsToRemove = append(cmdsToRemove, cmd) + } + } + + txCmd.RemoveCommand(cmdsToRemove...) + return txCmd }