-
Notifications
You must be signed in to change notification settings - Fork 717
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: support for metaprotocol types (#2960)
* experimental: add message types for metaprotocols * experimental: refine multiprotocols support * Update x/metaprotocols/types/keys.go Co-authored-by: Simon Noetzlin <[email protected]> * appease linter * add docs and rebuild protos * add docs, tests, readme * update docs * update e2e - enable all * appease linter * Update tests/e2e/e2e_bank_test.go Co-authored-by: Philip Offtermatt <[email protected]> * Update x/metaprotocols/README.md Co-authored-by: Simon Noetzlin <[email protected]> * docs: update changelog files --------- Co-authored-by: Simon Noetzlin <[email protected]> Co-authored-by: Philip Offtermatt <[email protected]>
- Loading branch information
1 parent
53f695a
commit 3ae75ed
Showing
16 changed files
with
912 additions
and
1 deletion.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
.changelog/unreleased/features/2960-add-metaprotocols-support.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add support for metaprotocols using Tx extension options ([\#2960](https://github.com/cosmos/gaia/pull/2960)) |
1 change: 1 addition & 0 deletions
1
.changelog/unreleased/state-breaking/2960-add-metaprotocols-support.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add support for metaprotocols using Tx extension options ([\#2960](https://github.com/cosmos/gaia/pull/2960)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
build | ||
.github | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
title: Metaprotocol Support | ||
order: false | ||
parent: | ||
order: 2 | ||
--- | ||
|
||
The `x/metaprotocol` module adds support for encoding and decoding additional fields attached to transactions. | ||
|
||
`extension_options` and `non_critical_extension_options` are optional fields that can be used to attach data to valid transactions. The fields are validated by the blockchain, but they are not used in any way. The fields pass validation if they are provided as empty lists (`[ ]`) or they use a list of `ExtensionData` types. | ||
|
||
The application does not use the attached data but it does ensure that the correct type is provided and that it can be successfully unmarshalled. The attached data will be part of a block. | ||
|
||
:::tip | ||
Txs where `extension_options` or `non_critical_extension_options` are populated with a type other than `/gaia.metaprotocols.ExtensionData` are considered invalid and will be rejected. | ||
::: | ||
|
||
Here is an example of a correctly formed `non_critical_extension_options` field: | ||
|
||
```json | ||
{ | ||
"@type": "/gaia.metaprotocols.ExtensionData", // must be this exact string | ||
"protocol_id": "some-protocol", | ||
"protocol_version": "1", | ||
"data": "<base64 encoded bytes>" | ||
} | ||
``` | ||
|
||
Here is an example of a correctly populated `non_critical_extension_options` on a `bank.MsgSend` transaction: | ||
|
||
```json | ||
{ | ||
"body": { | ||
"messages": [ | ||
{ | ||
"@type": "/cosmos.bank.v1beta1.MsgSend", | ||
"from_address": "cosmos1ehpqg9sj09037uhe56sqktk30asn47asthyr22", | ||
"to_address": "cosmos1ehpqg9sj09037uhe56sqktk30asn47asthyr22", | ||
"amount": [ | ||
{ | ||
"denom": "uatom", | ||
"amount": "100" | ||
} | ||
] | ||
} | ||
], | ||
"memo": "memo_smaller_than_512_bytes", | ||
"timeout_height": "0", | ||
"extension_options": [], | ||
"non_critical_extension_options": [ | ||
{ | ||
"@type": "/gaia.metaprotocols.ExtensionData", | ||
"protocol_id": "some-protocol", | ||
"protocol_version": "1", | ||
"data": "<base64 encoded bytes>" | ||
} | ||
] | ||
}, | ||
"auth_info": { | ||
"signer_infos": [], | ||
"fee": { | ||
"amount": [], | ||
"gas_limit": "200000", | ||
"payer": "", | ||
"granter": "" | ||
}, | ||
"tip": null | ||
}, | ||
"signatures": [] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"label": "Metaprotocol support", | ||
"position": 15, | ||
"link": { "type": "doc", "id": "metaprotocols/README" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
syntax = "proto3"; | ||
package gaia.metaprotocols; | ||
|
||
option go_package = "github.com/cosmos/gaia/x/metaprotocols/types"; | ||
|
||
// ExtensionData is a data structure that can be used in transaction extensions. | ||
message ExtensionData { | ||
// protocol_id is the identifier of the protocol | ||
// the field is not used internally but it is validated for correctness | ||
string protocol_id = 1; | ||
|
||
// protocol_version is the identifier of the protocol version | ||
// the field is not used internally but it is validated for correctness | ||
string protocol_version = 2; | ||
|
||
// arbitrary bytes data that can be used to store any data | ||
// the field is not used internally but it is validated and must be provided | ||
bytes data = 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.