Merge pull request #699 from lino-network/builder

Encapsulate Get Passphrase Logic in Builder
This commit is contained in:
Ethan Buchman
2018-03-27 20:25:48 -04:00
committed by GitHub
6 changed files with 21 additions and 48 deletions
+2 -18
View File
@@ -36,16 +36,8 @@ func QuizTxCmd(cdc *wire.Codec) *cobra.Command {
// get account name
name := viper.GetString(client.FlagName)
// get password
buf := client.BufferStdin()
prompt := fmt.Sprintf("Password to sign with '%s':", name)
passphrase, err := client.GetPassword(prompt, buf)
if err != nil {
return err
}
// build and sign the transaction, then broadcast to Tendermint
res, err := builder.SignBuildBroadcast(name, passphrase, msg, cdc)
res, err := builder.SignBuildBroadcast(name, msg, cdc)
if err != nil {
return err
}
@@ -75,19 +67,11 @@ func SetTrendTxCmd(cdc *wire.Codec) *cobra.Command {
// get account name
name := viper.GetString(client.FlagName)
// get password
buf := client.BufferStdin()
prompt := fmt.Sprintf("Password to sign with '%s':", name)
passphrase, err := client.GetPassword(prompt, buf)
if err != nil {
return err
}
// create the message
msg := cool.NewSetTrendMsg(from, args[0])
// build and sign the transaction, then broadcast to Tendermint
res, err := builder.SignBuildBroadcast(name, passphrase, msg, cdc)
res, err := builder.SignBuildBroadcast(name, msg, cdc)
if err != nil {
return err
}