diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bb5fa536d..ebc4d34b8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Breaking Changes * (rest) [\#807](https://github.com/line/lbm-sdk/pull/807) remove legacy REST API +* (codec) [#833](https://github.com/line/lbm-sdk/pull/833) Fix foundation amino codec + ### Build, CI * (ci) [\#829](https://github.com/line/lbm-sdk/pull/829) automate release process diff --git a/x/auth/types/codec.go b/x/auth/types/codec.go index 540e86c054..edd9984d3d 100644 --- a/x/auth/types/codec.go +++ b/x/auth/types/codec.go @@ -7,6 +7,7 @@ import ( sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/x/auth/legacy/legacytx" authzcodec "github.com/line/lbm-sdk/x/authz/codec" + fdncodec "github.com/line/lbm-sdk/x/foundation/codec" govcodec "github.com/line/lbm-sdk/x/gov/codec" ) @@ -54,4 +55,5 @@ func init() { // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances RegisterLegacyAminoCodec(authzcodec.Amino) RegisterLegacyAminoCodec(govcodec.Amino) + RegisterLegacyAminoCodec(fdncodec.Amino) } diff --git a/x/auth/vesting/types/codec.go b/x/auth/vesting/types/codec.go index 0e0e05c04f..f8571fc1d5 100644 --- a/x/auth/vesting/types/codec.go +++ b/x/auth/vesting/types/codec.go @@ -10,6 +10,7 @@ import ( authtypes "github.com/line/lbm-sdk/x/auth/types" "github.com/line/lbm-sdk/x/auth/vesting/exported" authzcodec "github.com/line/lbm-sdk/x/authz/codec" + fdncodec "github.com/line/lbm-sdk/x/foundation/codec" govcodec "github.com/line/lbm-sdk/x/gov/codec" ) @@ -77,4 +78,5 @@ func init() { // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances RegisterLegacyAminoCodec(authzcodec.Amino) RegisterLegacyAminoCodec(govcodec.Amino) + RegisterLegacyAminoCodec(fdncodec.Amino) } diff --git a/x/authz/codec.go b/x/authz/codec.go index e8df8d6aea..f042ee66d3 100644 --- a/x/authz/codec.go +++ b/x/authz/codec.go @@ -7,6 +7,7 @@ import ( sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/types/msgservice" authzcodec "github.com/line/lbm-sdk/x/authz/codec" + fdncodec "github.com/line/lbm-sdk/x/foundation/codec" govcodec "github.com/line/lbm-sdk/x/gov/codec" ) @@ -42,4 +43,5 @@ func init() { // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances RegisterLegacyAminoCodec(authzcodec.Amino) RegisterLegacyAminoCodec(govcodec.Amino) + RegisterLegacyAminoCodec(fdncodec.Amino) } diff --git a/x/bank/types/codec.go b/x/bank/types/codec.go index afd79d9af0..1b9616db84 100644 --- a/x/bank/types/codec.go +++ b/x/bank/types/codec.go @@ -9,6 +9,7 @@ import ( "github.com/line/lbm-sdk/types/msgservice" "github.com/line/lbm-sdk/x/authz" authzcodec "github.com/line/lbm-sdk/x/authz/codec" + fdncodec "github.com/line/lbm-sdk/x/foundation/codec" govcodec "github.com/line/lbm-sdk/x/gov/codec" ) @@ -47,4 +48,5 @@ func init() { // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances RegisterLegacyAminoCodec(authzcodec.Amino) RegisterLegacyAminoCodec(govcodec.Amino) + RegisterLegacyAminoCodec(fdncodec.Amino) } diff --git a/x/collection/codec.go b/x/collection/codec.go index f43051747b..ae47cd28d7 100644 --- a/x/collection/codec.go +++ b/x/collection/codec.go @@ -8,6 +8,7 @@ import ( sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/types/msgservice" authzcodec "github.com/line/lbm-sdk/x/authz/codec" + fdncodec "github.com/line/lbm-sdk/x/foundation/codec" govcodec "github.com/line/lbm-sdk/x/gov/codec" ) @@ -94,4 +95,5 @@ func init() { // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances RegisterLegacyAminoCodec(authzcodec.Amino) RegisterLegacyAminoCodec(govcodec.Amino) + RegisterLegacyAminoCodec(fdncodec.Amino) } diff --git a/x/crisis/types/codec.go b/x/crisis/types/codec.go index 500b22fa45..8a456a83ee 100644 --- a/x/crisis/types/codec.go +++ b/x/crisis/types/codec.go @@ -8,6 +8,7 @@ import ( sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/types/msgservice" authzcodec "github.com/line/lbm-sdk/x/authz/codec" + fdncodec "github.com/line/lbm-sdk/x/foundation/codec" govcodec "github.com/line/lbm-sdk/x/gov/codec" ) @@ -39,4 +40,5 @@ func init() { // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances RegisterLegacyAminoCodec(authzcodec.Amino) RegisterLegacyAminoCodec(govcodec.Amino) + RegisterLegacyAminoCodec(fdncodec.Amino) } diff --git a/x/distribution/types/codec.go b/x/distribution/types/codec.go index 4c326872d8..0f881ccd95 100644 --- a/x/distribution/types/codec.go +++ b/x/distribution/types/codec.go @@ -8,6 +8,7 @@ import ( sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/types/msgservice" authzcodec "github.com/line/lbm-sdk/x/authz/codec" + fdncodec "github.com/line/lbm-sdk/x/foundation/codec" govcodec "github.com/line/lbm-sdk/x/gov/codec" govtypes "github.com/line/lbm-sdk/x/gov/types" ) @@ -53,4 +54,5 @@ func init() { // instances. RegisterLegacyAminoCodec(authzcodec.Amino) RegisterLegacyAminoCodec(govcodec.Amino) + RegisterLegacyAminoCodec(fdncodec.Amino) } diff --git a/x/evidence/types/codec.go b/x/evidence/types/codec.go index f7abd556df..9e66cc0884 100644 --- a/x/evidence/types/codec.go +++ b/x/evidence/types/codec.go @@ -9,6 +9,7 @@ import ( "github.com/line/lbm-sdk/types/msgservice" authzcodec "github.com/line/lbm-sdk/x/authz/codec" "github.com/line/lbm-sdk/x/evidence/exported" + fdncodec "github.com/line/lbm-sdk/x/foundation/codec" govcodec "github.com/line/lbm-sdk/x/gov/codec" ) @@ -45,4 +46,5 @@ func init() { // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances RegisterLegacyAminoCodec(authzcodec.Amino) RegisterLegacyAminoCodec(govcodec.Amino) + RegisterLegacyAminoCodec(fdncodec.Amino) } diff --git a/x/feegrant/codec.go b/x/feegrant/codec.go index fc1868f31e..a22b64908b 100644 --- a/x/feegrant/codec.go +++ b/x/feegrant/codec.go @@ -8,6 +8,7 @@ import ( sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/types/msgservice" authzcodec "github.com/line/lbm-sdk/x/authz/codec" + fdncodec "github.com/line/lbm-sdk/x/foundation/codec" govcodec "github.com/line/lbm-sdk/x/gov/codec" ) @@ -62,4 +63,5 @@ func init() { // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances RegisterLegacyAminoCodec(authzcodec.Amino) RegisterLegacyAminoCodec(govcodec.Amino) + RegisterLegacyAminoCodec(fdncodec.Amino) } diff --git a/x/foundation/codec.go b/x/foundation/codec.go index 8416acc137..8993f76116 100644 --- a/x/foundation/codec.go +++ b/x/foundation/codec.go @@ -4,10 +4,10 @@ import ( "github.com/line/lbm-sdk/codec" "github.com/line/lbm-sdk/codec/legacy" "github.com/line/lbm-sdk/codec/types" - cryptocodec "github.com/line/lbm-sdk/crypto/codec" sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/types/msgservice" authzcodec "github.com/line/lbm-sdk/x/authz/codec" + fdncodec "github.com/line/lbm-sdk/x/foundation/codec" govcodec "github.com/line/lbm-sdk/x/gov/codec" ) @@ -67,18 +67,10 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { ) } -var ( - Amino = codec.NewLegacyAmino() - ModuleCdc = codec.NewAminoCodec(Amino) -) - func init() { - RegisterLegacyAminoCodec(Amino) - cryptocodec.RegisterCrypto(Amino) - sdk.RegisterLegacyAminoCodec(Amino) - // Register all Amino interfaces and concrete types on the authz and gov Amino codec so that this can later be // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances RegisterLegacyAminoCodec(authzcodec.Amino) RegisterLegacyAminoCodec(govcodec.Amino) + RegisterLegacyAminoCodec(fdncodec.Amino) } diff --git a/x/foundation/codec/cdc.go b/x/foundation/codec/cdc.go new file mode 100644 index 0000000000..ba6fa1ed87 --- /dev/null +++ b/x/foundation/codec/cdc.go @@ -0,0 +1,18 @@ +package codec + +import ( + "github.com/line/lbm-sdk/codec" + cryptocodec "github.com/line/lbm-sdk/crypto/codec" + sdk "github.com/line/lbm-sdk/types" +) + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(Amino) +) + +func init() { + cryptocodec.RegisterCrypto(Amino) + codec.RegisterEvidences(Amino) + sdk.RegisterLegacyAminoCodec(Amino) +} diff --git a/x/foundation/keeper/keeper.go b/x/foundation/keeper/keeper.go index 18fff03b39..fbff2ef548 100644 --- a/x/foundation/keeper/keeper.go +++ b/x/foundation/keeper/keeper.go @@ -34,7 +34,6 @@ type Keeper struct { // - MsgGrant // - MsgRevoke // - MsgWithdrawFromTreasury - // - MsgGovMint // // Typically, this should be the x/foundation module account. authority string diff --git a/x/foundation/msgs.go b/x/foundation/msgs.go index c6b27ab700..5d7c334300 100644 --- a/x/foundation/msgs.go +++ b/x/foundation/msgs.go @@ -6,6 +6,7 @@ import ( codectypes "github.com/line/lbm-sdk/codec/types" sdk "github.com/line/lbm-sdk/types" sdkerrors "github.com/line/lbm-sdk/types/errors" + "github.com/line/lbm-sdk/x/foundation/codec" ) var _ sdk.Msg = (*MsgUpdateParams)(nil) @@ -41,7 +42,7 @@ func (m MsgUpdateParams) Route() string { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (m MsgUpdateParams) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(codec.ModuleCdc.MustMarshalJSON(&m)) } var _ sdk.Msg = (*MsgFundTreasury)(nil) @@ -77,7 +78,7 @@ func (m MsgFundTreasury) Route() string { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (m MsgFundTreasury) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(codec.ModuleCdc.MustMarshalJSON(&m)) } var _ sdk.Msg = (*MsgWithdrawFromTreasury)(nil) @@ -117,7 +118,7 @@ func (m MsgWithdrawFromTreasury) Route() string { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (m MsgWithdrawFromTreasury) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(codec.ModuleCdc.MustMarshalJSON(&m)) } var _ sdk.Msg = (*MsgUpdateMembers)(nil) @@ -157,7 +158,7 @@ func (m MsgUpdateMembers) Route() string { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (m MsgUpdateMembers) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(codec.ModuleCdc.MustMarshalJSON(&m)) } var _ sdk.Msg = (*MsgUpdateDecisionPolicy)(nil) @@ -196,7 +197,7 @@ func (m MsgUpdateDecisionPolicy) Route() string { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (m MsgUpdateDecisionPolicy) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(codec.ModuleCdc.MustMarshalJSON(&m)) } func (m MsgUpdateDecisionPolicy) GetDecisionPolicy() DecisionPolicy { @@ -293,7 +294,7 @@ func (m MsgSubmitProposal) Route() string { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (m MsgSubmitProposal) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(codec.ModuleCdc.MustMarshalJSON(&m)) } var _ sdk.Msg = (*MsgWithdrawProposal)(nil) @@ -329,7 +330,7 @@ func (m MsgWithdrawProposal) Route() string { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (m MsgWithdrawProposal) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(codec.ModuleCdc.MustMarshalJSON(&m)) } var _ sdk.Msg = (*MsgVote)(nil) @@ -373,7 +374,7 @@ func (m MsgVote) Route() string { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (m MsgVote) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(codec.ModuleCdc.MustMarshalJSON(&m)) } var _ sdk.Msg = (*MsgExec)(nil) @@ -409,7 +410,7 @@ func (m MsgExec) Route() string { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (m MsgExec) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(codec.ModuleCdc.MustMarshalJSON(&m)) } var _ sdk.Msg = (*MsgLeaveFoundation)(nil) @@ -441,7 +442,7 @@ func (m MsgLeaveFoundation) Route() string { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (m MsgLeaveFoundation) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(codec.ModuleCdc.MustMarshalJSON(&m)) } var _ sdk.Msg = (*MsgGrant)(nil) @@ -512,7 +513,7 @@ func (m MsgGrant) Route() string { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (m MsgGrant) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(codec.ModuleCdc.MustMarshalJSON(&m)) } var _ sdk.Msg = (*MsgRevoke)(nil) @@ -552,5 +553,5 @@ func (m MsgRevoke) Route() string { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (m MsgRevoke) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(codec.ModuleCdc.MustMarshalJSON(&m)) } diff --git a/x/gov/types/codec.go b/x/gov/types/codec.go index 5a38d0946f..c20087bcf3 100644 --- a/x/gov/types/codec.go +++ b/x/gov/types/codec.go @@ -7,6 +7,7 @@ import ( sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/types/msgservice" authzcodec "github.com/line/lbm-sdk/x/authz/codec" + fdncodec "github.com/line/lbm-sdk/x/foundation/codec" govcodec "github.com/line/lbm-sdk/x/gov/codec" ) @@ -42,4 +43,5 @@ func init() { // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances RegisterLegacyAminoCodec(authzcodec.Amino) RegisterLegacyAminoCodec(govcodec.Amino) + RegisterLegacyAminoCodec(fdncodec.Amino) } diff --git a/x/slashing/types/codec.go b/x/slashing/types/codec.go index 17ea68c315..768f9a6b31 100644 --- a/x/slashing/types/codec.go +++ b/x/slashing/types/codec.go @@ -8,6 +8,7 @@ import ( sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/types/msgservice" authzcodec "github.com/line/lbm-sdk/x/authz/codec" + fdncodec "github.com/line/lbm-sdk/x/foundation/codec" govcodec "github.com/line/lbm-sdk/x/gov/codec" ) @@ -38,4 +39,5 @@ func init() { // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances RegisterLegacyAminoCodec(authzcodec.Amino) RegisterLegacyAminoCodec(govcodec.Amino) + RegisterLegacyAminoCodec(fdncodec.Amino) } diff --git a/x/staking/types/codec.go b/x/staking/types/codec.go index deeea4740c..2f3ec9d1c0 100644 --- a/x/staking/types/codec.go +++ b/x/staking/types/codec.go @@ -9,6 +9,7 @@ import ( "github.com/line/lbm-sdk/types/msgservice" "github.com/line/lbm-sdk/x/authz" authzcodec "github.com/line/lbm-sdk/x/authz/codec" + fdncodec "github.com/line/lbm-sdk/x/foundation/codec" govcodec "github.com/line/lbm-sdk/x/gov/codec" ) @@ -58,4 +59,5 @@ func init() { // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances RegisterLegacyAminoCodec(authzcodec.Amino) RegisterLegacyAminoCodec(govcodec.Amino) + RegisterLegacyAminoCodec(fdncodec.Amino) } diff --git a/x/stakingplus/codec.go b/x/stakingplus/codec.go index a92b98fa22..05e7b2e8ed 100644 --- a/x/stakingplus/codec.go +++ b/x/stakingplus/codec.go @@ -5,6 +5,7 @@ import ( "github.com/line/lbm-sdk/codec/types" authzcodec "github.com/line/lbm-sdk/x/authz/codec" "github.com/line/lbm-sdk/x/foundation" + fdncodec "github.com/line/lbm-sdk/x/foundation/codec" govcodec "github.com/line/lbm-sdk/x/gov/codec" ) @@ -26,6 +27,5 @@ func init() { // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances RegisterLegacyAminoCodec(authzcodec.Amino) RegisterLegacyAminoCodec(govcodec.Amino) - - RegisterLegacyAminoCodec(foundation.Amino) + RegisterLegacyAminoCodec(fdncodec.Amino) } diff --git a/x/token/codec.go b/x/token/codec.go index 6ef0c06e69..6ed9b6d189 100644 --- a/x/token/codec.go +++ b/x/token/codec.go @@ -8,6 +8,7 @@ import ( sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/types/msgservice" authzcodec "github.com/line/lbm-sdk/x/authz/codec" + fdncodec "github.com/line/lbm-sdk/x/foundation/codec" govcodec "github.com/line/lbm-sdk/x/gov/codec" ) @@ -58,4 +59,5 @@ func init() { // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances RegisterLegacyAminoCodec(authzcodec.Amino) RegisterLegacyAminoCodec(govcodec.Amino) + RegisterLegacyAminoCodec(fdncodec.Amino) } diff --git a/x/upgrade/types/codec.go b/x/upgrade/types/codec.go index a888019cb9..8637104a63 100644 --- a/x/upgrade/types/codec.go +++ b/x/upgrade/types/codec.go @@ -6,6 +6,7 @@ import ( cryptocodec "github.com/line/lbm-sdk/crypto/codec" sdk "github.com/line/lbm-sdk/types" authzcodec "github.com/line/lbm-sdk/x/authz/codec" + fdncodec "github.com/line/lbm-sdk/x/foundation/codec" govcodec "github.com/line/lbm-sdk/x/gov/codec" govtypes "github.com/line/lbm-sdk/x/gov/types" ) @@ -40,4 +41,5 @@ func init() { // instances. RegisterLegacyAminoCodec(authzcodec.Amino) RegisterLegacyAminoCodec(govcodec.Amino) + RegisterLegacyAminoCodec(fdncodec.Amino) }