2424------
2525"""
2626
27- from datetime import datetime
2827import logging
2928from typing import List , Optional
3029
3837 PayoutFilter ,
3938)
4039from human_protocol_sdk .utils import (
41- get_data_from_subgraph ,
40+ SubgraphOptions ,
41+ custom_gql_fetch ,
4242)
4343
4444from human_protocol_sdk .escrow .escrow_client import EscrowClientError
@@ -219,10 +219,12 @@ class EscrowUtils:
219219 @staticmethod
220220 def get_escrows (
221221 filter : EscrowFilter ,
222+ options : Optional [SubgraphOptions ] = None ,
222223 ) -> List [EscrowData ]:
223224 """Get an array of escrow addresses based on the specified filter parameters.
224225
225226 :param filter: Object containing all the necessary parameters to filter
227+ :param options: Optional config for subgraph requests
226228
227229 :return: List of escrows
228230
@@ -257,7 +259,7 @@ def get_escrows(
257259 else :
258260 statuses = [filter .status .name ]
259261
260- escrows_data = get_data_from_subgraph (
262+ escrows_data = custom_gql_fetch (
261263 network ,
262264 query = get_escrows_query (filter ),
263265 params = {
@@ -283,6 +285,7 @@ def get_escrows(
283285 "skip" : filter .skip ,
284286 "orderDirection" : filter .order_direction .value ,
285287 },
288+ options = options ,
286289 )
287290
288291 if (
@@ -334,11 +337,13 @@ def get_escrows(
334337 def get_escrow (
335338 chain_id : ChainId ,
336339 escrow_address : str ,
340+ options : Optional [SubgraphOptions ] = None ,
337341 ) -> Optional [EscrowData ]:
338342 """Returns the escrow for a given address.
339343
340344 :param chain_id: Network in which the escrow has been deployed
341345 :param escrow_address: Address of the escrow
346+ :param options: Optional config for subgraph requests
342347
343348 :return: Escrow data
344349
@@ -367,12 +372,13 @@ def get_escrow(
367372
368373 network = NETWORKS [ChainId (chain_id )]
369374
370- escrow_data = get_data_from_subgraph (
375+ escrow_data = custom_gql_fetch (
371376 network ,
372377 query = get_escrow_query (),
373378 params = {
374379 "escrowAddress" : escrow_address .lower (),
375380 },
381+ options = options ,
376382 )
377383
378384 if (
@@ -414,11 +420,15 @@ def get_escrow(
414420 )
415421
416422 @staticmethod
417- def get_status_events (filter : StatusEventFilter ) -> List [StatusEvent ]:
423+ def get_status_events (
424+ filter : StatusEventFilter ,
425+ options : Optional [SubgraphOptions ] = None ,
426+ ) -> List [StatusEvent ]:
418427 """
419428 Retrieve status events for specified networks and statuses within a date range.
420429
421430 :param filter: Object containing all the necessary parameters to filter status events.
431+ :param options: Optional config for subgraph requests
422432
423433 :return List[StatusEvent]: List of status events matching the query parameters.
424434
@@ -435,7 +445,7 @@ def get_status_events(filter: StatusEventFilter) -> List[StatusEvent]:
435445
436446 status_names = [status .name for status in filter .statuses ]
437447
438- data = get_data_from_subgraph (
448+ data = custom_gql_fetch (
439449 network ,
440450 get_status_query (filter .date_from , filter .date_to , filter .launcher ),
441451 {
@@ -447,6 +457,7 @@ def get_status_events(filter: StatusEventFilter) -> List[StatusEvent]:
447457 "skip" : filter .skip ,
448458 "orderDirection" : filter .order_direction .value ,
449459 },
460+ options = options ,
450461 )
451462
452463 if (
@@ -472,11 +483,15 @@ def get_status_events(filter: StatusEventFilter) -> List[StatusEvent]:
472483 return events_with_chain_id
473484
474485 @staticmethod
475- def get_payouts (filter : PayoutFilter ) -> List [Payout ]:
486+ def get_payouts (
487+ filter : PayoutFilter ,
488+ options : Optional [SubgraphOptions ] = None ,
489+ ) -> List [Payout ]:
476490 """
477491 Fetch payouts from the subgraph based on the provided filter.
478492
479493 :param filter: Object containing all the necessary parameters to filter payouts.
494+ :param options: Optional config for subgraph requests
480495
481496 :return List[Payout]: List of payouts matching the query parameters.
482497
@@ -494,7 +509,7 @@ def get_payouts(filter: PayoutFilter) -> List[Payout]:
494509 if not network :
495510 raise EscrowClientError ("Unsupported Chain ID" )
496511
497- data = get_data_from_subgraph (
512+ data = custom_gql_fetch (
498513 network ,
499514 get_payouts_query (filter ),
500515 {
@@ -508,6 +523,7 @@ def get_payouts(filter: PayoutFilter) -> List[Payout]:
508523 "skip" : filter .skip ,
509524 "orderDirection" : filter .order_direction .value ,
510525 },
526+ options = options ,
511527 )
512528
513529 if (
@@ -536,11 +552,13 @@ def get_payouts(filter: PayoutFilter) -> List[Payout]:
536552 @staticmethod
537553 def get_cancellation_refunds (
538554 filter : CancellationRefundFilter ,
555+ options : Optional [SubgraphOptions ] = None ,
539556 ) -> List [CancellationRefund ]:
540557 """
541558 Fetch cancellation refunds from the subgraph based on the provided filter.
542559
543560 :param filter: Object containing all the necessary parameters to filter cancellation refunds.
561+ :param options: Optional config for subgraph requests
544562
545563 :return List[CancellationRefund]: List of cancellation refunds matching the query parameters.
546564
@@ -558,7 +576,7 @@ def get_cancellation_refunds(
558576 if not network :
559577 raise EscrowClientError ("Unsupported Chain ID" )
560578
561- data = get_data_from_subgraph (
579+ data = custom_gql_fetch (
562580 network ,
563581 get_cancellation_refunds_query (filter ),
564582 {
@@ -572,6 +590,7 @@ def get_cancellation_refunds(
572590 "skip" : filter .skip ,
573591 "orderDirection" : filter .order_direction .value ,
574592 },
593+ options = options ,
575594 )
576595
577596 if (
@@ -601,13 +620,16 @@ def get_cancellation_refunds(
601620
602621 @staticmethod
603622 def get_cancellation_refund (
604- chain_id : ChainId , escrow_address : str
623+ chain_id : ChainId ,
624+ escrow_address : str ,
625+ options : Optional [SubgraphOptions ] = None ,
605626 ) -> CancellationRefund :
606627 """
607628 Returns the cancellation refund for a given escrow address.
608629
609630 :param chain_id: Network in which the escrow has been deployed
610631 :param escrow_address: Address of the escrow
632+ :param options: Optional config for subgraph requests
611633
612634 :return: CancellationRefund data or None
613635
@@ -635,12 +657,13 @@ def get_cancellation_refund(
635657 if not network :
636658 raise EscrowClientError ("Unsupported Chain ID" )
637659
638- data = get_data_from_subgraph (
660+ data = custom_gql_fetch (
639661 network ,
640662 get_cancellation_refund_by_escrow_query (),
641663 {
642664 "escrowAddress" : escrow_address .lower (),
643665 },
666+ options = options ,
644667 )
645668
646669 if (
0 commit comments