Skip to content

Commit 411fdb8

Browse files
authored
refactor: move tap from common to service (#495)
1 parent 4a1c74e commit 411fdb8

22 files changed

+87
-73
lines changed

Cargo.lock

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/common/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ graphql_client.workspace = true
2727
serde = { workspace = true, features = ["derive"] }
2828
serde_json = { workspace = true }
2929
tokio = { workspace = true, features = ["fs", "tokio-macros"] }
30-
cost-model = { git = "https://github.com/graphprotocol/agora", rev = "3ed34ca" }
3130
regex = "1.7.1"
32-
tokio-util = "0.7.10"
3331
bip39 = "2.0.0"
3432

3533
[dev-dependencies]

crates/common/src/escrow_accounts.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ async fn get_escrow_accounts(
165165
#[cfg(test)]
166166
mod tests {
167167
use test_log::test;
168+
use test_tap_utils::{
169+
ESCROW_ACCOUNTS_BALANCES, ESCROW_ACCOUNTS_SENDERS_TO_SIGNERS,
170+
ESCROW_ACCOUNTS_SIGNERS_TO_SENDERS,
171+
};
168172
use wiremock::matchers::{method, path};
169173
use wiremock::{Mock, MockServer, ResponseTemplate};
170174

@@ -176,13 +180,13 @@ mod tests {
176180
#[test]
177181
fn test_new_escrow_accounts() {
178182
let escrow_accounts = EscrowAccounts::new(
179-
test_vectors::ESCROW_ACCOUNTS_BALANCES.to_owned(),
180-
test_vectors::ESCROW_ACCOUNTS_SENDERS_TO_SIGNERS.to_owned(),
183+
ESCROW_ACCOUNTS_BALANCES.to_owned(),
184+
ESCROW_ACCOUNTS_SENDERS_TO_SIGNERS.to_owned(),
181185
);
182186

183187
assert_eq!(
184188
escrow_accounts.signers_to_senders,
185-
test_vectors::ESCROW_ACCOUNTS_SIGNERS_TO_SENDERS.to_owned()
189+
ESCROW_ACCOUNTS_SIGNERS_TO_SENDERS.to_owned()
186190
)
187191
}
188192

@@ -227,8 +231,8 @@ mod tests {
227231
assert_eq!(
228232
accounts.borrow().clone(),
229233
EscrowAccounts::new(
230-
test_vectors::ESCROW_ACCOUNTS_BALANCES.to_owned(),
231-
test_vectors::ESCROW_ACCOUNTS_SENDERS_TO_SIGNERS.to_owned(),
234+
ESCROW_ACCOUNTS_BALANCES.to_owned(),
235+
ESCROW_ACCOUNTS_SENDERS_TO_SIGNERS.to_owned(),
232236
)
233237
);
234238
}

crates/common/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
pub mod address;
55
pub mod allocations;
66
pub mod attestations;
7-
pub mod cost_model;
87
pub mod escrow_accounts;
98
pub mod graphql;
109
pub mod subgraph_client;
11-
pub mod tap;
1210
pub mod watcher;
1311

1412
#[cfg(test)]
@@ -23,5 +21,4 @@ pub mod prelude {
2321
};
2422
pub use super::escrow_accounts::escrow_accounts;
2523
pub use super::subgraph_client::{DeploymentDetails, Query, QueryVariables, SubgraphClient};
26-
pub use super::tap::IndexerTapContext;
2724
}

crates/common/src/test_vectors.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -179,45 +179,4 @@ lazy_static! {
179179
},
180180
),
181181
]);
182-
183-
pub static ref ESCROW_ACCOUNTS_BALANCES: HashMap<Address, U256> = HashMap::from([
184-
(Address::from_str("0x9858EfFD232B4033E47d90003D41EC34EcaEda94").unwrap(), U256::from(24)), // TAP_SENDER
185-
(Address::from_str("0x22d491bde2303f2f43325b2108d26f1eaba1e32b").unwrap(), U256::from(42)),
186-
(Address::from_str("0x192c3B6e0184Fa0Cc5B9D2bDDEb6B79Fb216a002").unwrap(), U256::from(2975)),
187-
]);
188-
189-
/// Maps signers back to their senders
190-
pub static ref ESCROW_ACCOUNTS_SIGNERS_TO_SENDERS: HashMap<Address, Address> = HashMap::from([
191-
(
192-
Address::from_str("0x533661F0fb14d2E8B26223C86a610Dd7D2260892").unwrap(), // TAP_SIGNER
193-
Address::from_str("0x9858EfFD232B4033E47d90003D41EC34EcaEda94").unwrap(), // TAP_SENDER
194-
),
195-
(
196-
Address::from_str("0x2740f6fA9188cF53ffB6729DDD21575721dE92ce").unwrap(),
197-
Address::from_str("0x9858EfFD232B4033E47d90003D41EC34EcaEda94").unwrap(), // TAP_SENDER
198-
),
199-
(
200-
Address::from_str("0x245059163ff6ee14279aa7b35ea8f0fdb967df6e").unwrap(),
201-
Address::from_str("0x22d491bde2303f2f43325b2108d26f1eaba1e32b").unwrap(),
202-
),
203-
]);
204-
205-
pub static ref ESCROW_ACCOUNTS_SENDERS_TO_SIGNERS: HashMap<Address, Vec<Address>> = HashMap::from([
206-
(
207-
Address::from_str("0x9858EfFD232B4033E47d90003D41EC34EcaEda94").unwrap(), // TAP_SENDER
208-
vec![
209-
Address::from_str("0x533661F0fb14d2E8B26223C86a610Dd7D2260892").unwrap(), // TAP_SIGNER
210-
Address::from_str("0x2740f6fA9188cF53ffB6729DDD21575721dE92ce").unwrap(),
211-
],
212-
),
213-
(
214-
Address::from_str("0x22d491bde2303f2f43325b2108d26f1eaba1e32b").unwrap(),
215-
vec![Address::from_str("0x245059163ff6ee14279aa7b35ea8f0fdb967df6e").unwrap()],
216-
),
217-
(
218-
Address::from_str("0x192c3B6e0184Fa0Cc5B9D2bDDEb6B79Fb216a002").unwrap(),
219-
vec![],
220-
),
221-
]);
222-
223182
}

