txBld -> txBldr

This commit is contained in:
Jae Kwon 2018-09-07 10:15:49 -07:00
parent acd125029d
commit 6325441861
16 changed files with 116 additions and 116 deletions

View File

@ -52,13 +52,13 @@ func ParseFloat64OrReturnBadRequest(w http.ResponseWriter, s string, defaultIfEm
} }
// WriteGenerateStdTxResponse writes response for the generate_only mode. // WriteGenerateStdTxResponse writes response for the generate_only mode.
func WriteGenerateStdTxResponse(w http.ResponseWriter, txBld authtxb.TxBuilder, msgs []sdk.Msg) { func WriteGenerateStdTxResponse(w http.ResponseWriter, txBldr authtxb.TxBuilder, msgs []sdk.Msg) {
stdMsg, err := txBld.Build(msgs) stdMsg, err := txBldr.Build(msgs)
if err != nil { if err != nil {
WriteErrorResponse(w, http.StatusBadRequest, err.Error()) WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return return
} }
output, err := txBld.Codec.MarshalJSON(auth.NewStdTx(stdMsg.Msgs, stdMsg.Fee, nil, stdMsg.Memo)) output, err := txBldr.Codec.MarshalJSON(auth.NewStdTx(stdMsg.Msgs, stdMsg.Fee, nil, stdMsg.Memo))
if err != nil { if err != nil {
WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return return

View File

@ -18,18 +18,18 @@ import (
// ensures that the account exists, has a proper number and sequence set. In // ensures that the account exists, has a proper number and sequence set. In
// addition, it builds and signs a transaction with the supplied messages. // addition, it builds and signs a transaction with the supplied messages.
// Finally, it broadcasts the signed transaction to a node. // Finally, it broadcasts the signed transaction to a node.
func SendTx(txBld authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) error { func SendTx(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) error {
txBld, err := prepareTxContext(txBld, cliCtx) txBldr, err := prepareTxContext(txBldr, cliCtx)
if err != nil { if err != nil {
return err return err
} }
autogas := cliCtx.DryRun || (cliCtx.Gas == 0) autogas := cliCtx.DryRun || (cliCtx.Gas == 0)
if autogas { if autogas {
txBld, err = EnrichCtxWithGas(txBld, cliCtx, cliCtx.FromAddressName, msgs) txBldr, err = EnrichCtxWithGas(txBldr, cliCtx, cliCtx.FromAddressName, msgs)
if err != nil { if err != nil {
return err return err
} }
fmt.Fprintf(os.Stderr, "estimated gas = %v\n", txBld.Gas) fmt.Fprintf(os.Stderr, "estimated gas = %v\n", txBldr.Gas)
} }
if cliCtx.DryRun { if cliCtx.DryRun {
return nil return nil
@ -41,7 +41,7 @@ func SendTx(txBld authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg)
} }
// build and sign the transaction // build and sign the transaction
txBytes, err := txBld.BuildAndSign(cliCtx.FromAddressName, passphrase, msgs) txBytes, err := txBldr.BuildAndSign(cliCtx.FromAddressName, passphrase, msgs)
if err != nil { if err != nil {
return err return err
} }
@ -50,8 +50,8 @@ func SendTx(txBld authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg)
} }
// SimulateMsgs simulates the transaction and returns the gas estimate and the adjusted value. // SimulateMsgs simulates the transaction and returns the gas estimate and the adjusted value.
func SimulateMsgs(txBld authtxb.TxBuilder, cliCtx context.CLIContext, name string, msgs []sdk.Msg, gas int64) (estimated, adjusted int64, err error) { func SimulateMsgs(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, name string, msgs []sdk.Msg, gas int64) (estimated, adjusted int64, err error) {
txBytes, err := txBld.WithGas(gas).BuildWithPubKey(name, msgs) txBytes, err := txBldr.WithGas(gas).BuildWithPubKey(name, msgs)
if err != nil { if err != nil {
return return
} }
@ -61,12 +61,12 @@ func SimulateMsgs(txBld authtxb.TxBuilder, cliCtx context.CLIContext, name strin
// EnrichCtxWithGas calculates the gas estimate that would be consumed by the // EnrichCtxWithGas calculates the gas estimate that would be consumed by the
// transaction and set the transaction's respective value accordingly. // transaction and set the transaction's respective value accordingly.
func EnrichCtxWithGas(txBld authtxb.TxBuilder, cliCtx context.CLIContext, name string, msgs []sdk.Msg) (authtxb.TxBuilder, error) { func EnrichCtxWithGas(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, name string, msgs []sdk.Msg) (authtxb.TxBuilder, error) {
_, adjusted, err := SimulateMsgs(txBld, cliCtx, name, msgs, 0) _, adjusted, err := SimulateMsgs(txBldr, cliCtx, name, msgs, 0)
if err != nil { if err != nil {
return txBld, err return txBldr, err
} }
return txBld.WithGas(adjusted), nil return txBldr.WithGas(adjusted), nil
} }
// CalculateGas simulates the execution of a transaction and returns // 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. // PrintUnsignedStdTx builds an unsigned StdTx and prints it to os.Stdout.
func PrintUnsignedStdTx(txBld authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) (err error) { func PrintUnsignedStdTx(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) (err error) {
stdTx, err := buildUnsignedStdTx(txBld, cliCtx, msgs) stdTx, err := buildUnsignedStdTx(txBldr, cliCtx, msgs)
if err != nil { if err != nil {
return return
} }
json, err := txBld.Codec.MarshalJSON(stdTx) json, err := txBldr.Codec.MarshalJSON(stdTx)
if err == nil { if err == nil {
fmt.Printf("%s\n", json) fmt.Printf("%s\n", json)
} }
@ -111,53 +111,53 @@ func parseQueryResponse(cdc *amino.Codec, rawRes []byte) (int64, error) {
return simulationResult.GasUsed, nil return simulationResult.GasUsed, nil
} }
func prepareTxContext(txBld authtxb.TxBuilder, cliCtx context.CLIContext) (authtxb.TxBuilder, error) { func prepareTxContext(txBldr authtxb.TxBuilder, cliCtx context.CLIContext) (authtxb.TxBuilder, error) {
if err := cliCtx.EnsureAccountExists(); err != nil { if err := cliCtx.EnsureAccountExists(); err != nil {
return txBld, err return txBldr, err
} }
from, err := cliCtx.GetFromAddress() from, err := cliCtx.GetFromAddress()
if err != nil { if err != nil {
return txBld, err return txBldr, err
} }
// TODO: (ref #1903) Allow for user supplied account number without // TODO: (ref #1903) Allow for user supplied account number without
// automatically doing a manual lookup. // automatically doing a manual lookup.
if txBld.AccountNumber == 0 { if txBldr.AccountNumber == 0 {
accNum, err := cliCtx.GetAccountNumber(from) accNum, err := cliCtx.GetAccountNumber(from)
if err != nil { if err != nil {
return txBld, err return txBldr, err
} }
txBld = txBld.WithAccountNumber(accNum) txBldr = txBldr.WithAccountNumber(accNum)
} }
// TODO: (ref #1903) Allow for user supplied account sequence without // TODO: (ref #1903) Allow for user supplied account sequence without
// automatically doing a manual lookup. // automatically doing a manual lookup.
if txBld.Sequence == 0 { if txBldr.Sequence == 0 {
accSeq, err := cliCtx.GetAccountSequence(from) accSeq, err := cliCtx.GetAccountSequence(from)
if err != nil { if err != nil {
return txBld, err return txBldr, err
} }
txBld = txBld.WithSequence(accSeq) txBldr = txBldr.WithSequence(accSeq)
} }
return txBld, nil return txBldr, nil
} }
// buildUnsignedStdTx builds a StdTx as per the parameters passed in the // buildUnsignedStdTx builds a StdTx as per the parameters passed in the
// contexts. Gas is automatically estimated if gas wanted is set to 0. // contexts. Gas is automatically estimated if gas wanted is set to 0.
func buildUnsignedStdTx(txBld authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) (stdTx auth.StdTx, err error) { func buildUnsignedStdTx(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) (stdTx auth.StdTx, err error) {
txBld, err = prepareTxContext(txBld, cliCtx) txBldr, err = prepareTxContext(txBldr, cliCtx)
if err != nil { if err != nil {
return return
} }
if txBld.Gas == 0 { if txBldr.Gas == 0 {
txBld, err = EnrichCtxWithGas(txBld, cliCtx, cliCtx.FromAddressName, msgs) txBldr, err = EnrichCtxWithGas(txBldr, cliCtx, cliCtx.FromAddressName, msgs)
if err != nil { if err != nil {
return return
} }
fmt.Fprintf(os.Stderr, "estimated gas = %v\n", txBld.Gas) fmt.Fprintf(os.Stderr, "estimated gas = %v\n", txBldr.Gas)
} }
stdSignMsg, err := txBld.Build(msgs) stdSignMsg, err := txBldr.Build(msgs)
if err != nil { if err != nil {
return return
} }

View File

@ -21,7 +21,7 @@ func QuizTxCmd(cdc *wire.Codec) *cobra.Command {
Short: "What's cooler than being cool?", Short: "What's cooler than being cool?",
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout). WithLogger(os.Stdout).
@ -34,7 +34,7 @@ func QuizTxCmd(cdc *wire.Codec) *cobra.Command {
msg := cool.NewMsgQuiz(from, args[0]) msg := cool.NewMsgQuiz(from, args[0])
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, 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!", Short: "You're so cool, tell us what is cool!",
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout). WithLogger(os.Stdout).
@ -59,7 +59,7 @@ func SetTrendTxCmd(cdc *wire.Codec) *cobra.Command {
msg := cool.NewMsgSetTrend(from, args[0]) msg := cool.NewMsgSetTrend(from, args[0])
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
}, },
} }
} }

View File

@ -22,7 +22,7 @@ func MineCmd(cdc *wire.Codec) *cobra.Command {
Short: "Mine some coins with proof-of-work!", Short: "Mine some coins with proof-of-work!",
Args: cobra.ExactArgs(4), Args: cobra.ExactArgs(4),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout). WithLogger(os.Stdout).
@ -53,7 +53,7 @@ func MineCmd(cdc *wire.Codec) *cobra.Command {
// Build and sign the transaction, then broadcast to a Tendermint // Build and sign the transaction, then broadcast to a Tendermint
// node. // node.
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
}, },
} }
} }

View File

@ -30,7 +30,7 @@ func BondTxCmd(cdc *wire.Codec) *cobra.Command {
Use: "bond", Use: "bond",
Short: "Bond to a validator", Short: "Bond to a validator",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout). WithLogger(os.Stdout).
@ -68,7 +68,7 @@ func BondTxCmd(cdc *wire.Codec) *cobra.Command {
// Build and sign the transaction, then broadcast to a Tendermint // Build and sign the transaction, then broadcast to a Tendermint
// node. // node.
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
}, },
} }
@ -84,7 +84,7 @@ func UnbondTxCmd(cdc *wire.Codec) *cobra.Command {
Use: "unbond", Use: "unbond",
Short: "Unbond from a validator", Short: "Unbond from a validator",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout) WithLogger(os.Stdout)
@ -98,7 +98,7 @@ func UnbondTxCmd(cdc *wire.Codec) *cobra.Command {
// Build and sign the transaction, then broadcast to a Tendermint // Build and sign the transaction, then broadcast to a Tendermint
// node. // node.
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
}, },
} }

