44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
package nft
|
|
|
|
import (
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
)
|
|
|
|
const (
|
|
// TypeMsgSend nft message types
|
|
TypeMsgSend = "send"
|
|
)
|
|
|
|
var (
|
|
_ sdk.Msg = &MsgSend{}
|
|
)
|
|
|
|
// GetSigners implements the Msg.ValidateBasic method.
|
|
func (m MsgSend) ValidateBasic() error {
|
|
if err := ValidateClassID(m.ClassId); err != nil {
|
|
return sdkerrors.Wrapf(ErrInvalidID, "Invalid class id (%s)", m.ClassId)
|
|
}
|
|
|
|
if err := ValidateNFTID(m.Id); err != nil {
|
|
return sdkerrors.Wrapf(ErrInvalidID, "Invalid nft id (%s)", m.Id)
|
|
}
|
|
|
|
_, err := sdk.AccAddressFromBech32(m.Sender)
|
|
if err != nil {
|
|
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", m.Sender)
|
|
}
|
|
|
|
_, err = sdk.AccAddressFromBech32(m.Receiver)
|
|
if err != nil {
|
|
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid receiver address (%s)", m.Receiver)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetSigners implements Msg
|
|
func (m MsgSend) GetSigners() []sdk.AccAddress {
|
|
signer, _ := sdk.AccAddressFromBech32(m.Sender)
|
|
return []sdk.AccAddress{signer}
|
|
}
|