#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[allow(dead_code)] pub(crate) enum Substrate {
Entity,
Note,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[allow(dead_code)] pub(crate) struct FinalizerEntryPoint {
pub(crate) id: &'static str,
pub(crate) constructor: &'static str,
pub(crate) mutation: &'static str,
pub(crate) substrate: Substrate,
pub(crate) origins: &'static [&'static str],
}
#[allow(dead_code)] pub(crate) const FINALIZER_ENTRY_POINTS: &[FinalizerEntryPoint] = &[
FinalizerEntryPoint {
id: "entity.create",
constructor: "entity candidate",
mutation: "create",
substrate: Substrate::Entity,
origins: &["runtime", "code.ingest"],
},
FinalizerEntryPoint {
id: "entity.update",
constructor: "entity candidate",
mutation: "update",
substrate: Substrate::Entity,
origins: &["runtime", "code.ingest"],
},
FinalizerEntryPoint {
id: "entity.bulk",
constructor: "entity candidate",
mutation: "bulk",
substrate: Substrate::Entity,
origins: &["runtime"],
},
FinalizerEntryPoint {
id: "note.create",
constructor: "note candidate",
mutation: "create",
substrate: Substrate::Note,
origins: &["runtime", "code.ingest"],
},
FinalizerEntryPoint {
id: "note.update",
constructor: "note candidate",
mutation: "update",
substrate: Substrate::Note,
origins: &["runtime", "code.ingest"],
},
FinalizerEntryPoint {
id: "note.atomic_message",
constructor: "note candidate",
mutation: "atomic message",
substrate: Substrate::Note,
origins: &["runtime"],
},
];
#[cfg(test)]
mod tests {
use super::*;
use std::collections::BTreeSet;
#[test]
fn declares_exactly_six_entry_points() {
assert_eq!(FINALIZER_ENTRY_POINTS.len(), 6);
}
#[test]
fn entry_point_ids_are_unique() {
let ids: BTreeSet<&str> = FINALIZER_ENTRY_POINTS.iter().map(|e| e.id).collect();
assert_eq!(ids.len(), FINALIZER_ENTRY_POINTS.len());
}
#[test]
fn matches_contract_id_list_exactly() {
let ids: Vec<&str> = FINALIZER_ENTRY_POINTS.iter().map(|e| e.id).collect();
assert_eq!(
ids,
vec![
"entity.create",
"entity.update",
"entity.bulk",
"note.create",
"note.update",
"note.atomic_message",
]
);
}
}