1use iota_sdk_types::ObjectId;
6use move_core_types::annotated_value::MoveStructLayout;
7use serde::{Deserialize, Serialize};
8
9use crate::{
10 base_types::{SequenceNumber, TransactionDigest},
11 crypto::{AuthoritySignInfo, AuthorityStrongQuorumSignInfo},
12 effects::{SignedTransactionEffects, TransactionEvents, VerifiedSignedTransactionEffects},
13 messages_consensus::SignedAuthorityCapabilitiesV1,
14 object::Object,
15 transaction::{CertifiedTransaction, SenderSignedData, SignedTransaction},
16};
17
18#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize)]
19pub enum ObjectInfoRequestKind {
20 LatestObjectInfo,
22 PastObjectInfoDebug(SequenceNumber),
27}
28
29#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize)]
32pub enum LayoutGenerationOption {
33 Generate,
34 None,
35}
36
37#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize)]
40pub struct ObjectInfoRequest {
41 pub object_id: ObjectId,
43 pub generate_layout: LayoutGenerationOption,
45 pub request_kind: ObjectInfoRequestKind,
47}
48
49impl ObjectInfoRequest {
50 pub fn past_object_info_debug_request(
51 object_id: ObjectId,
52 version: SequenceNumber,
53 generate_layout: LayoutGenerationOption,
54 ) -> Self {
55 ObjectInfoRequest {
56 object_id,
57 generate_layout,
58 request_kind: ObjectInfoRequestKind::PastObjectInfoDebug(version),
59 }
60 }
61
62 pub fn latest_object_info_request(
63 object_id: ObjectId,
64 generate_layout: LayoutGenerationOption,
65 ) -> Self {
66 ObjectInfoRequest {
67 object_id,
68 generate_layout,
69 request_kind: ObjectInfoRequestKind::LatestObjectInfo,
70 }
71 }
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76pub struct ObjectInfoResponse {
77 pub object: Object,
79 pub layout: Option<MoveStructLayout>,
83 pub lock_for_debugging: Option<SignedTransaction>,
88}
89
90#[derive(Debug, Clone)]
93pub struct VerifiedObjectInfoResponse {
94 pub object: Object,
96}
97
98#[derive(Clone, Debug, Serialize, Deserialize)]
99pub struct TransactionInfoRequest {
100 pub transaction_digest: TransactionDigest,
101}
102
103#[expect(clippy::large_enum_variant)]
104#[derive(Clone, Debug, Serialize, Deserialize)]
105pub enum TransactionStatus {
106 Signed(AuthoritySignInfo),
108 Executed(
114 Option<AuthorityStrongQuorumSignInfo>,
115 SignedTransactionEffects,
116 TransactionEvents,
117 ),
118}
119
120impl TransactionStatus {
121 pub fn into_signed_for_testing(self) -> AuthoritySignInfo {
122 match self {
123 Self::Signed(s) => s,
124 _ => unreachable!("Incorrect response type"),
125 }
126 }
127
128 pub fn into_effects_for_testing(self) -> SignedTransactionEffects {
129 match self {
130 Self::Executed(_, e, _) => e,
131 _ => unreachable!("Incorrect response type"),
132 }
133 }
134}
135
136impl PartialEq for TransactionStatus {
137 fn eq(&self, other: &Self) -> bool {
138 match self {
139 Self::Signed(s1) => match other {
140 Self::Signed(s2) => s1.epoch == s2.epoch,
141 _ => false,
142 },
143 Self::Executed(c1, e1, ev1) => match other {
144 Self::Executed(c2, e2, ev2) => {
145 c1.as_ref().map(|a| a.epoch) == c2.as_ref().map(|a| a.epoch)
146 && e1.epoch() == e2.epoch()
147 && e1.digest() == e2.digest()
148 && ev1.digest() == ev2.digest()
149 }
150 _ => false,
151 },
152 }
153 }
154}
155
156#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
157pub struct HandleTransactionResponse {
158 pub status: TransactionStatus,
159}
160
161#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
162pub struct TransactionInfoResponse {
163 pub transaction: SenderSignedData,
164 pub status: TransactionStatus,
165}
166
167#[derive(Clone, Debug, Serialize, Deserialize)]
168pub struct SubmitCertificateResponse {
169 pub executed: Option<HandleCertificateResponseV1>,
172}
173
174#[derive(Clone, Debug)]
175pub struct VerifiedHandleCertificateResponse {
176 pub signed_effects: VerifiedSignedTransactionEffects,
177 pub events: TransactionEvents,
178}
179
180#[derive(Serialize, Deserialize, Clone, Debug)]
181pub struct SystemStateRequest {
182 pub _unused: bool,
184}
185
186#[derive(Clone, Debug, Serialize, Deserialize)]
195pub struct HandleCertificateResponseV1 {
196 pub signed_effects: SignedTransactionEffects,
197 pub events: Option<TransactionEvents>,
198
199 pub input_objects: Option<Vec<Object>>,
205
206 pub output_objects: Option<Vec<Object>>,
210 pub auxiliary_data: Option<Vec<u8>>,
211}
212
213#[derive(Clone, Debug, Serialize, Deserialize)]
214pub struct HandleCertificateRequestV1 {
215 pub certificate: CertifiedTransaction,
216
217 pub include_events: bool,
218 pub include_input_objects: bool,
219 pub include_output_objects: bool,
220 pub include_auxiliary_data: bool,
221}
222
223impl HandleCertificateRequestV1 {
224 pub fn new(certificate: CertifiedTransaction) -> Self {
225 Self {
226 certificate,
227 include_events: false,
228 include_input_objects: false,
229 include_output_objects: false,
230 include_auxiliary_data: false,
231 }
232 }
233
234 pub fn with_events(mut self) -> Self {
235 self.include_events = true;
236 self
237 }
238
239 pub fn with_input_objects(mut self) -> Self {
240 self.include_input_objects = true;
241 self
242 }
243
244 pub fn with_output_objects(mut self) -> Self {
245 self.include_output_objects = true;
246 self
247 }
248
249 pub fn with_auxiliary_data(mut self) -> Self {
250 self.include_auxiliary_data = true;
251 self
252 }
253}
254
255#[derive(Clone, Debug, Serialize, Deserialize)]
262pub struct HandleSoftBundleCertificatesResponseV1 {
263 pub responses: Vec<HandleCertificateResponseV1>,
264}
265
266#[derive(Clone, Debug, Serialize, Deserialize)]
268pub struct HandleSoftBundleCertificatesRequestV1 {
269 pub certificates: Vec<CertifiedTransaction>,
270
271 pub wait_for_effects: bool,
272 pub include_events: bool,
273 pub include_input_objects: bool,
274 pub include_output_objects: bool,
275 pub include_auxiliary_data: bool,
276}
277
278#[derive(Clone, Debug, Serialize, Deserialize)]
279pub struct HandleCapabilityNotificationRequestV1 {
280 pub message: SignedAuthorityCapabilitiesV1,
281}
282
283#[derive(Clone, Debug, Serialize, Deserialize)]
284pub struct HandleCapabilityNotificationResponseV1 {
285 pub _unused: bool,
287}