darkpool_client/
config.rs1use ethers::types::{Address, H256, U256};
4
5use crate::builder::BuilderConfig;
6
7#[derive(Debug, Clone)]
8pub struct GasLimits {
9 pub withdraw: u64,
10 pub split: u64,
11 pub transfer: u64,
12 pub join: u64,
13 pub public_claim: u64,
14}
15
16impl Default for GasLimits {
17 fn default() -> Self {
18 Self {
19 withdraw: 400_000,
20 split: 500_000,
21 transfer: 500_000,
22 join: 600_000,
23 public_claim: 800_000,
24 }
25 }
26}
27
28#[derive(Debug, Clone)]
29pub struct DarkPoolConfig {
30 pub darkpool_address: Address,
31 pub compliance_pk: (U256, U256),
32 pub start_block: u64,
33 pub builder_config: BuilderConfig,
34 pub gas_limits: GasLimits,
35 pub provider_timeout_ms: u64,
36}
37
38impl Default for DarkPoolConfig {
39 fn default() -> Self {
40 Self {
41 darkpool_address: Address::zero(),
42 compliance_pk: (U256::zero(), U256::zero()),
43 start_block: 0,
44 builder_config: BuilderConfig::default(),
45 gas_limits: GasLimits::default(),
46 provider_timeout_ms: 30_000,
47 }
48 }
49}
50
51#[derive(Debug, Clone)]
52pub struct PrivacyTxResult {
53 pub tx_hash: H256,
54 pub new_commitments: Vec<U256>,
55 pub spent_nullifiers: Vec<U256>,
56 pub gas_used: U256,
57}
58
59#[cfg(test)]
60mod tests {
61 use super::*;
62
63 #[test]
64 fn test_darkpool_config_default() {
65 let config = DarkPoolConfig::default();
66 assert_eq!(config.darkpool_address, Address::zero());
67 assert_eq!(config.start_block, 0);
68 assert_eq!(config.provider_timeout_ms, 30_000);
69 assert_eq!(config.gas_limits.withdraw, 400_000);
70 assert_eq!(config.gas_limits.split, 500_000);
71 assert_eq!(config.gas_limits.transfer, 500_000);
72 assert_eq!(config.gas_limits.join, 600_000);
73 }
74
75 #[test]
76 fn test_gas_limits_custom() {
77 let limits = GasLimits {
78 withdraw: 300_000,
79 split: 400_000,
80 transfer: 400_000,
81 join: 500_000,
82 public_claim: 700_000,
83 };
84 assert_eq!(limits.withdraw, 300_000);
85 assert_eq!(limits.join, 500_000);
86 assert_eq!(limits.public_claim, 700_000);
87 }
88}