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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
//! The shared identifier + value types of the store surface.
//!
//! The coin/identity types are re-exported VERBATIM from `dig-merkle` (which re-exports the
//! `chia-wallet-sdk` byte-source-of-truth) so a consumer depends on ONE canonical shape and never a
//! shadow copy that could byte-drift:
//!
//! - [`Bytes32`] — a 32-byte identifier (a `store_id` / `launcher_id`, a merkle root, a DID id);
//! - [`Coin`] / [`CoinSpend`] — the Chia coin + confirmed spend;
//! - [`DataStore`] / [`DigDataStoreMetadata`] — the hydrated DataLayer coin + its on-chain metadata;
//! - [`DidRef`] — a reference to an owning DID by its launcher id;
//! - [`MerkleCoinSpend`] — the unsigned result of a lifecycle operation (coin spends + child store);
//! - [`Proof`] / [`LineageProof`] — a singleton's eve-or-lineage proof and the lineage proof a child
//! spend must carry (see [`crate::child_lineage_proof`]);
//! - [`DelegatedPuzzle`] — an admin/writer/oracle delegated puzzle a store may carry (SPEC §5).
//!
//! Two `dig-store`-owned view types are added here:
//!
//! - [`RootHistory`] — the ordered list of merkle roots a store has anchored across its generations,
//! produced by the on-chain lineage walk (SPEC §5);
//! - [`CapsuleIdentity`] — the `(store_id, root_hash)` a capsule declares, recovered OFF-CHAIN from a
//! compiled `.dig` module's bytes (SPEC §5/§11). It is the `dig-store`-native view (canonical
//! [`Bytes32`]) of a `dig_capsule::capsule::Capsule`, so the whole store surface speaks ONE byte
//! type rather than exposing `dig-capsule`'s separate `Bytes32`.
use ;
pub use ;
/// The lifecycle state of a store as seen on chain (SPEC §5).
///
/// The three outcomes of the single lineage walk that backs [`crate::get_store_status`]:
///
/// - [`Live`](StoreStatusKind::Live) — the launcher resolved and the walk reached an UNSPENT tip;
/// - [`Melted`](StoreStatusKind::Melted) — the launcher resolved but the lineage ends in a terminal
/// melt (no live tip); the store still has a root history but no current content;
/// - [`NotFound`](StoreStatusKind::NotFound) — no launcher spend exists on chain for this store id.
/// How deeply the live tip is buried under the current chain peak (SPEC §5).
///
/// `have` is the number of blocks between the tip's confirming height and the current peak
/// (`peak.saturating_sub(confirmed_height)`); `target` is the caller-chosen confirmation depth at
/// which the tip is considered settled (see [`crate::DEFAULT_CONFIRMATION_TARGET`]). Present only when
/// the chain source exposed BOTH a peak height and the tip's confirmed height.
/// The aggregate on-chain status of a store, produced by [`crate::get_store_status`] from ONE
/// consistent lineage walk plus a single supplementary read on the resolved tip (SPEC §5, NC-9).
///
/// Every identifier field is a bare lowercase-hex string byte-identical to the URN body form (so
/// `store_id` equals the id in the store's `urn:dig:chia:<store_id>`), making the whole snapshot
/// directly JSON-serializable for a CLI/RPC surface without leaking a chia byte type across serde.
///
/// # Field availability by [`status`](StoreStatus::status)
///
/// - `NotFound` — every optional field is `None`, `verified` is `false`, `generation_count` is 0.
/// - `Melted` — identity fields (`owner_puzzle_hash`/`live_root`/`program_hash`/`coin_id`) and
/// `confirmations` are `None`, `verified` is `false`; `generation_count` still counts every root
/// the store anchored while live.
/// - `Live` — `live_root`/`owner_puzzle_hash`/`coin_id` are always present; `program_hash`,
/// `confirmations`, and `verified` reflect what the metadata + supplementary tip read carried.
///
/// `head_signature` is ALWAYS `None`: a per-coin BLS head signature is structurally unavailable
/// through the [`ChainSource`](crate::ChainSource) surface (it yields `CoinSpend` — coin/puzzle/
/// solution — with no signature). The field ships present-but-`None` for forward-compat; a routed
/// follow-up sources it out-of-band (SPEC §5/§7).
/// The ordered history of merkle roots a store has anchored, oldest first.
///
/// Each entry is proven on chain by walking the singleton's lineage from the launcher forward (NC-9,
/// SPEC §5). The last element is the latest root. A live store is never empty (the mint anchors
/// generation 0); a fully-melted store's history still lists every root it anchored while live.
/// The identity a capsule declares: one immutable store generation, the pair `(store_id, root_hash)`.
///
/// Recovered OFF-CHAIN from a compiled `.dig` module's bytes by [`crate::get_capsule_identity`] /
/// [`crate::open_capsule`] (SPEC §5/§11). This is `dig-store`'s canonical-[`Bytes32`] view of a
/// `dig_capsule::capsule::Capsule`.
///
/// # `store_id` is NOT self-verified
///
/// `root_hash` is proven internally consistent by the reader (it recomputes the merkle root from the
/// module's committed leaves and rejects a forged one). `store_id`, however, is the store's on-chain
/// Chia launcher id, baked into the module at compile time and NOT self-verifiable from the module
/// bytes alone — nothing in the bytes binds them to that launcher. Treat a `store_id` from
/// [`crate::get_capsule_identity`] as a CLAIM until cross-checked against a trusted anchor (the URN you
/// resolved, the on-chain singleton, or a verified `ChainSource`). [`crate::open_capsule`] performs
/// that cross-check for you.