diff --git a/client/builder/builder.go b/client/builder/builder.go index 31e518949..e252f40af 100644 --- a/client/builder/builder.go +++ b/client/builder/builder.go @@ -88,7 +88,16 @@ func GetFromAddress() (from sdk.Address, err error) { } // sign and build the transaction from the msg -func SignAndBuild(signMsg sdk.StdSignMsg, cdc *wire.Codec) ([]byte, error) { +func SignAndBuild(msg sdk.Msg, cdc *wire.Codec) ([]byte, error) { + + // build the Sign Messsage from the Standard Message + chainID := viper.GetString(client.FlagChainID) + sequence := int64(viper.GetInt(client.FlagSequence)) + signMsg := sdk.StdSignMsg{ + ChainID: chainID, + Sequences: []int64{sequence}, + Msg: msg, + } keybase, err := keys.GetKeyBase() if err != nil { @@ -121,8 +130,8 @@ func SignAndBuild(signMsg sdk.StdSignMsg, cdc *wire.Codec) ([]byte, error) { } // sign and build the transaction from the msg -func SignBuildBroadcast(signMsg sdk.StdSignMsg, cdc *wire.Codec) (*ctypes.ResultBroadcastTxCommit, error) { - txBytes, err := SignAndBuild(signMsg, cdc) +func SignBuildBroadcast(msg sdk.Msg, cdc *wire.Codec) (*ctypes.ResultBroadcastTxCommit, error) { + txBytes, err := SignAndBuild(msg, cdc) if err != nil { return nil, err } diff --git a/examples/basecoin/x/cool/commands/tx.go b/examples/basecoin/x/cool/commands/tx.go index 71e80c98e..2b1654680 100644 --- a/examples/basecoin/x/cool/commands/tx.go +++ b/examples/basecoin/x/cool/commands/tx.go @@ -5,11 +5,8 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" - "github.com/spf13/viper" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/builder" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/wire" "github.com/cosmos/cosmos-sdk/examples/basecoin/x/cool" @@ -33,17 +30,9 @@ func QuizTxCmd(cdc *wire.Codec) *cobra.Command { // create the message msg := cool.NewQuizMsg(from, args[0]) - chainID := viper.GetString(client.FlagChainID) - sequence := int64(viper.GetInt(client.FlagSequence)) - - signMsg := sdk.StdSignMsg{ - ChainID: chainID, - Sequences: []int64{sequence}, - Msg: msg, - } // build and sign the transaction, then broadcast to Tendermint - res, err := builder.SignBuildBroadcast(signMsg, cdc) + res, err := builder.SignBuildBroadcast(msg, cdc) if err != nil { return err } @@ -72,17 +61,9 @@ func SetTrendTxCmd(cdc *wire.Codec) *cobra.Command { // create the message msg := cool.NewSetTrendMsg(from, args[0]) - chainID := viper.GetString(client.FlagChainID) - sequence := int64(viper.GetInt(client.FlagSequence)) - - signMsg := sdk.StdSignMsg{ - ChainID: chainID, - Sequences: []int64{sequence}, - Msg: msg, - } // build and sign the transaction, then broadcast to Tendermint - res, err := builder.SignBuildBroadcast(signMsg, cdc) + res, err := builder.SignBuildBroadcast(msg, cdc) if err != nil { return err } diff --git a/x/bank/commands/sendtx.go b/x/bank/commands/sendtx.go index 6ce0097a8..7e6dd463d 100644 --- a/x/bank/commands/sendtx.go +++ b/x/bank/commands/sendtx.go @@ -7,7 +7,6 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/builder" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/wire" @@ -51,17 +50,8 @@ func (c commander) sendTxCmd(cmd *cobra.Command, args []string) error { return err } - chainID := viper.GetString(client.FlagChainID) - sequence := int64(viper.GetInt(client.FlagSequence)) - - signMsg := sdk.StdSignMsg{ - ChainID: chainID, - Sequences: []int64{sequence}, - Msg: msg, - } - // build and sign the transaction, then broadcast to Tendermint - res, err := builder.SignBuildBroadcast(signMsg, c.cdc) + res, err := builder.SignBuildBroadcast(msg, c.cdc) if err != nil { return err }