Skip to content

Commit 4a1c74e

Browse files
authored
refactor: move common service to proper crate (#493)
1 parent b0d2cd8 commit 4a1c74e

File tree

18 files changed

+156
-138
lines changed

18 files changed

+156
-138
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ members = [
66
"crates/query",
77
"crates/service",
88
"crates/tap-agent",
9+
"crates/tests/tap-utils",
910
]
1011
resolver = "2"
1112

crates/common/Cargo.toml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,11 @@ serde_json = { workspace = true }
2929
tokio = { workspace = true, features = ["fs", "tokio-macros"] }
3030
cost-model = { git = "https://github.com/graphprotocol/agora", rev = "3ed34ca" }
3131
regex = "1.7.1"
32-
axum-extra = { version = "0.9.3", features = [
33-
"typed-header",
34-
], default-features = false }
35-
autometrics = { version = "1.0.1", features = ["prometheus-exporter"] }
36-
tower_governor = "0.4.0"
37-
tower-http = { version = "0.5.2", features = [
38-
"cors",
39-
"normalize-path",
40-
"trace",
41-
] }
4232
tokio-util = "0.7.10"
4333
bip39 = "2.0.0"
4434

4535
[dev-dependencies]
4636
env_logger = { version = "0.11.0", default-features = false }
4737
test-log = { version = "0.2.12", default-features = false }
4838
wiremock = "0.5.19"
39+
test-tap-utils = { path = "../tests/tap-utils" }

crates/common/src/indexer_service/http/mod.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

crates/common/src/indexer_service/mod.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

crates/common/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ pub mod attestations;
77
pub mod cost_model;
88
pub mod escrow_accounts;
99
pub mod graphql;
10-
pub mod indexer_service;
1110
pub mod subgraph_client;
1211
pub mod tap;
1312
pub mod watcher;

crates/common/src/tap/checks/deny_list_check.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ mod tests {
202202
use tap_core::receipt::{Context, ReceiptWithState};
203203
use tokio::sync::watch;
204204

205-
use crate::test_vectors::{self, create_signed_receipt, TAP_SENDER};
205+
use crate::test_vectors;
206+
use test_tap_utils::{self, create_signed_receipt, TAP_EIP712_DOMAIN, TAP_SENDER};
206207

207208
use super::*;
208209

@@ -216,12 +217,7 @@ mod tests {
216217
))
217218
.1;
218219

219-
DenyListCheck::new(
220-
pgpool,
221-
escrow_accounts_rx,
222-
test_vectors::TAP_EIP712_DOMAIN.to_owned(),
223-
)
224-
.await
220+
DenyListCheck::new(pgpool, escrow_accounts_rx, TAP_EIP712_DOMAIN.to_owned()).await
225221
}
226222

227223
#[sqlx::test(migrations = "../../migrations")]

