Prathamesh Musale
5e68c7d9b3
Reviewed-on: deep-stack/laconic2d#5 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
36 lines
852 B
Go
36 lines
852 B
Go
package registry
|
|
|
|
import (
|
|
errorsmod "cosmossdk.io/errors"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
)
|
|
|
|
// NewMsgSetRecord is the constructor function for MsgSetRecord.
|
|
func NewMsgSetRecord(payload Payload, bondId string, signer sdk.AccAddress) *MsgSetRecord {
|
|
return &MsgSetRecord{
|
|
Payload: payload,
|
|
BondId: bondId,
|
|
Signer: signer.String(),
|
|
}
|
|
}
|
|
|
|
func (msg MsgSetRecord) ValidateBasic() error {
|
|
if len(msg.Signer) == 0 {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidAddress, msg.Signer)
|
|
}
|
|
|
|
owners := msg.Payload.Record.Owners
|
|
for _, owner := range owners {
|
|
if owner == "" {
|
|
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Record owner not set.")
|
|
}
|
|
}
|
|
|
|
if len(msg.BondId) == 0 {
|
|
return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Bond Id is required.")
|
|
}
|
|
|
|
return nil
|
|
}
|