terra_rust_api/client/
fcd.rs

1use crate::errors::TerraRustAPIError;
2use crate::Terra;
3use rust_decimal::Decimal;
4use std::collections::HashMap;
5
6pub struct FCD<'a> {
7    terra: &'a Terra,
8    fcd_url: &'a str,
9}
10impl FCD<'_> {
11    pub fn create<'a>(terra: &'a Terra, fcd_url: &'a str) -> FCD<'a> {
12        FCD { terra, fcd_url }
13    }
14    pub async fn gas_prices(&self) -> Result<HashMap<String, Decimal>, TerraRustAPIError> {
15        Ok(self
16            .terra
17            .send_cmd_url::<HashMap<String, Decimal>>(self.fcd_url, "/v1/txs/gas_prices", None)
18            .await?)
19    }
20    pub async fn fetch_gas_prices(
21        client: &reqwest::Client,
22        fcd_url: &str,
23    ) -> Result<HashMap<String, Decimal>, TerraRustAPIError> {
24        Ok(Terra::fetch_url::<HashMap<String, Decimal>>(
25            client,
26            fcd_url,
27            "/v1/txs/gas_prices",
28            None,
29        )
30        .await?)
31    }
32}