ord/subcommand/
runes.rs

1use super::*;
2
3#[derive(Debug, PartialEq, Serialize, Deserialize)]
4pub struct Output {
5  pub runes: BTreeMap<Rune, RuneInfo>,
6}
7
8#[derive(Debug, PartialEq, Serialize, Deserialize)]
9pub struct RuneInfo {
10  pub block: u64,
11  pub burned: u128,
12  pub divisibility: u8,
13  pub etching: Txid,
14  pub id: RuneId,
15  pub mints: u128,
16  pub number: u64,
17  pub premine: u128,
18  pub rune: SpacedRune,
19  pub supply: u128,
20  pub symbol: Option<char>,
21  pub terms: Option<Terms>,
22  pub timestamp: DateTime<Utc>,
23  pub turbo: bool,
24  pub tx: u32,
25}
26
27pub(crate) fn run(settings: Settings) -> SubcommandResult {
28  let index = Index::open(&settings)?;
29
30  ensure!(
31    index.has_rune_index(),
32    "`ord runes` requires index created with `--index-runes` flag",
33  );
34
35  index.update()?;
36
37  Ok(Some(Box::new(Output {
38    runes: index
39      .runes()?
40      .into_iter()
41      .map(
42        |(
43          id,
44          entry @ RuneEntry {
45            block,
46            burned,
47            divisibility,
48            etching,
49            mints,
50            number,
51            premine,
52            spaced_rune,
53            symbol,
54            terms,
55            timestamp,
56            turbo,
57          },
58        )| {
59          (
60            spaced_rune.rune,
61            RuneInfo {
62              block,
63              burned,
64              divisibility,
65              etching,
66              id,
67              mints,
68              number,
69              premine,
70              rune: spaced_rune,
71              supply: entry.supply(),
72              symbol,
73              terms,
74              timestamp: crate::timestamp(timestamp),
75              turbo,
76              tx: id.tx,
77            },
78          )
79        },
80      )
81      .collect::<BTreeMap<Rune, RuneInfo>>(),
82  })))
83}