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