express_relay_api_types/
lib.rs1use {
2 ::serde::{
3 Deserialize,
4 Serialize,
5 },
6 serde_with::{
7 base64::{
8 Base64,
9 Standard,
10 },
11 formats::Padded,
12 serde_as,
13 DeserializeAs,
14 DisplayFromStr,
15 SerializeAs,
16 },
17 solana_sdk::hash::Hash,
18 strum::AsRefStr,
19 utoipa::{
20 ToResponse,
21 ToSchema,
22 },
23};
24
25pub mod bid;
26pub mod opportunity;
27pub mod profile;
28pub mod quote;
29pub mod serde;
30pub mod ws;
31
32pub type MicroLamports = u64;
33pub type ChainId = String;
34
35#[derive(Clone, Debug)]
36pub struct PermissionKeySvm(pub [u8; 65]);
37impl Serialize for PermissionKeySvm {
38 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
39 where
40 S: ::serde::Serializer,
41 {
42 Base64::<Standard, Padded>::serialize_as(&self.0, serializer)
43 }
44}
45
46impl<'de> Deserialize<'de> for PermissionKeySvm {
47 fn deserialize<D>(deserializer: D) -> Result<PermissionKeySvm, D::Error>
48 where
49 D: ::serde::Deserializer<'de>,
50 {
51 let bytes = Base64::<Standard, Padded>::deserialize_as(deserializer)?;
52 Ok(PermissionKeySvm(bytes))
53 }
54}
55
56#[serde_as]
57#[derive(Serialize, Clone, ToSchema, ToResponse, Deserialize, Debug, PartialEq)]
58pub struct SvmChainUpdate {
59 #[schema(example = "solana", value_type = String)]
60 pub chain_id: ChainId,
61 #[serde_as(as = "DisplayFromStr")]
62 #[schema(example = "SLxp9LxX1eE9Z5v99Y92DaYEwyukFgMUF6zRerCF12j", value_type = String)]
63 pub blockhash: Hash,
64 #[schema(example = "1000", value_type = u64)]
66 pub latest_prioritization_fee: MicroLamports,
67}
68
69#[derive(ToResponse, ToSchema, Serialize, Deserialize)]
70#[response(description = "An error occurred processing the request")]
71pub struct ErrorBodyResponse {
72 pub error: String,
73}
74
75#[derive(AsRefStr)]
76#[strum(prefix = "/")]
77pub enum Route {
78 #[strum(serialize = "v1")]
79 V1,
80 #[strum(serialize = "v1/:chain_id")]
81 V1Chain,
82 #[strum(serialize = "bids")]
83 Bid,
84 #[strum(serialize = "opportunities")]
85 Opportunity,
86 #[strum(serialize = "quotes")]
87 Quote,
88 #[strum(serialize = "profiles")]
89 Profile,
90 #[strum(serialize = "")]
91 Root,
92 #[strum(serialize = "live")]
93 Liveness,
94 #[strum(serialize = "docs")]
95 Docs,
96 #[strum(serialize = "docs/openapi.json")]
97 OpenApi,
98}
99
100#[derive(PartialEq)]
101pub enum AccessLevel {
102 Admin,
103 LoggedIn,
104 Public,
105}
106
107pub struct RouteProperties {
108 pub access_level: AccessLevel,
109 pub method: http::Method,
110 pub full_path: String,
111}
112
113pub trait Routable: AsRef<str> + Clone {
114 fn properties(&self) -> RouteProperties;
115}