From 3fca8bee18438db7cc00c6b01331ae0bc23269ed Mon Sep 17 00:00:00 2001 From: Dzung Do Date: Sun, 14 Jul 2024 23:20:02 +0700 Subject: [PATCH] fix MsgUpdateParams --- x/meshsecurityprovider/types/codec.go | 2 ++ x/meshsecurityprovider/types/msgs.go | 31 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/x/meshsecurityprovider/types/codec.go b/x/meshsecurityprovider/types/codec.go index 23cd328f..76e10469 100644 --- a/x/meshsecurityprovider/types/codec.go +++ b/x/meshsecurityprovider/types/codec.go @@ -11,11 +11,13 @@ import ( // RegisterLegacyAminoCodec registers the necessary x/meshsecurityprovider interfaces and concrete types // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgUpdateParams{}, "meshsecurityprovider/MsgUpdateParams", nil) } func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), + &MsgUpdateParams{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/meshsecurityprovider/types/msgs.go b/x/meshsecurityprovider/types/msgs.go index ab1254f4..8cdbbabf 100644 --- a/x/meshsecurityprovider/types/msgs.go +++ b/x/meshsecurityprovider/types/msgs.go @@ -1 +1,32 @@ package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ sdk.Msg = &MsgUpdateParams{} + + +const ( + TypeMsgUpdateParams = "update-params" +) + + +func (msg MsgUpdateParams) Route() string { return ModuleName } +func (msg MsgUpdateParams) Type() string { return TypeMsgUpdateParams } +func (msg MsgUpdateParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return errorsmod.Wrap(err, "invalid authority address") + } + return msg.Params.Validate() +} + +func (msg MsgUpdateParams) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(msg.Authority) + return []sdk.AccAddress{addr} +} \ No newline at end of file