Refactor x/auth/client/utils/ (#5555)

Packages named utils, common, or misc provide clients with no
sense of what the package contains. This makes it harder for
clients to use the package and makes it harder for maintainers
to keep the package focused. Over time, they accumulate dependencies
that can make compilation significantly and unnecessarily slower,
especially in large programs. And since such package names are
generic, they are more likely to collide with other packages
imported by client code, forcing clients to invent names to
distinguish them.

 cit. https://blog.golang.org/package-names
This commit is contained in:
Alessio Treglia 2020-01-24 16:40:56 +00:00 committed by GitHub
parent 26d6e49d6a
commit b647824716
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 117 additions and 114 deletions

View File

@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
## [Unreleased] ## [Unreleased]
### API Breaking Changes
* (modules) [\#5555](https://github.com/cosmos/cosmos-sdk/pull/5555) Move x/auth/client/utils/ types and functions to x/auth/client/.
## [v0.38.0] - 2020-01-23 ## [v0.38.0] - 2020-01-23
### State Machine Breaking ### State Machine Breaking

View File

@ -8,7 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" "github.com/cosmos/cosmos-sdk/x/auth/client"
) )
// GetBroadcastCommand returns the tx broadcast command. // GetBroadcastCommand returns the tx broadcast command.
@ -26,7 +26,7 @@ $ <appcli> tx broadcast ./mytxn.json
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) { RunE: func(cmd *cobra.Command, args []string) (err error) {
cliCtx := context.NewCLIContext().WithCodec(cdc) cliCtx := context.NewCLIContext().WithCodec(cdc)
stdTx, err := utils.ReadStdTxFromFile(cliCtx.Codec, args[0]) stdTx, err := client.ReadStdTxFromFile(cliCtx.Codec, args[0])
if err != nil { if err != nil {
return return
} }

View File

@ -8,7 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" "github.com/cosmos/cosmos-sdk/x/auth/client"
) )
// txEncodeRespStr implements a simple Stringer wrapper for a encoded tx. // txEncodeRespStr implements a simple Stringer wrapper for a encoded tx.
@ -31,7 +31,7 @@ If you supply a dash (-) argument in place of an input filename, the command rea
RunE: func(cmd *cobra.Command, args []string) (err error) { RunE: func(cmd *cobra.Command, args []string) (err error) {
cliCtx := context.NewCLIContext().WithCodec(cdc) cliCtx := context.NewCLIContext().WithCodec(cdc)
stdTx, err := utils.ReadStdTxFromFile(cliCtx.Codec, args[0]) stdTx, err := client.ReadStdTxFromFile(cliCtx.Codec, args[0])
if err != nil { if err != nil {
return return
} }

View File

@ -14,7 +14,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/types"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
@ -118,7 +118,7 @@ $ %s query txs --%s 'message.sender=cosmos1...&message.action=withdraw_delegator
limit := viper.GetInt(flags.FlagLimit) limit := viper.GetInt(flags.FlagLimit)
cliCtx := context.NewCLIContext().WithCodec(cdc) cliCtx := context.NewCLIContext().WithCodec(cdc)
txs, err := utils.QueryTxsByEvents(cliCtx, tmEvents, page, limit) txs, err := authclient.QueryTxsByEvents(cliCtx, tmEvents, page, limit)
if err != nil { if err != nil {
return err return err
} }
@ -162,7 +162,7 @@ func QueryTxCmd(cdc *codec.Codec) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc) cliCtx := context.NewCLIContext().WithCodec(cdc)
output, err := utils.QueryTx(cliCtx, args[0]) output, err := authclient.QueryTx(cliCtx, args[0])
if err != nil { if err != nil {
return err return err
} }

View File

@ -18,7 +18,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys" "github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/types"
) )
@ -60,7 +60,7 @@ recommended to set such parameters manually.
func makeMultiSignCmd(cdc *codec.Codec) func(cmd *cobra.Command, args []string) error { func makeMultiSignCmd(cdc *codec.Codec) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) (err error) { return func(cmd *cobra.Command, args []string) (err error) {
stdTx, err := utils.ReadStdTxFromFile(cdc, args[0]) stdTx, err := client.ReadStdTxFromFile(cdc, args[0])
if err != nil { if err != nil {
return return
} }

View File

@ -14,7 +14,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/types"
) )
@ -94,7 +94,7 @@ func preSignCmd(cmd *cobra.Command, _ []string) {
func makeSignCmd(cdc *codec.Codec) func(cmd *cobra.Command, args []string) error { func makeSignCmd(cdc *codec.Codec) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error { return func(cmd *cobra.Command, args []string) error {
stdTx, err := utils.ReadStdTxFromFile(cdc, args[0]) stdTx, err := client.ReadStdTxFromFile(cdc, args[0])
if err != nil { if err != nil {
return err return err
} }
@ -125,13 +125,13 @@ func makeSignCmd(cdc *codec.Codec) func(cmd *cobra.Command, args []string) error
return err return err
} }
newTx, err = utils.SignStdTxWithSignerAddress( newTx, err = client.SignStdTxWithSignerAddress(
txBldr, cliCtx, multisigAddr, cliCtx.GetFromName(), stdTx, offline, txBldr, cliCtx, multisigAddr, cliCtx.GetFromName(), stdTx, offline,
) )
generateSignatureOnly = true generateSignatureOnly = true
} else { } else {
appendSig := viper.GetBool(flagAppend) && !generateSignatureOnly appendSig := viper.GetBool(flagAppend) && !generateSignatureOnly
newTx, err = utils.SignStdTx(txBldr, cliCtx, cliCtx.GetFromName(), stdTx, appendSig, offline) newTx, err = client.SignStdTx(txBldr, cliCtx, cliCtx.GetFromName(), stdTx, appendSig, offline)
} }
if err != nil { if err != nil {

View File

@ -1,4 +1,4 @@
package utils package client
import ( import (
"encoding/hex" "encoding/hex"

View File

@ -1,4 +1,4 @@
package utils package client
import ( import (
"log" "log"
@ -31,7 +31,7 @@ func WriteGenerateStdTxResponse(w http.ResponseWriter, cliCtx context.CLIContext
if br.Simulate || simAndExec { if br.Simulate || simAndExec {
if gasAdj < 0 { if gasAdj < 0 {
rest.WriteErrorResponse(w, http.StatusBadRequest, errInvalidGasAdjustment.Error()) rest.WriteErrorResponse(w, http.StatusBadRequest, types.ErrorInvalidGasAdjustment.Error())
return return
} }

View File

@ -11,7 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/types"
genutilrest "github.com/cosmos/cosmos-sdk/x/genutil/client/rest" genutilrest "github.com/cosmos/cosmos-sdk/x/genutil/client/rest"
) )
@ -99,7 +99,7 @@ func QueryTxsRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return return
} }
searchResult, err := utils.QueryTxsByEvents(cliCtx, events, page, limit) searchResult, err := client.QueryTxsByEvents(cliCtx, events, page, limit)
if err != nil { if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return return
@ -121,7 +121,7 @@ func QueryTxRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return return
} }
output, err := utils.QueryTx(cliCtx, hashHexStr) output, err := client.QueryTx(cliCtx, hashHexStr)
if err != nil { if err != nil {
if strings.Contains(err.Error(), hashHexStr) { if strings.Contains(err.Error(), hashHexStr) {
rest.WriteErrorResponse(w, http.StatusNotFound, err.Error()) rest.WriteErrorResponse(w, http.StatusNotFound, err.Error())

View File

@ -1,4 +1,4 @@
package utils package client
import ( import (
"bufio" "bufio"
@ -182,7 +182,7 @@ func SignStdTx(
// check whether the address is a signer // check whether the address is a signer
if !isTxSigner(sdk.AccAddress(addr), stdTx.GetSigners()) { if !isTxSigner(sdk.AccAddress(addr), stdTx.GetSigners()) {
return signedStdTx, fmt.Errorf("%s: %s", errInvalidSigner, name) return signedStdTx, fmt.Errorf("%s: %s", authtypes.ErrorInvalidSigner, name)
} }
if !offline { if !offline {
@ -204,7 +204,7 @@ func SignStdTxWithSignerAddress(txBldr authtypes.TxBuilder, cliCtx context.CLICo
// check whether the address is a signer // check whether the address is a signer
if !isTxSigner(addr, stdTx.GetSigners()) { if !isTxSigner(addr, stdTx.GetSigners()) {
return signedStdTx, fmt.Errorf("%s: %s", errInvalidSigner, name) return signedStdTx, fmt.Errorf("%s: %s", authtypes.ErrorInvalidSigner, name)
} }
if !offline { if !offline {

View File

@ -1,4 +1,4 @@
package utils package client
import ( import (
"encoding/json" "encoding/json"

View File

@ -1,8 +0,0 @@
package utils
import "errors"
var (
errInvalidSigner = errors.New("tx intended signer does not match the given signer")
errInvalidGasAdjustment = errors.New("invalid gas adjustment")
)

8
x/auth/types/errors.go Normal file
View File

@ -0,0 +1,8 @@
package types
import "errors"
var (
ErrorInvalidSigner = errors.New("tx intended signer does not match the given signer")
ErrorInvalidGasAdjustment = errors.New("invalid gas adjustment")
)

View File

@ -11,7 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/bank/internal/types" "github.com/cosmos/cosmos-sdk/x/bank/internal/types"
) )
@ -38,7 +38,7 @@ func SendTxCmd(cdc *codec.Codec) *cobra.Command {
Args: cobra.ExactArgs(3), Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
cliCtx := context.NewCLIContextWithInputAndFrom(inBuf, args[0]).WithCodec(cdc) cliCtx := context.NewCLIContextWithInputAndFrom(inBuf, args[0]).WithCodec(cdc)
to, err := sdk.AccAddressFromBech32(args[1]) to, err := sdk.AccAddressFromBech32(args[1])
@ -54,7 +54,7 @@ func SendTxCmd(cdc *codec.Codec) *cobra.Command {
// build and sign the transaction, then broadcast to Tendermint // build and sign the transaction, then broadcast to Tendermint
msg := types.NewMsgSend(cliCtx.GetFromAddress(), to, coins) msg := types.NewMsgSend(cliCtx.GetFromAddress(), to, coins)
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}, },
} }

View File

@ -8,8 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/bank/internal/types" "github.com/cosmos/cosmos-sdk/x/bank/internal/types"
) )
@ -54,6 +53,6 @@ func SendRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
} }
msg := types.NewMsgSend(fromAddr, toAddr, req.Amount) msg := types.NewMsgSend(fromAddr, toAddr, req.Amount)
utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg})
} }
} }

View File

@ -12,7 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/crisis/internal/types" "github.com/cosmos/cosmos-sdk/x/crisis/internal/types"
) )
@ -25,13 +25,13 @@ func GetCmdInvariantBroken(cdc *codec.Codec) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
senderAddr := cliCtx.GetFromAddress() senderAddr := cliCtx.GetFromAddress()
moduleName, route := args[0], args[1] moduleName, route := args[0], args[1]
msg := types.NewMsgVerifyInvariant(senderAddr, moduleName, route) msg := types.NewMsgVerifyInvariant(senderAddr, moduleName, route)
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}, },
} }
return cmd return cmd

