Skip to main content

rpc/
common.rs

1use alloy_primitives::U256;
2use serde::{Deserialize, Serialize};
3
4use crate::guarantee::PaymentGuaranteeClaims;
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct UserTransactionInfo {
8    pub user_address: String,
9    pub recipient_address: String,
10    pub tx_hash: String,
11    pub amount: U256,
12    pub verified: bool,
13    pub finalized: bool,
14    pub failed: bool,
15    pub created_at: i64,
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
19pub struct CreatePaymentTabRequest {
20    pub user_address: String,
21    pub recipient_address: String,
22    /// Address of ERC20-Token
23    pub erc20_token: Option<String>,
24    /// Tab TTL in seconds
25    pub ttl: Option<u64>,
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
29pub struct CreatePaymentTabResult {
30    pub id: U256,
31    pub user_address: String,
32    pub recipient_address: String,
33    pub erc20_token: Option<String>,
34    pub next_req_id: U256,
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
38pub struct UserInfo {
39    pub collateral: U256,
40    pub available_collateral: U256,
41    pub guarantees: Vec<PaymentGuaranteeClaims>,
42    pub transactions: Vec<UserTransactionInfo>,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct TabInfo {
47    pub tab_id: U256,
48    pub user_address: String,
49    pub recipient_address: String,
50    pub asset_address: String,
51    pub start_timestamp: i64,
52    pub ttl_seconds: i64,
53    pub status: String,
54    pub settlement_status: String,
55    pub created_at: i64,
56    pub updated_at: i64,
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
60pub struct GuaranteeInfo {
61    pub tab_id: U256,
62    pub req_id: U256,
63    pub from_address: String,
64    pub to_address: String,
65    pub asset_address: String,
66    pub amount: U256,
67    pub start_timestamp: i64,
68    pub certificate: Option<String>,
69}
70
71#[derive(Debug, Clone, Serialize, Deserialize)]
72pub struct PendingRemunerationInfo {
73    pub tab: TabInfo,
74    pub latest_guarantee: Option<GuaranteeInfo>,
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize)]
78pub struct CollateralEventInfo {
79    pub id: String,
80    pub user_address: String,
81    pub asset_address: String,
82    pub amount: U256,
83    pub event_type: String,
84    pub tab_id: Option<U256>,
85    pub req_id: Option<U256>,
86    pub tx_id: Option<String>,
87    pub created_at: i64,
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
91pub struct AssetBalanceInfo {
92    pub user_address: String,
93    pub asset_address: String,
94    pub total: U256,
95    pub locked: U256,
96    pub version: i32,
97    pub updated_at: i64,
98}
99
100#[derive(Debug, Clone, Serialize, Deserialize)]
101pub struct UpdateUserSuspensionRequest {
102    pub suspended: bool,
103}
104
105#[derive(Debug, Clone, Serialize, Deserialize)]
106pub struct UserSuspensionStatus {
107    pub user_address: String,
108    pub suspended: bool,
109    pub updated_at: i64,
110}