refactor(client): add client/Context.Codec and deprecate JSONCodec (#9498)
* chore(types): add sdk.Context.Codec and deprecate JSONCodec * Use clientContext.Codec rather than JSONCodec everywhere * update tests to use clientContext.Codec * added a note that EncodingConfig.Marshaler will be renamed to Codec * update changelog * fix tests to use clientCtx.WithCodec instead of WithJSONCodec * fix genutil build * Update simapp/params/encoding.go Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com> Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
This commit is contained in:
@@ -27,7 +27,7 @@ func CollectGenTxsCmd(genBalIterator types.GenesisBalancesIterator, defaultNodeH
|
||||
config := serverCtx.Config
|
||||
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
cdc := clientCtx.JSONCodec
|
||||
cdc := clientCtx.Codec
|
||||
|
||||
config.SetRoot(clientCtx.HomeDir)
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ $ %s gentx my-key-name 1000000stake --home=/path/to/home/dir --keyring-backend=o
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cdc := clientCtx.JSONCodec
|
||||
cdc := clientCtx.Codec
|
||||
|
||||
config := serverCtx.Config
|
||||
config.SetRoot(clientCtx.HomeDir)
|
||||
@@ -78,7 +78,7 @@ $ %s gentx my-key-name 1000000stake --home=/path/to/home/dir --keyring-backend=o
|
||||
|
||||
// read --pubkey, if empty take it from priv_validator.json
|
||||
if val, _ := cmd.Flags().GetString(cli.FlagPubKey); val != "" {
|
||||
err = clientCtx.JSONCodec.UnmarshalJSON([]byte(val), valPubKey)
|
||||
err = clientCtx.Codec.UnmarshalJSON([]byte(val), valPubKey)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to unmarshal consensus node public key")
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
cdc := clientCtx.JSONCodec
|
||||
cdc := clientCtx.Codec
|
||||
|
||||
serverCtx := server.GetServerContextFromCmd(cmd)
|
||||
config := serverCtx.Config
|
||||
|
||||
@@ -63,7 +63,7 @@ func TestInitCmd(t *testing.T) {
|
||||
interfaceRegistry := types.NewInterfaceRegistry()
|
||||
marshaler := codec.NewProtoCodec(interfaceRegistry)
|
||||
clientCtx := client.Context{}.
|
||||
WithJSONCodec(marshaler).
|
||||
WithCodec(marshaler).
|
||||
WithLegacyAmino(makeCodec()).
|
||||
WithHomeDir(home)
|
||||
|
||||
@@ -97,7 +97,7 @@ func TestInitRecover(t *testing.T) {
|
||||
interfaceRegistry := types.NewInterfaceRegistry()
|
||||
marshaler := codec.NewProtoCodec(interfaceRegistry)
|
||||
clientCtx := client.Context{}.
|
||||
WithJSONCodec(marshaler).
|
||||
WithCodec(marshaler).
|
||||
WithLegacyAmino(makeCodec()).
|
||||
WithHomeDir(home)
|
||||
|
||||
@@ -128,7 +128,7 @@ func TestEmptyState(t *testing.T) {
|
||||
interfaceRegistry := types.NewInterfaceRegistry()
|
||||
marshaler := codec.NewProtoCodec(interfaceRegistry)
|
||||
clientCtx := client.Context{}.
|
||||
WithJSONCodec(marshaler).
|
||||
WithCodec(marshaler).
|
||||
WithLegacyAmino(makeCodec()).
|
||||
WithHomeDir(home)
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ func ValidateGenesisCmd(mbm module.BasicManager) *cobra.Command {
|
||||
serverCtx := server.GetServerContextFromCmd(cmd)
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
|
||||
cdc := clientCtx.JSONCodec
|
||||
cdc := clientCtx.Codec
|
||||
|
||||
// Load default if passed no args, otherwise load passed file
|
||||
var genesis string
|
||||
|
||||
Reference in New Issue
Block a user