crates/service/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ thiserror.workspace = true
2020
serde = { workspace = true }
2121
serde_json.workspace = true
2222
axum.workspace = true
23+
bigdecimal.workspace = true
2324
sqlx.workspace = true
2425
thegraph-core.workspace = true
2526
thegraph-graphql-http.workspace = true
@@ -28,6 +29,7 @@ tracing-subscriber = { workspace = true, features = ["fmt"] }
2829
clap = { workspace = true, features = ["derive"] }
2930
build-info.workspace = true
3031
lazy_static.workspace = true
32+
async-trait.workspace = true
3133
async-graphql = { version = "7.0.11", default-features = false }
3234
async-graphql-axum = "7.0.11"
3335
base64.workspace = true
@@ -45,6 +47,8 @@ autometrics = { version = "1.0.1", features = ["prometheus-exporter"] }
4547
axum-extra = { version = "0.9.3", features = [
4648
"typed-header",
4749
], default-features = false }
50+
tokio-util = "0.7.10"
51+
cost-model = { git = "https://github.com/graphprotocol/agora", rev = "3ed34ca" }
4852

4953
[dev-dependencies]
5054
hex-literal = "0.4.1"
File renamed without changes.

crates/service/src/database/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
pub mod cost_model;
45
pub mod dips;
56

67
use std::time::Duration;

crates/service/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ mod database;
66
mod error;
77
mod routes;
88
pub mod service;
9+
mod tap;

crates/service/src/routes/cost.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
use std::str::FromStr;
55
use std::sync::Arc;
66

7+
use crate::database::cost_model::{self, CostModel};
78
use async_graphql::{Context, EmptyMutation, EmptySubscription, Object, Schema, SimpleObject};
89
use async_graphql_axum::{GraphQLRequest, GraphQLResponse};
910
use axum::extract::State;
10-
use indexer_common::cost_model::{self, CostModel};
1111
use lazy_static::lazy_static;
1212
use prometheus::{
1313
register_counter, register_counter_vec, register_histogram, register_histogram_vec, Counter,

0 commit comments

Comments
 (0)