Skip to content

Commit

Permalink
feat: gov/v1.Proposal convertion to v1beta1.Proposal cleanup (cosmos#…
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba authored Dec 23, 2022
1 parent a809ce4 commit 5791219
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions x/gov/migrations/v3/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,14 @@ func ConvertToLegacyProposal(proposal v1.Proposal) (v1beta1.Proposal, error) {
if len(msgs) != 1 {
return v1beta1.Proposal{}, sdkerrors.ErrInvalidType.Wrap("can't convert a gov/v1 Proposal to gov/v1beta1 Proposal when amount of proposal messages is more than one")
}
for _, msg := range msgs {
if legacyMsg, ok := msg.(*v1.MsgExecLegacyContent); ok {
// check that the content struct can be unmarshalled
_, err := v1.LegacyContentFromMessage(legacyMsg)
if err != nil {
return v1beta1.Proposal{}, err
}
legacyProposal.Content = legacyMsg.Content
return legacyProposal, nil
if legacyMsg, ok := msgs[0].(*v1.MsgExecLegacyContent); ok {
// check that the content struct can be unmarshalled
_, err := v1.LegacyContentFromMessage(legacyMsg)
if err != nil {
return v1beta1.Proposal{}, err
}
legacyProposal.Content = legacyMsg.Content
return legacyProposal, nil
}
// hack to fill up the content with the first message
// this is to support clients that have not yet (properly) use gov/v1 endpoints
Expand Down

0 comments on commit 5791219

Please sign in to comment.