Skip to main content

nexus_sdk/types/
dag.rs

1use crate::{
2    move_bindings::interface::{
3        graph::{EdgeKind, PostFailureAction},
4        verifier::ToolVerifierMode,
5    },
6    ToolFqn,
7};
8
9/// Name of the default entry group.
10pub const DEFAULT_ENTRY_GROUP: &str = "_default_group";
11
12/// Normalized typed specification for constructing a Nexus DAG on chain.
13#[derive(Clone, Debug, Default)]
14pub struct DagSpec {
15    pub vertices: Vec<DagVertex>,
16    pub edges: Vec<DagEdge>,
17    pub default_values: Vec<DagDefaultValue>,
18    pub post_failure_action: Option<PostFailureAction>,
19    pub entry_groups: Vec<DagEntryGroup>,
20    pub outputs: Vec<DagOutput>,
21}
22
23#[derive(Clone, Debug)]
24pub enum DagVertexKind {
25    OffChain { tool_fqn: ToolFqn },
26    OnChain { tool_fqn: ToolFqn },
27}
28
29#[derive(Clone, Debug)]
30pub struct DagEntryPort {
31    pub name: String,
32}
33
34#[derive(Clone, Debug)]
35pub struct DagVertex {
36    pub kind: DagVertexKind,
37    pub name: String,
38    pub entry_ports: Vec<DagEntryPort>,
39    pub post_failure_action: Option<PostFailureAction>,
40    pub verifier: Option<ToolVerifierMode>,
41}
42
43#[derive(Clone, Debug)]
44pub struct DagEntryGroup {
45    pub name: String,
46    pub vertices: Vec<String>,
47}
48
49#[derive(Clone, Debug)]
50pub struct DagDefaultValue {
51    pub vertex: String,
52    pub input_port: String,
53    /// Canonical readable One/Many JSON retained until PTB construction.
54    pub value: serde_json::Value,
55}
56
57#[derive(Clone, Debug)]
58pub struct DagEdge {
59    pub from: DagOutput,
60    pub to: DagInput,
61    pub kind: EdgeKind,
62}
63
64#[derive(Clone, Debug, PartialEq, Eq)]
65pub struct DagOutput {
66    pub vertex: String,
67    pub output_variant: String,
68    pub output_port: String,
69}
70
71#[derive(Clone, Debug)]
72pub struct DagInput {
73    pub vertex: String,
74    pub input_port: String,
75}