ave_common/bridge/
request.rs

1//! Request types for Ave API
2//!
3//! These types are used for communication with the Ave HTTP API
4
5use crate::signature::BridgeSignature;
6use serde::{Deserialize, Serialize};
7use serde_json::Value;
8
9#[cfg(feature = "openapi")]
10use utoipa::ToSchema;
11
12/// Signed event request
13#[derive(Serialize, Deserialize, Debug, Clone)]
14#[cfg_attr(feature = "openapi", derive(ToSchema))]
15pub struct BridgeSignedEventRequest {
16    /// Event request
17    pub request: BridgeEventRequest,
18    /// Signature
19    pub signature: Option<BridgeSignature>,
20}
21
22/// Event request
23#[derive(Serialize, Deserialize, Debug, Clone)]
24#[cfg_attr(feature = "openapi", derive(ToSchema))]
25pub enum BridgeEventRequest {
26    Create(BridgeCreateRequest),
27    Fact(BridgeFactRequest),
28    Transfer(BridgeTransferRequest),
29    EOL(BridgeEOLRequest),
30    Confirm(BridgeConfirmRequest),
31    Reject(BridgeRejectRequest),
32}
33
34#[derive(Serialize, Deserialize, Debug, Clone)]
35#[cfg_attr(feature = "openapi", derive(ToSchema))]
36pub struct BridgeRejectRequest {
37    /// Subject identifier
38    pub subject_id: String,
39}
40
41#[derive(Serialize, Deserialize, Debug, Clone)]
42#[cfg_attr(feature = "openapi", derive(ToSchema))]
43pub struct BridgeCreateRequest {
44    pub name: Option<String>,
45    pub description: Option<String>,
46    /// The identifier of the governance contract
47    pub governance_id: Option<String>,
48    /// The identifier of the schema used to validate the event
49    pub schema_id: String,
50    /// The namespace of the subject
51    pub namespace: Option<String>,
52}
53
54#[derive(Serialize, Deserialize, Debug, Clone)]
55#[cfg_attr(feature = "openapi", derive(ToSchema))]
56pub struct BridgeFactRequest {
57    /// Subject identifier
58    pub subject_id: String,
59    /// Changes to be applied to the subject
60    pub payload: Value,
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize)]
64#[cfg_attr(feature = "openapi", derive(ToSchema))]
65pub struct BridgeTransferRequest {
66    /// Subject identifier
67    pub subject_id: String,
68    /// Public key of the new owner
69    pub new_owner: String,
70}
71
72/// EOL request
73#[derive(Debug, Clone, Serialize, Deserialize)]
74#[cfg_attr(feature = "openapi", derive(ToSchema))]
75pub struct BridgeEOLRequest {
76    /// Subject identifier
77    pub subject_id: String,
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
81#[cfg_attr(feature = "openapi", derive(ToSchema))]
82pub struct BridgeConfirmRequest {
83    /// Subject identifier
84    pub subject_id: String,
85    pub name_old_owner: Option<String>,
86}