sui_sdk_types/
events.rs

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