From 9a9e5b59aefbebd54336164ff80699972620a696 Mon Sep 17 00:00:00 2001 From: Amaury <1293565+amaurym@users.noreply.github.com> Date: Wed, 19 Oct 2022 15:16:23 +0200 Subject: [PATCH] fix(group)!: Register types with Amino (#13592) * fix!(group): Register types with Amino * Chagenlog --- CHANGELOG.md | 1 + x/group/module/module.go | 4 +++- x/group/msgs_test.go | 13 +++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 842ae95d4e25..049aad3c18eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,6 +90,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (codec) [#13307](https://github.com/cosmos/cosmos-sdk/pull/13307) Register all modules' `Msg`s with group's ModuleCdc so that Amino sign bytes are correctly generated. * (codec) [#13196](https://github.com/cosmos/cosmos-sdk/pull/13196) Register all modules' `Msg`s with gov's ModuleCdc so that Amino sign bytes are correctly generated. +* (group) [#13592](https://github.com/cosmos/cosmos-sdk/pull/13592) Fix group types registration with Amino. * (x/distribution) [#12852](https://github.com/cosmos/cosmos-sdk/pull/12852) Deprecate `CommunityPoolSpendProposal`. Please execute a `MsgCommunityPoolSpend` message via the new v1 `x/gov` module instead. This message can be used to directly fund the `x/gov` module account. * (x/bank) [#12610](https://github.com/cosmos/cosmos-sdk/pull/12610) `MsgMultiSend` now allows only a single input. * (x/bank) [#12630](https://github.com/cosmos/cosmos-sdk/pull/12630) Migrate `x/bank` to self-managed parameters and deprecate its usage of `x/params`. diff --git a/x/group/module/module.go b/x/group/module/module.go index 9de8a11ff2d4..528eaf4c919e 100644 --- a/x/group/module/module.go +++ b/x/group/module/module.go @@ -100,7 +100,9 @@ func (AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { } // RegisterLegacyAminoCodec registers the group module's types for the given codec. -func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + group.RegisterLegacyAminoCodec(cdc) +} // Name returns the group module's name. func (AppModule) Name() string { diff --git a/x/group/msgs_test.go b/x/group/msgs_test.go index 2e528ada3c22..0b9ff53aa786 100644 --- a/x/group/msgs_test.go +++ b/x/group/msgs_test.go @@ -8,8 +8,10 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module/testutil" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/group" + "github.com/cosmos/cosmos-sdk/x/group/module" ) var ( @@ -1193,3 +1195,14 @@ func TestMsgLeaveGroup(t *testing.T) { }) } } + +func TestAmino(t *testing.T) { + cdc := testutil.MakeTestEncodingConfig(module.AppModuleBasic{}) + + out, err := cdc.Amino.MarshalJSON(group.MsgSubmitProposal{Proposers: []string{member1.String()}}) + require.NoError(t, err) + require.Equal(t, + `{"type":"cosmos-sdk/group/MsgSubmitProposal","value":{"proposers":["cosmos1d4jk6cn9wgcsj540xq"]}}`, + string(out), + ) +}