Skip to content

Commit a9d7a71

Browse files
committed
refactor: update subgraph client results
Signed-off-by: Gustavo Inacio <[email protected]>
1 parent ef9f1ef commit a9d7a71

File tree

2 files changed

+24
-36
lines changed

2 files changed

+24
-36
lines changed

crates/monitor/src/client/subgraph_client.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,26 @@ impl DeploymentDetails {
2626
graph_node_base_url: &str,
2727
deployment: DeploymentId,
2828
) -> Result<Self, anyhow::Error> {
29-
Self::for_graph_node_url(
29+
Ok(Self::for_graph_node_url(
3030
Url::parse(graph_node_status_url)?,
3131
Url::parse(graph_node_base_url)?,
3232
deployment,
33-
)
33+
))
3434
}
3535

3636
pub fn for_graph_node_url(
3737
graph_node_status_url: Url,
3838
graph_node_base_url: Url,
3939
deployment: DeploymentId,
40-
) -> Result<Self, anyhow::Error> {
41-
Ok(Self {
40+
) -> Self {
41+
Self {
4242
deployment: Some(deployment),
4343
status_url: Some(graph_node_status_url),
44-
query_url: graph_node_base_url.join(&format!("subgraphs/id/{deployment}"))?,
44+
query_url: graph_node_base_url
45+
.join(&format!("subgraphs/id/{deployment}"))
46+
.expect("Must be correct"),
4547
query_auth_token: None,
46-
})
48+
}
4749
}
4850

4951
pub fn for_query_url(query_url: &str) -> Result<Self, anyhow::Error> {
@@ -55,14 +57,8 @@ impl DeploymentDetails {
5557
})
5658
}
5759

58-
pub fn for_query_url_with_token(
59-
query_url: &str,
60-
query_auth_token: Option<String>,
61-
) -> Result<Self, anyhow::Error> {
62-
Ok(Self::for_query_url_with_token_url(
63-
Url::parse(query_url)?,
64-
query_auth_token,
65-
))
60+
pub fn for_query_url_with_token(query_url: Url, query_auth_token: Option<String>) -> Self {
61+
Self::for_query_url_with_token_url(query_url, query_auth_token)
6662
}
6763

6864
pub fn for_query_url_with_token_url(query_url: Url, query_auth_token: Option<String>) -> Self {

crates/tap-agent/src/agent.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,13 @@ pub async fn start_agent() -> (ActorRef<SenderAccountsManagerMessage>, JoinHandl
7171
let network_subgraph = Box::leak(Box::new(
7272
SubgraphClient::new(
7373
http_client.clone(),
74-
network_deployment_id
75-
.map(|deployment| {
76-
DeploymentDetails::for_graph_node_url(
77-
graph_node_status_endpoint.clone(),
78-
graph_node_query_endpoint.clone(),
79-
deployment,
80-
)
81-
})
82-
.transpose()
83-
.expect(
84-
"Failed to parse graph node query endpoint and network subgraph deployment",
85-
),
74+
network_deployment_id.map(|deployment| {
75+
DeploymentDetails::for_graph_node_url(
76+
graph_node_status_endpoint.clone(),
77+
graph_node_query_endpoint.clone(),
78+
deployment,
79+
)
80+
}),
8681
DeploymentDetails::for_query_url_with_token_url(
8782
network_query_url.clone(),
8883
network_query_auth_token.clone(),
@@ -103,16 +98,13 @@ pub async fn start_agent() -> (ActorRef<SenderAccountsManagerMessage>, JoinHandl
10398
let escrow_subgraph = Box::leak(Box::new(
10499
SubgraphClient::new(
105100
http_client.clone(),
106-
escrow_deployment_id
107-
.map(|deployment| {
108-
DeploymentDetails::for_graph_node_url(
109-
graph_node_status_endpoint.clone(),
110-
graph_node_query_endpoint.clone(),
111-
deployment,
112-
)
113-
})
114-
.transpose()
115-
.expect("Failed to parse graph node query endpoint and escrow subgraph deployment"),
101+
escrow_deployment_id.map(|deployment| {
102+
DeploymentDetails::for_graph_node_url(
103+
graph_node_status_endpoint.clone(),
104+
graph_node_query_endpoint.clone(),
105+
deployment,
106+
)
107+
}),
116108
DeploymentDetails::for_query_url_with_token_url(
117109
escrow_query_url.clone(),
118110
escrow_query_auth_token.clone(),

0 commit comments

Comments
 (0)