forked from StellarRouter/StellarRouter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.rs
More file actions
136 lines (120 loc) · 3.51 KB
/
Copy pathtypes.rs
File metadata and controls
136 lines (120 loc) · 3.51 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SimulateRequest {
/// Target contract address (56-char Stellar contract ID starting with C)
pub target: String,
/// Function name to invoke
pub function: String,
/// Transaction amount in stroops (used for fee estimation)
#[serde(default = "default_amount")]
pub amount: i64,
/// Fee rate in basis points (default 30 = 0.30%)
#[serde(default = "default_fee_bps")]
pub fee_bps: u32,
/// Network load in basis points for surge pricing (0–10000)
#[serde(default)]
pub network_load_bps: u32,
#[serde(default)]
pub route_details: Option<RouteDetails>,
}
fn default_amount() -> i64 {
1_000_000
}
fn default_fee_bps() -> u32 {
30
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RouteDetails {
pub name: String,
#[serde(default)]
pub version: Option<u32>,
#[serde(default)]
pub expected_outputs: Option<Vec<String>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SimulateResponse {
pub success: bool,
pub estimated_fees: FeeEstimate,
pub simulation: SimulationDetail,
pub message: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FeeEstimate {
pub base_fee: i64,
pub resource_fee: i64,
pub total_fee: i64,
pub surge_multiplier: u32,
pub high_load: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SimulationDetail {
pub target: String,
pub function: String,
pub would_succeed: bool,
}
#[allow(dead_code)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RouteBreakdown {
pub route_name: String,
pub version: u32,
pub target_contract: String,
pub function: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ErrorResponse {
pub error: String,
}
/// Response for GET /routes/:name — mirrors router-core::RouteEntry
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RouteEntryResponse {
pub address: String,
pub name: String,
pub paused: bool,
pub updated_by: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<RouteMetadataResponse>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RouteMetadataResponse {
pub description: String,
pub tags: Vec<String>,
pub owner: String,
}
/// Response for GET /stats
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
pub struct StatsResponse {
/// Total number of active WebSocket subscriptions (sum of all per-tx counts)
pub active_subscriptions: usize,
/// Number of distinct transaction IDs currently being tracked
pub unique_tx_ids: usize,
/// Broadcast channel capacity (fixed at startup)
pub broadcast_channel_capacity: usize,
}
/// Transaction status event (used by WebSocket)
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TransactionStatusEvent {
pub tx_id: String,
pub status: TransactionStatus,
pub timestamp: String,
#[serde(default)]
pub message: Option<String>,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "UPPERCASE")]
pub enum TransactionStatus {
Pending,
Submitted,
Confirmed,
Failed,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SubscribeMessage {
pub action: String,
pub tx_id: String,
}
#[allow(dead_code)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WsMessage {
pub msg_type: String,
pub data: serde_json::Value,
}