revert: replace all ModuleCdc instances with legacy.Cdc (#11680)

## Description
Reverts the usage of a singleton `legacy.Cdc` codec while (de)serializing `x/authz` messages.

Closes: #11643



---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
This commit is contained in:
Riccardo Montagnin 2022-04-20 11:27:40 +02:00 committed by GitHub
parent 2af642e6b6
commit 610b2eec6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 303 additions and 128 deletions

View File

@ -73,12 +73,12 @@ Since the `MsgExec` message type can contain different messages instances, it is
add the following code inside the `init` method of their module's `codec.go` file:
```go
import "github.com/cosmos/cosmos-sdk/codec/legacy"
import authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
init() {
// Register all Amino interfaces and concrete types on the global Amino codec so that this can later be
// used to properly serialize x/authz MsgExec instances
RegisterLegacyAminoCodec(legacy.Cdc)
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterLegacyAminoCodec(authzcodec.Amino)
}
```

View File

@ -2,9 +2,11 @@ package types
import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
)
// RegisterLegacyAminoCodec registers the account interfaces and concrete types on the
@ -37,6 +39,17 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
)
}
var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)
func init() {
RegisterLegacyAminoCodec(legacy.Cdc)
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterLegacyAminoCodec(authzcodec.Amino)
}

View File

@ -4,10 +4,12 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting/exported"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
)
// RegisterLegacyAminoCodec registers the vesting interfaces and concrete types on the
@ -62,6 +64,17 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)
func init() {
RegisterLegacyAminoCodec(legacy.Cdc)
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterLegacyAminoCodec(authzcodec.Amino)
}

View File

@ -2,8 +2,6 @@ package types
import (
"fmt"
"github.com/cosmos/cosmos-sdk/codec/legacy"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
@ -68,7 +66,7 @@ func (msg MsgCreateVestingAccount) ValidateBasic() error {
// GetSignBytes returns the bytes all expected signers must sign over for a
// MsgCreateVestingAccount.
func (msg MsgCreateVestingAccount) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
}
// GetSigners returns the expected signers for a MsgCreateVestingAccount.
@ -116,7 +114,7 @@ func (msg MsgCreatePermanentLockedAccount) ValidateBasic() error {
// GetSignBytes returns the bytes all expected signers must sign over for a
// MsgCreatePermanentLockedAccount.
func (msg MsgCreatePermanentLockedAccount) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
}
// GetSigners returns the expected signers for a MsgCreatePermanentLockedAccount.
@ -154,7 +152,7 @@ func (msg MsgCreatePeriodicVestingAccount) GetSigners() []sdk.AccAddress {
// GetSignBytes returns the bytes all expected signers must sign over for a
// MsgCreatePeriodicVestingAccount.
func (msg MsgCreatePeriodicVestingAccount) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
}
// ValidateBasic Implements Msg.

View File

@ -6,6 +6,7 @@ import (
types "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
)
// RegisterLegacyAminoCodec registers the necessary x/authz interfaces and concrete types
@ -36,7 +37,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, MsgServiceDesc())
}
func init() {
// Register all Amino interfaces and concrete types on the global Amino codec so that this can later be
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterLegacyAminoCodec(legacy.Cdc)
RegisterLegacyAminoCodec(authzcodec.Amino)
}

18
x/authz/codec/cdc.go Normal file
View File

@ -0,0 +1,18 @@
package codec
import (
"github.com/cosmos/cosmos-sdk/codec"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
)
var (
Amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(Amino)
)
func init() {
cryptocodec.RegisterCrypto(Amino)
codec.RegisterEvidences(Amino)
sdk.RegisterLegacyAminoCodec(Amino)
}

18
x/authz/codec/doc.go Normal file
View File

@ -0,0 +1,18 @@
/*
Package codec provides a singleton instance of Amino codec that should be used to register
any concrete type that can later be referenced inside a MsgGrant or MsgExec instance so that they
can be (de)serialized properly.
Amino types should be ideally registered inside this codec within the init function of each module's
codec.go file as follows:
func init() {
// ...
RegisterLegacyAminoCodec(authzcodec.Amino)
}
The codec instance is put inside this package and not the x/authz package in order to avoid any dependency cycle.
*/
package codec

