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