-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.rs
72 lines (65 loc) · 2.04 KB
/
config.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use std::{collections::BTreeMap, fmt, ops::Deref, path::PathBuf, str::FromStr};
use alloy::primitives::{Address, B256};
use reqwest::Url;
use serde::Deserialize;
use serde_with::{serde_as, DisplayFromStr};
#[serde_as]
#[derive(Debug, Deserialize)]
pub struct Config {
/// Authorize signers on startup.
pub authorize_signers: bool,
/// Table of minimum debts by indexer. This can be used, for example, to account for receipts
/// missing from the kafka topic.
pub debts: BTreeMap<Address, u64>,
/// TAP escrow contract address
pub escrow_contract: Address,
/// TAP escrow subgraph
#[serde_as(as = "DisplayFromStr")]
pub escrow_subgraph: Url,
/// GRT contract for updating allowance
pub grt_contract: Address,
/// GRT allowance to set on startup
pub grt_allowance: u64,
/// Kafka configuration
pub kafka: Kafka,
/// Graph network subgraph URL
#[serde_as(as = "DisplayFromStr")]
pub network_subgraph: Url,
/// API key for querying subgraphs
pub query_auth: Hidden<String>,
/// RPC for executing transactions
#[serde_as(as = "DisplayFromStr")]
pub rpc_url: Hidden<Url>,
/// Secret key of the TAP sender wallet
pub secret_key: Hidden<B256>,
/// Secret keys of the TAP signer wallets, used to filter the indexer fees messages.
pub signers: Vec<Hidden<B256>>,
/// Period of the subgraph polling cycle
pub update_interval_seconds: u32,
}
#[derive(Debug, Deserialize)]
pub struct Kafka {
pub config: Hidden<BTreeMap<String, String>>,
pub cache: PathBuf,
pub topic: String,
}
#[derive(Deserialize)]
#[serde(transparent)]
pub struct Hidden<T>(T);
impl<T: fmt::Debug> fmt::Debug for Hidden<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "HIDDEN")
}
}
impl<T: FromStr> FromStr for Hidden<T> {
type Err = T::Err;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Self(s.parse()?))
}
}
impl<T> Deref for Hidden<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.0
}
}