1use {
2 crate::inscription_id::InscriptionId,
3 bitcoin::Txid,
4 borsh::{BorshDeserialize, BorshSerialize},
5 ordinals::{RuneId, SpacedRune},
6 serde::{Deserialize, Serialize},
7 std::io::{Read, Result, Write},
8};
9
10#[derive(Debug, Serialize, Deserialize)]
11pub struct MintResponse {
12 pub start: Option<u64>,
13 pub end: Option<u64>,
14 pub mintable: bool,
15 pub cap: u128,
16 pub amount: u128,
17 pub mints: u128,
18}
19
20#[derive(Debug, Serialize, Deserialize)]
21pub struct RuneResponse {
22 pub id: RuneId,
23 pub block: u64,
24 pub burned: u128,
25 pub divisibility: u8,
26 pub etching: Txid,
27 pub number: u64,
28 pub premine: u128,
29 pub supply: u128,
30 pub max_supply: u128,
31 pub spaced_rune: SpacedRune,
32 pub symbol: Option<char>,
33 pub mint: Option<MintResponse>,
34 pub burns: u128,
35 pub pending_burns: u128,
36 pub pending_mints: u128,
37 pub inscription_id: Option<InscriptionId>,
38 pub timestamp: u64,
39 pub turbo: bool,
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
43pub struct RuneAmount {
44 pub rune_id: RuneId,
45 pub amount: u128,
46}
47
48impl From<(RuneId, u128)> for RuneAmount {
49 fn from((rune_id, amount): (RuneId, u128)) -> Self {
50 Self { rune_id, amount }
51 }
52}
53
54impl BorshSerialize for RuneAmount {
55 fn serialize<W: Write>(&self, writer: &mut W) -> Result<()> {
56 BorshSerialize::serialize(&self.rune_id.block, writer)?;
58 BorshSerialize::serialize(&self.rune_id.tx, writer)?;
59
60 BorshSerialize::serialize(&self.amount, writer)?;
62
63 Ok(())
64 }
65}
66
67impl BorshDeserialize for RuneAmount {
68 fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self> {
69 let block = u64::deserialize_reader(reader)?;
71 let tx = u32::deserialize_reader(reader)?;
72
73 let amount = u128::deserialize_reader(reader)?;
75
76 Ok(RuneAmount {
77 rune_id: RuneId { block, tx },
78 amount,
79 })
80 }
81}