View File

@ -16,7 +16,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/distribution/client/common" "github.com/cosmos/cosmos-sdk/x/distribution/client/common"
@ -105,7 +105,7 @@ $ %s tx distribution withdraw-rewards cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fx
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
delAddr := cliCtx.GetFromAddress() delAddr := cliCtx.GetFromAddress()
@ -119,7 +119,7 @@ $ %s tx distribution withdraw-rewards cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fx
msgs = append(msgs, types.NewMsgWithdrawValidatorCommission(valAddr)) msgs = append(msgs, types.NewMsgWithdrawValidatorCommission(valAddr))
} }
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, msgs) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, msgs)
}, },
} }
cmd.Flags().Bool(flagCommission, false, "also withdraw validator's commission") cmd.Flags().Bool(flagCommission, false, "also withdraw validator's commission")
@ -143,7 +143,7 @@ $ %s tx distribution withdraw-all-rewards --from mykey
Args: cobra.NoArgs, Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
delAddr := cliCtx.GetFromAddress() delAddr := cliCtx.GetFromAddress()
@ -160,7 +160,7 @@ $ %s tx distribution withdraw-all-rewards --from mykey
} }
chunkSize := viper.GetInt(flagMaxMessagesPerTx) chunkSize := viper.GetInt(flagMaxMessagesPerTx)
return splitAndApply(utils.GenerateOrBroadcastMsgs, cliCtx, txBldr, msgs, chunkSize) return splitAndApply(authclient.GenerateOrBroadcastMsgs, cliCtx, txBldr, msgs, chunkSize)
}, },
} }
@ -186,7 +186,7 @@ $ %s tx distribution set-withdraw-addr cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
delAddr := cliCtx.GetFromAddress() delAddr := cliCtx.GetFromAddress()
@ -196,7 +196,7 @@ $ %s tx distribution set-withdraw-addr cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75
} }
msg := types.NewMsgSetWithdrawAddress(delAddr, withdrawAddr) msg := types.NewMsgSetWithdrawAddress(delAddr, withdrawAddr)
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}, },
} }
} }
@ -239,7 +239,7 @@ Where proposal.json contains:
), ),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
proposal, err := ParseCommunityPoolSpendProposalJSON(cdc, args[0]) proposal, err := ParseCommunityPoolSpendProposalJSON(cdc, args[0])
@ -255,7 +255,7 @@ Where proposal.json contains:
return err return err
} }
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}, },
} }
@ -280,7 +280,7 @@ $ %s tx distribution fund-community-pool 100uatom --from mykey
), ),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
depositorAddr := cliCtx.GetFromAddress() depositorAddr := cliCtx.GetFromAddress()
@ -294,7 +294,7 @@ $ %s tx distribution fund-community-pool 100uatom --from mykey
return err return err
} }
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}, },
} }
} }

