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 Tx envelope Value Renderer #13600

Merged
merged 75 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
0b0f659
wip
amaury1093 Oct 20, 2022
ea7691b
wip
amaury1093 Oct 20, 2022
d857356
Add signer data to Textual
amaury1093 Oct 20, 2022
6c3c77a
Use any
amaury1093 Oct 20, 2022
94c0501
wip
amaury1093 Oct 24, 2022
49cff84
WIP
amaury1093 Oct 24, 2022
10891fd
add tx vr
amaury1093 Oct 25, 2022
9700665
Add examples
amaury1093 Oct 25, 2022
709dfb5
revert
amaury1093 Oct 25, 2022
460bce9
Add hash
amaury1093 Oct 25, 2022
eeaeaa9
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Oct 25, 2022
ae1fb1f
codegen
amaury1093 Oct 25, 2022
1513109
updates
amaury1093 Oct 25, 2022
18777bf
simplify test
amaury1093 Oct 25, 2022
b29e359
go mod tidy
amaury1093 Oct 25, 2022
b3a5670
Useless import
amaury1093 Oct 25, 2022
4d28d9c
Revert
amaury1093 Oct 25, 2022
f97e3ea
typo
amaury1093 Oct 25, 2022
8e363d5
remove textual fields
amaury1093 Oct 27, 2022
0bad609
create proto types
amaury1093 Oct 27, 2022
6d252e4
Fix tests
amaury1093 Oct 27, 2022
4e24b71
add comment
amaury1093 Oct 27, 2022
d1338ed
regenerate to internal
amaury1093 Nov 2, 2022
65e60ed
wip
amaury1093 Nov 7, 2022
75e0bc3
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Nov 14, 2022
025a9eb
go mod tidy
amaury1093 Nov 14, 2022
93d4b5d
Use MessageValueRenderer
amaury1093 Nov 14, 2022
9c87a2c
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Nov 28, 2022
f2b7a58
fix conflicts
amaury1093 Nov 28, 2022
0efbc25
Add part2
amaury1093 Nov 28, 2022
77a6ae1
Start doing parse
amaury1093 Nov 28, 2022
4f810fa
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Nov 28, 2022
00c313a
wip
amaury1093 Nov 29, 2022
7c3a6e6
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Nov 29, 2022
96e5137
Show transactions
amaury1093 Nov 29, 2022
bbee363
Add metadata
amaury1093 Nov 29, 2022
98c26e9
Add all fields
amaury1093 Nov 29, 2022
721e0c6
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Nov 30, 2022
bac3383
Add complex test case
amaury1093 Dec 1, 2022
db5dbfb
Link to JSON
amaury1093 Dec 1, 2022
45401a8
changelog
amaury1093 Dec 1, 2022
463a5e4
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Dec 1, 2022
7042623
Update
amaury1093 Dec 1, 2022
6fd8d79
update links
amaury1093 Dec 1, 2022
d0bb4f8
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Dec 2, 2022
201a1ff
go mod tidy
amaury1093 Dec 2, 2022
32a0608
Fix enum
amaury1093 Dec 2, 2022
01cfb3c
Make JSON clearer
amaury1093 Dec 2, 2022
2169ea1
Update links
amaury1093 Dec 2, 2022
b3e0fca
Refactor proto files
amaury1093 Dec 2, 2022
cc59b56
Clean up
amaury1093 Dec 2, 2022
5d96b7d
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Dec 2, 2022
727b93c
WIP parsing
amaury1093 Dec 2, 2022
79c6698
newlines
amaury1093 Dec 6, 2022
0106bc1
Pluralize
amaury1093 Dec 6, 2022
d05479d
Use enveloppe in approach 2a
amaury1093 Dec 6, 2022
cb0b6cc
Coin amounts are Ints
amaury1093 Dec 6, 2022
a1bc7dd
Add tests
amaury1093 Dec 6, 2022
37c9c52
buf format
amaury1093 Dec 6, 2022
82c0dd7
Add address
amaury1093 Dec 6, 2022
ee78038
Fix all tests
amaury1093 Dec 6, 2022
7c9dabc
Add address to spec
amaury1093 Dec 6, 2022
d05951f
Add changelog
amaury1093 Dec 6, 2022
d2d6d19
Update links to examples
amaury1093 Dec 6, 2022
f80932c
Merge branch 'main' into am/13579-textual-tx
amaury1093 Dec 6, 2022
f14e704
envelope
amaury1093 Dec 7, 2022
094abcd
2 test files
amaury1093 Dec 7, 2022
5647c04
Update exampls
amaury1093 Dec 7, 2022
f540695
Merge branch 'main' into am/13579-textual-tx
amaury1093 Dec 7, 2022
979e3ba
Merge branch 'main' into am/13579-textual-tx
amaury1093 Dec 12, 2022
c827732
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Jan 9, 2023
caf25d9
Add references to when to change Envelope
amaury1093 Jan 11, 2023
1a94bd7
Merge branch 'main' into am/13579-textual-tx
amaury1093 Jan 11, 2023
e0a1626
Fix tests
amaury1093 Jan 11, 2023
e3e55b5
Merge branch 'am/13579-textual-tx' of ssh://github.com/cosmos/cosmos-…
amaury1093 Jan 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
346 changes: 29 additions & 317 deletions docs/architecture/adr-050-sign-mode-textual.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* Sep 07, 2022: Add custom `Msg`-renderers.
* Sep 18, 2022: Structured format instead of lines of text
* Nov 23, 2022: Specify CBOR encoding.
* Dec 01, 2022: Link to examples in separate JSON file.
* Dec 06, 2022: Re-ordering of envelope screens.
* Dec 14, 2022: Mention exceptions for invertability.

