@@ -16,7 +16,7 @@ use axum::{
1616use indexer_common:: indexer_service:: http:: {
1717 AttestationOutput , IndexerServiceImpl , IndexerServiceResponse ,
1818} ;
19- use indexer_config:: Config ;
19+ use indexer_config:: { Config , DipsConfig } ;
2020use reqwest:: Url ;
2121use serde:: { de:: DeserializeOwned , Serialize } ;
2222use serde_json:: { json, Value } ;
@@ -180,37 +180,44 @@ pub async fn run() -> anyhow::Result<()> {
180180 let agreement_store: Arc < dyn AgreementStore > = Arc :: new ( InMemoryAgreementStore :: default ( ) ) ;
181181 let prices: Vec < Price > = vec ! [ ] ;
182182
183- let schema = Schema :: build (
184- routes:: dips:: AgreementQuery { } ,
185- routes:: dips:: AgreementMutation {
186- expected_payee : config. indexer . indexer_address ,
187- allowed_payers : config. dips . allowed_payers . clone ( ) ,
188- domain : eip712_domain (
189- // 42161, // arbitrum
190- config. blockchain . chain_id as u64 ,
191- config. blockchain . receipts_verifier_address ,
192- ) ,
193- cancel_voucher_time_tolerance : config
194- . dips
195- . cancellation_time_tolerance
196- . unwrap_or ( Duration :: from_secs ( 5 ) ) ,
197- } ,
198- EmptySubscription ,
199- )
200- . data ( agreement_store)
201- . data ( prices)
202- . finish ( ) ;
183+ let mut router = Router :: new ( )
184+ . route ( "/cost" , post ( routes:: cost:: cost) )
185+ . route ( "/status" , post ( routes:: status) )
186+ . with_state ( state. clone ( ) ) ;
187+
188+ if let Some ( DipsConfig {
189+ allowed_payers,
190+ cancellation_time_tolerance,
191+ } ) = config. dips . as_ref ( )
192+ {
193+ let schema = Schema :: build (
194+ routes:: dips:: AgreementQuery { } ,
195+ routes:: dips:: AgreementMutation {
196+ expected_payee : config. indexer . indexer_address ,
197+ allowed_payers : allowed_payers. clone ( ) ,
198+ domain : eip712_domain (
199+ // 42161, // arbitrum
200+ config. blockchain . chain_id as u64 ,
201+ config. blockchain . receipts_verifier_address ,
202+ ) ,
203+ cancel_voucher_time_tolerance : cancellation_time_tolerance
204+ . unwrap_or ( Duration :: from_secs ( 5 ) ) ,
205+ } ,
206+ EmptySubscription ,
207+ )
208+ . data ( agreement_store)
209+ . data ( prices)
210+ . finish ( ) ;
211+
212+ router = router. route ( "/dips" , post_service ( GraphQL :: new ( schema) ) ) ;
213+ }
203214
204215 IndexerService :: run ( IndexerServiceOptions {
205216 release,
206217 config,
207218 url_namespace : "subgraphs" ,
208- service_impl : SubgraphService :: new ( state. clone ( ) ) ,
209- extra_routes : Router :: new ( )
210- . route ( "/cost" , post ( routes:: cost:: cost) )
211- . route ( "/status" , post ( routes:: status) )
212- . route ( "/dips" , post_service ( GraphQL :: new ( schema) ) )
213- . with_state ( state) ,
219+ service_impl : SubgraphService :: new ( state) ,
220+ extra_routes : router,
214221 } )
215222 . await
216223}
0 commit comments