Skip to main content

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))]
25#[serde(tag = "event", content = "data", rename_all = "snake_case")]
26pub enum BridgeEventRequest {
27    Create(BridgeCreateRequest),
28    Fact(BridgeFactRequest),
29    Transfer(BridgeTransferRequest),
30    EOL(BridgeEOLRequest),
31    Confirm(BridgeConfirmRequest),
32    Reject(BridgeRejectRequest),
33}
34
35#[derive(Serialize, Deserialize, Debug, Clone)]
36#[cfg_attr(feature = "openapi", derive(ToSchema))]
37pub struct BridgeRejectRequest {
38    /// Subject identifier
39    pub subject_id: String,
40}
41
42#[derive(Serialize, Deserialize, Debug, Clone)]
43#[cfg_attr(feature = "openapi", derive(ToSchema))]
44pub struct BridgeCreateRequest {
45    pub name: Option<String>,
46    pub description: Option<String>,
47    /// The identifier of the governance contract
48    pub governance_id: Option<String>,
49    /// The identifier of the schema used to validate the event
50    pub schema_id: String,
51    /// The namespace of the subject
52    pub namespace: Option<String>,
53}
54
55#[derive(Serialize, Deserialize, Debug, Clone)]
56#[cfg_attr(feature = "openapi", derive(ToSchema))]
57pub struct BridgeFactRequest {
58    /// Subject identifier
59    pub subject_id: String,
60    /// Changes to be applied to the subject
61    pub payload: Value,
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize)]
65#[cfg_attr(feature = "openapi", derive(ToSchema))]
66pub struct BridgeTransferRequest {
67    /// Subject identifier
68    pub subject_id: String,
69    /// Public key of the new owner
70    pub new_owner: String,
71}
72
73/// EOL request
74#[derive(Debug, Clone, Serialize, Deserialize)]
75#[cfg_attr(feature = "openapi", derive(ToSchema))]
76pub struct BridgeEOLRequest {
77    /// Subject identifier
78    pub subject_id: String,
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
82#[cfg_attr(feature = "openapi", derive(ToSchema))]
83pub struct BridgeConfirmRequest {
84    /// Subject identifier
85    pub subject_id: String,
86    pub name_old_owner: Option<String>,
87}