-
Notifications
You must be signed in to change notification settings - Fork 580
/
msgs.go
42 lines (33 loc) · 985 Bytes
/
msgs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package types
import (
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors"
)
var (
_ sdk.Msg = (*MsgUpdateParams)(nil)
_ sdk.HasValidateBasic = (*MsgUpdateParams)(nil)
)
// NewMsgUpdateParams creates a new MsgUpdateParams instance
func NewMsgUpdateParams(signer string, params Params) *MsgUpdateParams {
return &MsgUpdateParams{
Signer: signer,
Params: params,
}
}
// ValidateBasic implements sdk.Msg
func (msg MsgUpdateParams) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(msg.Signer)
if err != nil {
return errorsmod.Wrapf(ibcerrors.ErrInvalidAddress, "string could not be parsed as address: %v", err)
}
return msg.Params.Validate()
}
// GetSigners implements sdk.Msg
func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress {
accAddr, err := sdk.AccAddressFromBech32(msg.Signer)
if err != nil {
panic(err)
}
return []sdk.AccAddress{accAddr}
}