Skip to content

Commit

Permalink
cherry-pick cosmos-sdk authz validatebasic fix (#429)
Browse files Browse the repository at this point in the history
* cherry-pick cosmos-sdk authz validatebasic fix

* Add change log entry

Co-authored-by: bruce-wayne2 <97930236+bruce-wayne2@users.noreply.github.com>
  • Loading branch information
2 people authored and SpicyLemon committed Jan 12, 2023
1 parent d2c56d3 commit 982ad88
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ Ref: https://keepachangelog.com/en/1.0.0/

## Unreleased

* nothing
### Bug Fixes

* Pull in Cosmos-SDK authz validate basic fix [#12184](https://github.com/cosmos/cosmos-sdk/pull/12184)

---

Expand Down
4 changes: 2 additions & 2 deletions x/authz/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ func NewCmdGrantAuthorization() *cobra.Command {
fmt.Sprintf(`create a new grant authorization to an address to execute a transaction on your behalf:
Examples:
$ %s tx %s grant cosmos1skjw.. send %s --spend-limit=1000stake --from=cosmos1skl..
$ %s tx %s grant cosmos1skjw.. send --spend-limit=1000stake --from=cosmos1skl..
$ %s tx %s grant cosmos1skjw.. generic --msg-type=/cosmos.gov.v1.MsgVote --from=cosmos1sk..
`, version.AppName, authz.ModuleName, bank.SendAuthorization{}.MsgTypeURL(), version.AppName, authz.ModuleName),
`, version.AppName, authz.ModuleName, version.AppName, authz.ModuleName),
),
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
10 changes: 10 additions & 0 deletions x/authz/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@ func (msg MsgExec) ValidateBasic() error {
return sdkerrors.ErrInvalidRequest.Wrapf("messages cannot be empty")
}

msgs, err := msg.GetMessages()
if err != nil {
return err
}
for _, msg := range msgs {
if err = msg.ValidateBasic(); err != nil {
return err
}
}

return nil
}

Expand Down
7 changes: 7 additions & 0 deletions x/authz/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ func TestMsgExecAuthorized(t *testing.T) {
}{
{"nil grantee address", nil, []sdk.Msg{}, false},
{"zero-messages test: should fail", grantee, []sdk.Msg{}, false},
{"invalid nested msg", grantee, []sdk.Msg{
&banktypes.MsgSend{
Amount: sdk.NewCoins(sdk.NewInt64Coin("steak", 2)),
FromAddress: "invalid_from_address",
ToAddress: grantee.String(),
},
}, false},
{"valid test: msg type", grantee, []sdk.Msg{
&banktypes.MsgSend{
Amount: sdk.NewCoins(sdk.NewInt64Coin("steak", 2)),
Expand Down

0 comments on commit 982ad88

Please sign in to comment.