From ded6b47aea992af05dc2171b6e8c27617602387c Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 15 Aug 2023 10:40:45 +0200 Subject: [PATCH] feat(x/gov): add MsgSubmitProposal SetMsgs method (#17387) --- CHANGELOG.md | 1 + x/gov/types/v1/msgs.go | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 672b22f3ea4..589ea2b2919 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* (x/gov) [#17387](https://github.com/cosmos/cosmos-sdk/pull/17387) Add `MsgSubmitProposal` `SetMsgs` method. * (x/gov) [#17354](https://github.com/cosmos/cosmos-sdk/issues/17354) Emit `VoterAddr` in `proposal_vote` event. * (x/group, x/gov) [#17220](https://github.com/cosmos/cosmos-sdk/pull/17220) Add `--skip-metadata` flag in `draft-proposal` to skip metadata prompt. * (x/genutil) [#17296](https://github.com/cosmos/cosmos-sdk/pull/17296) Add `MigrateHandler` to allow reuse migrate genesis related function. diff --git a/x/gov/types/v1/msgs.go b/x/gov/types/v1/msgs.go index f1b1667d59d..64fefce8d35 100644 --- a/x/gov/types/v1/msgs.go +++ b/x/gov/types/v1/msgs.go @@ -46,6 +46,18 @@ func (m *MsgSubmitProposal) GetMsgs() ([]sdk.Msg, error) { return sdktx.GetMsgs(m.Messages, "sdk.MsgProposal") } +// SetMsgs packs sdk.Msg's into m.Messages Any's +// NOTE: this will overwrite any existing messages +func (m *MsgSubmitProposal) SetMsgs(msgs []sdk.Msg) error { + anys, err := sdktx.SetMsgs(msgs) + if err != nil { + return err + } + + m.Messages = anys + return nil +} + // Route implements the sdk.Msg interface. func (m MsgSubmitProposal) Route() string { return types.RouterKey }