Skip to content

Commit

Permalink
Only show rune mint progress during mint (#4013)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Oct 22, 2024
1 parent 8184208 commit 205dff6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 43 additions & 0 deletions src/templates/rune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ pub struct RuneHtml {

impl RuneHtml {
fn mint_progress(&self) -> Option<Decimal> {
if !self.mintable {
return None;
}

let cap = self.entry.terms?.cap?;

if cap == 0 {
Expand Down Expand Up @@ -284,6 +288,45 @@ mod tests {
}),
},
".*
<dt>mintable</dt>
<dd>false</dd>
</dl>.*"
);

assert_regex_match!(
RuneHtml {
entry: RuneEntry {
block: 0,
burned: 0,
divisibility: 0,
etching: Txid::all_zeros(),
mints: 5555,
terms: Some(Terms {
cap: Some(10000),
offset: (None, None),
height: (None, None),
amount: None,
}),
number: 0,
premine: 0,
spaced_rune: SpacedRune {
rune: Rune(0),
spacers: 0
},
symbol: None,
timestamp: 0,
turbo: false,
},
id: RuneId { block: 0, tx: 0 },
mintable: true,
parent: Some(InscriptionId {
txid: Txid::all_zeros(),
index: 0,
}),
},
".*
<dt>mintable</dt>
<dd>true</dd>
<dt>progress</dt>
<dd>55.55%</dd>.*"
);
Expand Down
2 changes: 1 addition & 1 deletion tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ fn batch(core: &mockcore::Handle, ord: &TestServer, batchfile: batch::File) -> E
mint_definition.push("<dt>mintable</dt>".into());
mint_definition.push(format!("<dd>{mintable}</dd>"));

if terms.cap > 0 {
if mintable {
mint_definition.push("<dt>progress</dt>".into());
mint_definition.push("<dd>0%</dd>".into());
}
Expand Down

0 comments on commit 205dff6

Please sign in to comment.