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 authored Sep 18, 2023
1 parent 782fb5c commit 98d7338
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#1459](https://github.com/NibiruChain/nibiru/pull/1459) - fix(spot): wire `x/spot` msgService into app router
* [#1467](https://github.com/NibiruChain/nibiru/pull/1467) - fix(oracle): make `calcTwap` safer
* [#1464](https://github.com/NibiruChain/nibiru/pull/1464) - fix(gov): wire legacy proposal handlers
* [#1586](https://github.com/NibiruChain/nibiru/pull/1586) - fix(sudo): make messages compatible with `Amino`

### State Machine Breaking

Expand Down
3 changes: 2 additions & 1 deletion x/perp/v2/integration/action/dnr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (

"cosmossdk.io/math"
"github.com/NibiruChain/collections"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/NibiruChain/nibiru/app"
"github.com/NibiruChain/nibiru/x/common/testutil/action"
sdk "github.com/cosmos/cosmos-sdk/types"
)

func DnREpochIs(epoch uint64) action.Action {
Expand Down
3 changes: 2 additions & 1 deletion x/perp/v2/keeper/dnr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import (
"time"

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/NibiruChain/nibiru/x/common/asset"
"github.com/NibiruChain/nibiru/x/common/denoms"
"github.com/NibiruChain/nibiru/x/common/testutil"
. "github.com/NibiruChain/nibiru/x/common/testutil/action"
. "github.com/NibiruChain/nibiru/x/perp/v2/integration/action"
"github.com/NibiruChain/nibiru/x/perp/v2/keeper"
"github.com/NibiruChain/nibiru/x/perp/v2/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

func TestUserVolumes(t *testing.T) {
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 98d7338

Please sign in to comment.