Skip to content

Commit f51f2af

Browse files
authored
Merge branch 'main' into fedekunze/update-posthandlers
2 parents 5332380 + f590f29 commit f51f2af

40 files changed

+7122
-1920
lines changed

docs/architecture/adr-050-sign-mode-textual.md

+29-317
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* Sep 07, 2022: Add custom `Msg`-renderers.
1010
* Sep 18, 2022: Structured format instead of lines of text
1111
* Nov 23, 2022: Specify CBOR encoding.
12+
* Dec 01, 2022: Link to examples in separate JSON file.
13+
* Dec 06, 2022: Re-ordering of envelope screens.
1214
* Dec 14, 2022: Mention exceptions for invertability.
1315

1416
## Status
@@ -176,29 +178,30 @@ We define "transaction envelope" as all data in a transaction that is not in the
176178
```
177179
Chain ID: <string>
178180
Account number: <uint64>
179-
*Public Key: <hex_string>
180181
Sequence: <uint64>
181-
<TxBody> // See #8.
182-
Fee: <coins> // See value renderers for coins encoding.
183-
*Fee payer: <string> // Skipped if no fee_payer set
184-
*Fee granter: <string> // Skipped if no fee_granter set
185-
Memo: <string> // Skipped if no memo set
182+
Address: <string>
183+
*Public Key: <Any>
184+
This transaction has <int> Message(s) // Pluralize "Message" only when int>1
185+
> Message (<int>/<int>): <Any> // See value renderers for Any rendering.
186+
End of Message
187+
Memo: <string> // Skipped if no memo set.
188+
Fee: <coins> // See value renderers for coins rendering.
189+
*Fee payer: <string> // Skipped if no fee_payer set.
190+
*Fee granter: <string> // Skipped if no fee_granter set.
191+
Tip: <coins> // Skippted if no tip.
192+
Tipper: <string>
186193
*Gas Limit: <uint64>
187-
*Timeout Height: <uint64> // Skipped if no timeout_height set
188-
Tipper: <string> // If there's a tip
189-
Tip: <string>
190-
*This transaction has <int> body extension: // Skipped if no body extension options
191-
*<repeated Any>
192-
*This transaction has <int> body non-critical extensions: // Skipped if no body non-critical extension options
193-
*<repeated Any> // See value renderers for Any and array encoding.
194-
*This transaction has <int> body auth info extensions: // Skipped if no auth info extension options
195-
*<repeated Any>
196-
*This transaction has <int> other signers: // Skipped if there is only one signer
197-
*Signer (<int>/<int>):
198-
*Public Key: <hex_string>
199-
*Sequence: <uint64>
194+
*Timeout Height: <uint64> // Skipped if no timeout_height set.
195+
*Other signer: <int> SignerInfo // Skipped if the transaction only has 1 signer.
196+
*> Other signer (<int>/<int>): <SignerInfo>
200197
*End of other signers
201-
*Hash of raw bytes: <hex_string> // Hex encoding of bytes defined in #10, to prevent tx hash malleability.
198+
*Extension options: <int> Any: // Skipped if no body extension options
199+
*> Extension options (<int>/<int>): <Any>
200+
*End of extension options
201+
*Non critical extension options: <int> Any: // Skipped if no body non critical extension options
202+
*> Non critical extension options (<int>/<int>): <Any>
203+
*End of Non critical extension options
204+
*Hash of raw bytes: <hex_string> // Hex encoding of bytes defined, to prevent tx hash malleability.
202205
```
203206

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

290293
## Examples
291294

