-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(simulations): marshal OperationMsg.Msg as protoBytes #16155
Merged
Merged
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
51b83d7
refactor(simuluations): marshal simulation.OperationMsg.Msg as protoB…
kocubinski fba521d
fix any unmarshal in tests
kocubinski ce12ee9
_ for unused param
kocubinski 3f90ebd
Merge branch 'main' into kocubinski/sims-protobytes
kocubinski 1a86fe7
lint fixes
kocubinski 5151587
Merge branch 'main' into kocubinski/sims-protobytes
kocubinski 81fac7b
add changelog entry
kocubinski 7bbb2f8
Merge branch 'kocubinski/sims-protobytes' of github.com:cosmos/cosmos…
kocubinski 5331dfa
fix CHANGELOG
kocubinski fa95ee2
remove codec.ProtoCodec from NewOperationMsg args
kocubinski 375a3b8
fix x/nft usage of NewOperationMsg
kocubinski 4ae2ca8
fix x/nft go.mod with replace, fix after merge
kocubinski edf2c01
x/nft needs store and collection replaces
kocubinski 5b8559e
go mod tidy
kocubinski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,10 @@ import ( | |
"math/rand" | ||
"time" | ||
|
||
"github.com/cosmos/gogoproto/proto" | ||
|
||
"github.com/cosmos/cosmos-sdk/baseapp" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
"github.com/cosmos/cosmos-sdk/codec/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/kv" | ||
) | ||
|
@@ -70,11 +71,11 @@ type Operation func(r *rand.Rand, app *baseapp.BaseApp, | |
|
||
// OperationMsg - structure for operation output | ||
type OperationMsg struct { | ||
Route string `json:"route" yaml:"route"` // msg route (i.e module name) | ||
Name string `json:"name" yaml:"name"` // operation name (msg Type or "no-operation") | ||
Comment string `json:"comment" yaml:"comment"` // additional comment | ||
OK bool `json:"ok" yaml:"ok"` // success | ||
Msg json.RawMessage `json:"msg" yaml:"msg"` // JSON encoded msg | ||
Route string `json:"route" yaml:"route"` // msg route (i.e module name) | ||
Name string `json:"name" yaml:"name"` // operation name (msg Type or "no-operation") | ||
Comment string `json:"comment" yaml:"comment"` // additional comment | ||
OK bool `json:"ok" yaml:"ok"` // success | ||
Msg []byte `json:"msg" yaml:"msg"` // protobuf encoded msg | ||
} | ||
|
||
// NewOperationMsgBasic creates a new operation message from raw input. | ||
|
@@ -89,21 +90,18 @@ func NewOperationMsgBasic(moduleName, msgType, comment string, ok bool, msg []by | |
} | ||
|
||
// NewOperationMsg - create a new operation message from sdk.Msg | ||
func NewOperationMsg(msg sdk.Msg, ok bool, comment string, cdc *codec.ProtoCodec) OperationMsg { | ||
func NewOperationMsg(msg sdk.Msg, ok bool, comment string, _ *codec.ProtoCodec) OperationMsg { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that this is anyway a behavior change, why not making it API breaking and remove this argument? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense to me. |
||
msgType := sdk.MsgTypeURL(msg) | ||
moduleName := sdk.GetModuleNameFromTypeURL(msgType) | ||
if moduleName == "" { | ||
moduleName = msgType | ||
} | ||
if cdc == nil { | ||
cdc = codec.NewProtoCodec(types.NewInterfaceRegistry()) | ||
} | ||
jsonBytes, err := cdc.MarshalAminoJSON(msg) | ||
protoBz, err := proto.Marshal(msg) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to marshal aminon JSON: %w", err)) | ||
panic(fmt.Errorf("failed to marshal proto message: %w", err)) | ||
} | ||
|
||
return NewOperationMsgBasic(moduleName, msgType, comment, ok, jsonBytes) | ||
return NewOperationMsgBasic(moduleName, msgType, comment, ok, protoBz) | ||
} | ||
|
||
// NoOpMsg - create a no-operation message | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add a changelog entry for chains using this.