openzeppelin_monitor/models/blockchain/stellar/event.rs
1//! Stellar contract event data structures.
2//!
3//! Note: These structures are based on the Stellar RPC implementation:
4//! <https://github.com/stellar/stellar-rpc/blob/main/cmd/stellar-rpc/internal/methods/get_events.go>
5
6use serde::{Deserialize, Serialize};
7
8/// Represents a contract event emitted during transaction execution
9///
10/// This structure represents the response from the Stellar RPC endpoint
11/// and matches the format defined in the stellar-rpc repository.
12#[derive(Deserialize, Serialize, Debug, Clone, Default)]
13pub struct Event {
14 /// Type of the event
15 #[serde(rename = "type")]
16 pub event_type: String,
17
18 /// Ledger sequence number containing this event
19 pub ledger: u32,
20
21 /// Timestamp when the ledger was closed
22 #[serde(rename = "ledgerClosedAt")]
23 pub ledger_closed_at: String,
24
25 /// Contract address that emitted the event
26 #[serde(rename = "contractId")]
27 pub contract_id: String,
28
29 /// Unique identifier for this event
30 pub id: String,
31
32 /// Deprecated: Use cursor at top level for pagination
33 #[serde(rename = "pagingToken")]
34 pub paging_token: String,
35
36 /// Whether the event was emitted during a successful contract call
37 #[serde(rename = "inSuccessfulContractCall")]
38 pub in_successful_contract_call: bool,
39
40 /// Transaction hash that generated this event
41 #[serde(rename = "txHash")]
42 pub transaction_hash: String,
43
44 /// Base64-encoded list of ScVals representing the event topics
45 #[serde(rename = "topic", skip_serializing_if = "Option::is_none")]
46 pub topic_xdr: Option<Vec<String>>,
47
48 /// Decoded JSON representation of the event topics
49 #[serde(rename = "topicJson", skip_serializing_if = "Option::is_none")]
50 pub topic_json: Option<Vec<serde_json::Value>>,
51
52 /// Base64-encoded ScVal representing the event value
53 #[serde(rename = "value", skip_serializing_if = "Option::is_none")]
54 pub value_xdr: Option<String>,
55
56 /// Decoded JSON representation of the event value
57 #[serde(rename = "valueJson", skip_serializing_if = "Option::is_none")]
58 pub value_json: Option<serde_json::Value>,
59}