Skip to content

Commit

Permalink
fix!: Fix foundation amino codec (#833) (#862)
Browse files Browse the repository at this point in the history
* Add foundation amino codec

* Update CHANGELOG.md

Co-authored-by: Youngtaek Yoon <[email protected]>
  • Loading branch information
zemyblue and 0Tech authored Jan 25, 2023
1 parent 1deccf3 commit df3df2f
Show file tree
Hide file tree
Showing 20 changed files with 65 additions and 25 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions x/auth/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -54,4 +55,5 @@ func init() {
// used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
RegisterLegacyAminoCodec(fdncodec.Amino)
}
2 changes: 2 additions & 0 deletions x/auth/vesting/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -77,4 +78,5 @@ func init() {
// used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
RegisterLegacyAminoCodec(fdncodec.Amino)
}
2 changes: 2 additions & 0 deletions x/authz/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -42,4 +43,5 @@ func init() {
// used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
RegisterLegacyAminoCodec(fdncodec.Amino)
}
2 changes: 2 additions & 0 deletions x/bank/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -47,4 +48,5 @@ func init() {
// used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
RegisterLegacyAminoCodec(fdncodec.Amino)
}
2 changes: 2 additions & 0 deletions x/collection/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -94,4 +95,5 @@ func init() {
// used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
RegisterLegacyAminoCodec(fdncodec.Amino)
}
2 changes: 2 additions & 0 deletions x/crisis/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -39,4 +40,5 @@ func init() {
// used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
RegisterLegacyAminoCodec(fdncodec.Amino)
}
2 changes: 2 additions & 0 deletions x/distribution/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -53,4 +54,5 @@ func init() {
// instances.
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
RegisterLegacyAminoCodec(fdncodec.Amino)
}
2 changes: 2 additions & 0 deletions x/evidence/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -45,4 +46,5 @@ func init() {
// used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
RegisterLegacyAminoCodec(fdncodec.Amino)
}
2 changes: 2 additions & 0 deletions x/feegrant/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -62,4 +63,5 @@ func init() {
// used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
RegisterLegacyAminoCodec(fdncodec.Amino)
}
12 changes: 2 additions & 10 deletions x/foundation/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
}
18 changes: 18 additions & 0 deletions x/foundation/codec/cdc.go
Original file line number Diff line number Diff line change
@@ -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)
}
1 change: 0 additions & 1 deletion x/foundation/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type Keeper struct {
// - MsgGrant
// - MsgRevoke
// - MsgWithdrawFromTreasury
// - MsgGovMint
//
// Typically, this should be the x/foundation module account.
authority string
Expand Down
25 changes: 13 additions & 12 deletions x/foundation/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
}
2 changes: 2 additions & 0 deletions x/gov/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -42,4 +43,5 @@ func init() {
// used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
RegisterLegacyAminoCodec(fdncodec.Amino)
}
2 changes: 2 additions & 0 deletions x/slashing/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -38,4 +39,5 @@ func init() {
// used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
RegisterLegacyAminoCodec(fdncodec.Amino)
}
2 changes: 2 additions & 0 deletions x/staking/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -58,4 +59,5 @@ func init() {
// used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
RegisterLegacyAminoCodec(fdncodec.Amino)
}
4 changes: 2 additions & 2 deletions x/stakingplus/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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)
}
2 changes: 2 additions & 0 deletions x/token/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -58,4 +59,5 @@ func init() {
// used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
RegisterLegacyAminoCodec(fdncodec.Amino)
}
2 changes: 2 additions & 0 deletions x/upgrade/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -40,4 +41,5 @@ func init() {
// instances.
RegisterLegacyAminoCodec(authzcodec.Amino)
RegisterLegacyAminoCodec(govcodec.Amino)
RegisterLegacyAminoCodec(fdncodec.Amino)
}

0 comments on commit df3df2f

Please sign in to comment.