From b647824716d9da2e93889c54f59af300bf1035cb Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Fri, 24 Jan 2020 16:40:56 +0000 Subject: [PATCH] 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 --- CHANGELOG.md | 4 ++++ x/auth/client/cli/broadcast.go | 4 ++-- x/auth/client/cli/encode.go | 4 ++-- x/auth/client/cli/query.go | 6 +++--- x/auth/client/cli/tx_multisign.go | 4 ++-- x/auth/client/cli/tx_sign.go | 8 ++++---- x/auth/client/{utils => }/query.go | 2 +- x/auth/client/{utils => }/rest.go | 4 ++-- x/auth/client/rest/query.go | 6 +++--- x/auth/client/{utils => }/tx.go | 6 +++--- x/auth/client/{utils => }/tx_test.go | 2 +- x/auth/client/utils/errors.go | 8 -------- x/auth/types/errors.go | 8 ++++++++ x/bank/client/cli/tx.go | 6 +++--- x/bank/client/rest/tx.go | 5 ++--- x/crisis/client/cli/tx.go | 6 +++--- x/distribution/client/cli/tx.go | 22 +++++++++++----------- x/distribution/client/cli/tx_test.go | 4 ++-- x/distribution/client/rest/rest.go | 4 ++-- x/distribution/client/rest/tx.go | 12 ++++++------ x/genutil/client/cli/gentx.go | 10 +++++----- x/gov/client/cli/tx.go | 14 +++++++------- x/gov/client/rest/tx.go | 8 ++++---- x/gov/client/utils/query.go | 12 ++++++------ x/params/client/cli/tx.go | 6 +++--- x/params/client/rest/rest.go | 4 ++-- x/slashing/client/cli/tx.go | 6 +++--- x/slashing/client/rest/tx.go | 4 ++-- x/staking/client/cli/tx.go | 14 +++++++------- x/staking/client/rest/tx.go | 8 ++++---- x/staking/client/rest/utils.go | 4 ++-- x/upgrade/client/cli/tx.go | 10 +++++----- x/upgrade/client/rest/tx.go | 6 +++--- 33 files changed, 117 insertions(+), 114 deletions(-) rename x/auth/client/{utils => }/query.go (99%) rename x/auth/client/{utils => }/rest.go (93%) rename x/auth/client/{utils => }/tx.go (98%) rename x/auth/client/{utils => }/tx_test.go (99%) delete mode 100644 x/auth/client/utils/errors.go create mode 100644 x/auth/types/errors.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 798b321d5..f4c258b72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [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 ### State Machine Breaking diff --git a/x/auth/client/cli/broadcast.go b/x/auth/client/cli/broadcast.go index 37590787b..e5a62e388 100644 --- a/x/auth/client/cli/broadcast.go +++ b/x/auth/client/cli/broadcast.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/flags" "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. @@ -26,7 +26,7 @@ $ tx broadcast ./mytxn.json Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { cliCtx := context.NewCLIContext().WithCodec(cdc) - stdTx, err := utils.ReadStdTxFromFile(cliCtx.Codec, args[0]) + stdTx, err := client.ReadStdTxFromFile(cliCtx.Codec, args[0]) if err != nil { return } diff --git a/x/auth/client/cli/encode.go b/x/auth/client/cli/encode.go index 304411dba..fa39a58ca 100644 --- a/x/auth/client/cli/encode.go +++ b/x/auth/client/cli/encode.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/flags" "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. @@ -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) { cliCtx := context.NewCLIContext().WithCodec(cdc) - stdTx, err := utils.ReadStdTxFromFile(cliCtx.Codec, args[0]) + stdTx, err := client.ReadStdTxFromFile(cliCtx.Codec, args[0]) if err != nil { return } diff --git a/x/auth/client/cli/query.go b/x/auth/client/cli/query.go index 08e796218..d0ebc155e 100644 --- a/x/auth/client/cli/query.go +++ b/x/auth/client/cli/query.go @@ -14,7 +14,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" "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" 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) cliCtx := context.NewCLIContext().WithCodec(cdc) - txs, err := utils.QueryTxsByEvents(cliCtx, tmEvents, page, limit) + txs, err := authclient.QueryTxsByEvents(cliCtx, tmEvents, page, limit) if err != nil { return err } @@ -162,7 +162,7 @@ func QueryTxCmd(cdc *codec.Codec) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { cliCtx := context.NewCLIContext().WithCodec(cdc) - output, err := utils.QueryTx(cliCtx, args[0]) + output, err := authclient.QueryTx(cliCtx, args[0]) if err != nil { return err } diff --git a/x/auth/client/cli/tx_multisign.go b/x/auth/client/cli/tx_multisign.go index 9d67f26ef..b46192925 100644 --- a/x/auth/client/cli/tx_multisign.go +++ b/x/auth/client/cli/tx_multisign.go @@ -18,7 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys" sdk "github.com/cosmos/cosmos-sdk/types" "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" ) @@ -60,7 +60,7 @@ recommended to set such parameters manually. func makeMultiSignCmd(cdc *codec.Codec) func(cmd *cobra.Command, args []string) 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 { return } diff --git a/x/auth/client/cli/tx_sign.go b/x/auth/client/cli/tx_sign.go index f2e72cb4e..ebbe936a7 100644 --- a/x/auth/client/cli/tx_sign.go +++ b/x/auth/client/cli/tx_sign.go @@ -14,7 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" 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" ) @@ -94,7 +94,7 @@ func preSignCmd(cmd *cobra.Command, _ []string) { func makeSignCmd(cdc *codec.Codec) 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 { return err } @@ -125,13 +125,13 @@ func makeSignCmd(cdc *codec.Codec) func(cmd *cobra.Command, args []string) error return err } - newTx, err = utils.SignStdTxWithSignerAddress( + newTx, err = client.SignStdTxWithSignerAddress( txBldr, cliCtx, multisigAddr, cliCtx.GetFromName(), stdTx, offline, ) generateSignatureOnly = true } else { 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 { diff --git a/x/auth/client/utils/query.go b/x/auth/client/query.go similarity index 99% rename from x/auth/client/utils/query.go rename to x/auth/client/query.go index 8fc236952..3a2c4c44f 100644 --- a/x/auth/client/utils/query.go +++ b/x/auth/client/query.go @@ -1,4 +1,4 @@ -package utils +package client import ( "encoding/hex" diff --git a/x/auth/client/utils/rest.go b/x/auth/client/rest.go similarity index 93% rename from x/auth/client/utils/rest.go rename to x/auth/client/rest.go index 9423fe629..f79caa1af 100644 --- a/x/auth/client/utils/rest.go +++ b/x/auth/client/rest.go @@ -1,4 +1,4 @@ -package utils +package client import ( "log" @@ -31,7 +31,7 @@ func WriteGenerateStdTxResponse(w http.ResponseWriter, cliCtx context.CLIContext if br.Simulate || simAndExec { if gasAdj < 0 { - rest.WriteErrorResponse(w, http.StatusBadRequest, errInvalidGasAdjustment.Error()) + rest.WriteErrorResponse(w, http.StatusBadRequest, types.ErrorInvalidGasAdjustment.Error()) return } diff --git a/x/auth/client/rest/query.go b/x/auth/client/rest/query.go index 77cba3e59..9662ebcc6 100644 --- a/x/auth/client/rest/query.go +++ b/x/auth/client/rest/query.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" sdk "github.com/cosmos/cosmos-sdk/types" "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" genutilrest "github.com/cosmos/cosmos-sdk/x/genutil/client/rest" ) @@ -99,7 +99,7 @@ func QueryTxsRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - searchResult, err := utils.QueryTxsByEvents(cliCtx, events, page, limit) + searchResult, err := client.QueryTxsByEvents(cliCtx, events, page, limit) if err != nil { rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) return @@ -121,7 +121,7 @@ func QueryTxRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - output, err := utils.QueryTx(cliCtx, hashHexStr) + output, err := client.QueryTx(cliCtx, hashHexStr) if err != nil { if strings.Contains(err.Error(), hashHexStr) { rest.WriteErrorResponse(w, http.StatusNotFound, err.Error()) diff --git a/x/auth/client/utils/tx.go b/x/auth/client/tx.go similarity index 98% rename from x/auth/client/utils/tx.go rename to x/auth/client/tx.go index 55b700700..12d50a65a 100644 --- a/x/auth/client/utils/tx.go +++ b/x/auth/client/tx.go @@ -1,4 +1,4 @@ -package utils +package client import ( "bufio" @@ -182,7 +182,7 @@ func SignStdTx( // check whether the address is a signer 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 { @@ -204,7 +204,7 @@ func SignStdTxWithSignerAddress(txBldr authtypes.TxBuilder, cliCtx context.CLICo // check whether the address is a signer if !isTxSigner(addr, stdTx.GetSigners()) { - return signedStdTx, fmt.Errorf("%s: %s", errInvalidSigner, name) + return signedStdTx, fmt.Errorf("%s: %s", authtypes.ErrorInvalidSigner, name) } if !offline { diff --git a/x/auth/client/utils/tx_test.go b/x/auth/client/tx_test.go similarity index 99% rename from x/auth/client/utils/tx_test.go rename to x/auth/client/tx_test.go index a9c33b232..1fb4ca3d2 100644 --- a/x/auth/client/utils/tx_test.go +++ b/x/auth/client/tx_test.go @@ -1,4 +1,4 @@ -package utils +package client import ( "encoding/json" diff --git a/x/auth/client/utils/errors.go b/x/auth/client/utils/errors.go deleted file mode 100644 index 0a0fc7a0f..000000000 --- a/x/auth/client/utils/errors.go +++ /dev/null @@ -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") -) diff --git a/x/auth/types/errors.go b/x/auth/types/errors.go new file mode 100644 index 000000000..3333cc8a4 --- /dev/null +++ b/x/auth/types/errors.go @@ -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") +) diff --git a/x/bank/client/cli/tx.go b/x/bank/client/cli/tx.go index 58bce19eb..b2b36c45d 100644 --- a/x/bank/client/cli/tx.go +++ b/x/bank/client/cli/tx.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "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" ) @@ -38,7 +38,7 @@ func SendTxCmd(cdc *codec.Codec) *cobra.Command { Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { 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) 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 msg := types.NewMsgSend(cliCtx.GetFromAddress(), to, coins) - return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) + return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) }, } diff --git a/x/bank/client/rest/tx.go b/x/bank/client/rest/tx.go index 10ac15abc..fdf245430 100644 --- a/x/bank/client/rest/tx.go +++ b/x/bank/client/rest/tx.go @@ -8,8 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" sdk "github.com/cosmos/cosmos-sdk/types" "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" ) @@ -54,6 +53,6 @@ func SendRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { } 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}) } } diff --git a/x/crisis/client/cli/tx.go b/x/crisis/client/cli/tx.go index e2df844db..d54153b8f 100644 --- a/x/crisis/client/cli/tx.go +++ b/x/crisis/client/cli/tx.go @@ -12,7 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "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" ) @@ -25,13 +25,13 @@ func GetCmdInvariantBroken(cdc *codec.Codec) *cobra.Command { RunE: func(cmd *cobra.Command, args []string) error { 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) senderAddr := cliCtx.GetFromAddress() moduleName, route := args[0], args[1] msg := types.NewMsgVerifyInvariant(senderAddr, moduleName, route) - return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) + return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) }, } return cmd diff --git a/x/distribution/client/cli/tx.go b/x/distribution/client/cli/tx.go index 6eaee6099..a033fd28d 100644 --- a/x/distribution/client/cli/tx.go +++ b/x/distribution/client/cli/tx.go @@ -16,7 +16,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" "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/distribution/client/common" @@ -105,7 +105,7 @@ $ %s tx distribution withdraw-rewards cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fx Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { 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) delAddr := cliCtx.GetFromAddress() @@ -119,7 +119,7 @@ $ %s tx distribution withdraw-rewards cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fx 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") @@ -143,7 +143,7 @@ $ %s tx distribution withdraw-all-rewards --from mykey Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { 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) delAddr := cliCtx.GetFromAddress() @@ -160,7 +160,7 @@ $ %s tx distribution withdraw-all-rewards --from mykey } 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 { 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) delAddr := cliCtx.GetFromAddress() @@ -196,7 +196,7 @@ $ %s tx distribution set-withdraw-addr cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75 } 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 { 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) proposal, err := ParseCommunityPoolSpendProposalJSON(cdc, args[0]) @@ -255,7 +255,7 @@ Where proposal.json contains: 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 { 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) depositorAddr := cliCtx.GetFromAddress() @@ -294,7 +294,7 @@ $ %s tx distribution fund-community-pool 100uatom --from mykey return err } - return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) + return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) }, } } diff --git a/x/distribution/client/cli/tx_test.go b/x/distribution/client/cli/tx_test.go index af09d5445..860b31fa6 100644 --- a/x/distribution/client/cli/tx_test.go +++ b/x/distribution/client/cli/tx_test.go @@ -10,13 +10,13 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "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 { cdc := codec.New() return auth.NewTxBuilder( - utils.GetTxEncoder(cdc), + authclient.GetTxEncoder(cdc), 123, 9876, 0, diff --git a/x/distribution/client/rest/rest.go b/x/distribution/client/rest/rest.go index 3b09478ec..1a19f5b63 100644 --- a/x/distribution/client/rest/rest.go +++ b/x/distribution/client/rest/rest.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" sdk "github.com/cosmos/cosmos-sdk/types" "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/gov" govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest" @@ -48,6 +48,6 @@ func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) + authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) } } diff --git a/x/distribution/client/rest/tx.go b/x/distribution/client/rest/tx.go index ace2c11a7..23713add7 100644 --- a/x/distribution/client/rest/tx.go +++ b/x/distribution/client/rest/tx.go @@ -6,7 +6,7 @@ import ( "github.com/gorilla/mux" "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/types" @@ -88,7 +88,7 @@ func withdrawDelegatorRewardsHandlerFn(cliCtx context.CLIContext, queryRoute str 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 } - 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 } - 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 } - 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 } - utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) + authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) } } diff --git a/x/genutil/client/cli/gentx.go b/x/genutil/client/cli/gentx.go index 4624d1540..18ef098ff 100644 --- a/x/genutil/client/cli/gentx.go +++ b/x/genutil/client/cli/gentx.go @@ -27,7 +27,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "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/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") } - txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) + txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc)) cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) // 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 { 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 w := bytes.NewBuffer([]byte{}) 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") } @@ -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 - signedTx, err := utils.SignStdTx(txBldr, cliCtx, name, stdTx, false, true) + signedTx, err := authclient.SignStdTx(txBldr, cliCtx, name, stdTx, false, true) if err != nil { return errors.Wrap(err, "failed to sign std tx") } diff --git a/x/gov/client/cli/tx.go b/x/gov/client/cli/tx.go index 3946f9780..0af8eab61 100644 --- a/x/gov/client/cli/tx.go +++ b/x/gov/client/cli/tx.go @@ -15,7 +15,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" "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" "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 { 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) proposal, err := parseSubmitProposalFlags() @@ -127,7 +127,7 @@ $ %s tx gov submit-proposal --title="Test Proposal" --description="My awesome pr 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 { 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) // validate that the proposal id is a uint @@ -182,7 +182,7 @@ $ %s tx gov deposit 1 10stake --from mykey 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 { 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) // Get voting address @@ -231,7 +231,7 @@ $ %s tx gov vote 1 yes --from mykey return err } - return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) + return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) }, } } diff --git a/x/gov/client/rest/tx.go b/x/gov/client/rest/tx.go index c705bddf4..fb2bfa5c6 100644 --- a/x/gov/client/rest/tx.go +++ b/x/gov/client/rest/tx.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" sdk "github.com/cosmos/cosmos-sdk/types" "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" "github.com/cosmos/cosmos-sdk/x/gov/types" ) @@ -46,7 +46,7 @@ func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { 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 } - 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 } - utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) + authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) } } diff --git a/x/gov/client/utils/query.go b/x/gov/client/utils/query.go index d4be3c010..840f6df89 100644 --- a/x/gov/client/utils/query.go +++ b/x/gov/client/utils/query.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" 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" ) @@ -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 // support configurable pagination. - searchResult, err := utils.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit) + searchResult, err := authclient.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit) if err != nil { 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 for len(votes) < totalLimit { - searchResult, err := utils.QueryTxsByEvents(cliCtx, events, nextTxPage, defaultLimit) + searchResult, err := authclient.QueryTxsByEvents(cliCtx, events, nextTxPage, defaultLimit) if err != nil { 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 // support configurable pagination. - searchResult, err := utils.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit) + searchResult, err := authclient.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit) if err != nil { 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 // support configurable pagination. - searchResult, err := utils.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit) + searchResult, err := authclient.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit) if err != nil { 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 // support configurable pagination. - searchResult, err := utils.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit) + searchResult, err := authclient.QueryTxsByEvents(cliCtx, events, defaultPage, defaultLimit) if err != nil { return Proposer{}, err } diff --git a/x/params/client/cli/tx.go b/x/params/client/cli/tx.go index 08dc1c985..5b4fe2a9f 100644 --- a/x/params/client/cli/tx.go +++ b/x/params/client/cli/tx.go @@ -12,7 +12,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" "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" paramscutils "github.com/cosmos/cosmos-sdk/x/params/client/utils" "github.com/cosmos/cosmos-sdk/x/params/types" @@ -66,7 +66,7 @@ Where proposal.json contains: ), RunE: func(cmd *cobra.Command, args []string) error { 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) proposal, err := paramscutils.ParseParamChangeProposalJSON(cdc, args[0]) @@ -82,7 +82,7 @@ Where proposal.json contains: return err } - return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) + return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) }, } diff --git a/x/params/client/rest/rest.go b/x/params/client/rest/rest.go index 101dc49a4..e7461d391 100644 --- a/x/params/client/rest/rest.go +++ b/x/params/client/rest/rest.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" sdk "github.com/cosmos/cosmos-sdk/types" "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" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/params" @@ -42,6 +42,6 @@ func postProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) + authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) } } diff --git a/x/slashing/client/cli/tx.go b/x/slashing/client/cli/tx.go index 5aa262568..117e216a9 100644 --- a/x/slashing/client/cli/tx.go +++ b/x/slashing/client/cli/tx.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "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" ) @@ -44,13 +44,13 @@ $ tx slashing unjail --from mykey `, RunE: func(cmd *cobra.Command, args []string) error { 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) valAddr := cliCtx.GetFromAddress() msg := types.NewMsgUnjail(sdk.ValAddress(valAddr)) - return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) + return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) }, } } diff --git a/x/slashing/client/rest/tx.go b/x/slashing/client/rest/tx.go index bd7188a1c..1257b8e10 100644 --- a/x/slashing/client/rest/tx.go +++ b/x/slashing/client/rest/tx.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" sdk "github.com/cosmos/cosmos-sdk/types" "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" ) @@ -65,6 +65,6 @@ func unjailRequestHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return } - utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) + authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) } } diff --git a/x/staking/client/cli/tx.go b/x/staking/client/cli/tx.go index a9b8b5263..3199ece93 100644 --- a/x/staking/client/cli/tx.go +++ b/x/staking/client/cli/tx.go @@ -20,7 +20,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" "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" ) @@ -52,7 +52,7 @@ func GetCmdCreateValidator(cdc *codec.Codec) *cobra.Command { Short: "create new validator initialized with a self-delegation to it", RunE: func(cmd *cobra.Command, args []string) error { 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) txBldr, msg, err := BuildCreateValidatorMsg(cliCtx, txBldr) @@ -60,7 +60,7 @@ func GetCmdCreateValidator(cdc *codec.Codec) *cobra.Command { 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) // 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) - 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) - 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) - return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) + return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) }, } } diff --git a/x/staking/client/rest/tx.go b/x/staking/client/rest/tx.go index bd6016bed..7838d9551 100644 --- a/x/staking/client/rest/tx.go +++ b/x/staking/client/rest/tx.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" sdk "github.com/cosmos/cosmos-sdk/types" "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" ) @@ -85,7 +85,7 @@ func postDelegationsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { 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 } - 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 } - utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) + authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) } } diff --git a/x/staking/client/rest/utils.go b/x/staking/client/rest/utils.go index 5d106823a..8b0ead701 100644 --- a/x/staking/client/rest/utils.go +++ b/x/staking/client/rest/utils.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/context" sdk "github.com/cosmos/cosmos-sdk/types" "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" ) @@ -32,7 +32,7 @@ func queryTxs(cliCtx context.CLIContext, action string, delegatorAddr string) (* 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 { diff --git a/x/upgrade/client/cli/tx.go b/x/upgrade/client/cli/tx.go index 26aa0848c..a06347bc1 100644 --- a/x/upgrade/client/cli/tx.go +++ b/x/upgrade/client/cli/tx.go @@ -5,6 +5,7 @@ import ( "fmt" "time" + authclient "github.com/cosmos/cosmos-sdk/x/auth/client" "github.com/cosmos/cosmos-sdk/x/gov/client/cli" "github.com/spf13/cobra" @@ -13,7 +14,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth" - "github.com/cosmos/cosmos-sdk/x/auth/client/utils" "github.com/cosmos/cosmos-sdk/x/gov" 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()) - txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(utils.GetTxEncoder(cdc)) + txBldr := auth.NewTxBuilderFromCLI(inBuf).WithTxEncoder(authclient.GetTxEncoder(cdc)) cliCtx := context.NewCLIContextWithInput(inBuf).WithCodec(cdc) from := cliCtx.GetFromAddress() @@ -104,7 +104,7 @@ func GetCmdSubmitUpgradeProposal(cdc *codec.Codec) *cobra.Command { if err := msg.ValidateBasic(); err != nil { 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.", RunE: func(cmd *cobra.Command, args []string) error { 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) from := cliCtx.GetFromAddress() @@ -158,7 +158,7 @@ func GetCmdSubmitCancelUpgradeProposal(cdc *codec.Codec) *cobra.Command { return err } - return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) + return authclient.GenerateOrBroadcastMsgs(cliCtx, txBldr, []sdk.Msg{msg}) }, } diff --git a/x/upgrade/client/rest/tx.go b/x/upgrade/client/rest/tx.go index acdec0643..9354d9dd0 100644 --- a/x/upgrade/client/rest/tx.go +++ b/x/upgrade/client/rest/tx.go @@ -6,12 +6,12 @@ import ( "github.com/gorilla/mux" + authclient "github.com/cosmos/cosmos-sdk/x/auth/client" govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest" "github.com/cosmos/cosmos-sdk/client/context" sdk "github.com/cosmos/cosmos-sdk/types" "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/upgrade/internal/types" ) @@ -84,7 +84,7 @@ func postPlanHandler(cliCtx context.CLIContext) http.HandlerFunc { 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 } - utils.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) + authclient.WriteGenerateStdTxResponse(w, cliCtx, req.BaseReq, []sdk.Msg{msg}) } }