View File

@ -10,13 +10,13 @@ import (
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
) )
func createFakeTxBuilder() auth.TxBuilder { func createFakeTxBuilder() auth.TxBuilder {
cdc := codec.New() cdc := codec.New()
return auth.NewTxBuilder( return auth.NewTxBuilder(
utils.GetTxEncoder(cdc), authclient.GetTxEncoder(cdc),
123, 123,
9876, 9876,
0, 0,

View File

@ -8,7 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/distribution/types" "github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov"
govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest" govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
@ -48,6 +48,6 @@ func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return return
} }
utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg})
} }
} }

View File

@ -6,7 +6,7 @@ import (
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/distribution/client/common" "github.com/cosmos/cosmos-sdk/x/distribution/client/common"
"github.com/cosmos/cosmos-sdk/x/distribution/types" "github.com/cosmos/cosmos-sdk/x/distribution/types"
@ -88,7 +88,7 @@ func withdrawDelegatorRewardsHandlerFn(cliCtx context.CLIContext, queryRoute str
return return
} }
utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, msgs) authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, msgs)
} }
} }
@ -123,7 +123,7 @@ func withdrawDelegationRewardsHandlerFn(cliCtx context.CLIContext) http.HandlerF
return return
} }
utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg})
} }
} }
@ -153,7 +153,7 @@ func setDelegatorWithdrawalAddrHandlerFn(cliCtx context.CLIContext) http.Handler
return return
} }
utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg})
} }
} }
@ -184,7 +184,7 @@ func withdrawValidatorRewardsHandlerFn(cliCtx context.CLIContext) http.HandlerFu
return return
} }
utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, msgs) authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, msgs)
} }
} }
@ -212,7 +212,7 @@ func fundCommunityPoolHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return return
} }
utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg})
} }
} }

