1use serde::{Deserialize, Serialize};
2use serde_json::{Map, Value};
3
4#[derive(Debug, Clone, Default, PartialEq, Serialize)]
6pub struct ProvenanceCheckRequest {
7 pub ip: String,
8 #[serde(skip_serializing_if = "Option::is_none")]
9 pub claimed_jurisdiction: Option<String>,
10 #[serde(skip_serializing_if = "Option::is_none")]
11 pub request_context: Option<Map<String, Value>>,
12}
13
14impl ProvenanceCheckRequest {
15 pub fn new(ip: impl Into<String>) -> Self {
16 ProvenanceCheckRequest {
17 ip: ip.into(),
18 ..Default::default()
19 }
20 }
21}
22
23#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
25#[serde(default)]
26pub struct ProvenanceCheck {
27 pub network_origin: String,
28 pub anonymized: bool,
29 pub method: String,
30 pub confidence: f64,
31 pub policy_action: String,
33 pub attestation_id: i64,
34}
35
36#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
38#[serde(default, rename_all = "camelCase")]
39pub struct ChainVerification {
40 pub ok: bool,
41 pub count: i64,
42 pub broken_at: i64,
43}
44
45#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
47#[serde(default, rename_all = "camelCase")]
48pub struct AnchoredVerification {
49 pub ok: bool,
50 pub count: i64,
51 pub broken_at: i64,
52 pub yours: i64,
53 pub anchor: Option<Anchor>,
54 pub at: String,
55}
56
57#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
59#[serde(default, rename_all = "camelCase")]
60pub struct Anchor {
61 pub day: String,
62 pub root_hash: String,
63 pub last_id: i64,
64}
65
66#[derive(Debug, Clone, Default)]
68pub struct ChainParams {
69 pub limit: Option<u32>,
71 pub before: Option<i64>,
72}
73
74#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
76#[serde(default, rename_all = "camelCase")]
77pub struct Chain {
78 pub links: Vec<ChainLink>,
79 pub next_before: i64,
80 pub total: i64,
81 pub summary: ChainSummary,
82 pub anchor: Option<Anchor>,
83 pub jurisdictions: Vec<Jurisdiction>,
84 pub as_of: String,
85}
86
87#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
89#[serde(default, rename_all = "camelCase")]
90pub struct ChainLink {
91 pub id: i64,
92 pub ts: String,
93 pub ip: String,
94 pub claimed_jurisdiction: String,
95 pub network_origin: String,
96 pub anonymized: bool,
97 pub method: String,
98 pub confidence: f64,
99 pub policy_action: String,
100 pub entry_hash: String,
101 pub prev_hash: String,
102 pub prev_id: i64,
103 pub entry_ok: bool,
104 pub link_ok: bool,
105}
106
107#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
109#[serde(default)]
110pub struct ChainSummary {
111 pub allow: i64,
112 pub step_up: i64,
113 pub block: i64,
114}
115
116#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
118#[serde(default, rename_all = "camelCase")]
119pub struct Jurisdiction {
120 pub code: String,
121 pub label: String,
122 pub law: Option<String>,
123 pub strict: bool,
124 pub clean_action: String,
125 pub masked_action: String,
126 pub rule: String,
127}
128
129#[derive(Debug, Default, Deserialize)]
130#[serde(default)]
131pub(crate) struct Jurisdictions {
132 pub jurisdictions: Vec<Jurisdiction>,
133}
134
135#[derive(Debug, Clone, Default)]
137pub struct ExportParams {
138 pub from: Option<String>,
139 pub to: Option<String>,
140}