From 3622f9e5d73ba0ce88b313573335360f4ae455ba Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Mon, 13 May 2024 08:40:43 -0400 Subject: [PATCH 01/21] Draft Update rune.html presents options to fix #3630 --- templates/rune.html | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/templates/rune.html b/templates/rune.html index 98a9b1ac00..cf3c0cc06e 100644 --- a/templates/rune.html +++ b/templates/rune.html @@ -50,12 +50,35 @@

{{ self.entry.spaced_rune }}

%% } else {
no
%% } -
supply
+
current supply
{{ self.entry.pile(self.entry.supply()) }}
+ %% if let Some(terms) = self.entry.terms { + %% if let Some(symbol) = self.entry.symbol { +
maximum supply
+
{{ (terms.cap.unwrap_or_default() * terms.amount.unwrap_or_default()) + self.entry.premine }}{{ symbol }}
+ %% } } else { +
maximum supply
+
Unable to calculate maximum supply
+ %% } + %% if let Some(terms) = self.entry.terms { + %% if let Some(symbol) = self.entry.symbol { +
supply progress
+
{{ self.entry.pile(self.entry.supply()) }} of {{ (terms.cap.unwrap_or_default() * terms.amount.unwrap_or_default()) + self.entry.premine }}{{ symbol }}
+ %% } } else { +
supply progress
+
Unable to calculate supply progress
+ %% }
premine
{{ self.entry.pile(self.entry.premine) }}
-
premine percentage
+
premine percentage of current supply
{{ Decimal { value: ((self.entry.premine as f64 / self.entry.supply() as f64) * 10000.0) as u128, scale: 2 } }}%
+ %% if let Some(terms) = self.entry.terms { +
premine percentage of maximum supply
+
{{ Decimal { value: ((self.entry.premine as f64 / ((terms.cap.unwrap_or_default() as f64 * terms.amount.unwrap_or_default() as f64) + self.entry.premine as f64)) * 10000.0) as u128, scale: 2 } }}%
+ %% } else { +
premine percentage of maximum supply
+
Unable to calculate premine percentage of maximum supply
+ %% }
burned
{{ self.entry.pile(self.entry.burned) }}
divisibility
From d37966ce2758268e5fc9d530bb21e931c513f8d2 Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Thu, 16 May 2024 17:36:29 -0400 Subject: [PATCH 02/21] Update index.rs to fix ord list command this is Greg's code to fix #3493 - I replicated the issue and verified that this fixed it on my local. --- src/index.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.rs b/src/index.rs index b3e26e02d0..d7a272b15f 100644 --- a/src/index.rs +++ b/src/index.rs @@ -1660,7 +1660,7 @@ impl Index { return Ok(false); }; - if !info.in_active_chain.unwrap_or_default() { + if info.blockhash.is_none() { return Ok(false); } From 2eb09fb4f4d93b2e2a1879bf73d244ae385fd5a3 Mon Sep 17 00:00:00 2001 From: nine Date: Sun, 19 May 2024 18:02:40 -0400 Subject: [PATCH 03/21] Updated runes_are_displayed_on_rune_page test to account for new html fields --- src/subcommand/server.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index 2a0c3706f6..8b42cf8868 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -2906,13 +2906,19 @@ mod tests {
1
mint
no
-
supply
+
current supply
340282366920938463463374607431768211455\u{A0}%
-
premine
+
maximum supply
+
Unable to calculate maximum supply
+
supply progress
+
Unable to calculate supply progress
+
premine
340282366920938463463374607431768211455\u{A0}%
-
premine percentage
+
premine percentage of current supply
100%
-
burned
+
premine percentage of maximum supply
+
Unable to calculate premine percentage of maximum supply
+
burned
0\u{A0}%
divisibility
0
From 273b432f994bd419221380d070e7ab386f5f7af9 Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Mon, 20 May 2024 16:07:19 -0400 Subject: [PATCH 04/21] Update rune.html reverting changes for test troubleshooting From 2b58a7bd3011e719107bdbda655df7d4d5c4f762 Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Mon, 20 May 2024 16:12:32 -0400 Subject: [PATCH 05/21] Update rune.html real revert to 0.18.5 rune.html --- templates/rune.html | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/templates/rune.html b/templates/rune.html index cf3c0cc06e..98a9b1ac00 100644 --- a/templates/rune.html +++ b/templates/rune.html @@ -50,35 +50,12 @@