View File

@ -27,7 +27,7 @@ func SendTxCmd(cdc *wire.Codec) *cobra.Command {
Use: "send", Use: "send",
Short: "Create and sign a send tx", Short: "Create and sign a send tx",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout). WithLogger(os.Stdout).
@ -69,10 +69,10 @@ func SendTxCmd(cdc *wire.Codec) *cobra.Command {
// build and sign the transaction, then broadcast to Tendermint // build and sign the transaction, then broadcast to Tendermint
msg := client.BuildMsg(from, to, coins) msg := client.BuildMsg(from, to, coins)
if cliCtx.GenerateOnly { if cliCtx.GenerateOnly {
return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
} }
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
}, },
} }

View File

@ -80,7 +80,7 @@ func SendRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.CLICo
return return
} }
txBld := authtxb.TxBuilder{ txBldr := authtxb.TxBuilder{
Codec: cdc, Codec: cdc,
Gas: m.Gas, Gas: m.Gas,
ChainID: m.ChainID, ChainID: m.ChainID,
@ -95,24 +95,24 @@ func SendRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.CLICo
cliCtx = cliCtx.WithGasAdjustment(adjustment) cliCtx = cliCtx.WithGasAdjustment(adjustment)
if utils.HasDryRunArg(r) || m.Gas == 0 { if utils.HasDryRunArg(r) || m.Gas == 0 {
newCtx, err := utils.EnrichCtxWithGas(txBld, cliCtx, m.LocalAccountName, []sdk.Msg{msg}) newCtx, err := utils.EnrichCtxWithGas(txBldr, cliCtx, m.LocalAccountName, []sdk.Msg{msg})
if err != nil { if err != nil {
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return return
} }
if utils.HasDryRunArg(r) { if utils.HasDryRunArg(r) {
utils.WriteSimulationResponse(w, txBld.Gas) utils.WriteSimulationResponse(w, txBldr.Gas)
return return
} }
txBld = newCtx txBldr = newCtx
} }
if utils.HasGenerateOnlyArg(r) { if utils.HasGenerateOnlyArg(r) {
utils.WriteGenerateStdTxResponse(w, txBld, []sdk.Msg{msg}) utils.WriteGenerateStdTxResponse(w, txBldr, []sdk.Msg{msg})
return return
} }
txBytes, err := txBld.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg}) txBytes, err := txBldr.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg})
if err != nil { if err != nil {
utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error()) utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error())
return return