View File

@ -27,7 +27,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/genutil" "github.com/cosmos/cosmos-sdk/x/genutil"
"github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/cosmos/cosmos-sdk/x/genutil/types"
) )
@ -121,7 +121,7 @@ func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, sm
return errors.Wrap(err, "failed to validate account in genesis") return errors.Wrap(err, "failed to validate account in genesis")
} }
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
// Set the generate-only flag here after the CLI context has // Set the generate-only flag here after the CLI context has
@ -139,14 +139,14 @@ func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, sm
if key.GetType() == keys.TypeOffline || key.GetType() == keys.TypeMulti { if key.GetType() == keys.TypeOffline || key.GetType() == keys.TypeMulti {
fmt.Println("Offline key passed in. Use `tx sign` command to sign:") fmt.Println("Offline key passed in. Use `tx sign` command to sign:")
return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg}) return authclient.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
} }
// write the unsigned transaction to the buffer // write the unsigned transaction to the buffer
w := bytes.NewBuffer([]byte{}) w := bytes.NewBuffer([]byte{})
cliCtx = cliCtx.WithOutput(w) cliCtx = cliCtx.WithOutput(w)
if err = utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg}); err != nil { if err = authclient.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg}); err != nil {
return errors.Wrap(err, "failed to print unsigned std tx") return errors.Wrap(err, "failed to print unsigned std tx")
} }
@ -157,7 +157,7 @@ func GenTxCmd(ctx *server.Context, cdc *codec.Codec, mbm module.BasicManager, sm
} }
// sign the transaction and write it to the output file // sign the transaction and write it to the output file
signedTx, err := utils.SignStdTx(txBldr, cliCtx, name, stdTx, false, true) signedTx, err := authclient.SignStdTx(txBldr, cliCtx, name, stdTx, false, true)
if err != nil { if err != nil {
return errors.Wrap(err, "failed to sign std tx") return errors.Wrap(err, "failed to sign std tx")
} }

