-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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(textual): Remove msg header screen #15208
Conversation
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.
LGTM!
x/tx/textual/any.go
Outdated
@@ -45,10 +47,15 @@ func (ar anyValueRenderer) Format(ctx context.Context, v protoreflect.Value) ([] | |||
return nil, err | |||
} | |||
|
|||
screens := make([]Screen, 1+len(subscreens)) | |||
// The Any value renderer suppresses emission of the object header | |||
if subscreens[0].Content == fmt.Sprintf("%s object", internalMsg.ProtoReflect().Descriptor().Name()) { |
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.
Consider extracting fmt.Sprintf("%s object", internalMsg.ProtoReflect().Descriptor().Name())
into a utility function taking a protoreflect.Message
argument so that it can be used by both the formatter and the parser.
Actually, more than that, we need to check that vr
is actually messageValueRenderer
, whether or not the first screen matches the pattern. For instance, it would be reasonable to extend the SignModeHandler
with a customer handler for StringValue
messages that would work like the string renderer, and the enclosed string data might happen to say "StringValue object"
, but in this case it would be data, not a header.
For similar reasons, we'd need to check the type of the ValueRenderer
in the parser, just for symmetry.
I'd still do the string comparison just to be sure. We want to be careful in omitting data from the sub-renderer.
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.
About extracting the fmt.Sprintf("%s object",...
: there are 2 usages by 2 different types protoreflect.MessageType
and protoreflect.ProtoMessage
. Would it make sense to make it so we call msgType.New()
?
Actually, more than that, we need to check that vr is actually messageValueRenderer, whether or not the first screen matches the pattern. For instance, it would be reasonable to extend the SignModeHandler with a customer handler for StringValue messages that would work like the string renderer, and the enclosed string data might happen to say "StringValue object", but in this case it would be data, not a header.
For similar reasons, we'd need to check the type of the ValueRenderer in the parser, just for symmetry.
I'd still do the string comparison just to be sure. We want to be careful in omitting data from the sub-renderer.
I think I understand what you mean, but I'm not sure I know how to implement that. Looks like GetMessageValueRenderer
always return that type, even if the function returns an interface.
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.
For the Sprintf, feel free to disregard my suggestion if it would lead to inefficiency or if the necessary adaptations make the code just as wordy as it was before.
GetMessageValueRenderer
defaults to messageValueRenderer
, but it can return specialized renderers for Coin
, Timestamp
, and Duration
, and with SignModeHandler.DefineMessageRenderer()
we can extend this list. None of the first three can have a rendering like "Foo object"
, but an extension could, and a specific renderer for StringValue
(ref) would be quite reasonable.
It should be easy to modify the test to something like:
_, isMsgRender := vr.(*messageValueRenderer)
if isMsgRender && subscreens[0].Content == fmt.Sprintf(...) {
omitHeader = 1
}
…/rm-msg-header-screen
…/cosmos-sdk into facu/rm-msg-header-screen
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.
LGTM. @JimLarson said he'd take a look too, let's wait a bit before merging.
Description
@joeabbey 's PR with just some finishing touches
Closes: #14170
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change