crates/common/src/tap/checks/value_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ enum CostModelNotification {
348348
mod tests {
349349
use alloy::primitives::{address, Address};
350350
use std::time::Duration;
351+
use test_tap_utils::create_signed_receipt;
351352

352353
use sqlx::PgPool;
353354
use tap_core::receipt::{checks::Check, Context, ReceiptWithState};
@@ -356,7 +357,6 @@ mod tests {
356357
use crate::{
357358
cost_model::test::{add_cost_models, global_cost_model, to_db_models},
358359
tap::AgoraQuery,
359-
test_vectors::create_signed_receipt,
360360
};
361361

362362
use super::MinimumValue;

crates/common/src/test_vectors.rs

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,9 @@
33

44
use std::{collections::HashMap, str::FromStr};
55

6-
use alloy::{
7-
dyn_abi::Eip712Domain,
8-
primitives::U256,
9-
signers::local::{coins_bip39::English, MnemonicBuilder, PrivateKeySigner},
10-
};
6+
use alloy::primitives::U256;
117
use bip39::Mnemonic;
128
use lazy_static::lazy_static;
13-
use tap_core::{
14-
receipt::{Receipt, SignedReceipt},
15-
signed_message::EIP712SignedMessage,
16-
tap_eip712_domain,
17-
};
189
use thegraph_core::{Address, DeploymentId};
1910

2011
use crate::prelude::{Allocation, AllocationStatus, SubgraphDeployment};
@@ -229,54 +220,4 @@ lazy_static! {
229220
),
230221
]);
231222

232-
/// Fixture to generate a wallet and address.
233-
/// Address: 0x9858EfFD232B4033E47d90003D41EC34EcaEda94
234-
pub static ref TAP_SENDER: (PrivateKeySigner, Address) = {
235-
let wallet: PrivateKeySigner = MnemonicBuilder::<English>::default()
236-
.phrase("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about")
237-
.build()
238-
.unwrap();
239-
let address = wallet.address();
240-
241-
(wallet, address)
242-
};
243-
244-
/// Fixture to generate a wallet and address.
245-
/// Address: 0x533661F0fb14d2E8B26223C86a610Dd7D2260892
246-
pub static ref TAP_SIGNER: (PrivateKeySigner, Address) = {
247-
let wallet: PrivateKeySigner = MnemonicBuilder::<English>::default()
248-
.phrase("rude pipe parade travel organ vendor card festival magnet novel forget refuse keep draft tool")
249-
.build()
250-
.unwrap();
251-
let address = wallet.address();
252-
253-
(wallet, address)
254-
};
255-
256-
pub static ref TAP_EIP712_DOMAIN: Eip712Domain = tap_eip712_domain(
257-
1,
258-
Address::from([0x11u8; 20])
259-
);
260-
}
261-
262-
/// Function to generate a signed receipt using the TAP_SIGNER wallet.
263-
pub async fn create_signed_receipt(
264-
allocation_id: Address,
265-
nonce: u64,
266-
timestamp_ns: u64,
267-
value: u128,
268-
) -> SignedReceipt {
269-
let (wallet, _) = &*self::TAP_SIGNER;
270-
271-
EIP712SignedMessage::new(
272-
&self::TAP_EIP712_DOMAIN,
273-
Receipt {
274-
allocation_id,
275-
nonce,
276-
timestamp_ns,
277-
value,
278-
},
279-
wallet,
280-
)
281-
.unwrap()
282223
}

crates/service/Cargo.toml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ license = "Apache-2.0"
1010
indexer-common = { path = "../common" }
1111
indexer-config = { path = "../config" }
1212
indexer-dips = { path = "../dips" }
13+
indexer-query = { path = "../query" }
1314
anyhow = { workspace = true }
1415
prometheus = { workspace = true }
1516
reqwest = { workspace = true }
@@ -22,6 +23,7 @@ axum.workspace = true
2223
sqlx.workspace = true
2324
thegraph-core.workspace = true
2425
thegraph-graphql-http.workspace = true
26+
graphql_client.workspace = true
2527
tracing-subscriber = { workspace = true, features = ["fmt"] }
2628
clap = { workspace = true, features = ["derive"] }
2729
build-info.workspace = true
@@ -30,11 +32,23 @@ async-graphql = { version = "7.0.11", default-features = false }
3032
async-graphql-axum = "7.0.11"
3133
base64.workspace = true
3234
graphql = { git = "https://github.com/edgeandnode/toolshed", tag = "graphql-v0.3.0" }
35+
tap_core.workspace = true
3336
uuid.workspace = true
3437
alloy.workspace = true
35-
38+
tower_governor = "0.4.0"
39+
tower-http = { version = "0.5.2", features = [
40+
"cors",
41+
"normalize-path",
42+
"trace",
43+
] }
44+
autometrics = { version = "1.0.1", features = ["prometheus-exporter"] }
45+
axum-extra = { version = "0.9.3", features = [
46+
"typed-header",
47+
], default-features = false }
48+
3649
[dev-dependencies]
3750
hex-literal = "0.4.1"
51+
test-tap-utils = { path = "../tests/tap-utils" }
3852

3953
[build-dependencies]
4054
build-info-build = { version = "0.0.39", default-features = false }

0 commit comments

Comments
 (0)