View File

@ -15,7 +15,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
govutils "github.com/cosmos/cosmos-sdk/x/gov/client/utils" govutils "github.com/cosmos/cosmos-sdk/x/gov/client/utils"
"github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/gov/types"
) )
@ -107,7 +107,7 @@ $ %s tx gov submit-proposal --title="Test Proposal" --description="My awesome pr
), ),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
proposal, err := parseSubmitProposalFlags() proposal, err := parseSubmitProposalFlags()
@ -127,7 +127,7 @@ $ %s tx gov submit-proposal --title="Test Proposal" --description="My awesome pr
return err return err
} }
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}, },
} }
@ -158,7 +158,7 @@ $ %s tx gov deposit 1 10stake --from mykey
), ),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
// validate that the proposal id is a uint // validate that the proposal id is a uint
@ -182,7 +182,7 @@ $ %s tx gov deposit 1 10stake --from mykey
return err return err
} }
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}, },
} }
} }
@ -206,7 +206,7 @@ $ %s tx gov vote 1 yes --from mykey
), ),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
// Get voting address // Get voting address
@ -231,7 +231,7 @@ $ %s tx gov vote 1 yes --from mykey
return err return err
} }
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}, },
} }
} }

View File

@ -9,7 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
gcutils "github.com/cosmos/cosmos-sdk/x/gov/client/utils" gcutils "github.com/cosmos/cosmos-sdk/x/gov/client/utils"
"github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/gov/types"
) )
@ -46,7 +46,7 @@ func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return return
} }
utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg})
} }
} }
@ -82,7 +82,7 @@ func depositHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return return
} }
utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg})
} }
} }
@ -124,6 +124,6 @@ func voteHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return return
} }
utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg})
} }
} }

View File