292-
#### Example 1: Simple `MsgSend`
293-
294-
JSON:
295-
296-
```json
297-
{
298-
"body": {
299-
"messages": [
300-
{
301-
"@type": "/cosmos.bank.v1beta1.MsgSend",
302-
"from": "cosmos1...abc",
303-
"to": "cosmos1...def",
304-
"amount": [
305-
{
306-
"denom": "uatom",
307-
"amount": 10000000
308-
}
309-
]
310-
}
311-
]
312-
},
313-
"auth_info": {
314-
"signer_infos": [
315-
{
316-
"public_key": "iQ...==",
317-
"mode_info": { "single": { "mode": "SIGN_MODE_TEXTUAL" } },
318-
"sequence": 2
319-
}
320-
],
321-
"fee": {
322-
"amount": [
323-
{
324-
"denom": "atom",
325-
"amount": 0.002
326-
}
327-
],
328-
"gas_limit": 100000
329-
}
330-
},
331-
// Additional SignerData.
332-
"chain_id": "simapp-1",
333-
"account_number": 10
334-
}
335-
```
336-
337-
SIGN_MODE_TEXTUAL:
338-
339-
```
340-
Chain ID: simapp-1
341-
Account number: 10
342-
*Public Key: iQ...== // Hex pubkey
343-
Sequence: 2
344-
This transaction has 1 message:
345-
Message (1/1): bank v1beta1 send coins
346-
From: cosmos1...abc
347-
To: cosmos1...def
348-
Amount: 10 atom // Conversion from uatom to atom using value renderers
349-
End of transaction messages
350-
Fee: 0.002 atom
351-
*Gas: 100'000
352-
*Hash of raw bytes: <hex_string>
353-
```
354-
355-
#### Example 2: Multi-Msg Transaction with 3 signers
356-
357-
#### Example 3: Legacy Multisig
358-
359-
#### Example 4: Fee Payer with Tips
360-
361-
```json
362-
{
363-
"body": {
364-
"messages": [
365-
{
366-
"@type": "/cosmos.bank.v1beta1.MsgSend",
367-
"from": "cosmos1...tipper",
368-
"to": "cosmos1...abc",
369-
"amount": [
370-
{
371-
"denom": "uatom",
372-
"amount": 10000000
373-
}
374-
]
375-
}
376-
]
377-
},
378-
"auth_info": {
379-
"signer_infos": [
380-
{
381-
"public_key": "iQ...==",
382-
"mode_info": { "single": { "mode": "SIGN_MODE_DIRECT_AUX" } },
383-
"sequence": 42
384-
},
385-
{
386-
"public_key": "iR...==",
387-
"mode_info": { "single": { "mode": "SIGN_MODE_TEXTUAL" } },
388-
"sequence": 2
389-
}
390-
],
391-
"fee": {
392-
"amount": [
393-
{
394-
"denom": "atom",
395-
"amount": 0.002
396-
}
397-
],
398-
"gas_limit": 100000,
399-
"payer": "cosmos1...feepayer"
400-
},
401-
"tip": {
402-
"amount": [
403-
{
404-
"denom": "ibc/CDC4587874B85BEA4FCEC3CEA5A1195139799A1FEE711A07D972537E18FDA39D",
405-
"amount": 200
406-
}
407-
],
408-
"tipper": "cosmos1...tipper"
409-
}
410-
},
411-
// Additional SignerData.
412-
"chain_id": "simapp-1",
413-
"account_number": 10
414-
}
415-
```
416-
417-
SIGN_MODE_TEXTUAL for the feepayer:
418-
419-
```
420-
Chain ID: simapp-1
421-
Account number: 10
422-
*Public Key: iR...==
423-
Sequence: 2
424-
This transaction has 1 message:
425-
Message (1/1): bank v1beta1 send coins
426-
From: cosmos1...abc
427-
To: cosmos1...def
428-
Amount: 10 atom
429-
End of transaction messages
430-
Fee: 0.002 atom
431-
Fee Payer: cosmos1...feepayer
432-
Tipper: cosmos1...tipper
433-
Tip: 200 ibc/CDC4587874B85BEA4FCEC3CEA5A1195139799A1FEE711A07D972537E18FDA39D
434-
*Gas: 100'000
435-
*This transaction has 1 other signer:
436-
*Signer (1/2):
437-
*Public Key: iQ...==
438-
*Sign mode: SIGN_MODE_DIRECT_AUX
439-
*Sequence: 42
440-
*End of other signers
441-
*Hash of raw bytes: <hex_string>
442-
```
443-
444-
#### Example 5: Complex Transaction with Nested Messages
445-
446-
JSON:
447-
448-
```json
449-
{
450-
"body": {
451-
"messages": [
452-
{
453-
"@type": "/cosmos.bank.v1beta1.MsgSend",
454-
"from": "cosmos1...abc",
455-
"to": "cosmos1...def",
456-
"amount": [
457-
{
458-
"denom": "uatom",
459-
"amount": 10000000
460-
}
461-
]
462-
},
463-
{
464-
"@type": "/cosmos.gov.v1.MsgSubmitProposal",
465-
"proposer": "cosmos1...ghi",
466-
"messages": [
467-
{
468-
"@type": "/cosmos.bank.v1beta1.MsgSend",
469-
"from": "cosmos1...jkl",
470-
"to": "cosmos1...mno",
471-
"amount": [
472-
{
473-
"denom": "uatom",
474-
"amount": 20000000
475-
}
476-
]
477-
},
478-
{
479-
"@type": "/cosmos.authz.v1beta1.MsgExec",
480-
"grantee": "cosmos1...pqr",
481-
"msgs": [
482-
{
483-
"@type": "/cosmos.bank.v1beta1.MsgSend",
484-
"from": "cosmos1...stu",
485-
"to": "cosmos1...vwx",
486-
"amount": [
487-
{
488-
"denom": "uatom",
489-
"amount": 30000000
490-
}
491-
]
492-
},
493-
{
494-
"@type": "/cosmos.bank.v1beta1.MsgSend",
495-
"from": "cosmos1...abc",
496-
"to": "cosmos1...def",
497-
"amount": [
498-
{
499-
"denom": "uatom",
500-
"amount": 40000000
501-
}
502-
]
503-
}
504-
]
505-
}
506-
],
507-
"initial_deposit": [
508-
{
509-
"denom": "atom",
510-
"amount": 100.01
511-
}
512-
]
513-
}
514-
]
515-
},
516-
"auth_info": {
517-
"signer_infos": [
518-
{
519-
"public_key": "iQ...==",
520-
"mode_info": { "single": { "mode": "SIGN_MODE_TEXTUAL" } },
521-
"sequence": 2
522-
},
523-
{
524-
"public_key": "iR...==",
525-
"mode_info": { "single": { "mode": "SIGN_MODE_DIRECT" } },
526-
"sequence": 42
527-
}
528-
],
529-
"fee": {
530-
"amount": [
531-
{
532-
"denom": "atom",
533-
"amount": 0.002
534-
}
535-
],
536-
"gas_limit": 100000
537-
}
538-
},
539-
// Additional SignerData.
540-
"chain_id": "simapp-1",
541-
"account_number": 10
542-
}
543-
}
544-
```
545-
546-
SIGN_MODE_TEXTUAL for 1st signer `cosmos1...abc`:
295+
1. A minimal MsgSend: [see transaction](https://github.com/cosmos/cosmos-sdk/blob/094abcd393379acbbd043996024d66cd65246fb1/tx/textual/internal/testdata/e2e.json#L2-L70).
296+
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).
547297

