github.com/Finschia/finschia-sdk@v0.48.1/x/stakingplus/authz.go (about) 1 package stakingplus 2 3 import ( 4 sdk "github.com/Finschia/finschia-sdk/types" 5 sdkerrors "github.com/Finschia/finschia-sdk/types/errors" 6 "github.com/Finschia/finschia-sdk/x/foundation" 7 stakingtypes "github.com/Finschia/finschia-sdk/x/staking/types" 8 ) 9 10 var _ foundation.Authorization = (*CreateValidatorAuthorization)(nil) 11 12 func (a CreateValidatorAuthorization) MsgTypeURL() string { 13 return sdk.MsgTypeURL(&stakingtypes.MsgCreateValidator{}) 14 } 15 16 func (a CreateValidatorAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (foundation.AcceptResponse, error) { 17 mCreate, ok := msg.(*stakingtypes.MsgCreateValidator) 18 if !ok { 19 return foundation.AcceptResponse{}, sdkerrors.ErrInvalidType.Wrap("type mismatch") 20 } 21 22 if mCreate.ValidatorAddress != a.ValidatorAddress { 23 return foundation.AcceptResponse{}, sdkerrors.ErrUnauthorized.Wrap("validator address differs from the authorization's") 24 } 25 26 return foundation.AcceptResponse{Accept: true}, nil 27 } 28 29 func (a CreateValidatorAuthorization) ValidateBasic() error { 30 if _, err := sdk.ValAddressFromBech32(a.ValidatorAddress); err != nil { 31 return err 32 } 33 34 return nil 35 }