sp1_sdk/network/proto/
mod.rs1#![allow(clippy::all)]
2#![allow(missing_docs)]
3#![allow(clippy::pedantic)]
4
5#[rustfmt::skip]
6pub mod artifact;
7
8#[rustfmt::skip]
10pub mod auction {
11 #[rustfmt::skip]
12 pub mod network;
13 #[rustfmt::skip]
14 pub mod types;
15}
16
17#[rustfmt::skip]
18pub mod base {
19 #[rustfmt::skip]
20 pub mod network;
21 #[rustfmt::skip]
22 pub mod types;
23}
24
25#[rustfmt::skip]
27pub use self::auction::{network as auction_network, types as auction_types};
28#[rustfmt::skip]
29pub use self::base::{network as base_network, types as base_types};
30
31#[rustfmt::skip]
33pub use self::auction::{network, types};
34
35#[derive(Debug, Clone)]
37pub enum GetNonceResponse {
38 Auction(auction_types::GetNonceResponse),
39 Base(base_types::GetNonceResponse),
40}
41
42#[derive(Debug, Clone)]
43pub enum GetBalanceResponse {
44 Auction(auction_types::GetBalanceResponse),
45 Base(base_types::GetBalanceResponse),
46}
47
48#[derive(Debug, Clone)]
49pub enum GetProgramResponse {
50 Auction(auction_types::GetProgramResponse),
51 Base(base_types::GetProgramResponse),
52}
53
54#[derive(Debug, Clone)]
55pub enum RequestProofResponse {
56 Auction(auction_types::RequestProofResponse),
57 Base(base_types::RequestProofResponse),
58}
59
60#[derive(Debug, Clone)]
61pub enum GetProofRequestStatusResponse {
62 Auction(auction_types::GetProofRequestStatusResponse),
63 Base(base_types::GetProofRequestStatusResponse),
64}
65
66#[derive(Debug, Clone)]
67pub enum GetFilteredProofRequestsResponse {
68 Auction(auction_types::GetFilteredProofRequestsResponse),
69 Base(base_types::GetFilteredProofRequestsResponse),
70}
71
72impl From<auction_types::GetNonceResponse> for GetNonceResponse {
74 fn from(response: auction_types::GetNonceResponse) -> Self {
75 Self::Auction(response)
76 }
77}
78
79impl From<base_types::GetNonceResponse> for GetNonceResponse {
80 fn from(response: base_types::GetNonceResponse) -> Self {
81 Self::Base(response)
82 }
83}
84
85impl From<auction_types::GetBalanceResponse> for GetBalanceResponse {
86 fn from(response: auction_types::GetBalanceResponse) -> Self {
87 Self::Auction(response)
88 }
89}
90
91impl From<base_types::GetBalanceResponse> for GetBalanceResponse {
92 fn from(response: base_types::GetBalanceResponse) -> Self {
93 Self::Base(response)
94 }
95}
96
97impl From<auction_types::GetProgramResponse> for GetProgramResponse {
98 fn from(response: auction_types::GetProgramResponse) -> Self {
99 Self::Auction(response)
100 }
101}
102
103impl From<base_types::GetProgramResponse> for GetProgramResponse {
104 fn from(response: base_types::GetProgramResponse) -> Self {
105 Self::Base(response)
106 }
107}
108
109impl From<auction_types::RequestProofResponse> for RequestProofResponse {
110 fn from(response: auction_types::RequestProofResponse) -> Self {
111 Self::Auction(response)
112 }
113}
114
115impl From<base_types::RequestProofResponse> for RequestProofResponse {
116 fn from(response: base_types::RequestProofResponse) -> Self {
117 Self::Base(response)
118 }
119}
120
121impl From<auction_types::GetProofRequestStatusResponse> for GetProofRequestStatusResponse {
122 fn from(response: auction_types::GetProofRequestStatusResponse) -> Self {
123 Self::Auction(response)
124 }
125}
126
127impl From<base_types::GetProofRequestStatusResponse> for GetProofRequestStatusResponse {
128 fn from(response: base_types::GetProofRequestStatusResponse) -> Self {
129 Self::Base(response)
130 }
131}
132
133impl From<auction_types::GetFilteredProofRequestsResponse> for GetFilteredProofRequestsResponse {
134 fn from(response: auction_types::GetFilteredProofRequestsResponse) -> Self {
135 Self::Auction(response)
136 }
137}
138
139impl From<base_types::GetFilteredProofRequestsResponse> for GetFilteredProofRequestsResponse {
140 fn from(response: base_types::GetFilteredProofRequestsResponse) -> Self {
141 Self::Base(response)
142 }
143}
144
145impl GetNonceResponse {
147 pub fn nonce(&self) -> u64 {
148 match self {
149 Self::Auction(response) => response.nonce,
150 Self::Base(response) => response.nonce,
151 }
152 }
153}
154
155impl GetBalanceResponse {
156 pub fn balance(&self) -> &str {
157 match self {
158 Self::Auction(response) => &response.amount,
159 Self::Base(response) => &response.amount,
160 }
161 }
162}
163
164impl GetProgramResponse {
165 pub fn program_hash(&self) -> &[u8] {
166 match self {
167 Self::Auction(response) => response.program.as_ref().map(|p| p.vk_hash.as_slice()).unwrap_or(&[]),
168 Self::Base(response) => response.program.as_ref().map(|p| p.vk_hash.as_slice()).unwrap_or(&[]),
169 }
170 }
171
172 pub fn program_uri(&self) -> &str {
173 match self {
174 Self::Auction(response) => response.program.as_ref().map(|p| p.program_uri.as_str()).unwrap_or(""),
175 Self::Base(response) => response.program.as_ref().map(|p| p.program_uri.as_str()).unwrap_or(""),
176 }
177 }
178}
179
180impl RequestProofResponse {
181 pub fn request_id(&self) -> &[u8] {
182 match self {
183 Self::Auction(response) => response.body.as_ref().map(|b| b.request_id.as_slice()).unwrap_or(&[]),
184 Self::Base(response) => response.body.as_ref().map(|b| b.request_id.as_slice()).unwrap_or(&[]),
185 }
186 }
187
188 pub fn tx_hash(&self) -> &[u8] {
189 match self {
190 Self::Auction(response) => &response.tx_hash,
191 Self::Base(response) => &response.tx_hash,
192 }
193 }
194
195 pub fn body(&self) -> Option<&auction_types::RequestProofResponseBody> {
196 match self {
197 Self::Auction(response) => response.body.as_ref(),
198 Self::Base(_) => None, }
200 }
201}
202
203impl GetProofRequestStatusResponse {
204 pub fn fulfillment_status(&self) -> i32 {
205 match self {
206 Self::Auction(response) => response.fulfillment_status,
207 Self::Base(response) => response.fulfillment_status,
208 }
209 }
210
211 pub fn execution_status(&self) -> i32 {
212 match self {
213 Self::Auction(response) => response.execution_status,
214 Self::Base(response) => response.execution_status,
215 }
216 }
217
218 pub fn deadline(&self) -> u64 {
219 match self {
220 Self::Auction(response) => response.deadline,
221 Self::Base(response) => response.deadline,
222 }
223 }
224
225 pub fn proof_uri(&self) -> Option<&str> {
226 match self {
227 Self::Auction(response) => response.proof_uri.as_deref(),
228 Self::Base(response) => response.proof_uri.as_deref(),
229 }
230 }
231}
232
233#[derive(Debug, Clone)]
235pub enum CancelRequestResponse {
236 Auction(auction_types::CancelRequestResponse),
237 Unsupported,
238}
239
240#[derive(Debug, Clone)]
241pub enum GetProofRequestParamsResponse {
242 Auction(auction_types::GetProofRequestParamsResponse),
243 Unsupported,
244}
245
246impl From<auction_types::CancelRequestResponse> for CancelRequestResponse {
247 fn from(response: auction_types::CancelRequestResponse) -> Self {
248 Self::Auction(response)
249 }
250}
251
252impl From<auction_types::GetProofRequestParamsResponse> for GetProofRequestParamsResponse {
253 fn from(response: auction_types::GetProofRequestParamsResponse) -> Self {
254 Self::Auction(response)
255 }
256}