Skip to content

Commit

Permalink
register UpdateParams Msg with codec
Browse files Browse the repository at this point in the history
  • Loading branch information
harish551 committed Sep 23, 2023
1 parent 367d6d0 commit c54f7c9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&MsgTransferONFT{}, "OmniFlix/onft/MsgTransferONFT", nil)
cdc.RegisterConcrete(&MsgMintONFT{}, "OmniFlix/onft/MsgMintONFT", nil)
cdc.RegisterConcrete(&MsgBurnONFT{}, "OmniFlix/onft/MsgBurnONFT", nil)
cdc.RegisterConcrete(&MsgUpdateParams{}, "OmniFlix/onft/MsgUpdateParams", nil)

cdc.RegisterConcrete(&Params{}, "OmniFlix/onft/Params", nil)

cdc.RegisterInterface((*exported.ONFTI)(nil), nil)
}
Expand All @@ -29,6 +32,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
&MsgTransferONFT{},
&MsgMintONFT{},
&MsgBurnONFT{},
&MsgUpdateParams{},
)

registry.RegisterInterface(
Expand Down
24 changes: 24 additions & 0 deletions types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const (
)

var (
_ sdk.Msg = &MsgUpdateParams{}

_ sdk.Msg = &MsgCreateDenom{}
_ sdk.Msg = &MsgUpdateDenom{}
_ sdk.Msg = &MsgTransferDenom{}
Expand Down Expand Up @@ -320,3 +322,25 @@ func (msg MsgBurnONFT) GetSigners() []sdk.AccAddress {
}
return []sdk.AccAddress{from}
}

// MsgUpdateParams

// GetSignBytes implements the LegacyMsg interface.
func (m MsgUpdateParams) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}

// GetSigners returns the expected signers for a MsgUpdateParams message.
func (m *MsgUpdateParams) GetSigners() []sdk.AccAddress {
addr, _ := sdk.AccAddressFromBech32(m.Authority)
return []sdk.AccAddress{addr}
}

// ValidateBasic does a sanity check on the provided data.
func (m *MsgUpdateParams) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {
return errorsmod.Wrap(err, "invalid authority address")
}

return m.Params.ValidateBasic()
}

0 comments on commit c54f7c9

Please sign in to comment.