fix: Fix MsgExec not verifying the validity of nested messages (#12184)
This commit is contained in:
parent
b3ffde1b03
commit
64409bf990
@ -61,6 +61,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
* (x/auth) [#12108](https://github.com/cosmos/cosmos-sdk/pull/12108) Fix GetBlockWithTxs error when querying block with 0 tx
|
||||
* (genutil) [#12140](https://github.com/cosmos/cosmos-sdk/pull/12140) Fix staking's genesis JSON migrate in the `simd migrate v0.46` CLI command.
|
||||
* (types) [#12154](https://github.com/cosmos/cosmos-sdk/pull/12154) Add `baseAccountGetter` to avoid invalid account error when create vesting account.
|
||||
* (x/authz) [#12184](https://github.com/cosmos/cosmos-sdk/pull/12184) Fix MsgExec not verifying the validity of nested messages.
|
||||
|
||||
## [v0.46.0-rc1](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.0-rc1) - 2022-05-23
|
||||
|
||||
|
||||
@ -60,9 +60,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 {
|
||||
|
||||
@ -219,6 +219,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
|
||||
}
|
||||
|
||||
|
||||
@ -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)),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user