Prathamesh Musale
ec147272e6
Reviewed-on: deep-stack/laconic2d#14 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
package bond
|
|
|
|
import (
|
|
errorsmod "cosmossdk.io/errors"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
)
|
|
|
|
var (
|
|
_ sdk.Msg = &MsgCreateBond{}
|
|
)
|
|
|
|
// NewMsgCreateBond is the constructor function for MsgCreateBond.
|
|
func NewMsgCreateBond(coins sdk.Coins, signer sdk.AccAddress) MsgCreateBond {
|
|
return MsgCreateBond{
|
|
Coins: coins,
|
|
Signer: signer.String(),
|
|
}
|
|
}
|
|
|
|
func (msg MsgCreateBond) ValidateBasic() error {
|
|
if len(msg.Signer) == 0 {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer)
|
|
}
|
|
if len(msg.Coins) == 0 || !msg.Coins.IsValid() {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, "Invalid amount.")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (msg MsgRefillBond) ValidateBasic() error {
|
|
if len(msg.Id) == 0 {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, msg.Id)
|
|
}
|
|
if len(msg.Signer) == 0 {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer)
|
|
}
|
|
if len(msg.Coins) == 0 || !msg.Coins.IsValid() {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, "Invalid amount.")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (msg MsgWithdrawBond) ValidateBasic() error {
|
|
if len(msg.Id) == 0 {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, msg.Id)
|
|
}
|
|
if len(msg.Signer) == 0 {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer)
|
|
}
|
|
if len(msg.Coins) == 0 || !msg.Coins.IsValid() {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, "Invalid amount.")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (msg MsgCancelBond) ValidateBasic() error {
|
|
if len(msg.Id) == 0 {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, msg.Id)
|
|
}
|
|
if len(msg.Signer) == 0 {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer)
|
|
}
|
|
return nil
|
|
}
|