1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use std::fmt;
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
7#[serde(rename_all = "UPPERCASE")]
8pub enum NetworkType {
9 ERC20,
10 BEP20,
11 TRC20,
12 POLYGON,
13 SOLANA,
14}
15
16impl fmt::Display for NetworkType {
17 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18 match self {
19 NetworkType::ERC20 => write!(f, "ERC20"),
20 NetworkType::BEP20 => write!(f, "BEP20"),
21 NetworkType::TRC20 => write!(f, "TRC20"),
22 NetworkType::POLYGON => write!(f, "POLYGON"),
23 NetworkType::SOLANA => write!(f, "SOLANA"),
24 }
25 }
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
30#[serde(rename_all = "UPPERCASE")]
31pub enum TransactionStatus {
32 Pending,
33 Processing,
34 Completed,
35 Failed,
36 Cancelled,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
41#[serde(rename_all = "lowercase")]
42pub enum TransactionType {
43 Deposit,
44 Withdrawal,
45}
46
47#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(rename_all = "UPPERCASE")]
50pub enum AddressType {
51 Temporary,
52 Permanent,
53}
54
55#[derive(Debug, Clone, Serialize)]
57pub struct CreateDepositParams {
58 pub network_type: NetworkType,
59 pub contract_address: String,
60 pub amount: String,
61 pub ipn_url: String,
62 #[serde(skip_serializing_if = "Option::is_none")]
63 pub udf: Option<String>,
64 #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
65 pub address_type: Option<String>,
66}
67
68#[derive(Debug, Clone, Serialize)]
70pub struct CreateWithdrawalParams {
71 pub network_type: NetworkType,
72 pub contract_address: String,
73 pub address: String,
74 pub amount: String,
75 pub ipn_url: String,
76 #[serde(skip_serializing_if = "Option::is_none")]
77 pub udf: Option<String>,
78}
79
80#[derive(Debug, Clone, Deserialize)]
82pub struct DepositResponse {
83 pub id: String,
84 pub address: String,
85 #[serde(rename = "expiresAt")]
86 pub expires_at: DateTime<Utc>,
87 pub amount: String,
88 pub status: TransactionStatus,
89}
90
91#[derive(Debug, Clone, Deserialize)]
93pub struct WithdrawalResponse {
94 pub id: String,
95 pub status: TransactionStatus,
96 pub fee: String,
97}
98
99#[derive(Debug, Clone, Deserialize)]
101pub struct Token {
102 pub network_type: NetworkType,
103 pub contract_address: String,
104 pub symbol: String,
105 pub name: String,
106 pub decimals: u8,
107}
108
109#[derive(Debug, Clone, Deserialize)]
111pub struct Transaction {
112 pub id: String,
113 #[serde(rename = "transactionType")]
114 pub transaction_type: TransactionType,
115 pub status: TransactionStatus,
116 pub amount: String,
117 #[serde(rename = "createdAt")]
118 pub created_at: DateTime<Utc>,
119 #[serde(rename = "updatedAt")]
120 pub updated_at: DateTime<Utc>,
121 #[serde(rename = "txHash")]
122 pub tx_hash: Option<String>,
123 pub network_type: NetworkType,
124 pub contract_address: String,
125 pub address: String,
126 pub token: Token,
127}
128
129#[derive(Debug, Clone, Deserialize)]
131pub struct TransactionStatusResponse {
132 pub address: String,
133 #[serde(rename = "transactionType")]
134 pub transaction_type: TransactionType,
135 pub count: usize,
136 pub transactions: Vec<Transaction>,
137}
138
139#[derive(Debug, Clone, Deserialize)]
141pub struct Balance {
142 pub raw: String,
143 pub formatted: String,
144}
145
146#[derive(Debug, Clone, Deserialize)]
148pub struct WalletBalanceResponse {
149 pub address: String,
150 pub network_type: NetworkType,
151 pub contract_address: String,
152 pub token: Token,
153 pub balance: Balance,
154}
155
156#[derive(Debug, Clone, Deserialize, Serialize)]
158pub struct WebhookPayload {
159 pub id: String,
160 #[serde(rename = "type")]
161 pub transaction_type: TransactionType,
162 pub status: TransactionStatus,
163 pub address: String,
164 pub network_type: NetworkType,
165 pub amount: String,
166 pub udf: Option<String>,
167 #[serde(rename = "txHash")]
168 pub tx_hash: Option<String>,
169 pub timestamp: DateTime<Utc>,
170}