Skip to content

Commit c96d8f3

Browse files
alexanderbezcwgoes
authored andcommitted
Merge PR #3713: Use from instead of name CLI flag for the tx sign cmd
* Use from instead of name CLI flag for the tx sign cmd * Use cliCtx.GetFromName() instead of direct from value
1 parent b823203 commit c96d8f3

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

PENDING.md

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ decoded automatically.
4444

4545
### Gaia CLI
4646

47+
* [\#3711] Update `tx sign` to use `--from` instead of the deprecated `--name`
48+
CLI flag.
49+
4750
### Gaia
4851

4952
### SDK

cmd/gaia/cli_test/test_helpers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ func (f *Fixtures) TxSend(from string, to sdk.AccAddress, amount sdk.Coin, flags
290290

291291
// TxSign is gaiacli tx sign
292292
func (f *Fixtures) TxSign(signer, fileName string, flags ...string) (bool, string, string) {
293-
cmd := fmt.Sprintf("gaiacli tx sign %v --name=%s %v", f.Flags(), signer, fileName)
293+
cmd := fmt.Sprintf("gaiacli tx sign %v --from=%s %v", f.Flags(), signer, fileName)
294294
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), app.DefaultKeyPass)
295295
}
296296

x/auth/client/cli/sign.go

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package cli
22

33
import (
4-
"errors"
54
"fmt"
65
"os"
76

87
"github.com/spf13/cobra"
98
"github.com/spf13/viper"
10-
"github.com/tendermint/go-amino"
9+
amino "github.com/tendermint/go-amino"
1110

1211
"github.com/cosmos/cosmos-sdk/client"
1312
"github.com/cosmos/cosmos-sdk/client/context"
@@ -55,7 +54,7 @@ be generated via the 'multisign' command.
5554
RunE: makeSignCmd(codec),
5655
Args: cobra.ExactArgs(1),
5756
}
58-
cmd.Flags().String(client.FlagName, "", "Name of private key with which to sign")
57+
5958
cmd.Flags().String(flagMultisig, "",
6059
"Address of the multisig account on behalf of which the "+
6160
"transaction shall be signed")
@@ -69,7 +68,7 @@ be generated via the 'multisign' command.
6968
cmd.Flags().String(flagOutfile, "",
7069
"The document will be written to the given file instead of STDOUT")
7170

72-
// Add the flags here and return the command
71+
// add the flags here and return the command
7372
return client.PostCommands(cmd)[0]
7473
}
7574

@@ -92,9 +91,9 @@ func makeSignCmd(cdc *amino.Codec) func(cmd *cobra.Command, args []string) error
9291
return nil
9392
}
9493

95-
name := viper.GetString(client.FlagName)
96-
if name == "" {
97-
return errors.New("required flag \"name\" has not been set")
94+
from := viper.GetString(client.FlagFrom)
95+
if from == "" {
96+
return fmt.Errorf("required flag '%s' has not been set", client.FlagFrom)
9897
}
9998

10099
// if --signature-only is on, then override --append
@@ -104,19 +103,21 @@ func makeSignCmd(cdc *amino.Codec) func(cmd *cobra.Command, args []string) error
104103

105104
if multisigAddrStr != "" {
106105
var multisigAddr sdk.AccAddress
106+
107107
multisigAddr, err = sdk.AccAddressFromBech32(multisigAddrStr)
108108
if err != nil {
109109
return err
110110
}
111111

112112
newTx, err = utils.SignStdTxWithSignerAddress(
113-
txBldr, cliCtx, multisigAddr, name, stdTx, offline)
113+
txBldr, cliCtx, multisigAddr, cliCtx.GetFromName(), stdTx, offline,
114+
)
114115
generateSignatureOnly = true
115116
} else {
116117
appendSig := viper.GetBool(flagAppend) && !generateSignatureOnly
117-
newTx, err = utils.SignStdTx(
118-
txBldr, cliCtx, name, stdTx, appendSig, offline)
118+
newTx, err = utils.SignStdTx(txBldr, cliCtx, cliCtx.GetFromName(), stdTx, appendSig, offline)
119119
}
120+
120121
if err != nil {
121122
return err
122123
}
@@ -128,13 +129,16 @@ func makeSignCmd(cdc *amino.Codec) func(cmd *cobra.Command, args []string) error
128129
switch cliCtx.Indent {
129130
case true:
130131
json, err = cdc.MarshalJSONIndent(newTx.Signatures[0], "", " ")
132+
131133
default:
132134
json, err = cdc.MarshalJSON(newTx.Signatures[0])
133135
}
136+
134137
default:
135138
switch cliCtx.Indent {
136139
case true:
137140
json, err = cdc.MarshalJSONIndent(newTx, "", " ")
141+
138142
default:
139143
json, err = cdc.MarshalJSON(newTx)
140144
}

0 commit comments

Comments
 (0)