Skip to content

Commit

Permalink
feat: string and message value renderers for textual (#13510)
Browse files Browse the repository at this point in the history
## Description

Closes: #12713 
Refs: #12878

Sign mode textual value renderers for string and message.

### 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...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### 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...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
JimLarson authored Oct 25, 2022
1 parent 3c238eb commit dc3cf4a
Show file tree
Hide file tree
Showing 9 changed files with 1,949 additions and 26 deletions.
139 changes: 139 additions & 0 deletions tx/textual/internal/testdata/message.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
[
{
"proto": {},
"screens": [
{"text": "Foo object"}
]
},
{
"proto": {
"full_name": "nonempty"
},
"screens": [
{"text": "Foo object"},
{"text": "Full name: nonempty", "indent": 1}
]
},
{
"proto": {
"full_name": "thing one",
"nickname": ":thing two"
},
"screens": [
{"text": "Foo object"},
{"text": "Full name: thing one", "indent": 1},
{"text": "Nickname: :thing two", "indent": 1}
]
},
{
"proto": {
"full_name": "special child message",
"mtime": {
"seconds": 1136214245
}
},
"screens": [
{"text": "Foo object"},
{"text": "Full name: special child message", "indent": 1},
{"text": "Mtime: 2006-01-02T15:04:05Z", "indent": 1}
]
},
{
"proto": {
"nickname": "empty child",
"left": {}
},
"screens": [
{"text": "Foo object"},
{"text": "Nickname: empty child", "indent": 1},
{"text": "Left: Foo object", "indent": 1}
]
},
{
"proto": {
"nickname": "empty children",
"left": {},
"right": {},
"bar": {}
},
"screens": [
{"text": "Foo object"},
{"text": "Nickname: empty children", "indent": 1},
{"text": "Left: Foo object", "indent": 1},
{"text": "Right: Foo object", "indent": 1},
{"text": "Bar: Bar object", "indent": 1}
]
},
{
"proto": {
"full_name": "subfield",
"left": {},
"right": {
"nickname": "junior"
},
"bar": {}
},
"screens": [
{"text": "Foo object"},
{"text": "Full name: subfield", "indent": 1},
{"text": "Left: Foo object", "indent": 1},
{"text": "Right: Foo object", "indent": 1},
{"text": "Nickname: junior", "indent": 2},
{"text": "Bar: Bar object", "indent": 1}
]
},
{
"proto": {
"full_name": "deep",
"left": {
"left": {"nickname": "LL"},
"right": {"nickname": "LR"}
},
"right": {
"left": {"nickname": "RL"},
"right": {"nickname": "RR"}
}
},
"screens": [
{"text": "Foo object"},
{"text": "Full name: deep", "indent": 1},
{"text": "Left: Foo object", "indent": 1},
{"text": "Left: Foo object", "indent": 2},
{"text": "Nickname: LL", "indent": 3},
{"text": "Right: Foo object", "indent": 2},
{"text": "Nickname: LR", "indent": 3},
{"text": "Right: Foo object", "indent": 1},
{"text": "Left: Foo object", "indent": 2},
{"text": "Nickname: RL", "indent": 3},
{"text": "Right: Foo object", "indent": 2},
{"text": "Nickname: RR", "indent": 3}
]
},
{
"proto": {
"full_name": " the kitchen sink ",
"mtime": {},
"left": {},
"right": {
"nickname": "blub",
"right": {},
"bar": {
"bar_id": "quux",
"data": [255, 254]
}
}
},
"screens": [
{"text": "Foo object"},
{"text": "Full name: the kitchen sink ", "indent": 1},
{"text": "Mtime: 1970-01-01T00:00:00Z", "indent": 1},
{"text": "Left: Foo object", "indent": 1},
{"text": "Right: Foo object", "indent": 1},
{"text": "Nickname: blub", "indent": 2},
{"text": "Right: Foo object", "indent": 2},
{"text": "Bar: Bar object", "indent": 2},
{"text": "Bar id: quux", "indent": 3},
{"text": "Data: FFFE", "indent": 3}
]
}
]
11 changes: 11 additions & 0 deletions tx/textual/internal/testdata/string.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{"text": ""},
{"text": "x"},
{"text": "foo"},
{"text": "\"able"},
{"text": "unresolved\nambiguities\r\ncost\rbillions"},
{"text": "stealth whitespace is significant "},
{"text": "stealth whitespace snailed for your protection @@"},
{"text": "co\u00F6peration"},
{"text": "JSON limits unicode to 16 bits, surrogates must be transmitted as-is \uD852\uDF62"}
]
16 changes: 16 additions & 0 deletions tx/textual/internal/testpb/1.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,19 @@ message A {
double DOUBLE = 110;
map<string, A> MAP = 111;
}

// Foo is a sample message type used for testing message rendering.
message Foo {
string full_name = 1;
string nickname = 2;
google.protobuf.Timestamp mtime = 3;
Foo left = 4;
Foo right = 5;
Bar bar = 8; // skip some field numbers
}

// Bar is a sample message type used for testing message rendering.
message Bar {
string bar_id = 1;
bytes data = 2;
}
Loading

0 comments on commit dc3cf4a

Please sign in to comment.