From 8fe44f1d3e4300fc4fbe646d48a2d34c11083e08 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 3 Aug 2023 10:27:04 +0200 Subject: [PATCH] refactor!: remove `clientCtx.PrintObjectLegacy` (#17259) --- CHANGELOG.md | 1 + client/context.go | 11 ---------- client/context_test.go | 46 ------------------------------------------ 3 files changed, 1 insertion(+), 57 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9cd618671..9908d7d61d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`: diff --git a/client/context.go b/client/context.go index d73d72e215..72ad98a03d 100644 --- a/client/context.go +++ b/client/context.go @@ -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 { diff --git a/client/context_test.go b/client/context_test.go index 9ea673b64f..34dd381f4c 100644 --- a/client/context_test.go +++ b/client/context_test.go @@ -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"}`)