Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cherry-pick cosmos-sdk authz validatebasic fix #429

Merged
merged 2 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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