Skip to content
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

feat(textual): Add Enum value renderer #13853

Merged
merged 10 commits into from
Nov 23, 2022
Prev Previous commit
Next Next commit
Update ADR
  • Loading branch information
amaury1093 committed Nov 14, 2022
commit ff54427eea009548fedfcdf91024482364aa6288
12 changes: 3 additions & 9 deletions docs/architecture/adr-050-sign-mode-textual-annex1.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,23 +153,17 @@ Vote object
> Vote: cosmos1abc...def
> Options: 2 WeightedVoteOptions
> Options (1/2): WeightedVoteOption object
>> Option: Yes
>> Option: VOTE_OPTION_YES
>> Weight: 0.7
> Options (2/2): WeightedVoteOption object
>> Option: No
>> Option: VOTE_OPTION_NO
>> Weight: 0.3
> End of Options
```

### Enums

- String case convention: snake case to sentence case
- Allow optional annotation for textual name (TBD)
- Algorithm:
- convert enum name (`VoteOption`) to snake_case (`VOTE_OPTION`)
- truncate that prefix + `_` from the enum name if it exists (`VOTE_OPTION_` gets stripped from `VOTE_OPTION_YES` -> `YES`)
- convert rest to sentence case: `YES` -> `Yes`
- in summary: `VOTE_OPTION_YES` -> `Yes`
Comment on lines -166 to -172
Copy link
Contributor Author

@amaury1093 amaury1093 Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed all string transformation we initially had. It can be ambiguous even for Format.

Take:

enum AbC {
  D = 1;
  AB_C_D = 2;
}

I propose to go with simplicity with no transformation.

- Show the enum variant name as string.

#### Examples

Expand Down
4 changes: 2 additions & 2 deletions docs/architecture/adr-050-sign-mode-textual.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ Tip: 200 ibc/CDC4587874B85BEA4FCEC3CEA5A1195139799A1FEE711A07D972537E18FDA39D
*This transaction has 1 other signer:
*Signer (1/2):
*Public Key: iQ...==
*Sign mode: Direct Aux
*Sign mode: SIGN_MODE_DIRECT_AUX
*Sequence: 42
*End of other signers
*Hash of raw bytes: <hex_string>
Expand Down Expand Up @@ -549,7 +549,7 @@ Fee: 0.002 atom
*This transaction has 1 other signer:
*Signer (2/2):
*Public Key: iR...==
*Sign mode: Direct
*Sign mode: SIGN_MODE_DIRECT
*Sequence: 42
*End of other signers
*Hash of raw bytes: <hex_string>
Expand Down