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
use crate::errors::TerraRustAPIError;
use crate::Terra;
use rust_decimal::Decimal;
use std::collections::HashMap;

pub struct FCD<'a> {
    terra: &'a Terra,
    fcd_url: &'a str,
}
impl FCD<'_> {
    pub fn create<'a>(terra: &'a Terra, fcd_url: &'a str) -> FCD<'a> {
        FCD { terra, fcd_url }
    }
    pub async fn gas_prices(&self) -> Result<HashMap<String, Decimal>, TerraRustAPIError> {
        Ok(self
            .terra
            .send_cmd_url::<HashMap<String, Decimal>>(self.fcd_url, "/v1/txs/gas_prices", None)
            .await?)
    }
    pub async fn fetch_gas_prices(
        client: &reqwest::Client,
        fcd_url: &str,
    ) -> Result<HashMap<String, Decimal>, TerraRustAPIError> {
        Ok(Terra::fetch_url::<HashMap<String, Decimal>>(
            client,
            fcd_url,
            "/v1/txs/gas_prices",
            None,
        )
        .await?)
    }
}