blueprint_eigenlayer_extra/sidecar/
types.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct EarnerLeaf {
5 pub earner: String,
6 #[serde(with = "hex")]
7 pub earner_token_root: Vec<u8>,
8}
9
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct TokenLeaf {
12 pub token: String,
13 pub cumulative_earnings: String,
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub struct Proof {
18 #[serde(with = "hex")]
19 pub root: Vec<u8>,
20 pub root_index: u32,
21 pub earner_index: u32,
22 #[serde(with = "hex")]
23 pub earner_tree_proof: Vec<u8>,
24 pub earner_leaf: EarnerLeaf,
25 pub token_indices: Vec<u32>,
26 pub token_tree_proofs: Vec<String>,
27 pub token_leaves: Vec<TokenLeaf>,
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct SummarizedEarnerReward {
32 pub token: String,
33 pub earned: String,
34 pub active: String,
35 pub claimed: String,
36 pub claimable: String,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
40pub struct DistributionRoot {
41 pub root: String,
42 pub root_index: u64,
43 pub rewards_calculation_end: String,
44 pub activated_at: String,
45 pub created_at_block_number: u64,
46 pub transaction_hash: String,
47 pub block_height: u64,
48 pub disabled: bool,
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(rename_all = "camelCase")]
53pub struct GenerateClaimProofRequest {
54 pub earner_address: String,
55 pub tokens: Vec<String>,
56 #[serde(skip_serializing_if = "Option::is_none")]
57 pub root_index: Option<i64>,
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
61pub struct GenerateClaimProofResponse {
62 pub proof: Proof,
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(rename_all = "camelCase")]
67pub struct GetSummarizedRewardsRequest {
68 pub earner_address: String,
69 #[serde(skip_serializing_if = "Option::is_none")]
70 pub block_height: Option<u64>,
71}
72
73#[derive(Debug, Clone, Serialize, Deserialize)]
74pub struct GetSummarizedRewardsResponse {
75 pub rewards: Vec<SummarizedEarnerReward>,
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize)]
79pub struct ListDistributionRootsRequest {
80 #[serde(skip_serializing_if = "Option::is_none")]
81 pub block_height: Option<u64>,
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize)]
85pub struct ListDistributionRootsResponse {
86 pub distribution_roots: Vec<DistributionRoot>,
87}
88
89mod hex {
90 use serde::{Deserialize, Deserializer, Serializer};
91
92 pub fn serialize<S>(bytes: &[u8], serializer: S) -> Result<S::Ok, S::Error>
93 where
94 S: Serializer,
95 {
96 serializer.serialize_str(&format!("0x{}", hex::encode(bytes)))
97 }
98
99 pub fn deserialize<'de, D>(deserializer: D) -> Result<Vec<u8>, D::Error>
100 where
101 D: Deserializer<'de>,
102 {
103 let s = String::deserialize(deserializer)?;
104 let s = s.strip_prefix("0x").unwrap_or(&s);
105 hex::decode(s).map_err(serde::de::Error::custom)
106 }
107}