Skip to content

Commit 7417451

Browse files
committed
refactor: create senders based on escrow account
Signed-off-by: Gustavo Inacio <[email protected]>
1 parent 32f30db commit 7417451

File tree

7 files changed

+226
-56
lines changed

7 files changed

+226
-56
lines changed

crates/monitor/src/escrow_accounts.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,33 @@ pub async fn escrow_accounts(
9595
reject_thawing_signers: bool,
9696
) -> Result<EscrowAccountsWatcher, anyhow::Error> {
9797
indexer_watcher::new_watcher(interval, move || {
98-
get_escrow_accounts(escrow_subgraph, indexer_address, reject_thawing_signers)
98+
get_escrow_accounts_v1(escrow_subgraph, indexer_address, reject_thawing_signers)
9999
})
100100
.await
101101
}
102102

103-
async fn get_escrow_accounts(
103+
pub async fn escrow_accounts_v2(
104+
escrow_subgraph: &'static SubgraphClient,
105+
indexer_address: Address,
106+
interval: Duration,
107+
reject_thawing_signers: bool,
108+
) -> Result<EscrowAccountsWatcher, anyhow::Error> {
109+
indexer_watcher::new_watcher(interval, move || {
110+
get_escrow_accounts_v2(escrow_subgraph, indexer_address, reject_thawing_signers)
111+
})
112+
.await
113+
}
114+
115+
// TODO implement escrow accounts v2 query
116+
async fn get_escrow_accounts_v2(
117+
_escrow_subgraph: &'static SubgraphClient,
118+
_indexer_address: Address,
119+
_reject_thawing_signers: bool,
120+
) -> anyhow::Result<EscrowAccounts> {
121+
Ok(EscrowAccounts::new(HashMap::new(), HashMap::new()))
122+
}
123+
124+
async fn get_escrow_accounts_v1(
104125
escrow_subgraph: &'static SubgraphClient,
105126
indexer_address: Address,
106127
reject_thawing_signers: bool,

crates/monitor/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub use crate::{
1515
deployment_to_allocation::{deployment_to_allocation, DeploymentToAllocationWatcher},
1616
dispute_manager::{dispute_manager, DisputeManagerWatcher},
1717
escrow_accounts::{
18-
escrow_accounts, EscrowAccounts, EscrowAccountsError, EscrowAccountsWatcher,
18+
escrow_accounts, escrow_accounts_v2, EscrowAccounts, EscrowAccountsError,
19+
EscrowAccountsWatcher,
1920
},
2021
};

crates/tap-agent/src/agent.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ use indexer_config::{
3939
Config, EscrowSubgraphConfig, GraphNodeConfig, IndexerConfig, NetworkSubgraphConfig,
4040
SubgraphConfig, SubgraphsConfig, TapConfig,
4141
};
42-
use indexer_monitor::{escrow_accounts, indexer_allocations, DeploymentDetails, SubgraphClient};
42+
use indexer_monitor::{
43+
escrow_accounts, escrow_accounts_v2, indexer_allocations, DeploymentDetails, SubgraphClient,
44+
};
4345
use ractor::{concurrency::JoinHandle, Actor, ActorRef};
4446
use sender_account::SenderAccountConfig;
4547
use sender_accounts_manager::SenderAccountsManager;
@@ -154,7 +156,16 @@ pub async fn start_agent() -> (ActorRef<SenderAccountsManagerMessage>, JoinHandl
154156
.await,
155157
));
156158

157-
let escrow_accounts = escrow_accounts(
159+
let escrow_accounts_v1 = escrow_accounts(
160+
escrow_subgraph,
161+
*indexer_address,
162+
*escrow_sync_interval,
163+
false,
164+
)
165+
.await
166+
.expect("Error creating escrow_accounts channel");
167+
168+
let escrow_accounts_v2 = escrow_accounts_v2(
158169
escrow_subgraph,
159170
*indexer_address,
160171
*escrow_sync_interval,
@@ -170,7 +181,8 @@ pub async fn start_agent() -> (ActorRef<SenderAccountsManagerMessage>, JoinHandl
170181
domain_separator: EIP_712_DOMAIN.clone(),
171182
pgpool,
172183
indexer_allocations,
173-
escrow_accounts,
184+
escrow_accounts_v1,
185+
escrow_accounts_v2,
174186
escrow_subgraph,
175187
network_subgraph,
176188
sender_aggregator_endpoints: sender_aggregator_endpoints.clone(),

0 commit comments

Comments
 (0)