Skip to content

Commit

Permalink
x/auth/client/context -> x/auth/client/txbuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
jaekwon committed Sep 7, 2018
1 parent 54b3b5c commit acd1250
Show file tree
Hide file tree
Showing 18 changed files with 47 additions and 47 deletions.
4 changes: 2 additions & 2 deletions client/utils/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
auth "github.com/cosmos/cosmos-sdk/x/auth"
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
)

const (
Expand Down Expand Up @@ -52,7 +52,7 @@ func ParseFloat64OrReturnBadRequest(w http.ResponseWriter, s string, defaultIfEm
}

// WriteGenerateStdTxResponse writes response for the generate_only mode.
func WriteGenerateStdTxResponse(w http.ResponseWriter, txBld authctx.TxBuilder, msgs []sdk.Msg) {
func WriteGenerateStdTxResponse(w http.ResponseWriter, txBld authtxb.TxBuilder, msgs []sdk.Msg) {
stdMsg, err := txBld.Build(msgs)
if err != nil {
WriteErrorResponse(w, http.StatusBadRequest, err.Error())
Expand Down
14 changes: 7 additions & 7 deletions client/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
auth "github.com/cosmos/cosmos-sdk/x/auth"
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
amino "github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/libs/common"
)
Expand All @@ -18,7 +18,7 @@ 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(txBld authctx.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) error {
func SendTx(txBld authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) error {
txBld, err := prepareTxContext(txBld, cliCtx)
if err != nil {
return err
Expand Down Expand Up @@ -50,7 +50,7 @@ func SendTx(txBld authctx.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg)
}

// SimulateMsgs simulates the transaction and returns the gas estimate and the adjusted value.
func SimulateMsgs(txBld authctx.TxBuilder, cliCtx context.CLIContext, name string, msgs []sdk.Msg, gas int64) (estimated, adjusted int64, err error) {
func SimulateMsgs(txBld 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)
if err != nil {
return
Expand All @@ -61,7 +61,7 @@ func SimulateMsgs(txBld 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(txBld authctx.TxBuilder, cliCtx context.CLIContext, name string, msgs []sdk.Msg) (authctx.TxBuilder, error) {
func EnrichCtxWithGas(txBld authtxb.TxBuilder, cliCtx context.CLIContext, name string, msgs []sdk.Msg) (authtxb.TxBuilder, error) {
_, adjusted, err := SimulateMsgs(txBld, cliCtx, name, msgs, 0)
if err != nil {
return txBld, err
Expand All @@ -87,7 +87,7 @@ func CalculateGas(queryFunc func(string, common.HexBytes) ([]byte, error), cdc *
}

// PrintUnsignedStdTx builds an unsigned StdTx and prints it to os.Stdout.
func PrintUnsignedStdTx(txBld authctx.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) (err error) {
func PrintUnsignedStdTx(txBld authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) (err error) {
stdTx, err := buildUnsignedStdTx(txBld, cliCtx, msgs)
if err != nil {
return
Expand All @@ -111,7 +111,7 @@ func parseQueryResponse(cdc *amino.Codec, rawRes []byte) (int64, error) {
return simulationResult.GasUsed, nil
}

func prepareTxContext(txBld authctx.TxBuilder, cliCtx context.CLIContext) (authctx.TxBuilder, error) {
func prepareTxContext(txBld authtxb.TxBuilder, cliCtx context.CLIContext) (authtxb.TxBuilder, error) {
if err := cliCtx.EnsureAccountExists(); err != nil {
return txBld, err
}
Expand Down Expand Up @@ -145,7 +145,7 @@ func prepareTxContext(txBld authctx.TxBuilder, cliCtx context.CLIContext) (authc

// 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(txBld authctx.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) (stdTx auth.StdTx, err error) {
func buildUnsignedStdTx(txBld authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg) (stdTx auth.StdTx, err error) {
txBld, err = prepareTxContext(txBld, cliCtx)
if err != nil {
return
Expand Down
6 changes: 3 additions & 3 deletions examples/democoin/x/cool/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
)

// QuizTxCmd invokes the coolness quiz transaction.
Expand All @@ -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 {
txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc)
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext().
WithCodec(cdc).
WithLogger(os.Stdout).
Expand All @@ -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 {
txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc)
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext().
WithCodec(cdc).
WithLogger(os.Stdout).
Expand Down
4 changes: 2 additions & 2 deletions examples/democoin/x/pow/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"

"github.com/spf13/cobra"
)
Expand All @@ -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 {
txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc)
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext().
WithCodec(cdc).
WithLogger(os.Stdout).
Expand Down
6 changes: 3 additions & 3 deletions examples/democoin/x/simplestake/client/cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"

"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand All @@ -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 {
txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc)
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext().
WithCodec(cdc).
WithLogger(os.Stdout).
Expand Down Expand Up @@ -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 {
txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc)
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext().
WithCodec(cdc).
WithLogger(os.Stdout)
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions x/bank/client/cli/sendtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
"github.com/cosmos/cosmos-sdk/x/bank/client"

"github.com/pkg/errors"
Expand All @@ -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 {
txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc)
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext().
WithCodec(cdc).
WithLogger(os.Stdout).
Expand Down
4 changes: 2 additions & 2 deletions x/bank/client/rest/sendtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire"
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/bank/client"

Expand Down Expand Up @@ -80,7 +80,7 @@ func SendRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.CLICo
return
}

txBld := authctx.TxBuilder{
txBld := authtxb.TxBuilder{
Codec: cdc,
Gas: m.Gas,
ChainID: m.ChainID,
Expand Down
8 changes: 4 additions & 4 deletions x/gov/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
"github.com/cosmos/cosmos-sdk/x/gov"

"encoding/json"
Expand Down Expand Up @@ -77,7 +77,7 @@ $ gaiacli gov submit-proposal --title="Test Proposal" --description="My awesome
return err
}

txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc)
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext().
WithCodec(cdc).
WithLogger(os.Stdout).
Expand Down Expand Up @@ -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 {
txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc)
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext().
WithCodec(cdc).
WithLogger(os.Stdout).
Expand Down Expand Up @@ -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 {
txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc)
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext().
WithCodec(cdc).
WithLogger(os.Stdout).
Expand Down
4 changes: 2 additions & 2 deletions x/gov/client/rest/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/utils"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire"
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
)

type baseReq struct {
Expand Down Expand Up @@ -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
txBld := authctx.TxBuilder{
txBld := authtxb.TxBuilder{
Codec: cdc,
AccountNumber: baseReq.AccountNumber,
Sequence: baseReq.Sequence,
Expand Down
4 changes: 2 additions & 2 deletions x/ibc/client/cli/ibctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
wire "github.com/cosmos/cosmos-sdk/wire"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
"github.com/cosmos/cosmos-sdk/x/ibc"

"github.com/spf13/cobra"
Expand All @@ -28,7 +28,7 @@ func IBCTransferCmd(cdc *wire.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "transfer",
RunE: func(cmd *cobra.Command, args []string) error {
txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc)
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext().
WithCodec(cdc).
WithLogger(os.Stdout).
Expand Down
4 changes: 2 additions & 2 deletions x/ibc/client/cli/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
wire "github.com/cosmos/cosmos-sdk/wire"
"github.com/cosmos/cosmos-sdk/x/auth"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
"github.com/cosmos/cosmos-sdk/x/ibc"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -199,7 +199,7 @@ func (c relayCommander) refine(bz []byte, sequence int64, passphrase string) []b
Sequence: sequence,
}

txBld := authctx.NewTxBuilderFromCLI().WithSequence(sequence).WithCodec(c.cdc)
txBld := authtxb.NewTxBuilderFromCLI().WithSequence(sequence).WithCodec(c.cdc)
cliCtx := context.NewCLIContext()

res, err := txBld.BuildAndSign(cliCtx.FromAddressName, passphrase, []sdk.Msg{msg})
Expand Down
4 changes: 2 additions & 2 deletions x/ibc/client/rest/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire"
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
"github.com/cosmos/cosmos-sdk/x/ibc"

"github.com/gorilla/mux"
Expand Down Expand Up @@ -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}

txBld := authctx.TxBuilder{
txBld := authtxb.TxBuilder{
Codec: cdc,
ChainID: m.SrcChainID,
AccountNumber: m.AccountNumber,
Expand Down
4 changes: 2 additions & 2 deletions x/slashing/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
"github.com/cosmos/cosmos-sdk/x/slashing"

"github.com/spf13/cobra"
Expand All @@ -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 {
txBld := authctx.NewTxBuilderFromCLI().WithCodec(cdc)
txBld := authtxb.NewTxBuilderFromCLI().WithCodec(cdc)
cliCtx := context.NewCLIContext().
WithCodec(cdc).
WithLogger(os.Stdout).
Expand Down
4 changes: 2 additions & 2 deletions x/slashing/client/rest/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire"
authctx "github.com/cosmos/cosmos-sdk/x/auth/client/context"
authtxb "github.com/cosmos/cosmos-sdk/x/auth/client/txbuilder"
"github.com/cosmos/cosmos-sdk/x/slashing"

"github.com/gorilla/mux"
Expand Down Expand Up @@ -70,7 +70,7 @@ func unjailRequestHandlerFn(cdc *wire.Codec, kb keys.Keybase, cliCtx context.CLI
return
}

txBld := authctx.TxBuilder{
txBld := authtxb.TxBuilder{
Codec: cdc,
ChainID: m.ChainID,
AccountNumber: m.AccountNumber,
Expand Down
Loading

0 comments on commit acd1250

Please sign in to comment.