canton_api_client/models/exercised_event.rs
1/*
2 * JSON Ledger API HTTP endpoints
3 *
4 * This specification version fixes the API inconsistencies where certain fields marked as required in the spec are in fact optional. If you use code generation tool based on this file, you might need to adjust the existing application code to handle those fields as optional. If you do not want to change your client code, continue using the OpenAPI specification from the previous Canton 3.4 patch release. MINIMUM_CANTON_VERSION=3.4.12
5 *
6 * The version of the OpenAPI document: 3.4.12-SNAPSHOT
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// ExercisedEvent : Records that a choice has been exercised on a target contract.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct ExercisedEvent {
17 /// The offset of origin. Offsets are managed by the participant nodes. Transactions can thus NOT be assumed to have the same offsets on different participant nodes. It is a valid absolute offset (positive integer) Required
18 #[serde(rename = "offset")]
19 pub offset: i64,
20 /// The position of this event in the originating transaction or reassignment. Node IDs are not necessarily equal across participants, as these may see different projections/parts of transactions. Must be valid node ID (non-negative integer) Required
21 #[serde(rename = "nodeId")]
22 pub node_id: i32,
23 /// The ID of the target contract. Must be a valid LedgerString (as described in ``value.proto``). Required
24 #[serde(rename = "contractId")]
25 pub contract_id: String,
26 /// Identifies the template that defines the executed choice. This template's package-id may differ from the target contract's package-id if the target contract has been upgraded or downgraded. The identifier uses the package-id reference format. Required
27 #[serde(rename = "templateId")]
28 pub template_id: String,
29 /// The interface where the choice is defined, if inherited. If defined, the identifier uses the package-id reference format. Optional
30 #[serde(rename = "interfaceId", skip_serializing_if = "Option::is_none")]
31 pub interface_id: Option<String>,
32 /// The choice that was exercised on the target contract. Must be a valid NameString (as described in ``value.proto``). Required
33 #[serde(rename = "choice")]
34 pub choice: String,
35 /// The argument of the exercised choice. Required
36 #[serde(rename = "choiceArgument", deserialize_with = "Option::deserialize")]
37 pub choice_argument: Option<serde_json::Value>,
38 /// The parties that exercised the choice. Each element must be a valid PartyIdString (as described in ``value.proto``). Required: must be non-empty
39 #[serde(rename = "actingParties")]
40 pub acting_parties: Vec<String>,
41 /// If true, the target contract may no longer be exercised. Required
42 #[serde(rename = "consuming")]
43 pub consuming: bool,
44 /// The parties that are notified of this event. The witnesses of an exercise node will depend on whether the exercise was consuming or not. If consuming, the witnesses are the union of the stakeholders, the actors and all informees of all the ancestors of this event this participant knows about. If not consuming, the witnesses are the union of the signatories, the actors and all informees of all the ancestors of this event this participant knows about. In both cases the witnesses are limited to the querying parties, or not limited in case anyParty filters are used. Note that the actors might not necessarily be observers and thus stakeholders. This is the case when the controllers of a choice are specified using \"flexible controllers\", using the ``choice ... controller`` syntax, and said controllers are not explicitly marked as observers. Each element must be a valid PartyIdString (as described in ``value.proto``). Required: must be non-empty
45 #[serde(rename = "witnessParties")]
46 pub witness_parties: Vec<String>,
47 /// Specifies the upper boundary of the node ids of the events in the same transaction that appeared as a result of this ``ExercisedEvent``. This allows unambiguous identification of all the members of the subtree rooted at this node. A full subtree can be constructed when all descendant nodes are present in the stream. If nodes are heavily filtered, it is only possible to determine if a node is in a consequent subtree or not. Required
48 #[serde(rename = "lastDescendantNodeId")]
49 pub last_descendant_node_id: i32,
50 /// The result of exercising the choice. Optional
51 #[serde(rename = "exerciseResult", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
52 pub exercise_result: Option<Option<serde_json::Value>>,
53 /// The package name of the contract. Required
54 #[serde(rename = "packageName")]
55 pub package_name: String,
56 /// If the event is consuming, the interfaces implemented by the target template that have been matched from the interface filter query. Populated only in case interface filters with include_interface_view set. The identifier uses the package-id reference format. Optional: can be empty
57 #[serde(rename = "implementedInterfaces", skip_serializing_if = "Option::is_none")]
58 pub implemented_interfaces: Option<Vec<String>>,
59 /// Whether this event would be part of respective ACS_DELTA shaped stream, and should therefore considered when tracking contract activeness on the client-side. Required
60 #[serde(rename = "acsDelta")]
61 pub acs_delta: bool,
62}
63
64impl ExercisedEvent {
65 /// Records that a choice has been exercised on a target contract.
66 pub fn new(offset: i64, node_id: i32, contract_id: String, template_id: String, choice: String, choice_argument: Option<serde_json::Value>, acting_parties: Vec<String>, consuming: bool, witness_parties: Vec<String>, last_descendant_node_id: i32, package_name: String, acs_delta: bool) -> ExercisedEvent {
67 ExercisedEvent {
68 offset,
69 node_id,
70 contract_id,
71 template_id,
72 interface_id: None,
73 choice,
74 choice_argument,
75 acting_parties,
76 consuming,
77 witness_parties,
78 last_descendant_node_id,
79 exercise_result: None,
80 package_name,
81 implemented_interfaces: None,
82 acs_delta,
83 }
84 }
85}
86