## Status
Expand Down Expand Up @@ -176,29 +178,30 @@ We define "transaction envelope" as all data in a transaction that is not in the
```
Chain ID: <string>
Account number: <uint64>
*Public Key: <hex_string>
Sequence: <uint64>
<TxBody> // See #8.
Fee: <coins> // See value renderers for coins encoding.
*Fee payer: <string> // Skipped if no fee_payer set
*Fee granter: <string> // Skipped if no fee_granter set
Memo: <string> // Skipped if no memo set
Address: <string>
*Public Key: <Any>
This transaction has <int> Message(s) // Pluralize "Message" only when int>1
> Message (<int>/<int>): <Any> // See value renderers for Any rendering.
End of Message
Memo: <string> // Skipped if no memo set.
Fee: <coins> // See value renderers for coins rendering.
*Fee payer: <string> // Skipped if no fee_payer set.
*Fee granter: <string> // Skipped if no fee_granter set.
Tip: <coins> // Skippted if no tip.
Tipper: <string>
*Gas Limit: <uint64>
*Timeout Height: <uint64> // Skipped if no timeout_height set
Tipper: <string> // If there's a tip
Tip: <string>
*This transaction has <int> body extension: // Skipped if no body extension options
*<repeated Any>
*This transaction has <int> body non-critical extensions: // Skipped if no body non-critical extension options
*<repeated Any> // See value renderers for Any and array encoding.
*This transaction has <int> body auth info extensions: // Skipped if no auth info extension options
*<repeated Any>
*This transaction has <int> other signers: // Skipped if there is only one signer
*Signer (<int>/<int>):
*Public Key: <hex_string>
*Sequence: <uint64>
*Timeout Height: <uint64> // Skipped if no timeout_height set.
*Other signer: <int> SignerInfo // Skipped if the transaction only has 1 signer.
*> Other signer (<int>/<int>): <SignerInfo>
*End of other signers
*Hash of raw bytes: <hex_string> // Hex encoding of bytes defined in #10, to prevent tx hash malleability.
*Extension options: <int> Any: // Skipped if no body extension options
*> Extension options (<int>/<int>): <Any>
*End of extension options
*Non critical extension options: <int> Any: // Skipped if no body non critical extension options
*> Non critical extension options (<int>/<int>): <Any>
*End of Non critical extension options
*Hash of raw bytes: <hex_string> // Hex encoding of bytes defined, to prevent tx hash malleability.
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
```