View File

@ -77,7 +77,7 @@ $ gaiacli gov submit-proposal --title="Test Proposal" --description="My awesome
return err return err
} }
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout). WithLogger(os.Stdout).
@ -105,13 +105,13 @@ $ gaiacli gov submit-proposal --title="Test Proposal" --description="My awesome
} }
if cliCtx.GenerateOnly { if cliCtx.GenerateOnly {
return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
} }
// Build and sign the transaction, then broadcast to Tendermint // Build and sign the transaction, then broadcast to Tendermint
// proposalID must be returned, and it is a part of response. // proposalID must be returned, and it is a part of response.
cliCtx.PrintResponse = true cliCtx.PrintResponse = true
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
}, },
} }
@ -161,7 +161,7 @@ func GetCmdDeposit(cdc *wire.Codec) *cobra.Command {
Use: "deposit", Use: "deposit",
Short: "deposit tokens for activing proposal", Short: "deposit tokens for activing proposal",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout). WithLogger(os.Stdout).
@ -186,12 +186,12 @@ func GetCmdDeposit(cdc *wire.Codec) *cobra.Command {
} }
if cliCtx.GenerateOnly { if cliCtx.GenerateOnly {
return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
} }
// Build and sign the transaction, then broadcast to a Tendermint // Build and sign the transaction, then broadcast to a Tendermint
// node. // node.
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
}, },
} }
@ -207,7 +207,7 @@ func GetCmdVote(cdc *wire.Codec) *cobra.Command {
Use: "vote", Use: "vote",
Short: "vote for an active proposal, options: Yes/No/NoWithVeto/Abstain", Short: "vote for an active proposal, options: Yes/No/NoWithVeto/Abstain",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout). WithLogger(os.Stdout).
@ -233,7 +233,7 @@ func GetCmdVote(cdc *wire.Codec) *cobra.Command {
} }
if cliCtx.GenerateOnly { if cliCtx.GenerateOnly {
return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
} }
fmt.Printf("Vote[Voter:%s,ProposalID:%d,Option:%s]", 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 // Build and sign the transaction, then broadcast to a Tendermint
// node. // node.
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
}, },
} }

