-
Notifications
You must be signed in to change notification settings - Fork 579
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into jim/3315-integrate-hermes-into-our-e2e-tests
- Loading branch information
Showing
28 changed files
with
380 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package sanitize | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" | ||
grouptypes "github.com/cosmos/cosmos-sdk/x/group" | ||
|
||
"github.com/cosmos/ibc-go/e2e/semverutil" | ||
) | ||
|
||
var ( | ||
// groupsv1ProposalTitleAndSummary represents the releases that support the new title and summary fields. | ||
groupsv1ProposalTitleAndSummary = semverutil.FeatureReleases{ | ||
MajorVersion: "v7", | ||
} | ||
// govv1ProposalTitleAndSummary represents the releases that support the new title and summary fields. | ||
govv1ProposalTitleAndSummary = semverutil.FeatureReleases{ | ||
MajorVersion: "v7", | ||
} | ||
) | ||
|
||
// Messages removes any fields that are not supported by the chain version. | ||
// For example, any fields that have been added in later sdk releases. | ||
func Messages(tag string, msgs ...sdk.Msg) []sdk.Msg { | ||
sanitizedMsgs := make([]sdk.Msg, len(msgs)) | ||
for i := range msgs { | ||
sanitizedMsgs[i] = removeUnknownFields(tag, msgs[i]) | ||
} | ||
return sanitizedMsgs | ||
} | ||
|
||
// removeUnknownFields removes any fields that are not supported by the chain version. | ||
// The input message is returned if no changes are made. | ||
func removeUnknownFields(tag string, msg sdk.Msg) sdk.Msg { | ||
switch msg := msg.(type) { | ||
case *govtypesv1.MsgSubmitProposal: | ||
if !govv1ProposalTitleAndSummary.IsSupported(tag) { | ||
msg.Title = "" | ||
msg.Summary = "" | ||
} | ||
return msg | ||
case *grouptypes.MsgSubmitProposal: | ||
if !groupsv1ProposalTitleAndSummary.IsSupported(tag) { | ||
msg.Title = "" | ||
msg.Summary = "" | ||
} | ||
return msg | ||
} | ||
return msg | ||
} |
Oops, something went wrong.