refactor!: remove clientCtx.PrintObjectLegacy (#17259)
This commit is contained in:
parent
03966377c8
commit
8fe44f1d3e
@ -60,6 +60,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### API Breaking Changes
|
||||
|
||||
* (client) [#17259](https://github.com/cosmos/cosmos-sdk/pull/17259) Remove deprecated `clientCtx.PrintObjectLegacy`. Use `clientCtx.PrintProto` or `clientCtx.PrintRaw` instead.
|
||||
* (x/distribution) [#17115](https://github.com/cosmos/cosmos-sdk/pull/17115) Use collections for `PreviousProposer` and `ValidatorSlashEvents`:
|
||||
* remove from `Keeper`: `GetPreviousProposerConsAddr`, `SetPreviousProposerConsAddr`, `GetValidatorHistoricalReferenceCount`, `GetValidatorSlashEvent`, `SetValidatorSlashEvent`.
|
||||
* (x/slashing) [17063](https://github.com/cosmos/cosmos-sdk/pull/17063) Use collections for `HistoricalInfo`:
|
||||
|
||||
@ -321,17 +321,6 @@ func (ctx Context) PrintProto(toPrint proto.Message) error {
|
||||
return ctx.printOutput(out)
|
||||
}
|
||||
|
||||
// PrintObjectLegacy is a variant of PrintProto that doesn't require a proto.Message type
|
||||
// and uses amino JSON encoding.
|
||||
// Deprecated: It will be removed in the near future!
|
||||
func (ctx Context) PrintObjectLegacy(toPrint interface{}) error {
|
||||
out, err := ctx.LegacyAmino.MarshalJSON(toPrint)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ctx.printOutput(out)
|
||||
}
|
||||
|
||||
// PrintRaw is a variant of PrintProto that doesn't require a proto.Message type
|
||||
// and uses a raw JSON message. No marshaling is performed.
|
||||
func (ctx Context) PrintRaw(toPrint json.RawMessage) error {
|
||||
|
||||
@ -68,52 +68,6 @@ x: "10"
|
||||
`, buf.String())
|
||||
}
|
||||
|
||||
func TestContext_PrintObjectLegacy(t *testing.T) {
|
||||
ctx := client.Context{}
|
||||
|
||||
animal := &testdata.Dog{
|
||||
Size_: "big",
|
||||
Name: "Spot",
|
||||
}
|
||||
anyAnimal, err := types.NewAnyWithValue(animal)
|
||||
require.NoError(t, err)
|
||||
hasAnimal := &testdata.HasAnimal{
|
||||
Animal: anyAnimal,
|
||||
X: 10,
|
||||
}
|
||||
|
||||
// amino
|
||||
amino := testdata.NewTestAmino()
|
||||
ctx = ctx.WithLegacyAmino(&codec.LegacyAmino{Amino: amino})
|
||||
|
||||
// json
|
||||
buf := &bytes.Buffer{}
|
||||
ctx = ctx.WithOutput(buf)
|
||||
ctx.OutputFormat = flags.OutputFormatJSON
|
||||
err = ctx.PrintObjectLegacy(hasAnimal)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t,
|
||||
`{"type":"testpb/HasAnimal","value":{"animal":{"type":"testpb/Dog","value":{"size":"big","name":"Spot"}},"x":"10"}}
|
||||
`, buf.String())
|
||||
|
||||
// yaml
|
||||
buf = &bytes.Buffer{}
|
||||
ctx = ctx.WithOutput(buf)
|
||||
ctx.OutputFormat = flags.OutputFormatText
|
||||
err = ctx.PrintObjectLegacy(hasAnimal)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t,
|
||||
`type: testpb/HasAnimal
|
||||
value:
|
||||
animal:
|
||||
type: testpb/Dog
|
||||
value:
|
||||
name: Spot
|
||||
size: big
|
||||
x: "10"
|
||||
`, buf.String())
|
||||
}
|
||||
|
||||
func TestContext_PrintRaw(t *testing.T) {
|
||||
ctx := client.Context{}
|
||||
hasAnimal := json.RawMessage(`{"animal":{"@type":"/testpb.Dog","size":"big","name":"Spot"},"x":"10"}`)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user