View File

@ -70,7 +70,7 @@ func (req baseReq) baseReqValidate(w http.ResponseWriter) bool {
// (probably should live in client/lcd). // (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) { func signAndBuild(w http.ResponseWriter, r *http.Request, cliCtx context.CLIContext, baseReq baseReq, msg sdk.Msg, cdc *wire.Codec) {
var err error var err error
txBld := authtxb.TxBuilder{ txBldr := authtxb.TxBuilder{
Codec: cdc, Codec: cdc,
AccountNumber: baseReq.AccountNumber, AccountNumber: baseReq.AccountNumber,
Sequence: baseReq.Sequence, Sequence: baseReq.Sequence,
@ -85,24 +85,24 @@ func signAndBuild(w http.ResponseWriter, r *http.Request, cliCtx context.CLICont
cliCtx = cliCtx.WithGasAdjustment(adjustment) cliCtx = cliCtx.WithGasAdjustment(adjustment)
if utils.HasDryRunArg(r) || baseReq.Gas == 0 { if utils.HasDryRunArg(r) || baseReq.Gas == 0 {
newCtx, err := utils.EnrichCtxWithGas(txBld, cliCtx, baseReq.Name, []sdk.Msg{msg}) newCtx, err := utils.EnrichCtxWithGas(txBldr, cliCtx, baseReq.Name, []sdk.Msg{msg})
if err != nil { if err != nil {
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return return
} }
if utils.HasDryRunArg(r) { if utils.HasDryRunArg(r) {
utils.WriteSimulationResponse(w, txBld.Gas) utils.WriteSimulationResponse(w, txBldr.Gas)
return return
} }
txBld = newCtx txBldr = newCtx
} }
if utils.HasGenerateOnlyArg(r) { if utils.HasGenerateOnlyArg(r) {
utils.WriteGenerateStdTxResponse(w, txBld, []sdk.Msg{msg}) utils.WriteGenerateStdTxResponse(w, txBldr, []sdk.Msg{msg})
return return
} }
txBytes, err := txBld.BuildAndSign(baseReq.Name, baseReq.Password, []sdk.Msg{msg}) txBytes, err := txBldr.BuildAndSign(baseReq.Name, baseReq.Password, []sdk.Msg{msg})
if err != nil { if err != nil {
utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error()) utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error())
return return

View File

@ -28,7 +28,7 @@ func IBCTransferCmd(cdc *wire.Codec) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "transfer", Use: "transfer",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout). WithLogger(os.Stdout).
@ -44,10 +44,10 @@ func IBCTransferCmd(cdc *wire.Codec) *cobra.Command {
return err return err
} }
if cliCtx.GenerateOnly { if cliCtx.GenerateOnly {
return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
} }
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
}, },
} }

