From 9ec581da973fda5f45a0c9861356a05585405217 Mon Sep 17 00:00:00 2001 From: Maikol <86025070+Maikol@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:16:05 -0300 Subject: [PATCH] fix: ebo supported networks query (#25) * fix: ebo supported networks query * fix: lint --- .../src/epoch_block_oracle_subgraph.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/availability-oracle/src/epoch_block_oracle_subgraph.rs b/availability-oracle/src/epoch_block_oracle_subgraph.rs index 40c41f7..1cea45e 100644 --- a/availability-oracle/src/epoch_block_oracle_subgraph.rs +++ b/availability-oracle/src/epoch_block_oracle_subgraph.rs @@ -41,11 +41,13 @@ struct GraphqlResponse { const SUPPORTED_NETWORKS_QUERY: &str = r#" query Networks($skip: Int!) { - networks(first: 1000, skip: $skip) { - id - alias + globalState(id: "0") { + networks(first: 1000, skip: $skip) { + id + alias + } } - } +} "#; impl EpochBlockOracleSubgraph for EpochBlockOracleSubgraphImpl { @@ -81,8 +83,11 @@ impl EpochBlockOracleSubgraph for EpochBlockOracleSubgraphImpl { let data = res .data .ok_or_else(|| anyhow!("Data field is missing in the response"))? - .remove("networks") - .ok_or_else(|| anyhow!("'networks' field is missing in the data"))?; + .remove("globalState") + .and_then(|global_state| global_state.get("networks").cloned()) + .ok_or_else(|| { + anyhow!("'networks' field is missing in the globalState data") + })?; #[derive(Deserialize)] #[allow(non_snake_case)]