{{ self.entry.spaced_rune }}

%% } else {
no
%% } -
current supply
+
supply
{{ self.entry.pile(self.entry.supply()) }}
- %% if let Some(terms) = self.entry.terms { - %% if let Some(symbol) = self.entry.symbol { -
maximum supply
-
{{ (terms.cap.unwrap_or_default() * terms.amount.unwrap_or_default()) + self.entry.premine }}{{ symbol }}
- %% } } else { -
maximum supply
-
Unable to calculate maximum supply
- %% } - %% if let Some(terms) = self.entry.terms { - %% if let Some(symbol) = self.entry.symbol { -
supply progress
-
{{ self.entry.pile(self.entry.supply()) }} of {{ (terms.cap.unwrap_or_default() * terms.amount.unwrap_or_default()) + self.entry.premine }}{{ symbol }}
- %% } } else { -
supply progress
-
Unable to calculate supply progress
- %% }
premine
{{ self.entry.pile(self.entry.premine) }}
-
premine percentage of current supply
+
premine percentage
{{ Decimal { value: ((self.entry.premine as f64 / self.entry.supply() as f64) * 10000.0) as u128, scale: 2 } }}%
- %% if let Some(terms) = self.entry.terms { -
premine percentage of maximum supply
-
{{ Decimal { value: ((self.entry.premine as f64 / ((terms.cap.unwrap_or_default() as f64 * terms.amount.unwrap_or_default() as f64) + self.entry.premine as f64)) * 10000.0) as u128, scale: 2 } }}%
- %% } else { -
premine percentage of maximum supply
-
Unable to calculate premine percentage of maximum supply
- %% }
burned
{{ self.entry.pile(self.entry.burned) }}
divisibility
From ae7696b4763a10ce8ebfa3ae359d578671ba470e Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Mon, 20 May 2024 16:20:15 -0400 Subject: [PATCH 06/21] Revert server.rs test case for troubleshooting From 1c28cc9f9ecf3a7ce3ad33c72481c5255add6de1 Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Mon, 20 May 2024 16:25:42 -0400 Subject: [PATCH 07/21] reverting server.rs tests --- src/subcommand/server.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index 8b42cf8868..2a0c3706f6 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -2906,19 +2906,13 @@ mod tests {
1
mint
no
-
current supply
+
supply
340282366920938463463374607431768211455\u{A0}%
-
maximum supply
-
Unable to calculate maximum supply
-
supply progress
-
Unable to calculate supply progress
-
premine
+
premine
340282366920938463463374607431768211455\u{A0}%
-
premine percentage of current supply
+
premine percentage
100%
-
premine percentage of maximum supply
-
Unable to calculate premine percentage of maximum supply
-
burned
+
burned
0\u{A0}%
divisibility
0
From f45380b759fcf0300bfa55a4351e6ef96f65cc8a Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Wed, 22 May 2024 14:49:05 -0400 Subject: [PATCH 08/21] adding mint_progress to rune.html adding new field `mint progress` to rune.html to show the current supply of max supply ratio. --- templates/rune.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/rune.html b/templates/rune.html index 98a9b1ac00..5844699351 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
+
{{ self.entry.pile(self.entry.supply()) }} of {{ self.entry.pile(self.entry.max_supply()) }}
premine
{{ self.entry.pile(self.entry.premine) }}
premine percentage
From b535d944bca047ea47d634852230f47c2aaa212b Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Wed, 22 May 2024 14:52:12 -0400 Subject: [PATCH 09/21] Update batch function in lib.rs update batch function to account for new `mint_progress` field --- tests/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/lib.rs b/tests/lib.rs index 8c53a04cd3..54ddb810bd 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -334,6 +334,8 @@ fn batch(core: &mockcore::Handle, ord: &TestServer, batchfile: batch::File) -> E {}
supply
{premine} {symbol}
+
mint progress
+
{premine} {symbol} of ({supply}) {symbol}
premine
{premine} {symbol}
premine percentage
From fb4c6085b99e29abd4b5408571d499f904fac077 Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Wed, 22 May 2024 14:54:24 -0400 Subject: [PATCH 10/21] add max_supply function to entry.rs added fn max_supply --- src/index/entry.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/index/entry.rs b/src/index/entry.rs index faa3d2343a..26807e68f4 100644 --- a/src/index/entry.rs +++ b/src/index/entry.rs @@ -92,6 +92,16 @@ impl RuneEntry { .unwrap_or_default() } + pub fn max_supply(&self) -> u128 { + let cap = self.terms.map_or(0, |terms| terms.cap.unwrap_or_default()); + self.premine + + cap + * self + .terms + .and_then(|terms| terms.amount) + .unwrap_or_default() + } + pub fn pile(&self, amount: u128) -> Pile { Pile { amount, From e72ef173b4467311baf348ee5f32f0b083527889 Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Wed, 22 May 2024 14:56:55 -0400 Subject: [PATCH 11/21] update runes_are_displayed_on_rune_page test in server.rs added mint_progress to runes_are_displayed_on_rune_page test --- src/subcommand/server.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index 2a0c3706f6..15c05046d6 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -2908,6 +2908,8 @@ mod tests {
no
supply
340282366920938463463374607431768211455\u{A0}%
+
mint progress
+
340282366920938463463374607431768211455\u{A0}% of 340282366920938463463374607431768211455\u{A0}%
premine
340282366920938463463374607431768211455\u{A0}%
premine percentage
From e0def19dc576212048baf3f125de31f0f64c3a80 Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Wed, 22 May 2024 14:58:23 -0400 Subject: [PATCH 12/21] Update display test in rune.rs added `mint_progress` to display test --- src/templates/rune.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/templates/rune.rs b/src/templates/rune.rs index c4333315fa..b818c1437b 100644 --- a/src/templates/rune.rs +++ b/src/templates/rune.rs @@ -85,6 +85,8 @@ mod tests {
supply
100.123456889\u{A0}%
+
mint progress
+
100.123456889\u{A0}% of 101.12345689\u{A0}%
premine
0.123456789\u{A0}%
premine percentage
From 3dfda24d68aff79a60017087dcdc4e66a8141e0c Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Wed, 22 May 2024 15:10:49 -0400 Subject: [PATCH 13/21] cargo fmt fix for entry.rs bad indent --- src/index/entry.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index/entry.rs b/src/index/entry.rs index 26807e68f4..f2688906d2 100644 --- a/src/index/entry.rs +++ b/src/index/entry.rs @@ -92,7 +92,7 @@ impl RuneEntry { .unwrap_or_default() } - pub fn max_supply(&self) -> u128 { + pub fn max_supply(&self) -> u128 { let cap = self.terms.map_or(0, |terms| terms.cap.unwrap_or_default()); self.premine + cap From cb25d931272afd0536666e76673a6f9705d8f0e8 Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Thu, 23 May 2024 16:13:06 -0400 Subject: [PATCH 14/21] Update rune.html changing mint progress to percentage --- templates/rune.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/rune.html b/templates/rune.html index 5844699351..a45aecaff1 100644 --- a/templates/rune.html +++ b/templates/rune.html @@ -53,7 +53,7 @@

{{ self.entry.spaced_rune }}

supply
{{ self.entry.pile(self.entry.supply()) }}
mint progress
-
{{ self.entry.pile(self.entry.supply()) }} of {{ self.entry.pile(self.entry.max_supply()) }}
+
{{ 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
From 92151a6b5e8f208bac787cd5ac72e6588beca0c9 Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Thu, 23 May 2024 16:14:16 -0400 Subject: [PATCH 15/21] Update server.rs changing `mint progress` to percentage --- src/subcommand/server.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index 15c05046d6..354d59a0a4 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -2909,7 +2909,7 @@ mod tests {
supply
340282366920938463463374607431768211455\u{A0}%
mint progress
-
340282366920938463463374607431768211455\u{A0}% of 340282366920938463463374607431768211455\u{A0}%
+
100%
premine
340282366920938463463374607431768211455\u{A0}%
premine percentage
From 9e5c19f924c8f6af3b82c23150dd373a31a0ed7f Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Thu, 23 May 2024 16:14:57 -0400 Subject: [PATCH 16/21] Update runes.rs changing `mint progress` to percentage --- src/templates/runes.rs | 283 ++++++++++++++++++++++++++++++----------- 1 file changed, 212 insertions(+), 71 deletions(-) diff --git a/src/templates/runes.rs b/src/templates/runes.rs index bfc7e51760..b85c477915 100644 --- a/src/templates/runes.rs +++ b/src/templates/runes.rs @@ -1,16 +1,16 @@ use super::*; #[derive(Boilerplate, Debug, PartialEq, Serialize, Deserialize)] -pub struct RunesHtml { - pub entries: Vec<(RuneId, RuneEntry)>, - pub more: bool, - pub prev: Option, - pub next: Option, +pub struct RuneHtml { + pub entry: RuneEntry, + pub id: RuneId, + pub mintable: bool, + pub parent: Option, } -impl PageContent for RunesHtml { +impl PageContent for RuneHtml { fn title(&self) -> String { - "Runes".to_string() + format!("Rune {}", self.entry.spaced_rune) } } @@ -20,74 +20,215 @@ mod tests { #[test] fn display() { - assert_eq!( - RunesHtml { - entries: vec![( - RuneId { block: 0, tx: 0 }, - RuneEntry { - spaced_rune: SpacedRune { - rune: Rune(26), - spacers: 1 - }, - ..default() - } - )], - more: false, - prev: None, - next: None, - } - .to_string(), - "

Runes

- -
- prev - next -
" + assert_regex_match!( + RuneHtml { + entry: RuneEntry { + block: 1, + burned: 123456789123456789, + divisibility: 9, + etching: Txid::all_zeros(), + mints: 100, + terms: Some(Terms { + cap: Some(101), + offset: (None, None), + height: (Some(10), Some(11)), + amount: Some(1000000001), + }), + number: 25, + premine: 123456789, + spaced_rune: SpacedRune { + rune: Rune(u128::MAX), + spacers: 1 + }, + symbol: Some('%'), + timestamp: 0, + turbo: true, + }, + id: RuneId { block: 10, tx: 9 }, + mintable: true, + parent: Some(InscriptionId { + txid: Txid::all_zeros(), + index: 0, + }), + }, + "

B•CGDENLQRQWDSLRUGSNLBTMFIJAV

+.*.* +
+
number
+
25
+
timestamp
+
+
id
+
10:9
+
etching block
+
10
+
etching transaction
+
9
+
mint
+
+
+
start
+
10
+
end
+
11
+
amount
+
1.000000001 %
+
mints
+
100
+
cap
+
101
+
remaining
+
1
+
mintable
+
true
+
+
+
supply
+
100.123456889\u{A0}%
+
mint progress
+
99.01%
+
premine
+
0.123456789\u{A0}%
+
premine percentage
+
0.12%
+
burned
+
123456789.123456789\u{A0}%
+
divisibility
+
9
+
symbol
+
%
+
turbo
+
true
+
etching
+
0{64}
+
parent
+
0{64}i0
+
+" ); } #[test] - fn with_prev_and_next() { - assert_eq!( - RunesHtml { - entries: vec![ - ( - RuneId { block: 0, tx: 0 }, - RuneEntry { - spaced_rune: SpacedRune { - rune: Rune(0), - spacers: 0 - }, - ..Default::default() - } - ), - ( - RuneId { block: 0, tx: 1 }, - RuneEntry { - spaced_rune: SpacedRune { - rune: Rune(2), - spacers: 0 - }, - ..Default::default() - } - ) - ], - prev: Some(1), - next: Some(2), - more: true, - } - .to_string(), - "

Runes

-
    -
  • A
  • -
  • C
  • -
-
- - -
" + fn display_no_mint() { + assert_regex_match!( + RuneHtml { + entry: RuneEntry { + block: 0, + burned: 123456789123456789, + terms: None, + divisibility: 9, + etching: Txid::all_zeros(), + mints: 0, + number: 25, + premine: 0, + spaced_rune: SpacedRune { + rune: Rune(u128::MAX), + spacers: 1 + }, + symbol: Some('%'), + timestamp: 0, + turbo: false, + }, + id: RuneId { block: 10, tx: 9 }, + mintable: false, + parent: None, + }, + "

B•CGDENLQRQWDSLRUGSNLBTMFIJAV

+
.* +
mint
+
no
+.*
+" + ); + } + + #[test] + fn display_no_turbo() { + assert_regex_match!( + RuneHtml { + entry: RuneEntry { + block: 0, + burned: 123456789123456789, + terms: None, + divisibility: 9, + etching: Txid::all_zeros(), + mints: 0, + number: 25, + premine: 0, + spaced_rune: SpacedRune { + rune: Rune(u128::MAX), + spacers: 1 + }, + symbol: Some('%'), + timestamp: 0, + turbo: false, + }, + id: RuneId { block: 10, tx: 9 }, + mintable: false, + parent: None, + }, + "

B•CGDENLQRQWDSLRUGSNLBTMFIJAV

+
.* +
turbo
+
false
+.*
+" + ); + } + + #[test] + fn display_empty_mint() { + assert_regex_match!( + RuneHtml { + entry: RuneEntry { + block: 0, + burned: 123456789123456789, + terms: Some(Terms { + cap: None, + offset: (None, None), + height: (None, None), + amount: None, + }), + divisibility: 9, + etching: Txid::all_zeros(), + mints: 0, + premine: 0, + number: 25, + spaced_rune: SpacedRune { + rune: Rune(u128::MAX), + spacers: 1 + }, + symbol: Some('%'), + timestamp: 0, + turbo: false, + }, + id: RuneId { block: 10, tx: 9 }, + mintable: false, + parent: None, + }, + "

B•CGDENLQRQWDSLRUGSNLBTMFIJAV

+
.* +
mint
+
+
+
start
+
none
+
end
+
none
+
amount
+
none
+
mints
+
0
+
cap
+
0
+
remaining
+
0
+
mintable
+
false
+
+
+.*
+" ); } } From c7c869f3f653d46cff6bdb788c8105d968612412 Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Thu, 23 May 2024 16:15:39 -0400 Subject: [PATCH 17/21] Update lib.rs changing `mint progress` to percentage --- tests/lib.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/lib.rs b/tests/lib.rs index 54ddb810bd..9415dd148e 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -12,7 +12,7 @@ use { executable_path::executable_path, mockcore::TransactionTemplate, ord::{ - api, chain::Chain, outgoing::Outgoing, subcommand::runes::RuneInfo, wallet::batch, + api, chain::Chain, decimal::Decimal, outgoing::Outgoing, subcommand::runes::RuneInfo, wallet::batch, InscriptionId, RuneEntry, }, ordinals::{ @@ -320,6 +320,11 @@ 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}"), @@ -335,7 +340,7 @@ fn batch(core: &mockcore::Handle, ord: &TestServer, batchfile: batch::File) -> E
supply
{premine} {symbol}
mint progress
-
{premine} {symbol} of ({supply}) {symbol}
+
{mint_progress}%
premine
{premine} {symbol}
premine percentage
From 4337b6b2f22783aeff42e812c01896dd8f4d94c0 Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Thu, 23 May 2024 16:51:19 -0400 Subject: [PATCH 18/21] Update runes.rs reverting previous changes; this file was accidentally included in this change. --- src/templates/runes.rs | 283 +++++++++++------------------------------ 1 file changed, 71 insertions(+), 212 deletions(-) diff --git a/src/templates/runes.rs b/src/templates/runes.rs index b85c477915..bfc7e51760 100644 --- a/src/templates/runes.rs +++ b/src/templates/runes.rs @@ -1,16 +1,16 @@ use super::*; #[derive(Boilerplate, Debug, PartialEq, Serialize, Deserialize)] -pub struct RuneHtml { - pub entry: RuneEntry, - pub id: RuneId, - pub mintable: bool, - pub parent: Option, +pub struct RunesHtml { + pub entries: Vec<(RuneId, RuneEntry)>, + pub more: bool, + pub prev: Option, + pub next: Option, } -impl PageContent for RuneHtml { +impl PageContent for RunesHtml { fn title(&self) -> String { - format!("Rune {}", self.entry.spaced_rune) + "Runes".to_string() } } @@ -20,215 +20,74 @@ mod tests { #[test] fn display() { - assert_regex_match!( - RuneHtml { - entry: RuneEntry { - block: 1, - burned: 123456789123456789, - divisibility: 9, - etching: Txid::all_zeros(), - mints: 100, - terms: Some(Terms { - cap: Some(101), - offset: (None, None), - height: (Some(10), Some(11)), - amount: Some(1000000001), - }), - number: 25, - premine: 123456789, - spaced_rune: SpacedRune { - rune: Rune(u128::MAX), - spacers: 1 - }, - symbol: Some('%'), - timestamp: 0, - turbo: true, - }, - id: RuneId { block: 10, tx: 9 }, - mintable: true, - parent: Some(InscriptionId { - txid: Txid::all_zeros(), - index: 0, - }), - }, - "

B•CGDENLQRQWDSLRUGSNLBTMFIJAV

-.*.* -
-
number
-
25
-
timestamp
-
-
id
-
10:9
-
etching block
-
10
-
etching transaction
-
9
-
mint
-
-
-
start
-
10
-
end
-
11
-
amount
-
1.000000001 %
-
mints
-
100
-
cap
-
101
-
remaining
-
1
-
mintable
-
true
-
-
-
supply
-
100.123456889\u{A0}%
-
mint progress
-
99.01%
-
premine
-
0.123456789\u{A0}%
-
premine percentage
-
0.12%
-
burned
-
123456789.123456789\u{A0}%
-
divisibility
-
9
-
symbol
-
%
-
turbo
-
true
-
etching
-
0{64}
-
parent
-
0{64}i0
-
-" + assert_eq!( + RunesHtml { + entries: vec![( + RuneId { block: 0, tx: 0 }, + RuneEntry { + spaced_rune: SpacedRune { + rune: Rune(26), + spacers: 1 + }, + ..default() + } + )], + more: false, + prev: None, + next: None, + } + .to_string(), + "

Runes

+ +
+ prev + next +
" ); } #[test] - fn display_no_mint() { - assert_regex_match!( - RuneHtml { - entry: RuneEntry { - block: 0, - burned: 123456789123456789, - terms: None, - divisibility: 9, - etching: Txid::all_zeros(), - mints: 0, - number: 25, - premine: 0, - spaced_rune: SpacedRune { - rune: Rune(u128::MAX), - spacers: 1 - }, - symbol: Some('%'), - timestamp: 0, - turbo: false, - }, - id: RuneId { block: 10, tx: 9 }, - mintable: false, - parent: None, - }, - "

B•CGDENLQRQWDSLRUGSNLBTMFIJAV

-
.* -
mint
-
no
-.*
-" - ); - } - - #[test] - fn display_no_turbo() { - assert_regex_match!( - RuneHtml { - entry: RuneEntry { - block: 0, - burned: 123456789123456789, - terms: None, - divisibility: 9, - etching: Txid::all_zeros(), - mints: 0, - number: 25, - premine: 0, - spaced_rune: SpacedRune { - rune: Rune(u128::MAX), - spacers: 1 - }, - symbol: Some('%'), - timestamp: 0, - turbo: false, - }, - id: RuneId { block: 10, tx: 9 }, - mintable: false, - parent: None, - }, - "

B•CGDENLQRQWDSLRUGSNLBTMFIJAV

-
.* -
turbo
-
false
-.*
-" - ); - } - - #[test] - fn display_empty_mint() { - assert_regex_match!( - RuneHtml { - entry: RuneEntry { - block: 0, - burned: 123456789123456789, - terms: Some(Terms { - cap: None, - offset: (None, None), - height: (None, None), - amount: None, - }), - divisibility: 9, - etching: Txid::all_zeros(), - mints: 0, - premine: 0, - number: 25, - spaced_rune: SpacedRune { - rune: Rune(u128::MAX), - spacers: 1 - }, - symbol: Some('%'), - timestamp: 0, - turbo: false, - }, - id: RuneId { block: 10, tx: 9 }, - mintable: false, - parent: None, - }, - "

B•CGDENLQRQWDSLRUGSNLBTMFIJAV

-
.* -
mint
-
-
-
start
-
none
-
end
-
none
-
amount
-
none
-
mints
-
0
-
cap
-
0
-
remaining
-
0
-
mintable
-
false
-
-
-.*
-" + fn with_prev_and_next() { + assert_eq!( + RunesHtml { + entries: vec![ + ( + RuneId { block: 0, tx: 0 }, + RuneEntry { + spaced_rune: SpacedRune { + rune: Rune(0), + spacers: 0 + }, + ..Default::default() + } + ), + ( + RuneId { block: 0, tx: 1 }, + RuneEntry { + spaced_rune: SpacedRune { + rune: Rune(2), + spacers: 0 + }, + ..Default::default() + } + ) + ], + prev: Some(1), + next: Some(2), + more: true, + } + .to_string(), + "

Runes

+
    +
  • A
  • +
  • C
  • +
+
+ + +
" ); } } From 8441f15da5f425f49f7e8d563843217a6d2ef787 Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Thu, 23 May 2024 16:52:32 -0400 Subject: [PATCH 19/21] Update rune.rs changing `mint progress` to percentage --- src/templates/rune.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/rune.rs b/src/templates/rune.rs index b818c1437b..b85c477915 100644 --- a/src/templates/rune.rs +++ b/src/templates/rune.rs @@ -86,7 +86,7 @@ mod tests {
supply
100.123456889\u{A0}%
mint progress
-
100.123456889\u{A0}% of 101.12345689\u{A0}%
+
99.01%
premine
0.123456789\u{A0}%
premine percentage
From f54bf272e0f7661a4d5f9aa2a18dae0630c6574c Mon Sep 17 00:00:00 2001 From: nine <118634361+cryptoni9n@users.noreply.github.com> Date: Thu, 23 May 2024 17:00:35 -0400 Subject: [PATCH 20/21] lint fixes for lib.rs cargo fmt --- tests/lib.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/lib.rs b/tests/lib.rs index 9415dd148e..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, decimal::Decimal, 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, @@ -320,11 +320,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}; + 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}"), From 869b45f166e49bc91e10100cfa45bbe1941357ed Mon Sep 17 00:00:00 2001 From: raphjaph Date: Fri, 24 May 2024 12:55:10 +0200 Subject: [PATCH 21/21] Amend --- src/index/entry.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/index/entry.rs b/src/index/entry.rs index 7b001cb6a0..330c2541cf 100644 --- a/src/index/entry.rs +++ b/src/index/entry.rs @@ -93,9 +93,8 @@ impl RuneEntry { } pub fn max_supply(&self) -> u128 { - let cap = self.terms.map_or(0, |terms| terms.cap.unwrap_or_default()); self.premine - + cap + + self.terms.and_then(|terms| terms.cap).unwrap_or_default() * self .terms .and_then(|terms| terms.amount)