From 812ed54239fb4d21491c22faa1c2853a08189ea5 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Fri, 6 Mar 2020 10:54:29 -0500 Subject: [PATCH] Update transactions section --- .../adr-020-protobuf-client-encoding.md | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/docs/architecture/adr-020-protobuf-client-encoding.md b/docs/architecture/adr-020-protobuf-client-encoding.md index ab28ad4d58..9c928ef0ed 100644 --- a/docs/architecture/adr-020-protobuf-client-encoding.md +++ b/docs/architecture/adr-020-protobuf-client-encoding.md @@ -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