diff --git a/x/collection/codec.go b/x/collection/codec.go index 14136bc379..4dafaf0675 100644 --- a/x/collection/codec.go +++ b/x/collection/codec.go @@ -4,7 +4,6 @@ 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" ) @@ -56,19 +55,3 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } - -var ( - amino = codec.NewLegacyAmino() - ModuleCdc = codec.NewAminoCodec(amino) -) - -func init() { - cryptocodec.RegisterCrypto(amino) - // TODO: check, Can i remove commented out code? - - //// 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/collection/keys.go b/x/collection/keys.go index 0e47c9c64d..50fad8ae7d 100644 --- a/x/collection/keys.go +++ b/x/collection/keys.go @@ -6,7 +6,4 @@ const ( // StoreKey defines the primary module store key StoreKey = ModuleName - - // RouterKey defines the module's message routing key - RouterKey = ModuleName ) diff --git a/x/collection/msgs.go b/x/collection/msgs.go index 0c1fcbaabd..410f1c3681 100644 --- a/x/collection/msgs.go +++ b/x/collection/msgs.go @@ -194,8 +194,6 @@ func canonicalKey(key string) string { return key } -var _ sdk.Msg = (*MsgSendNFT)(nil) - // ValidateBasic implements Msg. func (m MsgSendNFT) ValidateBasic() error { if err := ValidateContractID(m.ContractId); err != nil { @@ -221,29 +219,6 @@ func (m MsgSendNFT) ValidateBasic() error { return nil } -// GetSigners implements Msg -func (m MsgSendNFT) GetSigners() []sdk.AccAddress { - signer, _ := sdk.AccAddressFromBech32(m.From) - return []sdk.AccAddress{signer} -} - -// Type implements the LegacyMsg.Type method. -func (m MsgSendNFT) Type() string { - return sdk.MsgTypeURL(&m) -} - -// Route implements the LegacyMsg.Route method. -func (m MsgSendNFT) Route() string { - return RouterKey -} - -// GetSignBytes implements the LegacyMsg.GetSignBytes method. -func (m MsgSendNFT) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -var _ sdk.Msg = (*MsgOperatorSendNFT)(nil) - // ValidateBasic implements Msg. func (m MsgOperatorSendNFT) ValidateBasic() error { if err := ValidateContractID(m.ContractId); err != nil { @@ -272,29 +247,6 @@ func (m MsgOperatorSendNFT) ValidateBasic() error { return nil } -// GetSigners implements Msg -func (m MsgOperatorSendNFT) GetSigners() []sdk.AccAddress { - signer, _ := sdk.AccAddressFromBech32(m.Operator) - return []sdk.AccAddress{signer} -} - -// Type implements the LegacyMsg.Type method. -func (m MsgOperatorSendNFT) Type() string { - return sdk.MsgTypeURL(&m) -} - -// Route implements the LegacyMsg.Route method. -func (m MsgOperatorSendNFT) Route() string { - return RouterKey -} - -// GetSignBytes implements the LegacyMsg.GetSignBytes method. -func (m MsgOperatorSendNFT) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -var _ sdk.Msg = (*MsgAuthorizeOperator)(nil) - // ValidateBasic implements Msg. func (m MsgAuthorizeOperator) ValidateBasic() error { if err := ValidateContractID(m.ContractId); err != nil { @@ -315,29 +267,6 @@ func (m MsgAuthorizeOperator) ValidateBasic() error { return nil } -// GetSigners implements Msg -func (m MsgAuthorizeOperator) GetSigners() []sdk.AccAddress { - signer, _ := sdk.AccAddressFromBech32(m.Holder) - return []sdk.AccAddress{signer} -} - -// Type implements the LegacyMsg.Type method. -func (m MsgAuthorizeOperator) Type() string { - return sdk.MsgTypeURL(&m) -} - -// Route implements the LegacyMsg.Route method. -func (m MsgAuthorizeOperator) Route() string { - return RouterKey -} - -// GetSignBytes implements the LegacyMsg.GetSignBytes method. -func (m MsgAuthorizeOperator) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -var _ sdk.Msg = (*MsgRevokeOperator)(nil) - // ValidateBasic implements Msg. func (m MsgRevokeOperator) ValidateBasic() error { if err := ValidateContractID(m.ContractId); err != nil { @@ -358,29 +287,6 @@ func (m MsgRevokeOperator) ValidateBasic() error { return nil } -// GetSigners implements Msg -func (m MsgRevokeOperator) GetSigners() []sdk.AccAddress { - signer, _ := sdk.AccAddressFromBech32(m.Holder) - return []sdk.AccAddress{signer} -} - -// Type implements the LegacyMsg.Type method. -func (m MsgRevokeOperator) Type() string { - return sdk.MsgTypeURL(&m) -} - -// Route implements the LegacyMsg.Route method. -func (m MsgRevokeOperator) Route() string { - return RouterKey -} - -// GetSignBytes implements the LegacyMsg.GetSignBytes method. -func (m MsgRevokeOperator) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -var _ sdk.Msg = (*MsgCreateContract)(nil) - // ValidateBasic implements Msg. func (m MsgCreateContract) ValidateBasic() error { if _, err := sdk.AccAddressFromBech32(m.Owner); err != nil { @@ -402,29 +308,6 @@ func (m MsgCreateContract) ValidateBasic() error { return nil } -// GetSigners implements Msg -func (m MsgCreateContract) GetSigners() []sdk.AccAddress { - signer, _ := sdk.AccAddressFromBech32(m.Owner) - return []sdk.AccAddress{signer} -} - -// Type implements the LegacyMsg.Type method. -func (m MsgCreateContract) Type() string { - return sdk.MsgTypeURL(&m) -} - -// Route implements the LegacyMsg.Route method. -func (m MsgCreateContract) Route() string { - return RouterKey -} - -// GetSignBytes implements the LegacyMsg.GetSignBytes method. -func (m MsgCreateContract) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -var _ sdk.Msg = (*MsgIssueNFT)(nil) - // ValidateBasic implements Msg. func (m MsgIssueNFT) ValidateBasic() error { if err := ValidateContractID(m.ContractId); err != nil { @@ -446,29 +329,6 @@ func (m MsgIssueNFT) ValidateBasic() error { return nil } -// GetSigners implements Msg -func (m MsgIssueNFT) GetSigners() []sdk.AccAddress { - signer, _ := sdk.AccAddressFromBech32(m.Owner) - return []sdk.AccAddress{signer} -} - -// Type implements the LegacyMsg.Type method. -func (m MsgIssueNFT) Type() string { - return sdk.MsgTypeURL(&m) -} - -// Route implements the LegacyMsg.Route method. -func (m MsgIssueNFT) Route() string { - return RouterKey -} - -// GetSignBytes implements the LegacyMsg.GetSignBytes method. -func (m MsgIssueNFT) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -var _ sdk.Msg = (*MsgMintNFT)(nil) - // ValidateBasic implements Msg. func (m MsgMintNFT) ValidateBasic() error { if err := ValidateContractID(m.ContractId); err != nil { @@ -506,29 +366,6 @@ func (m MsgMintNFT) ValidateBasic() error { return nil } -// GetSigners implements Msg -func (m MsgMintNFT) GetSigners() []sdk.AccAddress { - signer, _ := sdk.AccAddressFromBech32(m.From) - return []sdk.AccAddress{signer} -} - -// Type implements the LegacyMsg.Type method. -func (m MsgMintNFT) Type() string { - return sdk.MsgTypeURL(&m) -} - -// Route implements the LegacyMsg.Route method. -func (m MsgMintNFT) Route() string { - return RouterKey -} - -// GetSignBytes implements the LegacyMsg.GetSignBytes method. -func (m MsgMintNFT) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -var _ sdk.Msg = (*MsgBurnNFT)(nil) - // ValidateBasic implements Msg. func (m MsgBurnNFT) ValidateBasic() error { if err := ValidateContractID(m.ContractId); err != nil { @@ -551,29 +388,6 @@ func (m MsgBurnNFT) ValidateBasic() error { return nil } -// GetSigners implements Msg -func (m MsgBurnNFT) GetSigners() []sdk.AccAddress { - signer, _ := sdk.AccAddressFromBech32(m.From) - return []sdk.AccAddress{signer} -} - -// Type implements the LegacyMsg.Type method. -func (m MsgBurnNFT) Type() string { - return sdk.MsgTypeURL(&m) -} - -// Route implements the LegacyMsg.Route method. -func (m MsgBurnNFT) Route() string { - return RouterKey -} - -// GetSignBytes implements the LegacyMsg.GetSignBytes method. -func (m MsgBurnNFT) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -var _ sdk.Msg = (*MsgOperatorBurnNFT)(nil) - // ValidateBasic implements Msg. func (m MsgOperatorBurnNFT) ValidateBasic() error { if err := ValidateContractID(m.ContractId); err != nil { @@ -599,29 +413,6 @@ func (m MsgOperatorBurnNFT) ValidateBasic() error { return nil } -// GetSigners implements Msg -func (m MsgOperatorBurnNFT) GetSigners() []sdk.AccAddress { - signer, _ := sdk.AccAddressFromBech32(m.Operator) - return []sdk.AccAddress{signer} -} - -// Type implements the LegacyMsg.Type method. -func (m MsgOperatorBurnNFT) Type() string { - return sdk.MsgTypeURL(&m) -} - -// Route implements the LegacyMsg.Route method. -func (m MsgOperatorBurnNFT) Route() string { - return RouterKey -} - -// GetSignBytes implements the LegacyMsg.GetSignBytes method. -func (m MsgOperatorBurnNFT) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -var _ sdk.Msg = (*MsgModify)(nil) - // ValidateBasic implements Msg. func (m MsgModify) ValidateBasic() error { UpdateMsgModify(&m) @@ -696,29 +487,6 @@ func UpdateMsgModify(msg *MsgModify) { } } -// GetSigners implements Msg -func (m MsgModify) GetSigners() []sdk.AccAddress { - signer, _ := sdk.AccAddressFromBech32(m.Owner) - return []sdk.AccAddress{signer} -} - -// Type implements the LegacyMsg.Type method. -func (m MsgModify) Type() string { - return sdk.MsgTypeURL(&m) -} - -// Route implements the LegacyMsg.Route method. -func (m MsgModify) Route() string { - return RouterKey -} - -// GetSignBytes implements the LegacyMsg.GetSignBytes method. -func (m MsgModify) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -var _ sdk.Msg = (*MsgGrantPermission)(nil) - // ValidateBasic implements Msg. func (m MsgGrantPermission) ValidateBasic() error { if err := ValidateContractID(m.ContractId); err != nil { @@ -739,29 +507,6 @@ func (m MsgGrantPermission) ValidateBasic() error { return nil } -// GetSigners implements Msg -func (m MsgGrantPermission) GetSigners() []sdk.AccAddress { - signer, _ := sdk.AccAddressFromBech32(m.From) - return []sdk.AccAddress{signer} -} - -// Type implements the LegacyMsg.Type method. -func (m MsgGrantPermission) Type() string { - return sdk.MsgTypeURL(&m) -} - -// Route implements the LegacyMsg.Route method. -func (m MsgGrantPermission) Route() string { - return RouterKey -} - -// GetSignBytes implements the LegacyMsg.GetSignBytes method. -func (m MsgGrantPermission) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} - -var _ sdk.Msg = (*MsgRevokePermission)(nil) - // ValidateBasic implements Msg. func (m MsgRevokePermission) ValidateBasic() error { if err := ValidateContractID(m.ContractId); err != nil { @@ -778,24 +523,3 @@ func (m MsgRevokePermission) ValidateBasic() error { return nil } - -// GetSigners implements Msg -func (m MsgRevokePermission) GetSigners() []sdk.AccAddress { - signer, _ := sdk.AccAddressFromBech32(m.From) - return []sdk.AccAddress{signer} -} - -// Type implements the LegacyMsg.Type method. -func (m MsgRevokePermission) Type() string { - return sdk.MsgTypeURL(&m) -} - -// Route implements the LegacyMsg.Route method. -func (m MsgRevokePermission) Route() string { - return RouterKey -} - -// GetSignBytes implements the LegacyMsg.GetSignBytes method. -func (m MsgRevokePermission) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) -} diff --git a/x/collection/msgs_test.go b/x/collection/msgs_test.go index 00f3d4a996..17988117b3 100644 --- a/x/collection/msgs_test.go +++ b/x/collection/msgs_test.go @@ -83,8 +83,6 @@ func TestMsgSendNFT(t *testing.T) { if tc.err != nil { return } - - require.Equal(t, []sdk.AccAddress{tc.from}, msg.GetSigners()) }) } } @@ -171,8 +169,6 @@ func TestMsgOperatorSendNFT(t *testing.T) { if tc.err != nil { return } - - require.Equal(t, []sdk.AccAddress{tc.operator}, msg.GetSigners()) }) } } @@ -223,8 +219,6 @@ func TestMsgAuthorizeOperator(t *testing.T) { if tc.err != nil { return } - - require.Equal(t, []sdk.AccAddress{tc.holder}, msg.GetSigners()) }) } } @@ -275,8 +269,6 @@ func TestMsgRevokeOperator(t *testing.T) { if tc.err != nil { return } - - require.Equal(t, []sdk.AccAddress{tc.holder}, msg.GetSigners()) }) } } @@ -345,8 +337,6 @@ func TestMsgCreateContract(t *testing.T) { if tc.err != nil { return } - - require.Equal(t, []sdk.AccAddress{tc.owner}, msg.GetSigners()) }) } } @@ -414,8 +404,6 @@ func TestMsgIssueNFT(t *testing.T) { if tc.err != nil { return } - - require.Equal(t, []sdk.AccAddress{tc.operator}, msg.GetSigners()) }) } } @@ -522,8 +510,6 @@ func TestMsgMintNFT(t *testing.T) { if tc.err != nil { return } - - require.Equal(t, []sdk.AccAddress{tc.operator}, msg.GetSigners()) }) } } @@ -582,8 +568,6 @@ func TestMsgBurnNFT(t *testing.T) { if tc.err != nil { return } - - require.Equal(t, []sdk.AccAddress{tc.from}, msg.GetSigners()) }) } } @@ -655,8 +639,6 @@ func TestMsgOperatorBurnNFT(t *testing.T) { if tc.err != nil { return } - - require.Equal(t, []sdk.AccAddress{tc.grantee}, msg.GetSigners()) }) } } @@ -760,8 +742,6 @@ func TestMsgModify(t *testing.T) { if tc.err != nil { return } - - require.Equal(t, []sdk.AccAddress{tc.owner}, msg.GetSigners()) }) } } @@ -824,8 +804,6 @@ func TestMsgGrantPermission(t *testing.T) { if tc.err != nil { return } - - require.Equal(t, []sdk.AccAddress{tc.from}, msg.GetSigners()) }) } } @@ -876,8 +854,6 @@ func TestMsgRevokePermission(t *testing.T) { if tc.err != nil { return } - - require.Equal(t, []sdk.AccAddress{tc.from}, msg.GetSigners()) }) } } @@ -902,7 +878,7 @@ func TestAminoJSON(t *testing.T) { }} testCase := map[string]struct { - msg legacytx.LegacyMsg + msg sdk.Msg expectedType string expected string }{