### Encoding of the Transaction Body
Expand Down Expand Up @@ -289,304 +292,13 @@ See [annex 2](./adr-050-sign-mode-textual-annex2.md).

## Examples

#### Example 1: Simple `MsgSend`

JSON:

```json
{
"body": {
"messages": [
{
"@type": "/cosmos.bank.v1beta1.MsgSend",
"from": "cosmos1...abc",
"to": "cosmos1...def",
"amount": [
{
"denom": "uatom",
"amount": 10000000
}
]
}
]
},
"auth_info": {
"signer_infos": [
{
"public_key": "iQ...==",
"mode_info": { "single": { "mode": "SIGN_MODE_TEXTUAL" } },
"sequence": 2
}
],
"fee": {
"amount": [
{
"denom": "atom",
"amount": 0.002
}
],
"gas_limit": 100000
}
},
// Additional SignerData.
"chain_id": "simapp-1",
"account_number": 10
}
```

SIGN_MODE_TEXTUAL:

```
Chain ID: simapp-1
Account number: 10
*Public Key: iQ...== // Hex pubkey
Sequence: 2
This transaction has 1 message:
Message (1/1): bank v1beta1 send coins
From: cosmos1...abc
To: cosmos1...def
Amount: 10 atom // Conversion from uatom to atom using value renderers
End of transaction messages
Fee: 0.002 atom
*Gas: 100'000
*Hash of raw bytes: <hex_string>
```

#### Example 2: Multi-Msg Transaction with 3 signers

#### Example 3: Legacy Multisig

#### Example 4: Fee Payer with Tips

```json
{
"body": {
"messages": [
{
"@type": "/cosmos.bank.v1beta1.MsgSend",
"from": "cosmos1...tipper",
"to": "cosmos1...abc",
"amount": [
{
"denom": "uatom",
"amount": 10000000
}
]
}
]
},
"auth_info": {
"signer_infos": [
{
"public_key": "iQ...==",
"mode_info": { "single": { "mode": "SIGN_MODE_DIRECT_AUX" } },
"sequence": 42
},
{
"public_key": "iR...==",
"mode_info": { "single": { "mode": "SIGN_MODE_TEXTUAL" } },
"sequence": 2
}
],
"fee": {
"amount": [
{
"denom": "atom",
"amount": 0.002
}
],
"gas_limit": 100000,
"payer": "cosmos1...feepayer"
},
"tip": {
"amount": [
{
"denom": "ibc/CDC4587874B85BEA4FCEC3CEA5A1195139799A1FEE711A07D972537E18FDA39D",
"amount": 200
}
],
"tipper": "cosmos1...tipper"
}
},
// Additional SignerData.
"chain_id": "simapp-1",
"account_number": 10
}
```

SIGN_MODE_TEXTUAL for the feepayer:

```
Chain ID: simapp-1
Account number: 10
*Public Key: iR...==
Sequence: 2
This transaction has 1 message:
Message (1/1): bank v1beta1 send coins
From: cosmos1...abc
To: cosmos1...def
Amount: 10 atom
End of transaction messages
Fee: 0.002 atom
Fee Payer: cosmos1...feepayer
Tipper: cosmos1...tipper
Tip: 200 ibc/CDC4587874B85BEA4FCEC3CEA5A1195139799A1FEE711A07D972537E18FDA39D
*Gas: 100'000
*This transaction has 1 other signer:
*Signer (1/2):
*Public Key: iQ...==
*Sign mode: SIGN_MODE_DIRECT_AUX
*Sequence: 42
*End of other signers
*Hash of raw bytes: <hex_string>
```

#### Example 5: Complex Transaction with Nested Messages

JSON:

