11// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
22// SPDX-License-Identifier: Apache-2.0
33
4- use std:: time:: Duration ;
5-
64use indexer_common:: prelude:: {
75 escrow_accounts, indexer_allocations, DeploymentDetails , SubgraphClient ,
86} ;
7+ use indexer_config:: {
8+ Config , EscrowSubgraphConfig , GraphNodeConfig , IndexerConfig , NetworkSubgraphConfig ,
9+ SubgraphConfig , SubgraphsConfig , TapConfig ,
10+ } ;
911use ractor:: concurrency:: JoinHandle ;
1012use ractor:: { Actor , ActorRef } ;
13+ use sender_account:: SenderAccountConfig ;
1114
1215use crate :: agent:: sender_accounts_manager:: {
1316 SenderAccountsManagerArgs , SenderAccountsManagerMessage ,
1417} ;
15- use crate :: config:: {
16- Config , EscrowSubgraph , Ethereum , IndexerInfrastructure , NetworkSubgraph , Tap ,
17- } ;
1818use crate :: { database, CONFIG , EIP_712_DOMAIN } ;
1919use sender_accounts_manager:: SenderAccountsManager ;
2020
@@ -25,95 +25,105 @@ pub mod unaggregated_receipts;
2525
2626pub async fn start_agent ( ) -> ( ActorRef < SenderAccountsManagerMessage > , JoinHandle < ( ) > ) {
2727 let Config {
28- ethereum : Ethereum { indexer_address } ,
29- indexer_infrastructure :
30- IndexerInfrastructure {
31- graph_node_query_endpoint,
32- graph_node_status_endpoint,
33- ..
34- } ,
35- postgres,
36- network_subgraph :
37- NetworkSubgraph {
38- network_subgraph_deployment,
39- network_subgraph_endpoint,
40- network_subgraph_auth_token,
41- allocation_syncing_interval_ms,
42- recently_closed_allocation_buffer_seconds,
28+ indexer : IndexerConfig {
29+ indexer_address, ..
30+ } ,
31+ graph_node :
32+ GraphNodeConfig {
33+ status_url : graph_node_status_endpoint,
34+ query_url : graph_node_query_endpoint,
4335 } ,
44- escrow_subgraph :
45- EscrowSubgraph {
46- escrow_subgraph_deployment,
47- escrow_subgraph_endpoint,
48- escrow_subgraph_auth_token,
49- escrow_syncing_interval_ms,
36+ database,
37+ subgraphs :
38+ SubgraphsConfig {
39+ network :
40+ NetworkSubgraphConfig {
41+ config :
42+ SubgraphConfig {
43+ query_url : network_query_url,
44+ query_auth_token : network_query_auth_token,
45+ deployment_id : network_deployment_id,
46+ syncing_interval_secs : network_sync_interval,
47+ } ,
48+ recently_closed_allocation_buffer_secs : recently_closed_allocation_buffer,
49+ } ,
50+ escrow :
51+ EscrowSubgraphConfig {
52+ config :
53+ SubgraphConfig {
54+ query_url : escrow_query_url,
55+ query_auth_token : escrow_query_auth_token,
56+ deployment_id : escrow_deployment_id,
57+ syncing_interval_secs : escrow_sync_interval,
58+ } ,
59+ } ,
5060 } ,
5161 tap :
52- Tap {
62+ TapConfig {
5363 // TODO: replace with a proper implementation once the gateway registry contract is ready
5464 sender_aggregator_endpoints,
5565 ..
5666 } ,
5767 ..
5868 } = & * CONFIG ;
59- let pgpool = database:: connect ( postgres ) . await ;
69+ let pgpool = database:: connect ( database . clone ( ) ) . await ;
6070
6171 let http_client = reqwest:: Client :: new ( ) ;
6272
6373 let network_subgraph = Box :: leak ( Box :: new ( SubgraphClient :: new (
6474 http_client. clone ( ) ,
65- network_subgraph_deployment
75+ network_deployment_id
6676 . map ( |deployment| {
67- DeploymentDetails :: for_graph_node (
68- graph_node_status_endpoint,
69- graph_node_query_endpoint,
77+ DeploymentDetails :: for_graph_node_url (
78+ graph_node_status_endpoint. clone ( ) ,
79+ graph_node_query_endpoint. clone ( ) ,
7080 deployment,
7181 )
7282 } )
7383 . transpose ( )
7484 . expect ( "Failed to parse graph node query endpoint and network subgraph deployment" ) ,
75- DeploymentDetails :: for_query_url_with_token (
76- network_subgraph_endpoint,
77- network_subgraph_auth_token. clone ( ) ,
78- )
79- . expect ( "Failed to parse network subgraph endpoint" ) ,
85+ DeploymentDetails :: for_query_url_with_token_url (
86+ network_query_url. clone ( ) ,
87+ network_query_auth_token. clone ( ) ,
88+ ) ,
8089 ) ) ) ;
8190
8291 let indexer_allocations = indexer_allocations (
8392 network_subgraph,
8493 * indexer_address,
85- Duration :: from_millis ( * allocation_syncing_interval_ms ) ,
86- Duration :: from_secs ( * recently_closed_allocation_buffer_seconds ) ,
94+ * network_sync_interval ,
95+ * recently_closed_allocation_buffer ,
8796 ) ;
8897
8998 let escrow_subgraph = Box :: leak ( Box :: new ( SubgraphClient :: new (
9099 http_client. clone ( ) ,
91- escrow_subgraph_deployment
100+ escrow_deployment_id
92101 . map ( |deployment| {
93- DeploymentDetails :: for_graph_node (
94- graph_node_status_endpoint,
95- graph_node_query_endpoint,
102+ DeploymentDetails :: for_graph_node_url (
103+ graph_node_status_endpoint. clone ( ) ,
104+ graph_node_query_endpoint. clone ( ) ,
96105 deployment,
97106 )
98107 } )
99108 . transpose ( )
100109 . expect ( "Failed to parse graph node query endpoint and escrow subgraph deployment" ) ,
101- DeploymentDetails :: for_query_url_with_token (
102- escrow_subgraph_endpoint,
103- escrow_subgraph_auth_token. clone ( ) ,
104- )
105- . expect ( "Failed to parse escrow subgraph endpoint" ) ,
110+ DeploymentDetails :: for_query_url_with_token_url (
111+ escrow_query_url. clone ( ) ,
112+ escrow_query_auth_token. clone ( ) ,
113+ ) ,
106114 ) ) ) ;
107115
108116 let escrow_accounts = escrow_accounts (
109117 escrow_subgraph,
110118 * indexer_address,
111- Duration :: from_millis ( * escrow_syncing_interval_ms ) ,
119+ * escrow_sync_interval ,
112120 false ,
113121 ) ;
114122
123+ let config = Box :: leak ( Box :: new ( SenderAccountConfig :: from_config ( & CONFIG ) ) ) ;
124+
115125 let args = SenderAccountsManagerArgs {
116- config : & CONFIG ,
126+ config,
117127 domain_separator : EIP_712_DOMAIN . clone ( ) ,
118128 pgpool,
119129 indexer_allocations,
0 commit comments