1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* Copyright 2023 Architect Financial Technologies LLC. This is free
 * software released under the GNU Affero Public License version 3. */

//! the secrets protocol

use crate::packed_value;
use crate::protocol::JsonSchema;
use crate::protocol::{symbology::Venue, Account};

use netidx_derive::Pack;
use serde_derive::{Deserialize, Serialize};

#[derive(
    Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Pack, Serialize, Deserialize, JsonSchema,
)]
pub struct Label(pub String);

// mbac: if you don't specify serde(tag="type", content="data") you
// get json deserialization errors like: invalid value: map, expected
// map with a single key
/// The name of a secret in the secretsdb
#[derive(
    Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Pack, Serialize, Deserialize, JsonSchema,
)]
#[serde(tag = "type", content = "data")]
pub enum SecretKey {
    ExchangeKey(Label, Venue, Option<Account>),
    EVMKey(Label, Venue),
}

packed_value!(SecretKey);

// XCR estokes: Why does this exist?
// mbac: GetSecret is the component query, but there's no actul reason for it to be here.
// moved it to architect_core::secrets::protocol::GetSecret

#[derive(Debug, Clone, PartialEq, Eq, Pack)]
pub enum FromSecrets {
    SecretAdded(SecretKey),
    SecretDeleted(SecretKey),
}

packed_value!(FromSecrets);