```json
{
"body": {
"messages": [
{
"@type": "/cosmos.bank.v1beta1.MsgSend",
"from": "cosmos1...abc",
"to": "cosmos1...def",
"amount": [
{
"denom": "uatom",
"amount": 10000000
}
]
},
{
"@type": "/cosmos.gov.v1.MsgSubmitProposal",
"proposer": "cosmos1...ghi",
"messages": [
{
"@type": "/cosmos.bank.v1beta1.MsgSend",
"from": "cosmos1...jkl",
"to": "cosmos1...mno",
"amount": [
{
"denom": "uatom",
"amount": 20000000
}
]
},
{
"@type": "/cosmos.authz.v1beta1.MsgExec",
"grantee": "cosmos1...pqr",
"msgs": [
{
"@type": "/cosmos.bank.v1beta1.MsgSend",
"from": "cosmos1...stu",
"to": "cosmos1...vwx",
"amount": [
{
"denom": "uatom",
"amount": 30000000
}
]
},
{
"@type": "/cosmos.bank.v1beta1.MsgSend",
"from": "cosmos1...abc",
"to": "cosmos1...def",
"amount": [
{
"denom": "uatom",
"amount": 40000000
}
]
}
]
}
],
"initial_deposit": [
{
"denom": "atom",
"amount": 100.01
}
]
}
]
},
"auth_info": {
"signer_infos": [
{
"public_key": "iQ...==",
"mode_info": { "single": { "mode": "SIGN_MODE_TEXTUAL" } },
"sequence": 2
},
{
"public_key": "iR...==",
"mode_info": { "single": { "mode": "SIGN_MODE_DIRECT" } },
"sequence": 42
}
],
"fee": {
"amount": [
{
"denom": "atom",
"amount": 0.002
}
],
"gas_limit": 100000
}
},
// Additional SignerData.
"chain_id": "simapp-1",
"account_number": 10
}
}
```

SIGN_MODE_TEXTUAL for 1st signer `cosmos1...abc`:
1. A minimal MsgSend: [see transaction](https://github.com/cosmos/cosmos-sdk/blob/094abcd393379acbbd043996024d66cd65246fb1/tx/textual/internal/testdata/e2e.json#L2-L70).
2. A transaction with a bit of everything: [see transaction](https://github.com/cosmos/cosmos-sdk/blob/094abcd393379acbbd043996024d66cd65246fb1/tx/textual/internal/testdata/e2e.json#L71-L270).

```
Chain ID: simapp-1
Account number: 10
*Public Key: iQ...==
Sequence: 2
This transaction has 2 messages:
Message (1/2): bank v1beta1 send coins
From: cosmos1...abc
To: cosmos1...def
Amount: 10 atom
Message (2/2): gov v1 submit proposal
Messages: 2 Messages
> Message (1/2): bank v1beta1 send coins
> From: cosmos1...jkl
> To: cosmos1...mno
> Amount: 20 atom
> Message (2/2): authz v1beta exec
> Grantee: cosmos1...pqr
> Msgs: 2 Msgs
>> Msg (1/2): bank v1beta1 send coins
>> From: cosmos1...stu
>> To: cosmos1...vwx
>> Amount: 30 atom
>> Msg (2/2): bank v1beta1 send coins
>> From: cosmos1...abc
>> To: cosmos1...def
>> Amount: 40 atom
> End of Msgs
End of transaction messages
Proposer: cosmos1...ghi
Initial Deposit: 100.01 atom
End of transaction messages
Fee: 0.002 atom
*Gas: 100'000
*This transaction has 1 other signer:
*Signer (2/2):
*Public Key: iR...==
*Sign mode: SIGN_MODE_DIRECT
*Sequence: 42
*End of other signers
*Hash of raw bytes: <hex_string>
```
The examples below are stored in a JSON file with the following fields:
- `proto`: the representation of the transaction in ProtoJSON,
- `screens`: the transaction rendered into SIGN_MODE_TEXTUAL screens,
- `cbor`: the sign bytes of the transaction, which is the CBOR encoding of the screens.

## Consequences

Expand Down
Loading