1use super::*;
2
3#[derive(Boilerplate, Debug, PartialEq, Serialize, Deserialize)]
4pub struct RuneHtml {
5 pub entry: RuneEntry,
6 pub id: RuneId,
7 pub mintable: bool,
8 pub parent: Option<InscriptionId>,
9}
10
11impl PageContent for RuneHtml {
12 fn title(&self) -> String {
13 format!("Rune {}", self.entry.spaced_rune)
14 }
15}
16
17#[cfg(test)]
18mod tests {
19 use super::*;
20
21 #[test]
22 fn display() {
23 assert_regex_match!(
24 RuneHtml {
25 entry: RuneEntry {
26 block: 1,
27 burned: 123456789123456789,
28 divisibility: 9,
29 etching: Txid::all_zeros(),
30 mints: 100,
31 terms: Some(Terms {
32 cap: Some(101),
33 offset: (None, None),
34 height: (Some(10), Some(11)),
35 amount: Some(1000000001),
36 }),
37 number: 25,
38 premine: 123456789,
39 spaced_rune: SpacedRune {
40 rune: Rune(u128::MAX),
41 spacers: 1
42 },
43 symbol: Some('%'),
44 timestamp: 0,
45 turbo: true,
46 },
47 id: RuneId { block: 10, tx: 9 },
48 mintable: true,
49 parent: Some(InscriptionId {
50 txid: Txid::all_zeros(),
51 index: 0,
52 }),
53 },
54 "<h1>B•CGDENLQRQWDSLRUGSNLBTMFIJAV</h1>
55.*<a href=/inscription/.*<iframe .* src=/preview/0{64}i0></iframe></a>.*
56<dl>
57 <dt>number</dt>
58 <dd>25</dd>
59 <dt>timestamp</dt>
60 <dd><time>1970-01-01 00:00:00 UTC</time></dd>
61 <dt>id</dt>
62 <dd>10:9</dd>
63 <dt>etching block</dt>
64 <dd><a href=/block/10>10</a></dd>
65 <dt>etching transaction</dt>
66 <dd>9</dd>
67 <dt>mint</dt>
68 <dd>
69 <dl>
70 <dt>start</dt>
71 <dd><a href=/block/10>10</a></dd>
72 <dt>end</dt>
73 <dd><a href=/block/11>11</a></dd>
74 <dt>amount</dt>
75 <dd>1.000000001 %</dd>
76 <dt>mints</dt>
77 <dd>100</dd>
78 <dt>cap</dt>
79 <dd>101</dd>
80 <dt>remaining</dt>
81 <dd>1</dd>
82 <dt>mintable</dt>
83 <dd>true</dd>
84 </dl>
85 </dd>
86 <dt>supply</dt>
87 <dd>100.123456889\u{A0}%</dd>
88 <dt>premine</dt>
89 <dd>0.123456789\u{A0}%</dd>
90 <dt>premine percentage</dt>
91 <dd>0.12%</dd>
92 <dt>burned</dt>
93 <dd>123456789.123456789\u{A0}%</dd>
94 <dt>divisibility</dt>
95 <dd>9</dd>
96 <dt>symbol</dt>
97 <dd>%</dd>
98 <dt>turbo</dt>
99 <dd>true</dd>
100 <dt>etching</dt>
101 <dd><a class=monospace href=/tx/0{64}>0{64}</a></dd>
102 <dt>parent</dt>
103 <dd><a class=monospace href=/inscription/0{64}i0>0{64}i0</a></dd>
104</dl>
105"
106 );
107 }
108
109 #[test]
110 fn display_no_mint() {
111 assert_regex_match!(
112 RuneHtml {
113 entry: RuneEntry {
114 block: 0,
115 burned: 123456789123456789,
116 terms: None,
117 divisibility: 9,
118 etching: Txid::all_zeros(),
119 mints: 0,
120 number: 25,
121 premine: 0,
122 spaced_rune: SpacedRune {
123 rune: Rune(u128::MAX),
124 spacers: 1
125 },
126 symbol: Some('%'),
127 timestamp: 0,
128 turbo: false,
129 },
130 id: RuneId { block: 10, tx: 9 },
131 mintable: false,
132 parent: None,
133 },
134 "<h1>B•CGDENLQRQWDSLRUGSNLBTMFIJAV</h1>
135<dl>.*
136 <dt>mint</dt>
137 <dd>no</dd>
138.*</dl>
139"
140 );
141 }
142
143 #[test]
144 fn display_no_turbo() {
145 assert_regex_match!(
146 RuneHtml {
147 entry: RuneEntry {
148 block: 0,
149 burned: 123456789123456789,
150 terms: None,
151 divisibility: 9,
152 etching: Txid::all_zeros(),
153 mints: 0,
154 number: 25,
155 premine: 0,
156 spaced_rune: SpacedRune {
157 rune: Rune(u128::MAX),
158 spacers: 1
159 },
160 symbol: Some('%'),
161 timestamp: 0,
162 turbo: false,
163 },
164 id: RuneId { block: 10, tx: 9 },
165 mintable: false,
166 parent: None,
167 },
168 "<h1>B•CGDENLQRQWDSLRUGSNLBTMFIJAV</h1>
169<dl>.*
170 <dt>turbo</dt>
171 <dd>false</dd>
172.*</dl>
173"
174 );
175 }
176
177 #[test]
178 fn display_empty_mint() {
179 assert_regex_match!(
180 RuneHtml {
181 entry: RuneEntry {
182 block: 0,
183 burned: 123456789123456789,
184 terms: Some(Terms {
185 cap: None,
186 offset: (None, None),
187 height: (None, None),
188 amount: None,
189 }),
190 divisibility: 9,
191 etching: Txid::all_zeros(),
192 mints: 0,
193 premine: 0,
194 number: 25,
195 spaced_rune: SpacedRune {
196 rune: Rune(u128::MAX),
197 spacers: 1
198 },
199 symbol: Some('%'),
200 timestamp: 0,
201 turbo: false,
202 },
203 id: RuneId { block: 10, tx: 9 },
204 mintable: false,
205 parent: None,
206 },
207 "<h1>B•CGDENLQRQWDSLRUGSNLBTMFIJAV</h1>
208<dl>.*
209 <dt>mint</dt>
210 <dd>
211 <dl>
212 <dt>start</dt>
213 <dd>none</dd>
214 <dt>end</dt>
215 <dd>none</dd>
216 <dt>amount</dt>
217 <dd>none</dd>
218 <dt>mints</dt>
219 <dd>0</dd>
220 <dt>cap</dt>
221 <dd>0</dd>
222 <dt>remaining</dt>
223 <dd>0</dd>
224 <dt>mintable</dt>
225 <dd>false</dd>
226 </dl>
227 </dd>
228.*</dl>
229"
230 );
231 }
232}