View File

@ -199,10 +199,10 @@ func (c relayCommander) refine(bz []byte, sequence int64, passphrase string) []b
Sequence: sequence, Sequence: sequence,
} }
txBld := authtxb.NewTxBuilderFromCLI().WithSequence(sequence).WithCodec(c.cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithSequence(sequence).WithCodec(c.cdc)
cliCtx := context.NewCLIContext() cliCtx := context.NewCLIContext()
res, err := txBld.BuildAndSign(cliCtx.FromAddressName, passphrase, []sdk.Msg{msg}) res, err := txBldr.BuildAndSign(cliCtx.FromAddressName, passphrase, []sdk.Msg{msg})
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@ -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) packet := ibc.NewIBCPacket(sdk.AccAddress(info.GetPubKey().Address()), to, m.Amount, m.SrcChainID, destChainID)
msg := ibc.IBCTransferMsg{packet} msg := ibc.IBCTransferMsg{packet}
txBld := authtxb.TxBuilder{ txBldr := authtxb.TxBuilder{
Codec: cdc, Codec: cdc,
ChainID: m.SrcChainID, ChainID: m.SrcChainID,
AccountNumber: m.AccountNumber, AccountNumber: m.AccountNumber,
@ -86,24 +86,24 @@ func TransferRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.C
cliCtx = cliCtx.WithGasAdjustment(adjustment) cliCtx = cliCtx.WithGasAdjustment(adjustment)
if utils.HasDryRunArg(r) || m.Gas == 0 { if utils.HasDryRunArg(r) || m.Gas == 0 {
newCtx, err := utils.EnrichCtxWithGas(txBld, cliCtx, m.LocalAccountName, []sdk.Msg{msg}) newCtx, err := utils.EnrichCtxWithGas(txBldr, cliCtx, m.LocalAccountName, []sdk.Msg{msg})
if err != nil { if err != nil {
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return return
} }
if utils.HasDryRunArg(r) { if utils.HasDryRunArg(r) {
utils.WriteSimulationResponse(w, txBld.Gas) utils.WriteSimulationResponse(w, txBldr.Gas)
return return
} }
txBld = newCtx txBldr = newCtx
} }
if utils.HasGenerateOnlyArg(r) { if utils.HasGenerateOnlyArg(r) {
utils.WriteGenerateStdTxResponse(w, txBld, []sdk.Msg{msg}) utils.WriteGenerateStdTxResponse(w, txBldr, []sdk.Msg{msg})
return return
} }
txBytes, err := txBld.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg}) txBytes, err := txBldr.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg})
if err != nil { if err != nil {
utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error()) utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error())
return return

