You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `x/metaprotocol` module adds support for encoding and decoding additional fields attached to transactions.
9
+
10
+
`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.
11
+
12
+
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.
13
+
14
+
:::tip
15
+
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.
16
+
:::
17
+
18
+
Here is an example of a correctly formed `non_critical_extension_options` field:
19
+
20
+
```json
21
+
{
22
+
"@type": "/gaia.metaprotocols.ExtensionData", // must be this exact string
23
+
"protocol_id": "some-protocol",
24
+
"protocol_version": "1",
25
+
"data": "<base64 encoded bytes>"
26
+
}
27
+
```
28
+
29
+
Here is an example of a correctly populated `non_critical_extension_options` on a `bank.MsgSend` transaction:
ifetx, ok:=tx.(authTx.ExtensionOptionsTxBuilder); ok {
205
+
etx.SetNonCriticalExtensionOptions(extAny)
206
+
}
207
+
208
+
bz, err:=encodingConfig.TxConfig.TxEncoder()(tx)
209
+
s.Require().NoError(err)
210
+
s.Require().NotNil(bz)
211
+
212
+
// decode fails because the provided extension option does not implement the correct TxExtensionOptionI interface
213
+
txWithExt, err:=decodeTx(bz)
214
+
s.Require().Error(err)
215
+
s.Require().ErrorContains(err, "failed to decode tx: no concrete type registered for type URL /cosmos.bank.v1beta1.MsgMultiSend against interface *tx.TxExtensionOptionI")
0 commit comments