sui_sdk_types/effects/v1.rs
1use crate::execution_status::ExecutionStatus;
2use crate::object::Owner;
3use crate::object::Version;
4use crate::EpochId;
5use crate::GasCostSummary;
6use crate::ObjectId;
7use crate::ObjectReference;
8use crate::TransactionDigest;
9use crate::TransactionEventsDigest;
10
11/// Version 1 of TransactionEffects
12///
13/// # BCS
14///
15/// The BCS serialized form for this type is defined by the following ABNF:
16///
17/// ```text
18/// effects-v1 = execution-status
19/// u64 ; epoch
20/// gas-cost-summary
21/// (vector modified-at-version)
22/// (vector object-ref) ; shared object references
23/// digest ; transaction digest
24/// (vector object-ref-with-owner) ; created objects
25/// (vector object-ref-with-owner) ; mutated objects
26/// (vector object-ref-with-owner) ; unwrapped objects
27/// (vector object-ref) ; deleted objects
28/// (vector object-ref) ; unwrapped then deleted objects
29/// (vector object-ref) ; wrapped objects
30/// object-ref-with-owner ; gas object
31/// (option digest) ; events digest
32/// (vector digest) ; list of transaction dependencies
33/// ```
34#[derive(Eq, PartialEq, Clone, Debug)]
35#[cfg_attr(
36 feature = "serde",
37 derive(serde_derive::Serialize, serde_derive::Deserialize)
38)]
39#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
40pub struct TransactionEffectsV1 {
41 /// The status of the execution
42 pub status: ExecutionStatus,
43
44 /// The epoch when this transaction was executed.
45 pub epoch: EpochId,
46
47 /// The gas used by this transaction
48 pub gas_used: GasCostSummary,
49
50 /// The version that every modified (mutated or deleted) object had before it was modified by
51 /// this transaction.
52 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))]
53 pub modified_at_versions: Vec<ModifiedAtVersion>,
54
55 /// The object references of the shared objects used in this transaction. Empty if no shared objects were used.
56 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))]
57 pub shared_objects: Vec<ObjectReference>,
58
59 /// The transaction digest
60 pub transaction_digest: TransactionDigest,
61
62 /// ObjectReference and owner of new objects created.
63 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))]
64 pub created: Vec<ObjectReferenceWithOwner>,
65
66 /// ObjectReference and owner of mutated objects, including gas object.
67 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))]
68 pub mutated: Vec<ObjectReferenceWithOwner>,
69
70 /// ObjectReference and owner of objects that are unwrapped in this transaction.
71 /// Unwrapped objects are objects that were wrapped into other objects in the past,
72 /// and just got extracted out.
73 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))]
74 pub unwrapped: Vec<ObjectReferenceWithOwner>,
75
76 /// Object Refs of objects now deleted (the new refs).
77 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))]
78 pub deleted: Vec<ObjectReference>,
79
80 /// Object refs of objects previously wrapped in other objects but now deleted.
81 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))]
82 pub unwrapped_then_deleted: Vec<ObjectReference>,
83
84 /// Object refs of objects now wrapped in other objects.
85 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))]
86 pub wrapped: Vec<ObjectReference>,
87
88 /// The updated gas object reference. Have a dedicated field for convenient access.
89 /// It's also included in mutated.
90 pub gas_object: ObjectReferenceWithOwner,
91
92 /// The digest of the events emitted during execution,
93 /// can be None if the transaction does not emit any event.
94 pub events_digest: Option<TransactionEventsDigest>,
95
96 /// The set of transaction digests this transaction depends on.
97 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=5).lift()))]
98 pub dependencies: Vec<TransactionDigest>,
99}
100
101/// Indicates that an Object was modified at a specific version
102///
103/// # BCS
104///
105/// The BCS serialized form for this type is defined by the following ABNF:
106///
107/// ```text
108/// modified-at-version = object-id u64
109/// ```
110#[derive(Eq, PartialEq, Clone, Debug)]
111#[cfg_attr(
112 feature = "serde",
113 derive(serde_derive::Serialize, serde_derive::Deserialize)
114)]
115#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
116pub struct ModifiedAtVersion {
117 pub object_id: ObjectId,
118 pub version: Version,
119}
120
121/// An object reference with owner information
122///
123/// # BCS
124///
125/// The BCS serialized form for this type is defined by the following ABNF:
126///
127/// ```text
128/// object-ref-with-owner = object-ref owner
129/// ```
130#[derive(Eq, PartialEq, Clone, Debug)]
131#[cfg_attr(
132 feature = "serde",
133 derive(serde_derive::Serialize, serde_derive::Deserialize)
134)]
135#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
136pub struct ObjectReferenceWithOwner {
137 pub reference: ObjectReference,
138 pub owner: Owner,
139}
140
141impl TransactionEffectsV1 {
142 /// The status of the execution
143 pub fn status(&self) -> &ExecutionStatus {
144 &self.status
145 }
146
147 /// The epoch when this transaction was executed.
148 pub fn epoch(&self) -> EpochId {
149 self.epoch
150 }
151
152 /// The gas used in this transaction.
153 pub fn gas_summary(&self) -> &GasCostSummary {
154 &self.gas_used
155 }
156}