refactor: remove .Type() and .Route() from msgs (#14751)
This commit is contained in:
@@ -17,22 +17,14 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
)
|
||||
|
||||
// LegacyMsg defines the old interface a message must fulfill, containing
|
||||
// Amino signing method and legacy router info.
|
||||
// LegacyMsg defines the old interface a message must fulfill,
|
||||
// containing Amino signing method.
|
||||
// Deprecated: Please use `Msg` instead.
|
||||
type LegacyMsg interface {
|
||||
sdk.Msg
|
||||
|
||||
// Get the canonical byte representation of the Msg.
|
||||
GetSignBytes() []byte
|
||||
|
||||
// Return the message type.
|
||||
// Must be alphanumeric or empty.
|
||||
Route() string
|
||||
|
||||
// Returns a human-readable string for the message, intended for utilization
|
||||
// within tags
|
||||
Type() string
|
||||
}
|
||||
|
||||
// StdSignDoc is replay-prevention structure.
|
||||
|
||||
@@ -3,9 +3,13 @@ package types
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
|
||||
)
|
||||
|
||||
var _ sdk.Msg = &MsgUpdateParams{}
|
||||
var (
|
||||
_ sdk.Msg = &MsgUpdateParams{}
|
||||
_ legacytx.LegacyMsg = &MsgUpdateParams{}
|
||||
)
|
||||
|
||||
// GetSignBytes implements the LegacyMsg interface.
|
||||
func (msg MsgUpdateParams) GetSignBytes() []byte {
|
||||
@@ -13,13 +17,13 @@ func (msg MsgUpdateParams) GetSignBytes() []byte {
|
||||
}
|
||||
|
||||
// GetSigners returns the expected signers for a MsgUpdateParams message.
|
||||
func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress {
|
||||
func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress {
|
||||
addr, _ := sdk.AccAddressFromBech32(msg.Authority)
|
||||
return []sdk.AccAddress{addr}
|
||||
}
|
||||
|
||||
// ValidateBasic does a sanity check on the provided data.
|
||||
func (msg *MsgUpdateParams) ValidateBasic() error {
|
||||
func (msg MsgUpdateParams) ValidateBasic() error {
|
||||
if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil {
|
||||
return sdkerrors.Wrap(err, "invalid authority address")
|
||||
}
|
||||
|
||||
@@ -5,22 +5,18 @@ import (
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
|
||||
)
|
||||
|
||||
// TypeMsgCreateVestingAccount defines the type value for a MsgCreateVestingAccount.
|
||||
const TypeMsgCreateVestingAccount = "msg_create_vesting_account"
|
||||
var (
|
||||
_ sdk.Msg = &MsgCreateVestingAccount{}
|
||||
_ sdk.Msg = &MsgCreatePermanentLockedAccount{}
|
||||
_ sdk.Msg = &MsgCreatePeriodicVestingAccount{}
|
||||
|
||||
// TypeMsgCreatePermanentLockedAccount defines the type value for a MsgCreatePermanentLockedAccount.
|
||||
const TypeMsgCreatePermanentLockedAccount = "msg_create_permanent_locked_account"
|
||||
|
||||
// TypeMsgCreatePeriodicVestingAccount defines the type value for a MsgCreateVestingAccount.
|
||||
const TypeMsgCreatePeriodicVestingAccount = "msg_create_periodic_vesting_account"
|
||||
|
||||
var _ sdk.Msg = &MsgCreateVestingAccount{}
|
||||
|
||||
var _ sdk.Msg = &MsgCreatePermanentLockedAccount{}
|
||||
|
||||
var _ sdk.Msg = &MsgCreatePeriodicVestingAccount{}
|
||||
_ legacytx.LegacyMsg = &MsgCreateVestingAccount{}
|
||||
_ legacytx.LegacyMsg = &MsgCreatePermanentLockedAccount{}
|
||||
_ legacytx.LegacyMsg = &MsgCreatePeriodicVestingAccount{}
|
||||
)
|
||||
|
||||
// NewMsgCreateVestingAccount returns a reference to a new MsgCreateVestingAccount.
|
||||
//
|
||||
@@ -35,12 +31,6 @@ func NewMsgCreateVestingAccount(fromAddr, toAddr sdk.AccAddress, amount sdk.Coin
|
||||
}
|
||||
}
|
||||
|
||||
// Route returns the message route for a MsgCreateVestingAccount.
|
||||
func (msg MsgCreateVestingAccount) Route() string { return RouterKey }
|
||||
|
||||
// Type returns the message type for a MsgCreateVestingAccount.
|
||||
func (msg MsgCreateVestingAccount) Type() string { return TypeMsgCreateVestingAccount }
|
||||
|
||||
// ValidateBasic Implements Msg.
|
||||
func (msg MsgCreateVestingAccount) ValidateBasic() error {
|
||||
if _, err := sdk.AccAddressFromBech32(msg.FromAddress); err != nil {
|
||||
@@ -88,12 +78,6 @@ func NewMsgCreatePermanentLockedAccount(fromAddr, toAddr sdk.AccAddress, amount
|
||||
}
|
||||
}
|
||||
|
||||
// Route returns the message route for a MsgCreatePermanentLockedAccount.
|
||||
func (msg MsgCreatePermanentLockedAccount) Route() string { return RouterKey }
|
||||
|
||||
// Type returns the message type for a MsgCreatePermanentLockedAccount.
|
||||
func (msg MsgCreatePermanentLockedAccount) Type() string { return TypeMsgCreatePermanentLockedAccount }
|
||||
|
||||
// ValidateBasic Implements Msg.
|
||||
func (msg MsgCreatePermanentLockedAccount) ValidateBasic() error {
|
||||
if _, err := sdk.AccAddressFromBech32(msg.FromAddress); err != nil {
|
||||
@@ -138,12 +122,6 @@ func NewMsgCreatePeriodicVestingAccount(fromAddr, toAddr sdk.AccAddress, startTi
|
||||
}
|
||||
}
|
||||
|
||||
// Route returns the message route for a MsgCreatePeriodicVestingAccount.
|
||||
func (msg MsgCreatePeriodicVestingAccount) Route() string { return RouterKey }
|
||||
|
||||
// Type returns the message type for a MsgCreatePeriodicVestingAccount.
|
||||
func (msg MsgCreatePeriodicVestingAccount) Type() string { return TypeMsgCreatePeriodicVestingAccount }
|
||||
|
||||
// GetSigners returns the expected signers for a MsgCreatePeriodicVestingAccount.
|
||||
func (msg MsgCreatePeriodicVestingAccount) GetSigners() []sdk.AccAddress {
|
||||
from, err := sdk.AccAddressFromBech32(msg.FromAddress)
|
||||
|
||||
Reference in New Issue
Block a user