sui_sdk_types/
events.rs

1use super::Address;
2use super::Identifier;
3use super::ObjectId;
4use super::StructTag;
5use super::TypeTag;
6
7/// Events emitted during the successful execution of a transaction
8///
9/// # BCS
10///
11/// The BCS serialized form for this type is defined by the following ABNF:
12///
13/// ```text
14/// transaction-events = vector event
15/// ```
16#[derive(Eq, PartialEq, Clone, Debug)]
17#[cfg_attr(
18    feature = "serde",
19    derive(serde_derive::Serialize, serde_derive::Deserialize)
20)]
21#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
22pub struct TransactionEvents(pub Vec<Event>);
23
24/// An event
25///
26/// # BCS
27///
28/// The BCS serialized form for this type is defined by the following ABNF:
29///
30/// ```text
31/// event = object-id identifier address struct-tag bytes
32/// ```
33#[derive(PartialEq, Eq, Debug, Clone)]
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 Event {
40    /// Package id of the top-level function invoked by a MoveCall command which triggered this
41    /// event to be emitted.
42    pub package_id: ObjectId,
43
44    /// Module name of the top-level function invoked by a MoveCall command which triggered this
45    /// event to be emitted.
46    pub module: Identifier,
47
48    /// Address of the account that sent the transaction where this event was emitted.
49    pub sender: Address,
50
51    /// The type of the event emitted
52    #[cfg_attr(feature = "serde", serde(rename = "type"))]
53    pub type_: StructTag,
54
55    /// BCS serialized bytes of the event
56    #[cfg_attr(
57        feature = "serde",
58        serde(with = "crate::_serde::ReadableBase64Encoded")
59    )]
60    pub contents: Vec<u8>,
61}
62
63#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
64#[cfg_attr(
65    feature = "serde",
66    derive(serde_derive::Serialize, serde_derive::Deserialize)
67)]
68#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
69pub struct BalanceChange {
70    /// Owner of the balance change
71    pub address: Address,
72
73    /// Type of the Coin
74    pub coin_type: TypeTag,
75
76    /// The amount indicate the balance value changes.
77    ///
78    /// A negative amount means spending coin value and positive means receiving coin value.
79    #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
80    pub amount: i128,
81}