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 <[email protected]>
  • Loading branch information
nullpointer0x00 and bruce-wayne2 authored Jan 12, 2023
1 parent afe98ad commit c362da1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

* Bring in Cosmos-SDK [v0.46.7](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.7) changes [#402](https://github.com/provenance-io/cosmos-sdk/pull/402).

### Bug Fixes

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

---

## [v0.46.6-pio-3](https://github.com/provenance-io/cosmos-sdk/releases/tag/v0.46.6-pio-3) - 2022-12-20
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 c362da1

Please sign in to comment.