Skip to content

Commit 81f6a2c

Browse files
committed
refactor: use network subgraph for v2 escrow accounts
Signed-off-by: Joseph Livesey <[email protected]>
1 parent a830b72 commit 81f6a2c

File tree

10 files changed

+630
-170
lines changed

10 files changed

+630
-170
lines changed

contrib/indexer-service/config.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ query_url = "http://graph-node:8000/subgraphs/name/semiotic/tap"
2020
deployment_id = "ESCROW_DEPLOYMENT_PLACEHOLDER"
2121
syncing_interval_secs = 30
2222

23-
[subgraphs.escrow_v2]
24-
query_url = "http://graph-node:8000/subgraphs/name/semiotic/tap-v2"
25-
deployment_id = "ESCROW_V2_DEPLOYMENT_PLACEHOLDER"
26-
syncing_interval_secs = 30
23+
# Note: V2 escrow accounts are in the network subgraph, not a separate TAP v2 subgraph
2724

2825
[blockchain]
2926
chain_id = 1337

contrib/tap-agent/config.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ query_url = "http://graph-node:8000/subgraphs/name/semiotic/tap"
2020
deployment_id = "ESCROW_DEPLOYMENT_PLACEHOLDER"
2121
syncing_interval_secs = 30
2222

23-
[subgraphs.escrow_v2]
24-
query_url = "http://graph-node:8000/subgraphs/name/semiotic/tap-v2"
25-
deployment_id = "ESCROW_V2_DEPLOYMENT_PLACEHOLDER"
26-
syncing_interval_secs = 30
23+
# Note: V2 escrow accounts are in the network subgraph, not a separate TAP v2 subgraph
2724

2825
[blockchain]
2926
chain_id = 1337

crates/config/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl MetricsConfig {
303303
pub struct SubgraphsConfig {
304304
pub network: NetworkSubgraphConfig,
305305
pub escrow: EscrowSubgraphConfig,
306-
pub escrow_v2: Option<EscrowSubgraphConfig>,
306+
// Note: V2 escrow accounts are in the network subgraph, not a separate escrow_v2 subgraph
307307
}
308308

309309
#[serde_as]

crates/monitor/src/escrow_accounts.rs

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ use std::{
99

1010
use anyhow::anyhow;
1111
use indexer_query::escrow_account::{self, EscrowAccountQuery};
12-
use indexer_query::escrow_account_v2::{
13-
self as escrow_account_v2, EscrowAccountQuery as EscrowAccountQueryV2,
14-
};
1512
use thegraph_core::alloy::primitives::{Address, U256};
1613
use thiserror::Error;
1714
use tokio::sync::watch::Receiver;
@@ -120,22 +117,16 @@ async fn get_escrow_accounts_v2(
120117
indexer_address: Address,
121118
reject_thawing_signers: bool,
122119
) -> 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
120+
// Query V2 escrow accounts from the network subgraph which tracks PaymentsEscrow
121+
// and GraphTallyCollector contract events.
122+
123+
use indexer_query::network_escrow_account_v2::{
124+
self as network_escrow_account_v2, NetworkEscrowAccountQueryV2,
125+
};
135126

136127
let response = escrow_subgraph
137-
.query::<EscrowAccountQueryV2, _>(escrow_account_v2::Variables {
138-
indexer: format!("{:x?}", indexer_address),
128+
.query::<NetworkEscrowAccountQueryV2, _>(network_escrow_account_v2::Variables {
129+
receiver: format!("{:x?}", indexer_address),
139130
thaw_end_timestamp: if reject_thawing_signers {
140131
U256::ZERO.to_string()
141132
} else {
@@ -146,7 +137,20 @@ async fn get_escrow_accounts_v2(
146137

147138
let response = response?;
148139

149-
tracing::trace!("V2 Escrow accounts response: {:?}", response);
140+
tracing::trace!("Network V2 Escrow accounts response: {:?}", response);
141+
142+
// V2 TAP receipts use different field names (payer/service_provider) but the underlying
143+
// escrow account model is identical to V1. Both V1 and V2 receipts reference the same
144+
// sender addresses and the same escrow relationships.
145+
//
146+
// V1 queries the TAP subgraph while V2 queries the network subgraph, but both return
147+
// the same escrow account structure for processing.
148+
//
149+
// V2 receipt flow:
150+
// 1. V2 receipt contains payer address (equivalent to V1 sender)
151+
// 2. Receipt is signed by a signer authorized by the payer
152+
// 3. Escrow accounts map: signer -> payer (sender) -> balance
153+
// 4. Service provider (indexer) receives payments from payer's escrow
150154

151155
let senders_balances: HashMap<Address, U256> = response
152156
.escrow_accounts

0 commit comments

Comments
 (0)