@@ -9,9 +9,6 @@ use std::{
99
1010use anyhow:: anyhow;
1111use indexer_query:: escrow_account:: { self , EscrowAccountQuery } ;
12- use indexer_query:: escrow_account_v2:: {
13- self as escrow_account_v2, EscrowAccountQuery as EscrowAccountQueryV2 ,
14- } ;
1512use thegraph_core:: alloy:: primitives:: { Address , U256 } ;
1613use thiserror:: Error ;
1714use tokio:: sync:: watch:: Receiver ;
@@ -91,6 +88,12 @@ impl EscrowAccounts {
9188
9289pub type EscrowAccountsWatcher = Receiver < EscrowAccounts > ;
9390
91+ pub fn empty_escrow_accounts_watcher ( ) -> EscrowAccountsWatcher {
92+ let ( _, receiver) =
93+ tokio:: sync:: watch:: channel ( EscrowAccounts :: new ( HashMap :: new ( ) , HashMap :: new ( ) ) ) ;
94+ receiver
95+ }
96+
9497pub async fn escrow_accounts_v1 (
9598 escrow_subgraph : & ' static SubgraphClient ,
9699 indexer_address : Address ,
@@ -120,22 +123,16 @@ async fn get_escrow_accounts_v2(
120123 indexer_address : Address ,
121124 reject_thawing_signers : bool ,
122125) -> anyhow:: Result < EscrowAccounts > {
123- // V2 TAP receipts use different field names (payer/service_provider) but the underlying
124- // escrow account model is identical to V1. Both V1 and V2 receipts reference the same
125- // sender addresses and the same escrow relationships.
126- //
127- // The separation of V1/V2 escrow account watchers allows for potential future differences
128- // in escrow models, but currently both query the same subgraph data with identical logic.
129- //
130- // V2 receipt flow:
131- // 1. V2 receipt contains payer address (equivalent to V1 sender)
132- // 2. Receipt is signed by a signer authorized by the payer
133- // 3. Escrow accounts map: signer -> payer (sender) -> balance
134- // 4. Service provider (indexer) receives payments from payer's escrow
126+ // Query V2 escrow accounts from the network subgraph which tracks PaymentsEscrow
127+ // and GraphTallyCollector contract events.
128+
129+ use indexer_query:: network_escrow_account_v2:: {
130+ self as network_escrow_account_v2, NetworkEscrowAccountQueryV2 ,
131+ } ;
135132
136133 let response = escrow_subgraph
137- . query :: < EscrowAccountQueryV2 , _ > ( escrow_account_v2 :: Variables {
138- indexer : format ! ( "{:x?}" , indexer_address) ,
134+ . query :: < NetworkEscrowAccountQueryV2 , _ > ( network_escrow_account_v2 :: Variables {
135+ receiver : format ! ( "{:x?}" , indexer_address) ,
139136 thaw_end_timestamp : if reject_thawing_signers {
140137 U256 :: ZERO . to_string ( )
141138 } else {
@@ -146,7 +143,20 @@ async fn get_escrow_accounts_v2(
146143
147144 let response = response?;
148145
149- tracing:: trace!( "V2 Escrow accounts response: {:?}" , response) ;
146+ tracing:: trace!( "Network V2 Escrow accounts response: {:?}" , response) ;
147+
148+ // V2 TAP receipts use different field names (payer/service_provider) but the underlying
149+ // escrow account model is identical to V1. Both V1 and V2 receipts reference the same
150+ // sender addresses and the same escrow relationships.
151+ //
152+ // V1 queries the TAP subgraph while V2 queries the network subgraph, but both return
153+ // the same escrow account structure for processing.
154+ //
155+ // V2 receipt flow:
156+ // 1. V2 receipt contains payer address (equivalent to V1 sender)
157+ // 2. Receipt is signed by a signer authorized by the payer
158+ // 3. Escrow accounts map: signer -> payer (sender) -> balance
159+ // 4. Service provider (indexer) receives payments from payer's escrow
150160
151161 let senders_balances: HashMap < Address , U256 > = response
152162 . escrow_accounts
0 commit comments