View File

@ -21,7 +21,7 @@ func GetCmdUnjail(cdc *wire.Codec) *cobra.Command {
Args: cobra.NoArgs, Args: cobra.NoArgs,
Short: "unjail validator previously jailed for downtime", Short: "unjail validator previously jailed for downtime",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout). WithLogger(os.Stdout).
@ -34,9 +34,9 @@ func GetCmdUnjail(cdc *wire.Codec) *cobra.Command {
msg := slashing.NewMsgUnjail(sdk.ValAddress(valAddr)) msg := slashing.NewMsgUnjail(sdk.ValAddress(valAddr))
if cliCtx.GenerateOnly { if cliCtx.GenerateOnly {
return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
} }
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
}, },
} }

View File

@ -70,7 +70,7 @@ func unjailRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.CLI
return return
} }
txBld := authtxb.TxBuilder{ txBldr := authtxb.TxBuilder{
Codec: cdc, Codec: cdc,
ChainID: m.ChainID, ChainID: m.ChainID,
AccountNumber: m.AccountNumber, AccountNumber: m.AccountNumber,
@ -87,24 +87,24 @@ func unjailRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.CLI
cliCtx = cliCtx.WithGasAdjustment(adjustment) cliCtx = cliCtx.WithGasAdjustment(adjustment)
if utils.HasDryRunArg(r) || m.Gas == 0 { if utils.HasDryRunArg(r) || m.Gas == 0 {
newCtx, err := utils.EnrichCtxWithGas(txBld, cliCtx, m.LocalAccountName, []sdk.Msg{msg}) newCtx, err := utils.EnrichCtxWithGas(txBldr, cliCtx, m.LocalAccountName, []sdk.Msg{msg})
if err != nil { if err != nil {
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return return
} }
if utils.HasDryRunArg(r) { if utils.HasDryRunArg(r) {
utils.WriteSimulationResponse(w, txBld.Gas) utils.WriteSimulationResponse(w, txBldr.Gas)
return return
} }
txBld = newCtx txBldr = newCtx
} }
if utils.HasGenerateOnlyArg(r) { if utils.HasGenerateOnlyArg(r) {
utils.WriteGenerateStdTxResponse(w, txBld, []sdk.Msg{msg}) utils.WriteGenerateStdTxResponse(w, txBldr, []sdk.Msg{msg})
return return
} }
txBytes, err := txBld.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg}) txBytes, err := txBldr.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg})
if err != nil { if err != nil {
utils.WriteErrorResponse(w, http.StatusUnauthorized, "Must use own validator address") utils.WriteErrorResponse(w, http.StatusUnauthorized, "Must use own validator address")
return return

View File

@ -25,7 +25,7 @@ func GetCmdCreateValidator(cdc *wire.Codec) *cobra.Command {
Use: "create-validator", Use: "create-validator",
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 {
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout). WithLogger(os.Stdout).
@ -78,10 +78,10 @@ func GetCmdCreateValidator(cdc *wire.Codec) *cobra.Command {
msg = stake.NewMsgCreateValidator(sdk.ValAddress(valAddr), pk, amount, description) msg = stake.NewMsgCreateValidator(sdk.ValAddress(valAddr), pk, amount, description)
} }
if cliCtx.GenerateOnly { if cliCtx.GenerateOnly {
return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
} }
// build and sign the transaction, then broadcast to Tendermint // build and sign the transaction, then broadcast to Tendermint
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
}, },
} }
@ -99,7 +99,7 @@ func GetCmdEditValidator(cdc *wire.Codec) *cobra.Command {
Use: "edit-validator", Use: "edit-validator",
Short: "edit and existing validator account", Short: "edit and existing validator account",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout). WithLogger(os.Stdout).
@ -120,10 +120,10 @@ func GetCmdEditValidator(cdc *wire.Codec) *cobra.Command {
msg := stake.NewMsgEditValidator(sdk.ValAddress(valAddr), description) msg := stake.NewMsgEditValidator(sdk.ValAddress(valAddr), description)
if cliCtx.GenerateOnly { if cliCtx.GenerateOnly {
return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
} }
// build and sign the transaction, then broadcast to Tendermint // build and sign the transaction, then broadcast to Tendermint
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
}, },
} }
@ -138,7 +138,7 @@ func GetCmdDelegate(cdc *wire.Codec) *cobra.Command {
Use: "delegate", Use: "delegate",
Short: "delegate liquid tokens to an validator", Short: "delegate liquid tokens to an validator",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout). WithLogger(os.Stdout).
@ -162,10 +162,10 @@ func GetCmdDelegate(cdc *wire.Codec) *cobra.Command {
msg := stake.NewMsgDelegate(delAddr, valAddr, amount) msg := stake.NewMsgDelegate(delAddr, valAddr, amount)
if cliCtx.GenerateOnly { if cliCtx.GenerateOnly {
return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
} }
// build and sign the transaction, then broadcast to Tendermint // build and sign the transaction, then broadcast to Tendermint
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
}, },
} }
@ -197,7 +197,7 @@ func GetCmdBeginRedelegate(storeName string, cdc *wire.Codec) *cobra.Command {
Use: "begin", Use: "begin",
Short: "begin redelegation", Short: "begin redelegation",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout). WithLogger(os.Stdout).
@ -234,10 +234,10 @@ func GetCmdBeginRedelegate(storeName string, cdc *wire.Codec) *cobra.Command {
msg := stake.NewMsgBeginRedelegate(delAddr, valSrcAddr, valDstAddr, sharesAmount) msg := stake.NewMsgBeginRedelegate(delAddr, valSrcAddr, valDstAddr, sharesAmount)
if cliCtx.GenerateOnly { if cliCtx.GenerateOnly {
return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
} }
// build and sign the transaction, then broadcast to Tendermint // build and sign the transaction, then broadcast to Tendermint
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
}, },
} }
@ -301,7 +301,7 @@ func GetCmdCompleteRedelegate(cdc *wire.Codec) *cobra.Command {
Use: "complete", Use: "complete",
Short: "complete redelegation", Short: "complete redelegation",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout). WithLogger(os.Stdout).
@ -325,10 +325,10 @@ func GetCmdCompleteRedelegate(cdc *wire.Codec) *cobra.Command {
msg := stake.NewMsgCompleteRedelegate(delAddr, valSrcAddr, valDstAddr) msg := stake.NewMsgCompleteRedelegate(delAddr, valSrcAddr, valDstAddr)
if cliCtx.GenerateOnly { if cliCtx.GenerateOnly {
return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
} }
// build and sign the transaction, then broadcast to Tendermint // build and sign the transaction, then broadcast to Tendermint
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
}, },
} }
@ -359,7 +359,7 @@ func GetCmdBeginUnbonding(storeName string, cdc *wire.Codec) *cobra.Command {
Use: "begin", Use: "begin",
Short: "begin unbonding", Short: "begin unbonding",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout). WithLogger(os.Stdout).
@ -389,10 +389,10 @@ func GetCmdBeginUnbonding(storeName string, cdc *wire.Codec) *cobra.Command {
msg := stake.NewMsgBeginUnbonding(delAddr, valAddr, sharesAmount) msg := stake.NewMsgBeginUnbonding(delAddr, valAddr, sharesAmount)
if cliCtx.GenerateOnly { if cliCtx.GenerateOnly {
return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
} }
// build and sign the transaction, then broadcast to Tendermint // build and sign the transaction, then broadcast to Tendermint
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
}, },
} }
@ -408,7 +408,7 @@ func GetCmdCompleteUnbonding(cdc *wire.Codec) *cobra.Command {
Use: "complete", Use: "complete",
Short: "complete unbonding", Short: "complete unbonding",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc) txBldr := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext(). cliCtx := context.NewCLIContext().
WithCodec(cdc). WithCodec(cdc).
WithLogger(os.Stdout). WithLogger(os.Stdout).
@ -427,10 +427,10 @@ func GetCmdCompleteUnbonding(cdc *wire.Codec) *cobra.Command {
msg := stake.NewMsgCompleteUnbonding(delAddr, valAddr) msg := stake.NewMsgCompleteUnbonding(delAddr, valAddr)
if cliCtx.GenerateOnly { if cliCtx.GenerateOnly {
return utils.PrintUnsignedStdTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.PrintUnsignedStdTx(txBldr, cliCtx, []sdk.Msg{msg})
} }
// build and sign the transaction, then broadcast to Tendermint // build and sign the transaction, then broadcast to Tendermint
return utils.SendTx(txBld, cliCtx, []sdk.Msg{msg}) return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
}, },
} }

