1use crate::errors::TerraRustTestingError;
2use serde::{Deserialize, Serialize};
3use terra_rust_api::tendermint_types::EventAttribute;
4use terra_rust_api::Terra;
5
6pub mod errors;
7pub const VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION");
9pub const NAME: Option<&'static str> = option_env!("CARGO_PKG_NAME");
11
12pub async fn get_attribute_tx(
13 terra: &Terra,
14 hash: &str,
15 retries: usize,
16 sleep: tokio::time::Duration,
17 event_type: &str,
18 attribute_key: &str,
19) -> Result<String, TerraRustTestingError> {
20 let tx = terra.tx().get_and_wait_v1(hash, retries, sleep).await?;
21 let codes = tx
22 .tx_response
23 .get_attribute_from_logs(event_type, attribute_key);
24 if let Some(code) = codes.first() {
25 Ok(code.1.clone())
26 } else {
27 panic!("{}/{} not present in TX log", event_type, attribute_key)
28 }
29}
30#[derive(Deserialize, Serialize, Debug)]
31pub struct Event {
32 pub attributes: Vec<EventAttribute>,
33 #[serde(rename = "type")]
34 pub s_type: String,
35}