1use move_core_types::annotated_value::MoveStructLayout;
6use serde::{Deserialize, Serialize};
7
8use crate::{
9 base_types::{ObjectID, SequenceNumber, TransactionDigest},
10 crypto::{AuthoritySignInfo, AuthorityStrongQuorumSignInfo},
11 effects::{SignedTransactionEffects, TransactionEvents, VerifiedSignedTransactionEffects},
12 object::Object,
13 transaction::{CertifiedTransaction, SenderSignedData, SignedTransaction},
14};
15
16#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize)]
17pub enum ObjectInfoRequestKind {
18 LatestObjectInfo,
20 PastObjectInfoDebug(SequenceNumber),
25}
26
27#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize)]
30pub enum LayoutGenerationOption {
31 Generate,
32 None,
33}
34
35#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize)]
38pub struct ObjectInfoRequest {
39 pub object_id: ObjectID,
41 pub generate_layout: LayoutGenerationOption,
43 pub request_kind: ObjectInfoRequestKind,
45}
46
47impl ObjectInfoRequest {
48 pub fn past_object_info_debug_request(
49 object_id: ObjectID,
50 version: SequenceNumber,
51 generate_layout: LayoutGenerationOption,
52 ) -> Self {
53 ObjectInfoRequest {
54 object_id,
55 generate_layout,
56 request_kind: ObjectInfoRequestKind::PastObjectInfoDebug(version),
57 }
58 }
59
60 pub fn latest_object_info_request(
61 object_id: ObjectID,
62 generate_layout: LayoutGenerationOption,
63 ) -> Self {
64 ObjectInfoRequest {
65 object_id,
66 generate_layout,
67 request_kind: ObjectInfoRequestKind::LatestObjectInfo,
68 }
69 }
70}
71
72#[derive(Debug, Clone, Serialize, Deserialize)]
74pub struct ObjectInfoResponse {
75 pub object: Object,
77 pub layout: Option<MoveStructLayout>,
81 pub lock_for_debugging: Option<SignedTransaction>,
86}
87
88#[derive(Debug, Clone)]
91pub struct VerifiedObjectInfoResponse {
92 pub object: Object,
94}
95
96#[derive(Clone, Debug, Serialize, Deserialize)]
97pub struct TransactionInfoRequest {
98 pub transaction_digest: TransactionDigest,
99}
100
101#[derive(Clone, Debug, Serialize, Deserialize)]
102pub enum TransactionStatus {
103 Signed(AuthoritySignInfo),
105 Executed(
111 Option<AuthorityStrongQuorumSignInfo>,
112 SignedTransactionEffects,
113 TransactionEvents,
114 ),
115}
116
117impl TransactionStatus {
118 pub fn into_signed_for_testing(self) -> AuthoritySignInfo {
119 match self {
120 Self::Signed(s) => s,
121 _ => unreachable!("Incorrect response type"),
122 }
123 }
124
125 pub fn into_effects_for_testing(self) -> SignedTransactionEffects {
126 match self {
127 Self::Executed(_, e, _) => e,
128 _ => unreachable!("Incorrect response type"),
129 }
130 }
131}
132
133impl PartialEq for TransactionStatus {
134 fn eq(&self, other: &Self) -> bool {
135 match self {
136 Self::Signed(s1) => match other {
137 Self::Signed(s2) => s1.epoch == s2.epoch,
138 _ => false,
139 },
140 Self::Executed(c1, e1, ev1) => match other {
141 Self::Executed(c2, e2, ev2) => {
142 c1.as_ref().map(|a| a.epoch) == c2.as_ref().map(|a| a.epoch)
143 && e1.epoch() == e2.epoch()
144 && e1.digest() == e2.digest()
145 && ev1.digest() == ev2.digest()
146 }
147 _ => false,
148 },
149 }
150 }
151}
152
153#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
154pub struct HandleTransactionResponse {
155 pub status: TransactionStatus,
156}
157
158#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
159pub struct TransactionInfoResponse {
160 pub transaction: SenderSignedData,
161 pub status: TransactionStatus,
162}
163
164#[derive(Clone, Debug, Serialize, Deserialize)]
165pub struct SubmitCertificateResponse {
166 pub executed: Option<HandleCertificateResponseV1>,
169}
170
171#[derive(Clone, Debug)]
172pub struct VerifiedHandleCertificateResponse {
173 pub signed_effects: VerifiedSignedTransactionEffects,
174 pub events: TransactionEvents,
175}
176
177#[derive(Serialize, Deserialize, Clone, Debug)]
178pub struct SystemStateRequest {
179 pub _unused: bool,
181}
182
183#[derive(Clone, Debug, Serialize, Deserialize)]
192pub struct HandleCertificateResponseV1 {
193 pub signed_effects: SignedTransactionEffects,
194 pub events: Option<TransactionEvents>,
195
196 pub input_objects: Option<Vec<Object>>,
202
203 pub output_objects: Option<Vec<Object>>,
207 pub auxiliary_data: Option<Vec<u8>>,
208}
209
210#[derive(Clone, Debug, Serialize, Deserialize)]
211pub struct HandleCertificateRequestV1 {
212 pub certificate: CertifiedTransaction,
213
214 pub include_events: bool,
215 pub include_input_objects: bool,
216 pub include_output_objects: bool,
217 pub include_auxiliary_data: bool,
218}
219
220impl HandleCertificateRequestV1 {
221 pub fn new(certificate: CertifiedTransaction) -> Self {
222 Self {
223 certificate,
224 include_events: false,
225 include_input_objects: false,
226 include_output_objects: false,
227 include_auxiliary_data: false,
228 }
229 }
230
231 pub fn with_events(mut self) -> Self {
232 self.include_events = true;
233 self
234 }
235
236 pub fn with_input_objects(mut self) -> Self {
237 self.include_input_objects = true;
238 self
239 }
240
241 pub fn with_output_objects(mut self) -> Self {
242 self.include_output_objects = true;
243 self
244 }
245
246 pub fn with_auxiliary_data(mut self) -> Self {
247 self.include_auxiliary_data = true;
248 self
249 }
250}
251
252#[derive(Clone, Debug, Serialize, Deserialize)]
259pub struct HandleSoftBundleCertificatesResponseV1 {
260 pub responses: Vec<HandleCertificateResponseV1>,
261}
262
263#[derive(Clone, Debug, Serialize, Deserialize)]
265pub struct HandleSoftBundleCertificatesRequestV1 {
266 pub certificates: Vec<CertifiedTransaction>,
267
268 pub wait_for_effects: bool,
269 pub include_events: bool,
270 pub include_input_objects: bool,
271 pub include_output_objects: bool,
272 pub include_auxiliary_data: bool,
273}