cosmos-sdk/x/authz/generic_authorization.go
mergify[bot] aa72f10b5f
fix(authz): check string is not empty (backport #18209) (#18217)
Co-authored-by: Marko <marbar3778@yahoo.com>
2023-10-23 16:03:15 +00:00

36 lines
835 B
Go

package authz
import (
"context"
"errors"
sdk "github.com/cosmos/cosmos-sdk/types"
)
var _ Authorization = &GenericAuthorization{}
// NewGenericAuthorization creates a new GenericAuthorization object.
func NewGenericAuthorization(msgTypeURL string) *GenericAuthorization {
return &GenericAuthorization{
Msg: msgTypeURL,
}
}
// MsgTypeURL implements Authorization.MsgTypeURL.
func (a GenericAuthorization) MsgTypeURL() string {
return a.Msg
}
// Accept implements Authorization.Accept.
func (a GenericAuthorization) Accept(ctx context.Context, msg sdk.Msg) (AcceptResponse, error) {
return AcceptResponse{Accept: true}, nil
}
// ValidateBasic implements Authorization.ValidateBasic.
func (a GenericAuthorization) ValidateBasic() error {
if a.Msg == "" {
return errors.New("msg type cannot be empty")
}
return nil
}