Skip to content

Commit 6f486fd

Browse files
feat(x/gov): add MsgSubmitProposal SetMsgs method (backport #17387) (#17388)
Co-authored-by: Julien Robert <[email protected]>
1 parent dd028ed commit 6f486fd

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
3939

4040
### Improvements
4141

42+
* (x/gov) [#17387](https://github.com/cosmos/cosmos-sdk/pull/17387) Add `MsgSubmitProposal` `SetMsgs` method.
4243
* (x/gov) [#17354](https://github.com/cosmos/cosmos-sdk/issues/17354) Emit `VoterAddr` in `proposal_vote` event.
4344
* (x/genutil) [#17296](https://github.com/cosmos/cosmos-sdk/pull/17296) Add `MigrateHandler` to allow reuse migrate genesis related function.
4445
* In v0.46, v0.47 this function is additive to the `genesis migrate` command. However in v0.50+, adding custom migrations to the `genesis migrate` command is directly possible.

x/gov/types/v1/msgs.go

+12
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ func (m *MsgSubmitProposal) GetMsgs() ([]sdk.Msg, error) {
4040
return sdktx.GetMsgs(m.Messages, "sdk.MsgProposal")
4141
}
4242

43+
// SetMsgs packs sdk.Msg's into m.Messages Any's
44+
// NOTE: this will overwrite any existing messages
45+
func (m *MsgSubmitProposal) SetMsgs(msgs []sdk.Msg) error {
46+
anys, err := sdktx.SetMsgs(msgs)
47+
if err != nil {
48+
return err
49+
}
50+
51+
m.Messages = anys
52+
return nil
53+
}
54+
4355
// Route implements Msg
4456
func (m MsgSubmitProposal) Route() string { return types.RouterKey }
4557

0 commit comments

Comments
 (0)