Enable proto JSON generally and remove HybridCodec (#6859)
* Remove HybridCodec * WIP on fixing proto JSON issues * WIP on fixing proto JSON issues * WIP on fixing proto JSON issues * WIP on fixing proto JSON issues * WIP on fixing proto JSON issues * Test fixes * Delete hybrid_codec.go * Fixes * Fixes * Fixes * Test fixes * Test fixes * Test fixes * Lint * Sim fixes * Sim fixes * Revert * Remove vesting account JSON tests * Update CHANGELOG.md * Lint * Sim fixes * Sim fixes * Docs * Migrate more amino usages * Remove custom VoteOption String() and json marshaling * Fix tests * Add comments, update CHANGELOG.md Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com> Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
co-authored by
Jonathan Gimeno
Alexander Bezobchuk
parent
134e1dcecd
commit
816c5a37bd
+6
-30
@@ -54,7 +54,7 @@ var (
|
||||
WithTxConfig(encodingConfig.TxConfig).
|
||||
WithLegacyAmino(encodingConfig.Amino).
|
||||
WithInput(os.Stdin).
|
||||
WithAccountRetriever(types.NewAccountRetriever(encodingConfig.Marshaler)).
|
||||
WithAccountRetriever(types.NewAccountRetriever(encodingConfig.Amino)).
|
||||
WithBroadcastMode(flags.BroadcastBlock).
|
||||
WithHomeDir(simapp.DefaultNodeHome)
|
||||
)
|
||||
@@ -79,12 +79,12 @@ func init() {
|
||||
authclient.Codec = encodingConfig.Marshaler
|
||||
|
||||
rootCmd.AddCommand(
|
||||
withProtoJSON(genutilcli.InitCmd(simapp.ModuleBasics, simapp.DefaultNodeHome)),
|
||||
withProtoJSON(genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, simapp.DefaultNodeHome)),
|
||||
genutilcli.InitCmd(simapp.ModuleBasics, simapp.DefaultNodeHome),
|
||||
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, simapp.DefaultNodeHome),
|
||||
genutilcli.MigrateGenesisCmd(),
|
||||
withProtoJSON(genutilcli.GenTxCmd(simapp.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, simapp.DefaultNodeHome)),
|
||||
withProtoJSON(genutilcli.ValidateGenesisCmd(simapp.ModuleBasics, encodingConfig.TxConfig)),
|
||||
withProtoJSON(AddGenesisAccountCmd(simapp.DefaultNodeHome)),
|
||||
genutilcli.GenTxCmd(simapp.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, simapp.DefaultNodeHome),
|
||||
genutilcli.ValidateGenesisCmd(simapp.ModuleBasics, encodingConfig.TxConfig),
|
||||
AddGenesisAccountCmd(simapp.DefaultNodeHome),
|
||||
tmcli.NewCompletionCmd(rootCmd, true),
|
||||
testnetCmd(simapp.ModuleBasics, banktypes.GenesisBalancesIterator{}),
|
||||
debug.Cmd(),
|
||||
@@ -202,27 +202,3 @@ func exportAppStateAndTMValidators(
|
||||
|
||||
return simApp.ExportAppStateAndValidators(forZeroHeight, jailWhiteList)
|
||||
}
|
||||
|
||||
// This is a temporary command middleware to enable proto JSON marshaling for testing.
|
||||
// Once proto JSON works everywhere we can remove this and set ProtoCodec as default
|
||||
func withProtoJSON(command *cobra.Command) *cobra.Command {
|
||||
existing := command.PersistentPreRunE
|
||||
if existing != nil {
|
||||
command.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
|
||||
err := existing(cmd, args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return setProtoJSON(cmd, args)
|
||||
}
|
||||
} else {
|
||||
command.PersistentPreRunE = setProtoJSON
|
||||
}
|
||||
return command
|
||||
}
|
||||
|
||||
func setProtoJSON(cmd *cobra.Command, _ []string) error {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
clientCtx = clientCtx.WithJSONMarshaler(codec.NewProtoCodec(clientCtx.InterfaceRegistry))
|
||||
return client.SetCmdClientContext(cmd, clientCtx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user