Parse what Tendermint returns in the `data` field of [`DeliverTx`] into bytes. Somewhere along the way it replaces them with the bytes of a Base64 encoded string, and `tendermint_rpc` does not undo that wrapping.
(data: &Bytes)
| 11 | /// Somewhere along the way it replaces them with the bytes of a Base64 encoded string, |
| 12 | /// and `tendermint_rpc` does not undo that wrapping. |
| 13 | pub fn decode_data(data: &Bytes) -> anyhow::Result<RawBytes> { |
| 14 | let b64 = String::from_utf8(data.to_vec()).context("error parsing data as base64 string")?; |
| 15 | let data = base64::engine::general_purpose::STANDARD |
| 16 | .decode(b64) |
| 17 | .context("error parsing base64 to bytes")?; |
| 18 | Ok(RawBytes::from(data)) |
| 19 | } |
| 20 | |
| 21 | /// Apply the encoding that Tendermint does to the bytes inside [`DeliverTx`]. |
| 22 | pub fn encode_data(data: &[u8]) -> Bytes { |
no test coverage detected