Migrate x/auth cmd's to TxGenerator marshaling (#6391)
* Migrate encode, decode, and broadcast cmd's to use TxGenerator marshal methods * Fix tests, add EncodingConfig * Add simapp/encoding.go and wire up with simcli * add godocs * fix tests * Debugging CLI Tests * Fix integration test * 6391 - lint issues and code coverage (#6414) * fixed lint issue of "txEncodeRespStr" * added tests for encode.go * WIP: added tests for decode.go * added txEncoder at bytes * updated decode test * updated txBytes to use TxEncoder in decoder test * added a require after TxEncoder * removed file save * debug decode command * fixed decode tests * added decode cli * updated encode and decode in a single file * separated decode test from encode test * review changes * removed register interface * review change * Fix tests * WIP add test for tx sign * removed commented code * Fix flags * WIP add test for sign * Address review suggestions * fixed command issue * Add tests for TxEncoder * Revert sign changes * Fix TxEncoder tests * Fix GetSign Cmd * Add tx test * Remove duplicate validation * Add tests for TxDecoder * Fix tests * Fix tests * Output to clientCtx.Output * Fix cli_tests Co-authored-by: atheeshp <59333759+atheeshp@users.noreply.github.com> Co-authored-by: atheesh <atheesh@vitwit.com> Co-authored-by: anilCSE <anil@vitwit.com> Co-authored-by: sahith-narahari <sahithnarahari@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
atheeshp
atheesh
anilCSE
sahith-narahari
mergify[bot]
parent
5040ff87c4
commit
712d23740f
+21
-17
@@ -5,6 +5,8 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/tendermint/tendermint/libs/cli"
|
||||
@@ -13,7 +15,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/keys"
|
||||
"github.com/cosmos/cosmos-sdk/client/rpc"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
|
||||
@@ -23,11 +24,11 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
appCodec, cdc = simapp.MakeCodecs()
|
||||
encodingConfig = simapp.MakeEncodingConfig()
|
||||
)
|
||||
|
||||
func init() {
|
||||
authclient.Codec = appCodec
|
||||
authclient.Codec = encodingConfig.Marshaler
|
||||
}
|
||||
|
||||
func main() {
|
||||
@@ -60,8 +61,8 @@ func main() {
|
||||
rootCmd.AddCommand(
|
||||
rpc.StatusCommand(),
|
||||
client.ConfigCmd(simapp.DefaultCLIHome),
|
||||
queryCmd(cdc),
|
||||
txCmd(cdc),
|
||||
queryCmd(encodingConfig),
|
||||
txCmd(encodingConfig),
|
||||
flags.LineBreak,
|
||||
flags.LineBreak,
|
||||
keys.Commands(),
|
||||
@@ -79,7 +80,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
func queryCmd(cdc *codec.Codec) *cobra.Command {
|
||||
func queryCmd(config simappparams.EncodingConfig) *cobra.Command {
|
||||
queryCmd := &cobra.Command{
|
||||
Use: "query",
|
||||
Aliases: []string{"q"},
|
||||
@@ -89,6 +90,8 @@ func queryCmd(cdc *codec.Codec) *cobra.Command {
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
cdc := config.Amino
|
||||
|
||||
queryCmd.AddCommand(
|
||||
authcmd.GetAccountCmd(cdc),
|
||||
flags.LineBreak,
|
||||
@@ -102,14 +105,14 @@ func queryCmd(cdc *codec.Codec) *cobra.Command {
|
||||
// add modules' query commands
|
||||
clientCtx := client.Context{}
|
||||
clientCtx = clientCtx.
|
||||
WithJSONMarshaler(appCodec).
|
||||
WithJSONMarshaler(config.Marshaler).
|
||||
WithCodec(cdc)
|
||||
simapp.ModuleBasics.AddQueryCommands(queryCmd, clientCtx)
|
||||
|
||||
return queryCmd
|
||||
}
|
||||
|
||||
func txCmd(cdc *codec.Codec) *cobra.Command {
|
||||
func txCmd(config simappparams.EncodingConfig) *cobra.Command {
|
||||
txCmd := &cobra.Command{
|
||||
Use: "tx",
|
||||
Short: "Transactions subcommands",
|
||||
@@ -118,24 +121,25 @@ func txCmd(cdc *codec.Codec) *cobra.Command {
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
cdc := config.Amino
|
||||
clientCtx := client.Context{}
|
||||
clientCtx = clientCtx.
|
||||
WithJSONMarshaler(appCodec).
|
||||
WithTxGenerator(types.StdTxGenerator{Cdc: cdc}).
|
||||
WithAccountRetriever(types.NewAccountRetriever(appCodec)).
|
||||
WithJSONMarshaler(config.Marshaler).
|
||||
WithTxGenerator(config.TxGenerator).
|
||||
WithAccountRetriever(types.NewAccountRetriever(config.Marshaler)).
|
||||
WithCodec(cdc)
|
||||
|
||||
txCmd.AddCommand(
|
||||
bankcmd.NewSendTxCmd(clientCtx),
|
||||
flags.LineBreak,
|
||||
authcmd.GetSignCommand(cdc),
|
||||
authcmd.GetSignCommand(clientCtx),
|
||||
authcmd.GetSignBatchCommand(cdc),
|
||||
authcmd.GetMultiSignCommand(cdc),
|
||||
authcmd.GetValidateSignaturesCommand(cdc),
|
||||
authcmd.GetMultiSignCommand(clientCtx),
|
||||
authcmd.GetValidateSignaturesCommand(clientCtx),
|
||||
flags.LineBreak,
|
||||
authcmd.GetBroadcastCommand(cdc),
|
||||
authcmd.GetEncodeCommand(cdc),
|
||||
authcmd.GetDecodeCommand(cdc),
|
||||
authcmd.GetBroadcastCommand(clientCtx),
|
||||
authcmd.GetEncodeCommand(clientCtx),
|
||||
authcmd.GetDecodeCommand(clientCtx),
|
||||
flags.LineBreak,
|
||||
)
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/std"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
@@ -34,7 +32,7 @@ const (
|
||||
|
||||
// AddGenesisAccountCmd returns add-genesis-account cobra Command.
|
||||
func AddGenesisAccountCmd(
|
||||
ctx *server.Context, depCdc codec.JSONMarshaler, cdc *std.Codec, defaultNodeHome, defaultClientHome string,
|
||||
ctx *server.Context, depCdc codec.JSONMarshaler, cdc codec.Marshaler, defaultNodeHome, defaultClientHome string,
|
||||
) *cobra.Command {
|
||||
|
||||
cmd := &cobra.Command{
|
||||
|
||||
Reference in New Issue
Block a user