View File

@ -1,10 +1,9 @@
package authz
import (
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
"time"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/gogo/protobuf/proto"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
@ -77,7 +76,7 @@ func (msg MsgGrant) Route() string {
// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (msg MsgGrant) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg))
return sdk.MustSortJSON(authzcodec.ModuleCdc.MustMarshalJSON(&msg))
}
// GetAuthorization returns the cache value from the MsgGrant.Authorization if present.
@ -167,7 +166,7 @@ func (msg MsgRevoke) Route() string {
// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (msg MsgRevoke) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg))
return sdk.MustSortJSON(authzcodec.ModuleCdc.MustMarshalJSON(&msg))
}
// NewMsgExec creates a new MsgExecAuthorized
@ -234,5 +233,5 @@ func (msg MsgExec) Route() string {
// GetSignBytes implements the LegacyMsg.GetSignBytes method.
func (msg MsgExec) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg))
return sdk.MustSortJSON(authzcodec.ModuleCdc.MustMarshalJSON(&msg))
}

View File

@ -1,7 +1,6 @@
package simulation_test
import (
"github.com/cosmos/cosmos-sdk/codec/legacy"
"math/rand"
"testing"
@ -81,7 +80,7 @@ func (suite *SimTestSuite) TestSimulateMsgSend() {
suite.Require().NoError(err)
var msg types.MsgSend
legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().True(operationMsg.OK)
suite.Require().Equal("65337742stake", msg.Amount.String())
@ -110,7 +109,7 @@ func (suite *SimTestSuite) TestSimulateMsgMultiSend() {
require.NoError(err)
var msg types.MsgMultiSend
legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
require.True(operationMsg.OK)
require.Len(msg.Inputs, 3)
@ -147,7 +146,7 @@ func (suite *SimTestSuite) TestSimulateModuleAccountMsgSend() {
suite.Require().Error(err)
var msg types.MsgSend
legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().False(operationMsg.OK)
suite.Require().Equal(operationMsg.Comment, "invalid transfers")
@ -176,7 +175,7 @@ func (suite *SimTestSuite) TestSimulateMsgMultiSendToModuleAccount() {
suite.Require().Error(err)
var msg types.MsgMultiSend
legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().False(operationMsg.OK) // sending tokens to a module account should fail
suite.Require().Equal(operationMsg.Comment, "invalid transfers")

View File

@ -4,9 +4,11 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
"github.com/cosmos/cosmos-sdk/x/authz"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
)
// RegisterLegacyAminoCodec registers the necessary x/bank interfaces and concrete types
@ -30,6 +32,17 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)
func init() {
RegisterLegacyAminoCodec(legacy.Cdc)
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterLegacyAminoCodec(authzcodec.Amino)
}

View File

@ -1,7 +1,6 @@
package types
import (
"github.com/cosmos/cosmos-sdk/codec/legacy"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
@ -49,7 +48,7 @@ func (msg MsgSend) ValidateBasic() error {
// GetSignBytes Implements Msg.
func (msg MsgSend) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
}
// GetSigners Implements Msg.
@ -88,7 +87,7 @@ func (msg MsgMultiSend) ValidateBasic() error {
// GetSignBytes Implements Msg.
func (msg MsgMultiSend) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
}
// GetSigners Implements Msg.

View File

@ -4,8 +4,10 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
)
// RegisterLegacyAminoCodec registers the necessary x/crisis interfaces and concrete types
@ -22,6 +24,17 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)
func init() {
RegisterLegacyAminoCodec(legacy.Cdc)
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterLegacyAminoCodec(authzcodec.Amino)
}

View File

@ -1,7 +1,6 @@
package types
import (
"github.com/cosmos/cosmos-sdk/codec/legacy"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
@ -30,7 +29,7 @@ func (msg MsgVerifyInvariant) GetSigners() []sdk.AccAddress {
// GetSignBytes gets the sign bytes for the msg MsgVerifyInvariant
func (msg MsgVerifyInvariant) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&msg)
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}

View File

@ -1,7 +1,6 @@
package simulation_test
import (
"github.com/cosmos/cosmos-sdk/codec/legacy"
"math/rand"
"testing"
@ -74,7 +73,7 @@ func (suite *SimTestSuite) TestSimulateMsgSetWithdrawAddress() {
suite.Require().NoError(err)
var msg types.MsgSetWithdrawAddress
legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().True(operationMsg.OK)
suite.Require().Equal("cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", msg.DelegatorAddress)
@ -115,7 +114,7 @@ func (suite *SimTestSuite) TestSimulateMsgWithdrawDelegatorReward() {
suite.Require().NoError(err)
var msg types.MsgWithdrawDelegatorReward
legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().True(operationMsg.OK)
suite.Require().Equal("cosmosvaloper1l4s054098kk9hmr5753c6k3m2kw65h686d3mhr", msg.ValidatorAddress)
@ -176,7 +175,7 @@ func (suite *SimTestSuite) testSimulateMsgWithdrawValidatorCommission(tokenName
suite.Require().NoError(err)
var msg types.MsgWithdrawValidatorCommission
legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().True(operationMsg.OK)
suite.Require().Equal("cosmosvaloper1tnh2q55v8wyygtt9srz5safamzdengsn9dsd7z", msg.ValidatorAddress)
@ -203,7 +202,7 @@ func (suite *SimTestSuite) TestSimulateMsgFundCommunityPool() {
suite.Require().NoError(err)
var msg types.MsgFundCommunityPool
legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().True(operationMsg.OK)
suite.Require().Equal("4896096stake", msg.Amount.String())

View File

@ -4,8 +4,10 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
@ -35,6 +37,17 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)
func init() {
RegisterLegacyAminoCodec(legacy.Cdc)
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterLegacyAminoCodec(authzcodec.Amino)
}

View File

@ -1,7 +1,6 @@
package types
import (
"github.com/cosmos/cosmos-sdk/codec/legacy"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
@ -35,7 +34,7 @@ func (msg MsgSetWithdrawAddress) GetSigners() []sdk.AccAddress {
// get the bytes for the message signer to sign on
func (msg MsgSetWithdrawAddress) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&msg)
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@ -69,7 +68,7 @@ func (msg MsgWithdrawDelegatorReward) GetSigners() []sdk.AccAddress {
// get the bytes for the message signer to sign on
func (msg MsgWithdrawDelegatorReward) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&msg)
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@ -101,7 +100,7 @@ func (msg MsgWithdrawValidatorCommission) GetSigners() []sdk.AccAddress {
// get the bytes for the message signer to sign on
func (msg MsgWithdrawValidatorCommission) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&msg)
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@ -138,7 +137,7 @@ func (msg MsgFundCommunityPool) GetSigners() []sdk.AccAddress {
// GetSignBytes returns the raw bytes for a MsgFundCommunityPool message that
// the expected signer needs to sign.
func (msg MsgFundCommunityPool) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&msg)
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}

View File

@ -4,8 +4,10 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
)
@ -28,6 +30,17 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)
func init() {
RegisterLegacyAminoCodec(legacy.Cdc)
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterLegacyAminoCodec(authzcodec.Amino)
}

View File

@ -2,8 +2,6 @@ package types
import (
"fmt"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/gogo/protobuf/proto"
"github.com/cosmos/cosmos-sdk/codec/types"
@ -63,7 +61,7 @@ func (m MsgSubmitEvidence) ValidateBasic() error {
// GetSignBytes returns the raw bytes a signer is expected to sign when submitting
// a MsgSubmitEvidence message.
func (m MsgSubmitEvidence) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// GetSigners returns the single expected signer for a MsgSubmitEvidence.

View File

@ -4,8 +4,10 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
)
// RegisterLegacyAminoCodec registers the necessary x/feegrant interfaces and concrete types
@ -52,8 +54,10 @@ var (
func init() {
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
// Register all Amino interfaces and concrete types on the global Amino codec so that this can later be
// used to properly serialize x/authz MsgExec instances
RegisterLegacyAminoCodec(legacy.Cdc)
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterLegacyAminoCodec(authzcodec.Amino)
}

View File

@ -10,7 +10,6 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/simapp"
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -117,7 +116,7 @@ func TestSimulateMsgSubmitProposal(t *testing.T) {
require.NoError(t, err)
var msg v1.MsgSubmitProposal
err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
err = v1.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
require.NoError(t, err)
require.True(t, operationMsg.OK)
@ -164,7 +163,7 @@ func TestSimulateMsgDeposit(t *testing.T) {
require.NoError(t, err)
var msg v1.MsgDeposit
err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
err = v1.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
require.NoError(t, err)
require.True(t, operationMsg.OK)
@ -210,7 +209,7 @@ func TestSimulateMsgVote(t *testing.T) {
require.NoError(t, err)
var msg v1.MsgVote
legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
v1.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
require.True(t, operationMsg.OK)
require.Equal(t, uint64(1), msg.ProposalId)
@ -253,7 +252,7 @@ func TestSimulateMsgVoteWeighted(t *testing.T) {
require.NoError(t, err)
var msg v1.MsgVoteWeighted
legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
v1.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
require.True(t, operationMsg.OK)
require.Equal(t, uint64(1), msg.ProposalId)

View File

@ -4,8 +4,11 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
// RegisterLegacyAminoCodec registers all the necessary types and interfaces for the
@ -30,6 +33,18 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)
func init() {
RegisterLegacyAminoCodec(legacy.Cdc)
RegisterLegacyAminoCodec(amino)
v1beta1.RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterLegacyAminoCodec(authzcodec.Amino)
}

View File

@ -3,7 +3,6 @@ package v1
import (
"fmt"
"github.com/cosmos/cosmos-sdk/codec/legacy"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
@ -83,7 +82,7 @@ func (m MsgSubmitProposal) ValidateBasic() error {
// GetSignBytes implements Msg
func (m MsgSubmitProposal) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&m)
bz := ModuleCdc.MustMarshalJSON(&m)
return sdk.MustSortJSON(bz)
}
@ -128,7 +127,7 @@ func (msg MsgDeposit) ValidateBasic() error {
// GetSignBytes implements Msg
func (msg MsgDeposit) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&msg)
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@ -164,7 +163,7 @@ func (msg MsgVote) ValidateBasic() error {
// GetSignBytes implements Msg
func (msg MsgVote) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&msg)
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@ -225,7 +224,7 @@ func (msg MsgVoteWeighted) ValidateBasic() error {
// GetSignBytes implements Msg
func (msg MsgVoteWeighted) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&msg)
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}

View File

@ -4,8 +4,10 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
)
// RegisterLegacyAminoCodec registers all the necessary types and interfaces for the
@ -35,6 +37,17 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)
func init() {
RegisterLegacyAminoCodec(legacy.Cdc)
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterLegacyAminoCodec(authzcodec.Amino)
}

View File

@ -2,8 +2,6 @@ package v1beta1
import (
"fmt"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/gogo/protobuf/proto"
"sigs.k8s.io/yaml"
@ -110,7 +108,7 @@ func (m MsgSubmitProposal) ValidateBasic() error {
// GetSignBytes implements Msg
func (m MsgSubmitProposal) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&m)
bz := ModuleCdc.MustMarshalJSON(&m)
return sdk.MustSortJSON(bz)
}
@ -167,7 +165,7 @@ func (msg MsgDeposit) String() string {
// GetSignBytes implements Msg
func (msg MsgDeposit) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&msg)
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@ -209,7 +207,7 @@ func (msg MsgVote) String() string {
// GetSignBytes implements Msg
func (msg MsgVote) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&msg)
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@ -272,7 +270,7 @@ func (msg MsgVoteWeighted) String() string {
// GetSignBytes implements Msg
func (msg MsgVoteWeighted) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&msg)
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}

View File

@ -4,8 +4,10 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
)
// RegisterLegacyAminoCodec registers all the necessary group module concrete
@ -60,6 +62,17 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
)
}
var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)
func init() {
RegisterLegacyAminoCodec(legacy.Cdc)
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterLegacyAminoCodec(authzcodec.Amino)
}

View File

@ -1,8 +1,6 @@
package group
import (
"github.com/cosmos/cosmos-sdk/codec/legacy"
proto "github.com/gogo/protobuf/proto"
"github.com/cosmos/cosmos-sdk/codec/types"
@ -23,7 +21,7 @@ func (m MsgCreateGroup) Type() string { return sdk.MsgTypeURL(&m) }
// GetSignBytes Implements Msg.
func (m MsgCreateGroup) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// GetSigners returns the expected signers for a MsgCreateGroup.
@ -75,7 +73,7 @@ func (m MsgUpdateGroupAdmin) Type() string { return sdk.MsgTypeURL(&m) }
// GetSignBytes Implements Msg.
func (m MsgUpdateGroupAdmin) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// GetSigners returns the expected signers for a MsgUpdateGroupAdmin.
@ -125,7 +123,7 @@ func (m MsgUpdateGroupMetadata) Type() string { return sdk.MsgTypeURL(&m) }
// GetSignBytes Implements Msg.
func (m MsgUpdateGroupMetadata) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// GetSigners returns the expected signers for a MsgUpdateGroupMetadata.
@ -167,7 +165,7 @@ func (m MsgUpdateGroupMembers) Type() string { return sdk.MsgTypeURL(&m) }
// GetSignBytes Implements Msg.
func (m MsgUpdateGroupMembers) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
var _ sdk.Msg = &MsgUpdateGroupMembers{}
@ -260,7 +258,7 @@ func (m MsgCreateGroupWithPolicy) Type() string {
// GetSignBytes Implements Msg.
func (m MsgCreateGroupWithPolicy) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// GetSigners returns the expected signers for a MsgCreateGroupWithPolicy.
@ -301,7 +299,7 @@ func (m MsgCreateGroupPolicy) Type() string { return sdk.MsgTypeURL(&m) }
// GetSignBytes Implements Msg.
func (m MsgCreateGroupPolicy) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// GetSigners returns the expected signers for a MsgCreateGroupPolicy.
@ -346,7 +344,7 @@ func (m MsgUpdateGroupPolicyAdmin) Type() string { return sdk.MsgTypeURL(&m) }
// GetSignBytes Implements Msg.
func (m MsgUpdateGroupPolicyAdmin) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// GetSigners returns the expected signers for a MsgUpdateGroupPolicyAdmin.
@ -422,7 +420,7 @@ func (m MsgUpdateGroupPolicyDecisionPolicy) Type() string {
// GetSignBytes Implements Msg.
func (m MsgUpdateGroupPolicyDecisionPolicy) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// GetSigners returns the expected signers for a MsgUpdateGroupPolicyDecisionPolicy.
@ -485,7 +483,7 @@ func (m MsgUpdateGroupPolicyMetadata) Type() string { return sdk.MsgTypeURL(&m)
// GetSignBytes Implements Msg.
func (m MsgUpdateGroupPolicyMetadata) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// GetSigners returns the expected signers for a MsgUpdateGroupPolicyMetadata.
@ -591,7 +589,7 @@ func (m MsgSubmitProposal) Type() string { return sdk.MsgTypeURL(&m) }
// GetSignBytes Implements Msg.
func (m MsgSubmitProposal) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// GetSigners returns the expected signers for a MsgSubmitProposal.
@ -683,7 +681,7 @@ func (m MsgWithdrawProposal) Type() string { return sdk.MsgTypeURL(&m) }
// GetSignBytes Implements Msg.
func (m MsgWithdrawProposal) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// GetSigners returns the expected signers for a MsgWithdrawProposal.
@ -721,7 +719,7 @@ func (m MsgVote) Type() string { return sdk.MsgTypeURL(&m) }
// GetSignBytes Implements Msg.
func (m MsgVote) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// GetSigners returns the expected signers for a MsgVote.
@ -763,7 +761,7 @@ func (m MsgExec) Type() string { return sdk.MsgTypeURL(&m) }
// GetSignBytes Implements Msg.
func (m MsgExec) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// GetSigners returns the expected signers for a MsgExec.
@ -799,7 +797,7 @@ func (m MsgLeaveGroup) Type() string { return sdk.MsgTypeURL(&m) }
// GetSignBytes Implements Msg
func (m MsgLeaveGroup) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// GetSigners returns the expected signers for a MsgLeaveGroup

View File

@ -5,8 +5,6 @@ import (
"testing"
"time"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
@ -117,7 +115,7 @@ func (suite *SimTestSuite) TestSimulateCreateGroup() {
suite.Require().NoError(err)
var msg group.MsgCreateGroup
err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().NoError(err)
suite.Require().True(operationMsg.OK)
suite.Require().Equal(acc.Address.String(), msg.Admin)
@ -146,7 +144,7 @@ func (suite *SimTestSuite) TestSimulateCreateGroupWithPolicy() {
suite.Require().NoError(err)
var msg group.MsgCreateGroupWithPolicy
err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().NoError(err)
suite.Require().True(operationMsg.OK)
suite.Require().Equal(acc.Address.String(), msg.Admin)
@ -188,7 +186,7 @@ func (suite *SimTestSuite) TestSimulateCreateGroupPolicy() {
suite.Require().NoError(err)
var msg group.MsgCreateGroupPolicy
err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().NoError(err)
suite.Require().True(operationMsg.OK)
suite.Require().Equal(acc.Address.String(), msg.Admin)
@ -241,7 +239,7 @@ func (suite *SimTestSuite) TestSimulateSubmitProposal() {
suite.Require().NoError(err)
var msg group.MsgSubmitProposal
err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().NoError(err)
suite.Require().True(operationMsg.OK)
suite.Require().Equal(groupPolicyRes.Address, msg.GroupPolicyAddress)
@ -307,7 +305,7 @@ func (suite *SimTestSuite) TestWithdrawProposal() {
suite.Require().NoError(err)
var msg group.MsgWithdrawProposal
err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().NoError(err)
suite.Require().True(operationMsg.OK)
suite.Require().Equal(addr, msg.Address)
@ -374,7 +372,7 @@ func (suite *SimTestSuite) TestSimulateVote() {
suite.Require().NoError(err)
var msg group.MsgVote
err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().NoError(err)
suite.Require().True(operationMsg.OK)
suite.Require().Equal(addr, msg.Voter)
@ -449,7 +447,7 @@ func (suite *SimTestSuite) TestSimulateExec() {
suite.Require().NoError(err)
var msg group.MsgExec
err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().NoError(err)
suite.Require().True(operationMsg.OK)
suite.Require().Equal(addr, msg.Executor)
@ -491,7 +489,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupAdmin() {
suite.Require().NoError(err)
var msg group.MsgUpdateGroupAdmin
err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().NoError(err)
suite.Require().True(operationMsg.OK)
suite.Require().Equal(acc.Address.String(), msg.Admin)
@ -533,7 +531,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupMetadata() {
suite.Require().NoError(err)
var msg group.MsgUpdateGroupMetadata
err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().NoError(err)
suite.Require().True(operationMsg.OK)
suite.Require().Equal(acc.Address.String(), msg.Admin)
@ -575,7 +573,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupMembers() {
suite.Require().NoError(err)
var msg group.MsgUpdateGroupMembers
err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().NoError(err)
suite.Require().True(operationMsg.OK)
suite.Require().Equal(acc.Address.String(), msg.Admin)
@ -628,7 +626,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyAdmin() {
suite.Require().NoError(err)
var msg group.MsgUpdateGroupPolicyAdmin
err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().NoError(err)
suite.Require().True(operationMsg.OK)
suite.Require().Equal(groupPolicyRes.Address, msg.GroupPolicyAddress)
@ -681,7 +679,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyDecisionPolicy() {
suite.Require().NoError(err)
var msg group.MsgUpdateGroupPolicyDecisionPolicy
err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().NoError(err)
suite.Require().True(operationMsg.OK)
suite.Require().Equal(groupPolicyRes.Address, msg.GroupPolicyAddress)
@ -734,7 +732,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyMetadata() {
suite.Require().NoError(err)
var msg group.MsgUpdateGroupPolicyMetadata
err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().NoError(err)
suite.Require().True(operationMsg.OK)
suite.Require().Equal(groupPolicyRes.Address, msg.GroupPolicyAddress)
@ -800,7 +798,7 @@ func (suite *SimTestSuite) TestSimulateLeaveGroup() {
suite.Require().NoError(err)
var msg group.MsgLeaveGroup
err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
suite.Require().NoError(err)
suite.Require().True(operationMsg.OK)
suite.Require().Equal(groupRes.GroupId, msg.GroupId)

View File

@ -1,7 +1,6 @@
package simulation_test
import (
"github.com/cosmos/cosmos-sdk/codec/legacy"
"math/rand"
"testing"
"time"
@ -100,7 +99,7 @@ func TestSimulateMsgUnjail(t *testing.T) {
require.NoError(t, err)
var msg types.MsgUnjail
legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
require.True(t, operationMsg.OK)
require.Equal(t, types.TypeMsgUnjail, msg.Type())

View File

@ -4,8 +4,10 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
)
// RegisterLegacyAminoCodec registers concrete types on LegacyAmino codec
@ -21,6 +23,17 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)
func init() {
RegisterLegacyAminoCodec(legacy.Cdc)
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterLegacyAminoCodec(authzcodec.Amino)
}

View File

@ -1,7 +1,6 @@
package types
import (
"github.com/cosmos/cosmos-sdk/codec/legacy"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
@ -31,7 +30,7 @@ func (msg MsgUnjail) GetSigners() []sdk.AccAddress {
// GetSignBytes gets the bytes for the message signer to sign on
func (msg MsgUnjail) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&msg)
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}

View File

@ -6,8 +6,6 @@ import (
"testing"
"time"
"github.com/cosmos/cosmos-sdk/codec/legacy"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
@ -83,7 +81,7 @@ func TestSimulateMsgCreateValidator(t *testing.T) {
require.NoError(t, err)
var msg types.MsgCreateValidator
legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
require.True(t, operationMsg.OK)
require.Equal(t, "0.080000000000000000", msg.Commission.MaxChangeRate.String())
@ -137,7 +135,7 @@ func TestSimulateMsgCancelUnbondingDelegation(t *testing.T) {
require.NoError(t, err)
var msg types.MsgCancelUnbondingDelegation
legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
require.True(t, operationMsg.OK)
require.Equal(t, types.TypeMsgCancelUnbondingDelegation, msg.Type())
@ -170,7 +168,7 @@ func TestSimulateMsgEditValidator(t *testing.T) {
require.NoError(t, err)
var msg types.MsgEditValidator
legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
require.True(t, operationMsg.OK)
require.Equal(t, "0.280623462081924936", msg.CommissionRate.String())
@ -199,7 +197,7 @@ func TestSimulateMsgDelegate(t *testing.T) {
require.NoError(t, err)
var msg types.MsgDelegate
legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
require.True(t, operationMsg.OK)
require.Equal(t, "cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", msg.DelegatorAddress)
@ -245,7 +243,7 @@ func TestSimulateMsgUndelegate(t *testing.T) {
require.NoError(t, err)
var msg types.MsgUndelegate
legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
require.True(t, operationMsg.OK)
require.Equal(t, "cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", msg.DelegatorAddress)
@ -294,7 +292,7 @@ func TestSimulateMsgBeginRedelegate(t *testing.T) {
require.NoError(t, err)
var msg types.MsgBeginRedelegate
legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg)
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
require.True(t, operationMsg.OK)
require.Equal(t, "cosmos1092v0qgulpejj8y8hs6dmlw82x9gv8f7jfc7jl", msg.DelegatorAddress)

View File

@ -4,9 +4,11 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
"github.com/cosmos/cosmos-sdk/x/authz"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
)
// RegisterLegacyAminoCodec registers the necessary x/staking interfaces and concrete types
@ -43,6 +45,17 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewAminoCodec(amino)
)
func init() {
RegisterLegacyAminoCodec(legacy.Cdc)
RegisterLegacyAminoCodec(amino)
cryptocodec.RegisterCrypto(amino)
sdk.RegisterLegacyAminoCodec(amino)
// Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterLegacyAminoCodec(authzcodec.Amino)
}

View File

@ -1,7 +1,6 @@
package types
import (
"github.com/cosmos/cosmos-sdk/codec/legacy"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -79,7 +78,7 @@ func (msg MsgCreateValidator) GetSigners() []sdk.AccAddress {
// GetSignBytes returns the message bytes to sign over.
func (msg MsgCreateValidator) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&msg)
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@ -163,7 +162,7 @@ func (msg MsgEditValidator) GetSigners() []sdk.AccAddress {
// GetSignBytes implements the sdk.Msg interface.
func (msg MsgEditValidator) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&msg)
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@ -217,7 +216,7 @@ func (msg MsgDelegate) GetSigners() []sdk.AccAddress {
// GetSignBytes implements the sdk.Msg interface.
func (msg MsgDelegate) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&msg)
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@ -267,7 +266,7 @@ func (msg MsgBeginRedelegate) GetSigners() []sdk.AccAddress {
// GetSignBytes implements the sdk.Msg interface.
func (msg MsgBeginRedelegate) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&msg)
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@ -317,7 +316,7 @@ func (msg MsgUndelegate) GetSigners() []sdk.AccAddress {
// GetSignBytes implements the sdk.Msg interface.
func (msg MsgUndelegate) GetSignBytes() []byte {
bz := legacy.Cdc.MustMarshalJSON(&msg)
bz := ModuleCdc.MustMarshalJSON(&msg)
return sdk.MustSortJSON(bz)
}
@ -365,7 +364,7 @@ func (msg MsgCancelUnbondingDelegation) GetSigners() []sdk.AccAddress {
// GetSignBytes implements the sdk.Msg interface.
func (msg MsgCancelUnbondingDelegation) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
}
// ValidateBasic implements the sdk.Msg interface.

View File

@ -4,15 +4,13 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)
func init() {
RegisterLegacyAminoCodec(legacy.Cdc)
}
// RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(Plan{}, "cosmos-sdk/Plan", nil)
@ -36,3 +34,18 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
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 Amino codec so that this can later be
// used to properly serialize MsgGrant and MsgExec instances
RegisterLegacyAminoCodec(authzcodec.Amino)
}

View File

@ -1,7 +1,6 @@
package types
import (
"github.com/cosmos/cosmos-sdk/codec/legacy"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
@ -20,7 +19,7 @@ func (m MsgSoftwareUpgrade) Type() string { return sdk.MsgTypeURL(&m) }
// GetSignBytes implements the LegacyMsg interface.
func (m MsgSoftwareUpgrade) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// ValidateBasic does a sanity check on the provided data.
@ -50,7 +49,7 @@ func (m MsgCancelUpgrade) Type() string { return sdk.MsgTypeURL(&m) }
// GetSignBytes implements the LegacyMsg interface.
func (m MsgCancelUpgrade) GetSignBytes() []byte {
return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m))
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// ValidateBasic does a sanity check on the provided data.