Skip to content

Commit

Permalink
fix(sudo): make messages compatible with amino (#1586)
Browse files Browse the repository at this point in the history
* fix(sudo): make messages compatible with amino

* update changelog

* ci: sanity check

* chore: try updated golangci-lint

* fix: linter

---------

Co-authored-by: Unique-Divine <[email protected]>
  • Loading branch information
k-yang and Unique-Divine committed Sep 19, 2023
1 parent d167a49 commit 0fee65b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: 1.19
cache: false # the golangci-lint action already caches for us (https://github.com/golangci/golangci-lint-action#performance)

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.52.1
version: v1.54.2

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
37 changes: 31 additions & 6 deletions x/sudo/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

var _ sdk.Msg = &MsgEditSudoers{}
var (
_ sdk.Msg = &MsgEditSudoers{}
_ sdk.Msg = &MsgChangeRoot{}
)

// MsgEditSudoers

func (m *MsgEditSudoers) ValidateBasic() error {
func (m MsgEditSudoers) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil {
return err
}
Expand All @@ -31,29 +34,40 @@ func (m *MsgEditSudoers) ValidateBasic() error {
return nil
}

func (m *MsgEditSudoers) GetSigners() []sdk.AccAddress {
func (m MsgEditSudoers) GetSigners() []sdk.AccAddress {
signer, err := sdk.AccAddressFromBech32(m.Sender)
if err != nil {
panic(err)
}
return []sdk.AccAddress{signer}
}

func (m *MsgEditSudoers) RootAction() RootAction {
// Route Implements Msg.
func (msg MsgEditSudoers) Route() string { return ModuleName }

// Type Implements Msg.
func (msg MsgEditSudoers) Type() string { return "edit_sudoers" }

// GetSignBytes Implements Msg.
func (m MsgEditSudoers) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}

func (m MsgEditSudoers) RootAction() RootAction {
return RootAction(m.Action)
}

// MsgChangeRoot

func (m *MsgChangeRoot) GetSigners() []sdk.AccAddress {
func (m MsgChangeRoot) GetSigners() []sdk.AccAddress {
signer, err := sdk.AccAddressFromBech32(m.Sender)
if err != nil {
panic(err)
}
return []sdk.AccAddress{signer}
}

func (m *MsgChangeRoot) ValidateBasic() error {
func (m MsgChangeRoot) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil {
return err
}
Expand All @@ -64,3 +78,14 @@ func (m *MsgChangeRoot) ValidateBasic() error {

return nil
}

// Route Implements Msg.
func (msg MsgChangeRoot) Route() string { return ModuleName }

// Type Implements Msg.
func (msg MsgChangeRoot) Type() string { return "change_root" }

// GetSignBytes Implements Msg.
func (m MsgChangeRoot) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}

0 comments on commit 0fee65b

Please sign in to comment.