diff --git a/client/utils/rest.go b/client/utils/rest.go index 8bcb1173d..6446fb133 100644 --- a/client/utils/rest.go +++ b/client/utils/rest.go @@ -52,13 +52,13 @@ func ParseFloat64OrReturnBadRequest(w http.ResponseWriter, s string, defaultIfEm } // WriteGenerateStdTxResponse writes response for the generate_only mode. -func WriteGenerateStdTxResponse(w http.ResponseWriter, txCtx authctx.TxBuilder, msgs []sdk.Msg) { - stdMsg, err := txCtx.Build(msgs) +func WriteGenerateStdTxResponse(w http.ResponseWriter, txBld authctx.TxBuilder, msgs []sdk.Msg) { + stdMsg, err := txBld.Build(msgs) if err != nil { WriteErrorResponse(w, http.StatusBadRequest, err.Error()) return } - output, err := txCtx.Codec.MarshalJSON(auth.NewStdTx(stdMsg.Msgs, stdMsg.Fee, nil, stdMsg.Memo)) + output, err := txBld.Codec.MarshalJSON(auth.NewStdTx(stdMsg.Msgs, stdMsg.Fee, nil, stdMsg.Memo)) if err != nil { WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) return diff --git a/client/utils/utils.go b/client/utils/utils.go index c0188e5c9..32cc81000 100644 --- a/client/utils/utils.go +++ b/client/utils/utils.go @@ -18,18 +18,18 @@ import ( // ensures that the account exists, has a proper number and sequence set. In // addition, it builds and signs a transaction with the supplied messages. // Finally, it broadcasts the signed transaction to a node. -func SendTx(txCtx authctx.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) error { - txCtx, err := prepareTxContext(txCtx, cliCtx) +func SendTx(txBld authctx.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) error { + txBld, err := prepareTxContext(txBld, cliCtx) if err != nil { return err } autogas := cliCtx.DryRun || (cliCtx.Gas == 0) if autogas { - txCtx, err = EnrichCtxWithGas(txCtx, cliCtx, cliCtx.FromAddressName, msgs) + txBld, err = EnrichCtxWithGas(txBld, cliCtx, cliCtx.FromAddressName, msgs) if err != nil { return err } - fmt.Fprintf(os.Stderr, "estimated gas = %v\n", txCtx.Gas) + fmt.Fprintf(os.Stderr, "estimated gas = %v\n", txBld.Gas) } if cliCtx.DryRun { return nil @@ -41,7 +41,7 @@ func SendTx(txCtx authctx.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) } // build and sign the transaction - txBytes, err := txCtx.BuildAndSign(cliCtx.FromAddressName, passphrase, msgs) + txBytes, err := txBld.BuildAndSign(cliCtx.FromAddressName, passphrase, msgs) if err != nil { return err } @@ -50,8 +50,8 @@ func SendTx(txCtx authctx.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) } // SimulateMsgs simulates the transaction and returns the gas estimate and the adjusted value. -func SimulateMsgs(txCtx authctx.TxBuilder, cliCtx context.CLIContext, name string, msgs []sdk.Msg, gas int64) (estimated, adjusted int64, err error) { - txBytes, err := txCtx.WithGas(gas).BuildWithPubKey(name, msgs) +func SimulateMsgs(txBld authctx.TxBuilder, cliCtx context.CLIContext, name string, msgs []sdk.Msg, gas int64) (estimated, adjusted int64, err error) { + txBytes, err := txBld.WithGas(gas).BuildWithPubKey(name, msgs) if err != nil { return } @@ -61,12 +61,12 @@ func SimulateMsgs(txCtx authctx.TxBuilder, cliCtx context.CLIContext, name strin // EnrichCtxWithGas calculates the gas estimate that would be consumed by the // transaction and set the transaction's respective value accordingly. -func EnrichCtxWithGas(txCtx authctx.TxBuilder, cliCtx context.CLIContext, name string, msgs []sdk.Msg) (authctx.TxBuilder, error) { - _, adjusted, err := SimulateMsgs(txCtx, cliCtx, name, msgs, 0) +func EnrichCtxWithGas(txBld authctx.TxBuilder, cliCtx context.CLIContext, name string, msgs []sdk.Msg) (authctx.TxBuilder, error) { + _, adjusted, err := SimulateMsgs(txBld, cliCtx, name, msgs, 0) if err != nil { - return txCtx, err + return txBld, err } - return txCtx.WithGas(adjusted), nil + return txBld.WithGas(adjusted), nil } // CalculateGas simulates the execution of a transaction and returns @@ -87,12 +87,12 @@ func CalculateGas(queryFunc func(string, common.HexBytes) ([]byte, error), cdc * } // PrintUnsignedStdTx builds an unsigned StdTx and prints it to os.Stdout. -func PrintUnsignedStdTx(txCtx authctx.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) (err error) { - stdTx, err := buildUnsignedStdTx(txCtx, cliCtx, msgs) +func PrintUnsignedStdTx(txBld authctx.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) (err error) { + stdTx, err := buildUnsignedStdTx(txBld, cliCtx, msgs) if err != nil { return } - json, err := txCtx.Codec.MarshalJSON(stdTx) + json, err := txBld.Codec.MarshalJSON(stdTx) if err == nil { fmt.Printf("%s\n", json) } @@ -111,53 +111,53 @@ func parseQueryResponse(cdc *amino.Codec, rawRes []byte) (int64, error) { return simulationResult.GasUsed, nil } -func prepareTxContext(txCtx authctx.TxBuilder, cliCtx context.CLIContext) (authctx.TxBuilder, error) { +func prepareTxContext(txBld authctx.TxBuilder, cliCtx context.CLIContext) (authctx.TxBuilder, error) { if err := cliCtx.EnsureAccountExists(); err != nil { - return txCtx, err + return txBld, err } from, err := cliCtx.GetFromAddress() if err != nil { - return txCtx, err + return txBld, err } // TODO: (ref #1903) Allow for user supplied account number without // automatically doing a manual lookup. - if txCtx.AccountNumber == 0 { + if txBld.AccountNumber == 0 { accNum, err := cliCtx.GetAccountNumber(from) if err != nil { - return txCtx, err + return txBld, err } - txCtx = txCtx.WithAccountNumber(accNum) + txBld = txBld.WithAccountNumber(accNum) } // TODO: (ref #1903) Allow for user supplied account sequence without // automatically doing a manual lookup. - if txCtx.Sequence == 0 { + if txBld.Sequence == 0 { accSeq, err := cliCtx.GetAccountSequence(from) if err != nil { - return txCtx, err + return txBld, err } - txCtx = txCtx.WithSequence(accSeq) + txBld = txBld.WithSequence(accSeq) } - return txCtx, nil + return txBld, nil } // buildUnsignedStdTx builds a StdTx as per the parameters passed in the // contexts. Gas is automatically estimated if gas wanted is set to 0. -func buildUnsignedStdTx(txCtx authctx.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) (stdTx auth.StdTx, err error) { - txCtx, err = prepareTxContext(txCtx, cliCtx) +func buildUnsignedStdTx(txBld authctx.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) (stdTx auth.StdTx, err error) { + txBld, err = prepareTxContext(txBld, cliCtx) if err != nil { return } - if txCtx.Gas == 0 { - txCtx, err = EnrichCtxWithGas(txCtx, cliCtx, cliCtx.FromAddressName, msgs) + if txBld.Gas == 0 { + txBld, err = EnrichCtxWithGas(txBld, cliCtx, cliCtx.FromAddressName, msgs) if err != nil { return } - fmt.Fprintf(os.Stderr, "estimated gas = %v\n", txCtx.Gas) + fmt.Fprintf(os.Stderr, "estimated gas = %v\n", txBld.Gas) } - stdSignMsg, err := txCtx.Build(msgs) + stdSignMsg, err := txBld.Build(msgs) if err != nil { return } diff --git a/examples/democoin/x/cool/client/cli/tx.go b/examples/democoin/x/cool/client/cli/tx.go index 84ebffba4..0134a1ea6 100644 --- a/examples/democoin/x/cool/client/cli/tx.go +++ b/examples/democoin/x/cool/client/cli/tx.go @@ -21,7 +21,7 @@ func QuizTxCmd(cdc *wire.Codec) *cobra.Command { Short: "What's cooler than being cool?", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout). @@ -34,7 +34,7 @@ func QuizTxCmd(cdc *wire.Codec) *cobra.Command { msg := cool.NewMsgQuiz(from, args[0]) - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } } @@ -46,7 +46,7 @@ func SetTrendTxCmd(cdc *wire.Codec) *cobra.Command { Short: "You're so cool, tell us what is cool!", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout). @@ -59,7 +59,7 @@ func SetTrendTxCmd(cdc *wire.Codec) *cobra.Command { msg := cool.NewMsgSetTrend(from, args[0]) - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } } diff --git a/examples/democoin/x/pow/client/cli/tx.go b/examples/democoin/x/pow/client/cli/tx.go index ef62618ea..820dd105c 100644 --- a/examples/democoin/x/pow/client/cli/tx.go +++ b/examples/democoin/x/pow/client/cli/tx.go @@ -22,7 +22,7 @@ func MineCmd(cdc *wire.Codec) *cobra.Command { Short: "Mine some coins with proof-of-work!", Args: cobra.ExactArgs(4), RunE: func(cmd *cobra.Command, args []string) error { - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout). @@ -53,7 +53,7 @@ func MineCmd(cdc *wire.Codec) *cobra.Command { // Build and sign the transaction, then broadcast to a Tendermint // node. - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } } diff --git a/examples/democoin/x/simplestake/client/cli/commands.go b/examples/democoin/x/simplestake/client/cli/commands.go index 9e9a9004e..f8bd075de 100644 --- a/examples/democoin/x/simplestake/client/cli/commands.go +++ b/examples/democoin/x/simplestake/client/cli/commands.go @@ -30,7 +30,7 @@ func BondTxCmd(cdc *wire.Codec) *cobra.Command { Use: "bond", Short: "Bond to a validator", RunE: func(cmd *cobra.Command, args []string) error { - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout). @@ -68,7 +68,7 @@ func BondTxCmd(cdc *wire.Codec) *cobra.Command { // Build and sign the transaction, then broadcast to a Tendermint // node. - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } @@ -84,7 +84,7 @@ func UnbondTxCmd(cdc *wire.Codec) *cobra.Command { Use: "unbond", Short: "Unbond from a validator", RunE: func(cmd *cobra.Command, args []string) error { - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout) @@ -98,7 +98,7 @@ func UnbondTxCmd(cdc *wire.Codec) *cobra.Command { // Build and sign the transaction, then broadcast to a Tendermint // node. - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } diff --git a/x/bank/client/cli/sendtx.go b/x/bank/client/cli/sendtx.go index 9d812bfb0..98fb3e984 100644 --- a/x/bank/client/cli/sendtx.go +++ b/x/bank/client/cli/sendtx.go @@ -27,7 +27,7 @@ func SendTxCmd(cdc *wire.Codec) *cobra.Command { Use: "send", Short: "Create and sign a send tx", RunE: func(cmd *cobra.Command, args []string) error { - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout). @@ -69,10 +69,10 @@ func SendTxCmd(cdc *wire.Codec) *cobra.Command { // build and sign the transaction, then broadcast to Tendermint msg := client.BuildMsg(from, to, coins) if cliCtx.GenerateOnly { - return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) } - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } diff --git a/x/bank/client/rest/sendtx.go b/x/bank/client/rest/sendtx.go index 1c104cee0..f0d2d6308 100644 --- a/x/bank/client/rest/sendtx.go +++ b/x/bank/client/rest/sendtx.go @@ -80,7 +80,7 @@ func SendRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.CLICo return } - txCtx := authctx.TxBuilder{ + txBld := authctx.TxBuilder{ Codec: cdc, Gas: m.Gas, ChainID: m.ChainID, @@ -95,24 +95,24 @@ func SendRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.CLICo cliCtx = cliCtx.WithGasAdjustment(adjustment) if utils.HasDryRunArg(r) || m.Gas == 0 { - newCtx, err := utils.EnrichCtxWithGas(txCtx, cliCtx, m.LocalAccountName, []sdk.Msg{msg}) + newCtx, err := utils.EnrichCtxWithGas(txBld, cliCtx, m.LocalAccountName, []sdk.Msg{msg}) if err != nil { utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) return } if utils.HasDryRunArg(r) { - utils.WriteSimulationResponse(w, txCtx.Gas) + utils.WriteSimulationResponse(w, txBld.Gas) return } - txCtx = newCtx + txBld = newCtx } if utils.HasGenerateOnlyArg(r) { - utils.WriteGenerateStdTxResponse(w, txCtx, []sdk.Msg{msg}) + utils.WriteGenerateStdTxResponse(w, txBld, []sdk.Msg{msg}) return } - txBytes, err := txCtx.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg}) + txBytes, err := txBld.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg}) if err != nil { utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error()) return diff --git a/x/gov/client/cli/tx.go b/x/gov/client/cli/tx.go index 516753a61..da828e513 100644 --- a/x/gov/client/cli/tx.go +++ b/x/gov/client/cli/tx.go @@ -77,7 +77,7 @@ $ gaiacli gov submit-proposal --title="Test Proposal" --description="My awesome return err } - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout). @@ -105,13 +105,13 @@ $ gaiacli gov submit-proposal --title="Test Proposal" --description="My awesome } if cliCtx.GenerateOnly { - return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) } // Build and sign the transaction, then broadcast to Tendermint // proposalID must be returned, and it is a part of response. cliCtx.PrintResponse = true - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } @@ -161,7 +161,7 @@ func GetCmdDeposit(cdc *wire.Codec) *cobra.Command { Use: "deposit", Short: "deposit tokens for activing proposal", RunE: func(cmd *cobra.Command, args []string) error { - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout). @@ -186,12 +186,12 @@ func GetCmdDeposit(cdc *wire.Codec) *cobra.Command { } if cliCtx.GenerateOnly { - return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) } // Build and sign the transaction, then broadcast to a Tendermint // node. - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } @@ -207,7 +207,7 @@ func GetCmdVote(cdc *wire.Codec) *cobra.Command { Use: "vote", Short: "vote for an active proposal, options: Yes/No/NoWithVeto/Abstain", RunE: func(cmd *cobra.Command, args []string) error { - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout). @@ -233,7 +233,7 @@ func GetCmdVote(cdc *wire.Codec) *cobra.Command { } if cliCtx.GenerateOnly { - return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) } fmt.Printf("Vote[Voter:%s,ProposalID:%d,Option:%s]", @@ -242,7 +242,7 @@ func GetCmdVote(cdc *wire.Codec) *cobra.Command { // Build and sign the transaction, then broadcast to a Tendermint // node. - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } diff --git a/x/gov/client/rest/util.go b/x/gov/client/rest/util.go index d10ca48b7..f8152042e 100644 --- a/x/gov/client/rest/util.go +++ b/x/gov/client/rest/util.go @@ -70,7 +70,7 @@ func (req baseReq) baseReqValidate(w http.ResponseWriter) bool { // (probably should live in client/lcd). func signAndBuild(w http.ResponseWriter, r *http.Request, cliCtx context.CLIContext, baseReq baseReq, msg sdk.Msg, cdc *wire.Codec) { var err error - txCtx := authctx.TxBuilder{ + txBld := authctx.TxBuilder{ Codec: cdc, AccountNumber: baseReq.AccountNumber, Sequence: baseReq.Sequence, @@ -85,24 +85,24 @@ func signAndBuild(w http.ResponseWriter, r *http.Request, cliCtx context.CLICont cliCtx = cliCtx.WithGasAdjustment(adjustment) if utils.HasDryRunArg(r) || baseReq.Gas == 0 { - newCtx, err := utils.EnrichCtxWithGas(txCtx, cliCtx, baseReq.Name, []sdk.Msg{msg}) + newCtx, err := utils.EnrichCtxWithGas(txBld, cliCtx, baseReq.Name, []sdk.Msg{msg}) if err != nil { utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) return } if utils.HasDryRunArg(r) { - utils.WriteSimulationResponse(w, txCtx.Gas) + utils.WriteSimulationResponse(w, txBld.Gas) return } - txCtx = newCtx + txBld = newCtx } if utils.HasGenerateOnlyArg(r) { - utils.WriteGenerateStdTxResponse(w, txCtx, []sdk.Msg{msg}) + utils.WriteGenerateStdTxResponse(w, txBld, []sdk.Msg{msg}) return } - txBytes, err := txCtx.BuildAndSign(baseReq.Name, baseReq.Password, []sdk.Msg{msg}) + txBytes, err := txBld.BuildAndSign(baseReq.Name, baseReq.Password, []sdk.Msg{msg}) if err != nil { utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error()) return diff --git a/x/ibc/client/cli/ibctx.go b/x/ibc/client/cli/ibctx.go index bf5d551e5..9c20a44f7 100644 --- a/x/ibc/client/cli/ibctx.go +++ b/x/ibc/client/cli/ibctx.go @@ -28,7 +28,7 @@ func IBCTransferCmd(cdc *wire.Codec) *cobra.Command { cmd := &cobra.Command{ Use: "transfer", RunE: func(cmd *cobra.Command, args []string) error { - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout). @@ -44,10 +44,10 @@ func IBCTransferCmd(cdc *wire.Codec) *cobra.Command { return err } if cliCtx.GenerateOnly { - return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) } - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } diff --git a/x/ibc/client/cli/relay.go b/x/ibc/client/cli/relay.go index deeb4d2d1..1bb679987 100644 --- a/x/ibc/client/cli/relay.go +++ b/x/ibc/client/cli/relay.go @@ -199,10 +199,10 @@ func (c relayCommander) refine(bz []byte, sequence int64, passphrase string) []b Sequence: sequence, } - txCtx := authctx.NewTxBuilderFromCLI().WithSequence(sequence).WithCodec(c.cdc) + txBld := authctx.NewTxBuilderFromCLI().WithSequence(sequence).WithCodec(c.cdc) cliCtx := context.NewCLIContext() - res, err := txCtx.BuildAndSign(cliCtx.FromAddressName, passphrase, []sdk.Msg{msg}) + res, err := txBld.BuildAndSign(cliCtx.FromAddressName, passphrase, []sdk.Msg{msg}) if err != nil { panic(err) } diff --git a/x/ibc/client/rest/transfer.go b/x/ibc/client/rest/transfer.go index 1bd0cb84b..c071e48d1 100644 --- a/x/ibc/client/rest/transfer.go +++ b/x/ibc/client/rest/transfer.go @@ -71,7 +71,7 @@ func TransferRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.C packet := ibc.NewIBCPacket(sdk.AccAddress(info.GetPubKey().Address()), to, m.Amount, m.SrcChainID, destChainID) msg := ibc.IBCTransferMsg{packet} - txCtx := authctx.TxBuilder{ + txBld := authctx.TxBuilder{ Codec: cdc, ChainID: m.SrcChainID, AccountNumber: m.AccountNumber, @@ -86,24 +86,24 @@ func TransferRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.C cliCtx = cliCtx.WithGasAdjustment(adjustment) if utils.HasDryRunArg(r) || m.Gas == 0 { - newCtx, err := utils.EnrichCtxWithGas(txCtx, cliCtx, m.LocalAccountName, []sdk.Msg{msg}) + newCtx, err := utils.EnrichCtxWithGas(txBld, cliCtx, m.LocalAccountName, []sdk.Msg{msg}) if err != nil { utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) return } if utils.HasDryRunArg(r) { - utils.WriteSimulationResponse(w, txCtx.Gas) + utils.WriteSimulationResponse(w, txBld.Gas) return } - txCtx = newCtx + txBld = newCtx } if utils.HasGenerateOnlyArg(r) { - utils.WriteGenerateStdTxResponse(w, txCtx, []sdk.Msg{msg}) + utils.WriteGenerateStdTxResponse(w, txBld, []sdk.Msg{msg}) return } - txBytes, err := txCtx.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg}) + txBytes, err := txBld.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg}) if err != nil { utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error()) return diff --git a/x/slashing/client/cli/tx.go b/x/slashing/client/cli/tx.go index 777d1542c..60c89a2cb 100644 --- a/x/slashing/client/cli/tx.go +++ b/x/slashing/client/cli/tx.go @@ -21,7 +21,7 @@ func GetCmdUnjail(cdc *wire.Codec) *cobra.Command { Args: cobra.NoArgs, Short: "unjail validator previously jailed for downtime", RunE: func(cmd *cobra.Command, args []string) error { - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout). @@ -34,9 +34,9 @@ func GetCmdUnjail(cdc *wire.Codec) *cobra.Command { msg := slashing.NewMsgUnjail(sdk.ValAddress(valAddr)) if cliCtx.GenerateOnly { - return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) } - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } diff --git a/x/slashing/client/rest/tx.go b/x/slashing/client/rest/tx.go index 2b9c90195..4c07515cb 100644 --- a/x/slashing/client/rest/tx.go +++ b/x/slashing/client/rest/tx.go @@ -70,7 +70,7 @@ func unjailRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.CLI return } - txCtx := authctx.TxBuilder{ + txBld := authctx.TxBuilder{ Codec: cdc, ChainID: m.ChainID, AccountNumber: m.AccountNumber, @@ -87,24 +87,24 @@ func unjailRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.CLI cliCtx = cliCtx.WithGasAdjustment(adjustment) if utils.HasDryRunArg(r) || m.Gas == 0 { - newCtx, err := utils.EnrichCtxWithGas(txCtx, cliCtx, m.LocalAccountName, []sdk.Msg{msg}) + newCtx, err := utils.EnrichCtxWithGas(txBld, cliCtx, m.LocalAccountName, []sdk.Msg{msg}) if err != nil { utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) return } if utils.HasDryRunArg(r) { - utils.WriteSimulationResponse(w, txCtx.Gas) + utils.WriteSimulationResponse(w, txBld.Gas) return } - txCtx = newCtx + txBld = newCtx } if utils.HasGenerateOnlyArg(r) { - utils.WriteGenerateStdTxResponse(w, txCtx, []sdk.Msg{msg}) + utils.WriteGenerateStdTxResponse(w, txBld, []sdk.Msg{msg}) return } - txBytes, err := txCtx.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg}) + txBytes, err := txBld.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg}) if err != nil { utils.WriteErrorResponse(w, http.StatusUnauthorized, "Must use own validator address") return diff --git a/x/stake/client/cli/tx.go b/x/stake/client/cli/tx.go index 2e5e22755..a103932c3 100644 --- a/x/stake/client/cli/tx.go +++ b/x/stake/client/cli/tx.go @@ -25,7 +25,7 @@ func GetCmdCreateValidator(cdc *wire.Codec) *cobra.Command { Use: "create-validator", Short: "create new validator initialized with a self-delegation to it", RunE: func(cmd *cobra.Command, args []string) error { - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout). @@ -78,10 +78,10 @@ func GetCmdCreateValidator(cdc *wire.Codec) *cobra.Command { msg = stake.NewMsgCreateValidator(sdk.ValAddress(valAddr), pk, amount, description) } if cliCtx.GenerateOnly { - return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) } // build and sign the transaction, then broadcast to Tendermint - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } @@ -99,7 +99,7 @@ func GetCmdEditValidator(cdc *wire.Codec) *cobra.Command { Use: "edit-validator", Short: "edit and existing validator account", RunE: func(cmd *cobra.Command, args []string) error { - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout). @@ -120,10 +120,10 @@ func GetCmdEditValidator(cdc *wire.Codec) *cobra.Command { msg := stake.NewMsgEditValidator(sdk.ValAddress(valAddr), description) if cliCtx.GenerateOnly { - return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) } // build and sign the transaction, then broadcast to Tendermint - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } @@ -138,7 +138,7 @@ func GetCmdDelegate(cdc *wire.Codec) *cobra.Command { Use: "delegate", Short: "delegate liquid tokens to an validator", RunE: func(cmd *cobra.Command, args []string) error { - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout). @@ -162,10 +162,10 @@ func GetCmdDelegate(cdc *wire.Codec) *cobra.Command { msg := stake.NewMsgDelegate(delAddr, valAddr, amount) if cliCtx.GenerateOnly { - return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) } // build and sign the transaction, then broadcast to Tendermint - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } @@ -197,7 +197,7 @@ func GetCmdBeginRedelegate(storeName string, cdc *wire.Codec) *cobra.Command { Use: "begin", Short: "begin redelegation", RunE: func(cmd *cobra.Command, args []string) error { - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout). @@ -234,10 +234,10 @@ func GetCmdBeginRedelegate(storeName string, cdc *wire.Codec) *cobra.Command { msg := stake.NewMsgBeginRedelegate(delAddr, valSrcAddr, valDstAddr, sharesAmount) if cliCtx.GenerateOnly { - return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) } // build and sign the transaction, then broadcast to Tendermint - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } @@ -301,7 +301,7 @@ func GetCmdCompleteRedelegate(cdc *wire.Codec) *cobra.Command { Use: "complete", Short: "complete redelegation", RunE: func(cmd *cobra.Command, args []string) error { - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout). @@ -325,10 +325,10 @@ func GetCmdCompleteRedelegate(cdc *wire.Codec) *cobra.Command { msg := stake.NewMsgCompleteRedelegate(delAddr, valSrcAddr, valDstAddr) if cliCtx.GenerateOnly { - return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) } // build and sign the transaction, then broadcast to Tendermint - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } @@ -359,7 +359,7 @@ func GetCmdBeginUnbonding(storeName string, cdc *wire.Codec) *cobra.Command { Use: "begin", Short: "begin unbonding", RunE: func(cmd *cobra.Command, args []string) error { - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout). @@ -389,10 +389,10 @@ func GetCmdBeginUnbonding(storeName string, cdc *wire.Codec) *cobra.Command { msg := stake.NewMsgBeginUnbonding(delAddr, valAddr, sharesAmount) if cliCtx.GenerateOnly { - return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) } // build and sign the transaction, then broadcast to Tendermint - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } @@ -408,7 +408,7 @@ func GetCmdCompleteUnbonding(cdc *wire.Codec) *cobra.Command { Use: "complete", Short: "complete unbonding", RunE: func(cmd *cobra.Command, args []string) error { - txCtx := authctx.NewTxBuilderFromCLI().WithCodec(cdc) + txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc) cliCtx := context.NewCLIContext(). WithCodec(cdc). WithLogger(os.Stdout). @@ -427,10 +427,10 @@ func GetCmdCompleteUnbonding(cdc *wire.Codec) *cobra.Command { msg := stake.NewMsgCompleteUnbonding(delAddr, valAddr) if cliCtx.GenerateOnly { - return utils.PrintUnsignedStdTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) } // build and sign the transaction, then broadcast to Tendermint - return utils.SendTx(txCtx, cliCtx, []sdk.Msg{msg}) + return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) }, } diff --git a/x/stake/client/rest/tx.go b/x/stake/client/rest/tx.go index dd478487b..f43e83749 100644 --- a/x/stake/client/rest/tx.go +++ b/x/stake/client/rest/tx.go @@ -263,7 +263,7 @@ func delegationsRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx contex i++ } - txCtx := authcliCtx.TxBuilder{ + txBld := authcliCtx.TxBuilder{ Codec: cdc, ChainID: m.ChainID, Gas: m.Gas, @@ -273,8 +273,8 @@ func delegationsRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx contex signedTxs := make([][]byte, len(messages[:])) for i, msg := range messages { // increment sequence for each message - txCtx = txCtx.WithAccountNumber(m.AccountNumber) - txCtx = txCtx.WithSequence(m.Sequence) + txBld = txBld.WithAccountNumber(m.AccountNumber) + txBld = txBld.WithSequence(m.Sequence) m.Sequence++ @@ -285,24 +285,24 @@ func delegationsRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx contex cliCtx = cliCtx.WithGasAdjustment(adjustment) if utils.HasDryRunArg(r) || m.Gas == 0 { - newCtx, err := utils.EnrichCtxWithGas(txCtx, cliCtx, m.LocalAccountName, []sdk.Msg{msg}) + newCtx, err := utils.EnrichCtxWithGas(txBld, cliCtx, m.LocalAccountName, []sdk.Msg{msg}) if err != nil { utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) return } if utils.HasDryRunArg(r) { - utils.WriteSimulationResponse(w, txCtx.Gas) + utils.WriteSimulationResponse(w, txBld.Gas) return } - txCtx = newCtx + txBld = newCtx } if utils.HasGenerateOnlyArg(r) { - utils.WriteGenerateStdTxResponse(w, txCtx, []sdk.Msg{msg}) + utils.WriteGenerateStdTxResponse(w, txBld, []sdk.Msg{msg}) return } - txBytes, err := txCtx.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg}) + txBytes, err := txBld.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg}) if err != nil { utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error()) return