diff --git a/src/dune.rs b/src/dune.rs index 985a2e7..1d9fab6 100644 --- a/src/dune.rs +++ b/src/dune.rs @@ -5,65 +5,43 @@ use crate::env::ENV_CONFIG; use format_url::FormatUrl; use anyhow::Result; -const DUNE_API: &str = "https://api.dune.com/api/v1/query/3686915/results"; +const DUNE_ETH_IN_CONTRACTS_QUERY_URL: &str = "https://api.dune.com/api/v1/query/3686915/results"; #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] pub struct DuneResponse { - #[serde(rename = "execution_id")] pub execution_id: String, - #[serde(rename = "query_id")] pub query_id: i64, - #[serde(rename = "is_execution_finished")] pub is_execution_finished: bool, pub state: String, - #[serde(rename = "submitted_at")] pub submitted_at: String, - #[serde(rename = "expires_at")] pub expires_at: String, - #[serde(rename = "execution_started_at")] pub execution_started_at: String, - #[serde(rename = "execution_ended_at")] pub execution_ended_at: String, pub result: DuneResult, } #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] pub struct DuneResult { pub rows: Vec, pub metadata: Metadata, } #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] pub struct EthInContractsRow { - #[serde(rename = "block_date")] pub block_date: String, - #[serde(rename = "cumulative_sum")] pub cumulative_sum: f64, } #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] pub struct Metadata { - #[serde(rename = "column_names")] pub column_names: Vec, - #[serde(rename = "column_types")] pub column_types: Vec, - #[serde(rename = "row_count")] pub row_count: i64, - #[serde(rename = "result_set_bytes")] pub result_set_bytes: i64, - #[serde(rename = "total_row_count")] pub total_row_count: i64, - #[serde(rename = "total_result_set_bytes")] pub total_result_set_bytes: i64, - #[serde(rename = "datapoint_count")] pub datapoint_count: i64, - #[serde(rename = "pending_time_millis")] pub pending_time_millis: i64, - #[serde(rename = "execution_time_millis")] pub execution_time_millis: i64, } @@ -73,7 +51,7 @@ pub async fn get_eth_in_contracts() -> Result> { .dune_api_key .as_ref() .expect("expect DUNE_API_KEY in env in order to fetch eth in smart contracts"); - let url = FormatUrl::new(DUNE_API) + let url = FormatUrl::new(DUNE_ETH_IN_CONTRACTS_QUERY_URL) .format_url(); let client = reqwest::Client::new();