View File

@ -263,7 +263,7 @@ func delegationsRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx contex
i++ i++
} }
txBld := authtxb.TxBuilder{ txBldr := authtxb.TxBuilder{
Codec: cdc, Codec: cdc,
ChainID: m.ChainID, ChainID: m.ChainID,
Gas: m.Gas, Gas: m.Gas,
@ -273,8 +273,8 @@ func delegationsRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx contex
signedTxs := make([][]byte, len(messages[:])) signedTxs := make([][]byte, len(messages[:]))
for i, msg := range messages { for i, msg := range messages {
// increment sequence for each message // increment sequence for each message
txBld = txBld.WithAccountNumber(m.AccountNumber) txBldr = txBldr.WithAccountNumber(m.AccountNumber)
txBld = txBld.WithSequence(m.Sequence) txBldr = txBldr.WithSequence(m.Sequence)
m.Sequence++ m.Sequence++
@ -285,24 +285,24 @@ func delegationsRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx contex
cliCtx = cliCtx.WithGasAdjustment(adjustment) cliCtx = cliCtx.WithGasAdjustment(adjustment)
if utils.HasDryRunArg(r) || m.Gas == 0 { if utils.HasDryRunArg(r) || m.Gas == 0 {
newCtx, err := utils.EnrichCtxWithGas(txBld, cliCtx, m.LocalAccountName, []sdk.Msg{msg}) newCtx, err := utils.EnrichCtxWithGas(txBldr, cliCtx, m.LocalAccountName, []sdk.Msg{msg})
if err != nil { if err != nil {
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return return
} }
if utils.HasDryRunArg(r) { if utils.HasDryRunArg(r) {
utils.WriteSimulationResponse(w, txBld.Gas) utils.WriteSimulationResponse(w, txBldr.Gas)
return return
} }
txBld = newCtx txBldr = newCtx
} }
if utils.HasGenerateOnlyArg(r) { if utils.HasGenerateOnlyArg(r) {
utils.WriteGenerateStdTxResponse(w, txBld, []sdk.Msg{msg}) utils.WriteGenerateStdTxResponse(w, txBldr, []sdk.Msg{msg})
return return
} }
txBytes, err := txBld.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg}) txBytes, err := txBldr.BuildAndSign(m.LocalAccountName, m.Password, []sdk.Msg{msg})
if err != nil { if err != nil {
utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error()) utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error())
return return