Update context

This commit is contained in:
Aleksandr Bezobchuk
2020-03-13 13:59:14 -04:00
parent 7838d750e1
commit c49af0b8dd
4 changed files with 36 additions and 23 deletions
+19 -1
View File
@@ -14,6 +14,7 @@ import (
rpcclient "github.com/tendermint/tendermint/rpc/client"
"github.com/cosmos/cosmos-sdk/client/flags"
clientx "github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys"
sdk "github.com/cosmos/cosmos-sdk/types"
@@ -25,6 +26,8 @@ type CLIContext struct {
FromAddress sdk.AccAddress
Client rpcclient.Client
ChainID string
TxGenerator clientx.TxGenerator
Marshaler codec.Marshaler
Keybase keys.Keybase
Input io.Reader
Output io.Writer
@@ -36,13 +39,15 @@ type CLIContext struct {
BroadcastMode string
Verifier tmlite.Verifier
FromName string
Codec *codec.Codec
TrustNode bool
UseLedger bool
Simulate bool
GenerateOnly bool
Indent bool
SkipConfirm bool
// TODO: Deprecated (remove).
Codec *codec.Codec
}
// NewCLIContextWithInputAndFrom returns a new initialized CLIContext with parameters from the
@@ -130,7 +135,20 @@ func (ctx CLIContext) WithInput(r io.Reader) CLIContext {
return ctx
}
// WithTxGenerator returns a copy of the CLIContext with an updated TxGenerator.
func (ctx CLIContext) WithTxGenerator(txg clientx.TxGenerator) CLIContext {
ctx.TxGenerator = txg
return ctx
}
// WithMarshaler returns a copy of the CLIContext with an updated Marshaler.
func (ctx CLIContext) WithMarshaler(m codec.Marshaler) CLIContext {
ctx.Marshaler = m
return ctx
}
// WithCodec returns a copy of the context with an updated codec.
// TODO: Deprecated (remove).
func (ctx CLIContext) WithCodec(cdc *codec.Codec) CLIContext {
ctx.Codec = cdc
return ctx
+1 -9
View File
@@ -1,4 +1,4 @@
package client
package tx
import (
"github.com/cosmos/cosmos-sdk/codec"
@@ -6,14 +6,6 @@ import (
)
type (
// ClientMarshaler defines an interface that REST and CLI handler will use to
// create application-specific transactions and be able to serialize types
// specific to the application including transactions.
ClientMarshaler interface {
TxGenerator
codec.Marshaler
}
// TxGenerator defines an interface a client can utilize to generate an
// application-defined concrete transaction type. The type returned must
// implement ClientTx.