Update transactions section

This commit is contained in:
Aleksandr Bezobchuk 2020-03-06 10:54:29 -05:00
parent b064e1841c
commit 812ed54239
No known key found for this signature in database
GPG Key ID: 7DAC30FBD99879B0
1 changed files with 53 additions and 0 deletions

View File

@ -23,6 +23,59 @@ querying.
## Decision
### Transactions
Since the messages that an application is known and allowed to handle are specific
to the application itself, so must the transactions be specific to the application
itself. Similar to how we described in [ADR 019](./adr-019-protobuf-state-encoding.md),
the concrete types will be defined at the application level via Protobuf `oneof`.
The application will define a single canonical `Message` Protobuf message
with a single `oneof` that implements the SDK's `Msg` interface.
Example:
```protobuf
// app/codec/codec.proto
message Message {
option (cosmos_proto.interface_type) = "github.com/cosmos/cosmos-sdk/types.Msg";
oneof sum {
bank.MsgSend = 1;
staking.MsgCreateValidator = 2;
staking.MsgDelegate = 3;
// ...
}
}
```
Because an application needs to define it's unique `Message` Protobuf message, it
will by proxy have to define a `Transaction` Protobuf message that encapsulates this
`Message` type. The `Transaction` message type must implement the SDK's `Tx` interface.
Example:
```protobuf
// app/codec/codec.proto
message Transaction {
option (cosmos_proto.interface_type) = "github.com/cosmos/cosmos-sdk/types.Tx";
StdTxBase base = 1;
repeated Message msgs = 2;
}
```
Note, the `Transaction` type includes `StdTxBase` which will be defined by the SDK
and includes all the core field members that are common across all transaction types.
Developers do not have to include `StdTxBase` if they wish, so it is meant to be
used as an auxiliary type.
### Signing
### CLI, REST, & Querying
## Consequences
### Positive