Clean up nonce wrapper in cli

This commit is contained in:
Ethan Frey
2017-07-18 12:08:29 +02:00
parent 23615c5d37
commit 6d35b1f934
3 changed files with 29 additions and 32 deletions
@@ -1,8 +1,6 @@
package commands
import (
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@@ -13,7 +11,6 @@ import (
"github.com/tendermint/basecoin/docs/guide/counter/plugins/counter"
"github.com/tendermint/basecoin/modules/auth"
"github.com/tendermint/basecoin/modules/coin"
"github.com/tendermint/basecoin/modules/nonce"
)
//CounterTxCmd is the CLI command to execute the counter
@@ -58,10 +55,6 @@ func counterTx(cmd *cobra.Command, args []string) error {
return err
}
//get the nonce accounts
var addr []byte
nonceAccount := []basecoin.Actor{basecoin.NewActor(counter.NameCounter, addr)}
// TODO: make this more flexible for middleware
tx, err = bcmd.WrapFeeTx(tx)
if err != nil {
@@ -71,13 +64,10 @@ func counterTx(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
//add the nonce tx layer to the tx
seq := viper.GetInt(FlagSequence)
if seq < 0 {
return fmt.Errorf("sequence must be greater than 0")
tx, err = bcmd.WrapNonceTx(tx)
if err != nil {
return err
}
tx = nonce.NewTx(uint32(seq), nonceAccount, tx)
stx := auth.NewSig(tx)