Skip to main content

pin_gallery/
pin-gallery.rs

1//! Dump what the decoder makes of every pinned fixture, as JSON.
2//!
3//! The fixtures are verbatim revealed programs from real covenants, so this
4//! is the same path the indexer runs on a live spend — not a mock. Used to
5//! preview the families on localhost before a worker deploy:
6//!
7//!   cargo run -p kascov-decode --example pin-gallery > scripts/pins-dev-fixture.json
8
9use kascov_decode::Registry;
10
11macro_rules! fixture {
12    ($name:literal) => {
13        (
14            $name,
15            include_bytes!(concat!("../fixtures/", $name, ".bin")).as_slice(),
16        )
17    };
18}
19
20fn main() {
21    let reg = Registry::default();
22    let fixtures = [
23        fixture!("g0_root_a"),
24        fixture!("g0_slot_mint_413_a"),
25        fixture!("g0_slot_mint_421_b"),
26        fixture!("g0_slot_mint_520_a"),
27        fixture!("g0_slot_mint_565_b"),
28        fixture!("g0_buy_v3_a"),
29        fixture!("g0_list_v3_b"),
30        fixture!("g0_style_list_a"),
31        fixture!("g0_dutch_list_b"),
32        fixture!("g0_auction_a"),
33        fixture!("g0_krc_gate_boot_b"),
34        fixture!("g0_krc_gate_active_a"),
35        fixture!("kw_vault_schnorr_a"),
36        fixture!("kw_vault_pqcold_b"),
37        fixture!("kw_vault_htlc_a"),
38        fixture!("kw_vault_dms_b"),
39        fixture!("kcom_token_b"),
40        fixture!("zealous_launch_a_a"),
41        fixture!("zealous_launch_b_b"),
42        // already-pinned families, for context
43        fixture!("g0_list_v1_a"),
44        fixture!("g0_buy_v1_a"),
45        fixture!("g0_col_a"),
46        fixture!("pure_a"),
47    ];
48
49    let mut out = Vec::new();
50    for (name, program) in fixtures {
51        let d = reg.decode(0, program);
52        let fields: Vec<_> = d
53            .fields
54            .iter()
55            .map(|f| {
56                serde_json::json!({ "name": f.name, "value": hex::encode(&f.value) })
57            })
58            .collect();
59        out.push(serde_json::json!({
60            "fixture": name,
61            "family": d.template,
62            "bytes": program.len(),
63            "instructions": d.instructions.len(),
64            "uses_covenant_ops": d.uses_covenant_ops,
65            "fields": fields,
66        }));
67    }
68    println!(
69        "{}",
70        serde_json::to_string_pretty(&serde_json::json!({
71            "network": "testnet-10",
72            "generated_by": "cargo run -p kascov-decode --example pin-gallery",
73            "note": "Every program here is a verbatim spend-time reveal whose blake2b \
74                     matched its committed P2SH hash before capture; the fields are what \
75                     kascov's own decoder labels them.",
76            "pins": out,
77        }))
78        .unwrap()
79    );
80}