mesg-foundation/core

View on GitHub
x/service/internal/types/msg.go

Summary

Maintainability
A
3 hrs
Test Coverage
package types

import (
    sdk "github.com/cosmos/cosmos-sdk/types"
    sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
    "github.com/mesg-foundation/engine/ext/xvalidator"
)

// Route should return the name of the module route.
func (msg MsgCreate) Route() string {
    return RouterKey
}

// Type returns the action.
func (msg MsgCreate) Type() string {
    return "create"
}

// ValidateBasic runs stateless checks on the message.
func (msg MsgCreate) ValidateBasic() error {
    if err := xvalidator.Struct(msg); err != nil {
        return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, err.Error())
    }
    return nil
}

// GetSignBytes encodes the message for signing.
func (msg MsgCreate) GetSignBytes() []byte {
    return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(msg))
}

// GetSigners defines whose signature is required.
func (msg MsgCreate) GetSigners() []sdk.AccAddress {
    return []sdk.AccAddress{msg.Owner}
}