@ -6,7 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/gov/types"
) )
@ -45,7 +45,7 @@ func QueryDepositsByTxQuery(cliCtx context.CLIContext, params types.QueryProposa
// NOTE: SearchTxs is used to facilitate the txs query which does not currently // NOTE: SearchTxs is used to facilitate the txs query which does not currently
// support configurable pagination. // support configurable pagination.
searchResult, err := utils.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit) searchResult, err := authclient.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -88,7 +88,7 @@ func QueryVotesByTxQuery(cliCtx context.CLIContext, params types.QueryProposalVo
) )
// query interrupted either if we collected enough votes or tx indexer run out of relevant txs // query interrupted either if we collected enough votes or tx indexer run out of relevant txs
for len(votes) < totalLimit { for len(votes) < totalLimit {
searchResult, err := utils.QueryTxsByEvents(cliCtx, events, nextTxPage, defaultLimit) searchResult, err := authclient.QueryTxsByEvents(cliCtx, events, nextTxPage, defaultLimit)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -132,7 +132,7 @@ func QueryVoteByTxQuery(cliCtx context.CLIContext, params types.QueryVoteParams)
// NOTE: SearchTxs is used to facilitate the txs query which does not currently // NOTE: SearchTxs is used to facilitate the txs query which does not currently
// support configurable pagination. // support configurable pagination.
searchResult, err := utils.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit) searchResult, err := authclient.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -171,7 +171,7 @@ func QueryDepositByTxQuery(cliCtx context.CLIContext, params types.QueryDepositP
// NOTE: SearchTxs is used to facilitate the txs query which does not currently // NOTE: SearchTxs is used to facilitate the txs query which does not currently
// support configurable pagination. // support configurable pagination.
searchResult, err := utils.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit) searchResult, err := authclient.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -210,7 +210,7 @@ func QueryProposerByTxQuery(cliCtx context.CLIContext, proposalID uint64) (Propo
// NOTE: SearchTxs is used to facilitate the txs query which does not currently // NOTE: SearchTxs is used to facilitate the txs query which does not currently
// support configurable pagination. // support configurable pagination.
searchResult, err := utils.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit) searchResult, err := authclient.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit)
if err != nil { if err != nil {
return Proposer{}, err return Proposer{}, err
} }

View File

@ -12,7 +12,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
paramscutils "github.com/cosmos/cosmos-sdk/x/params/client/utils" paramscutils "github.com/cosmos/cosmos-sdk/x/params/client/utils"
"github.com/cosmos/cosmos-sdk/x/params/types" "github.com/cosmos/cosmos-sdk/x/params/types"
@ -66,7 +66,7 @@ Where proposal.json contains:
), ),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
proposal, err := paramscutils.ParseParamChangeProposalJSON(cdc, args[0]) proposal, err := paramscutils.ParseParamChangeProposalJSON(cdc, args[0])
@ -82,7 +82,7 @@ Where proposal.json contains:
return err return err
} }
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}, },
} }

View File

@ -6,7 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest" govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/params" "github.com/cosmos/cosmos-sdk/x/params"
@ -42,6 +42,6 @@ func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return return
} }
utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg})
} }
} }

View File

@ -11,7 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/slashing/internal/types" "github.com/cosmos/cosmos-sdk/x/slashing/internal/types"
) )
@ -44,13 +44,13 @@ $ <appcli> tx slashing unjail --from mykey
`, `,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
valAddr := cliCtx.GetFromAddress() valAddr := cliCtx.GetFromAddress()
msg := types.NewMsgUnjail(sdk.ValAddress(valAddr)) msg := types.NewMsgUnjail(sdk.ValAddress(valAddr))
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}, },
} }
} }

View File

@ -9,7 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/slashing/internal/types" "github.com/cosmos/cosmos-sdk/x/slashing/internal/types"
) )
@ -65,6 +65,6 @@ func unjailRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return return
} }
utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg})
} }
} }

View File

@ -20,7 +20,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/cosmos-sdk/x/staking/types"
) )
@ -52,7 +52,7 @@ func GetCmdCreateValidator(cdc *codec.Codec) *cobra.Command {
Short: "create new validator initialized with a self-delegation to it", Short: "create new validator initialized with a self-delegation to it",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
txBldr, msg, err := BuildCreateValidatorMsg(cliCtx, txBldr) txBldr, msg, err := BuildCreateValidatorMsg(cliCtx, txBldr)
@ -60,7 +60,7 @@ func GetCmdCreateValidator(cdc *codec.Codec) *cobra.Command {
return err return err
} }
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}, },
} }
@ -128,7 +128,7 @@ func GetCmdEditValidator(cdc *codec.Codec) *cobra.Command {
msg := types.NewMsgEditValidator(sdk.ValAddress(valAddr), description, newRate, newMinSelfDelegation) msg := types.NewMsgEditValidator(sdk.ValAddress(valAddr), description, newRate, newMinSelfDelegation)
// build and sign the transaction, then broadcast to Tendermint // build and sign the transaction, then broadcast to Tendermint
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}, },
} }
@ -171,7 +171,7 @@ $ %s tx staking delegate cosmosvaloper1l2rsakp388kuv9k8qzq6lrm9taddae7fpx59wm 10
} }
msg := types.NewMsgDelegate(delAddr, valAddr, amount) msg := types.NewMsgDelegate(delAddr, valAddr, amount)
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}, },
} }
} }
@ -213,7 +213,7 @@ $ %s tx staking redelegate cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
} }
msg := types.NewMsgBeginRedelegate(delAddr, valSrcAddr, valDstAddr, amount) msg := types.NewMsgBeginRedelegate(delAddr, valSrcAddr, valDstAddr, amount)
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}, },
} }
} }
@ -250,7 +250,7 @@ $ %s tx staking unbond cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 100s
} }
msg := types.NewMsgUndelegate(delAddr, valAddr, amount) msg := types.NewMsgUndelegate(delAddr, valAddr, amount)
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}, },
} }
} }

