diff --git a/src/index/entry.rs b/src/index/entry.rs index a908d73595..330c2541cf 100644 --- a/src/index/entry.rs +++ b/src/index/entry.rs @@ -92,6 +92,15 @@ impl RuneEntry { .unwrap_or_default() } + pub fn max_supply(&self) -> u128 { + self.premine + + self.terms.and_then(|terms| terms.cap).unwrap_or_default() + * self + .terms + .and_then(|terms| terms.amount) + .unwrap_or_default() + } + pub fn pile(&self, amount: u128) -> Pile { Pile { amount, diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index f1ab8e2c16..e6e168f2a1 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -3007,6 +3007,8 @@ mod tests {
no
supply
340282366920938463463374607431768211455\u{A0}%
+
mint progress
+
100%
premine
340282366920938463463374607431768211455\u{A0}%
premine percentage
diff --git a/src/templates/rune.rs b/src/templates/rune.rs index c4333315fa..b85c477915 100644 --- a/src/templates/rune.rs +++ b/src/templates/rune.rs @@ -85,6 +85,8 @@ mod tests {
supply
100.123456889\u{A0}%
+
mint progress
+
99.01%
premine
0.123456789\u{A0}%
premine percentage
diff --git a/templates/rune.html b/templates/rune.html index 98a9b1ac00..a45aecaff1 100644 --- a/templates/rune.html +++ b/templates/rune.html @@ -52,6 +52,8 @@

{{ self.entry.spaced_rune }}

%% }
supply
{{ self.entry.pile(self.entry.supply()) }}
+
mint progress
+
{{ Decimal { value: ((self.entry.supply() as f64 / self.entry.max_supply() as f64) * 10000.0) as u128, scale: 2 } }}%
premine
{{ self.entry.pile(self.entry.premine) }}
premine percentage
diff --git a/tests/lib.rs b/tests/lib.rs index 8c53a04cd3..6afc3cefe1 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -12,8 +12,8 @@ use { executable_path::executable_path, mockcore::TransactionTemplate, ord::{ - api, chain::Chain, outgoing::Outgoing, subcommand::runes::RuneInfo, wallet::batch, - InscriptionId, RuneEntry, + api, chain::Chain, decimal::Decimal, outgoing::Outgoing, subcommand::runes::RuneInfo, + wallet::batch, InscriptionId, RuneEntry, }, ordinals::{ Artifact, Charm, Edict, Pile, Rarity, Rune, RuneId, Runestone, Sat, SatPoint, SpacedRune, @@ -321,6 +321,14 @@ fn batch(core: &mockcore::Handle, ord: &TestServer, batchfile: batch::File) -> E let RuneId { block, tx } = id; + let supply_int = supply.to_integer(divisibility).unwrap(); + let premine_int = premine.to_integer(divisibility).unwrap(); + + let mint_progress = Decimal { + value: ((premine_int as f64 / supply_int as f64) * 10000.0) as u128, + scale: 2, + }; + ord.assert_response_regex( format!("/rune/{rune}"), format!( @@ -334,6 +342,8 @@ fn batch(core: &mockcore::Handle, ord: &TestServer, batchfile: batch::File) -> E {}
supply
{premine} {symbol}
+
mint progress
+
{mint_progress}%
premine
{premine} {symbol}
premine percentage