548-
```
549-
Chain ID: simapp-1
550-
Account number: 10
551-
*Public Key: iQ...==
552-
Sequence: 2
553-
This transaction has 2 messages:
554-
Message (1/2): bank v1beta1 send coins
555-
From: cosmos1...abc
556-
To: cosmos1...def
557-
Amount: 10 atom
558-
Message (2/2): gov v1 submit proposal
559-
Messages: 2 Messages
560-
> Message (1/2): bank v1beta1 send coins
561-
> From: cosmos1...jkl
562-
> To: cosmos1...mno
563-
> Amount: 20 atom
564-
> Message (2/2): authz v1beta exec
565-
> Grantee: cosmos1...pqr
566-
> Msgs: 2 Msgs
567-
>> Msg (1/2): bank v1beta1 send coins
568-
>> From: cosmos1...stu
569-
>> To: cosmos1...vwx
570-
>> Amount: 30 atom
571-
>> Msg (2/2): bank v1beta1 send coins
572-
>> From: cosmos1...abc
573-
>> To: cosmos1...def
574-
>> Amount: 40 atom
575-
> End of Msgs
576-
End of transaction messages
577-
Proposer: cosmos1...ghi
578-
Initial Deposit: 100.01 atom
579-
End of transaction messages
580-
Fee: 0.002 atom
581-
*Gas: 100'000
582-
*This transaction has 1 other signer:
583-
*Signer (2/2):
584-
*Public Key: iR...==
585-
*Sign mode: SIGN_MODE_DIRECT
586-
*Sequence: 42
587-
*End of other signers
588-
*Hash of raw bytes: <hex_string>
589-
```
298+
The examples below are stored in a JSON file with the following fields:
299+
- `proto`: the representation of the transaction in ProtoJSON,
300+
- `screens`: the transaction rendered into SIGN_MODE_TEXTUAL screens,
301+
- `cbor`: the sign bytes of the transaction, which is the CBOR encoding of the screens.
590302

591303
## Consequences
592304

0 commit comments

Comments
 (0)