View File

@ -9,7 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/cosmos-sdk/x/staking/types"
) )
@ -85,7 +85,7 @@ func postDelegationsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return return
} }
utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg})
} }
} }
@ -119,7 +119,7 @@ func postRedelegationsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return return
} }
utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg})
} }
} }
@ -153,6 +153,6 @@ func postUnbondingDelegationsHandlerFn(cliCtx context.CLIContext) http.HandlerFu
return return
} }
utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg})
} }
} }

View File

@ -9,7 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils" authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/cosmos-sdk/x/staking/types"
) )
@ -32,7 +32,7 @@ func queryTxs(cliCtx context.CLIContext, action string, delegatorAddr string) (*
fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeySender, delegatorAddr), fmt.Sprintf("%s.%s='%s'", sdk.EventTypeMessage, sdk.AttributeKeySender, delegatorAddr),
} }
return utils.QueryTxsByEvents(cliCtx, events, page, limit) return authclient.QueryTxsByEvents(cliCtx, events, page, limit)
} }
func queryBonds(cliCtx context.CLIContext, endpoint string) http.HandlerFunc { func queryBonds(cliCtx context.CLIContext, endpoint string) http.HandlerFunc {

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"time" "time"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
"github.com/cosmos/cosmos-sdk/x/gov/client/cli" "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -13,7 +14,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils"
"github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov"
upgrade "github.com/cosmos/cosmos-sdk/x/upgrade/internal/types" upgrade "github.com/cosmos/cosmos-sdk/x/upgrade/internal/types"
) )
@ -87,7 +87,7 @@ func GetCmdSubmitUpgradeProposal(cdc *codec.Codec) *cobra.Command {
} }
inBuf := bufio.NewReader(cmd.InOrStdin()) inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
from := cliCtx.GetFromAddress() from := cliCtx.GetFromAddress()
@ -104,7 +104,7 @@ func GetCmdSubmitUpgradeProposal(cdc *codec.Codec) *cobra.Command {
if err := msg.ValidateBasic(); err != nil { if err := msg.ValidateBasic(); err != nil {
return err return err
} }
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}, },
} }
@ -127,7 +127,7 @@ func GetCmdSubmitCancelUpgradeProposal(cdc *codec.Codec) *cobra.Command {
Long: "Cancel a software upgrade along with an initial deposit.", Long: "Cancel a software upgrade along with an initial deposit.",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
inBuf := bufio.NewReader(cmd.InOrStdin()) inBuf := bufio.NewReader(cmd.InOrStdin())
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc))
cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc)
from := cliCtx.GetFromAddress() from := cliCtx.GetFromAddress()
@ -158,7 +158,7 @@ func GetCmdSubmitCancelUpgradeProposal(cdc *codec.Codec) *cobra.Command {
return err return err
} }
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg})
}, },
} }

View File

@ -6,12 +6,12 @@ import (
"github.com/gorilla/mux" "github.com/gorilla/mux"
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest" govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest"
"github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/context"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/x/auth/client/utils"
"github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/upgrade/internal/types" "github.com/cosmos/cosmos-sdk/x/upgrade/internal/types"
) )
@ -84,7 +84,7 @@ func postPlanHandler(cliCtx context.CLIContext) http.HandlerFunc {
return return
} }
utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg})
} }
} }
@ -114,6 +114,6 @@ func cancelPlanHandler(cliCtx context.CLIContext) http.HandlerFunc {
return return
} }
utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg})
} }
} }