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