Skip to content

Commit

Permalink
fix: update to latest subgraph client API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jannis committed Oct 25, 2023
1 parent 3f9cf0d commit c44d47e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
9 changes: 9 additions & 0 deletions common/src/indexer_service/http/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::net::SocketAddr;

use alloy_primitives::Address;
use serde::{Deserialize, Serialize};
use toolshed::thegraph::DeploymentId;

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct DatabaseConfig {
Expand All @@ -10,12 +11,14 @@ pub struct DatabaseConfig {

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct NetworkSubgraphConfig {
pub deployment: Option<DeploymentId>,
pub query_url: String,
pub syncing_interval: u64,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EscrowSubgraphConfig {
pub deployment: Option<DeploymentId>,
pub query_url: String,
pub syncing_interval: u64,
}
Expand All @@ -32,11 +35,17 @@ pub struct IndexerServiceConfig {
pub indexer: IndexerConfig,
pub server: ServerConfig,
pub database: DatabaseConfig,
pub graph_node: Option<GraphNodeConfig>,
pub network_subgraph: NetworkSubgraphConfig,
pub escrow_subgraph: EscrowSubgraphConfig,
pub graph_network: GraphNetworkConfig,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct GraphNodeConfig {
pub query_base_url: String,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct GraphNetworkConfig {
pub id: u64,
Expand Down
26 changes: 21 additions & 5 deletions common/src/indexer_service/http/indexer_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use toolshed::thegraph::DeploymentId;
use crate::{
prelude::{
attestation_signers, dispute_manager, escrow_accounts, indexer_allocations,
AttestationSigner, SubgraphClient,
AttestationSigner, DeploymentDetails, SubgraphClient,
},
tap_manager::TapManager,
};
Expand Down Expand Up @@ -141,8 +141,16 @@ impl IndexerService {
I: IndexerServiceImpl + Sync + Send + 'static,
{
let network_subgraph = Box::leak(Box::new(SubgraphClient::new(
"network-subgraph",
&options.config.network_subgraph.query_url,
options
.config
.graph_node
.as_ref()
.zip(options.config.network_subgraph.deployment)
.map(|(graph_node, deployment)| {
DeploymentDetails::for_graph_node(&graph_node.query_base_url, deployment)
})
.transpose()?,
DeploymentDetails::for_query_url(&options.config.network_subgraph.query_url)?,
)?));

// Identify the dispute manager for the configured network
Expand Down Expand Up @@ -170,8 +178,16 @@ impl IndexerService {
);

let escrow_subgraph = Box::leak(Box::new(SubgraphClient::new(
"escrow-subgraph",
&options.config.escrow_subgraph.query_url,
options
.config
.graph_node
.as_ref()
.zip(options.config.escrow_subgraph.deployment)
.map(|(graph_node, deployment)| {
DeploymentDetails::for_graph_node(&graph_node.query_base_url, deployment)
})
.transpose()?,
DeploymentDetails::for_query_url(&options.config.escrow_subgraph.query_url)?,
)?));

let escrow_accounts = escrow_accounts(
Expand Down

0 comments on commit c44d47e

Please sign in to comment.