diff --git a/src/api.rs b/src/api.rs index 60ffe28f43..cbc92cad91 100644 --- a/src/api.rs +++ b/src/api.rs @@ -93,6 +93,7 @@ pub struct ChildInscriptions { pub struct Inscription { pub address: Option, pub charms: Vec, + pub child_count: u64, pub children: Vec, pub content_length: Option, pub content_type: Option, diff --git a/src/index.rs b/src/index.rs index c5b9f36e99..d1260359a1 100644 --- a/src/index.rs +++ b/src/index.rs @@ -2034,9 +2034,13 @@ impl Index { .get(sequence_number + 1)? .map(|guard| InscriptionEntry::load(guard.value()).id); - let children = rtx + let all_children = rtx .open_multimap_table(SEQUENCE_NUMBER_TO_CHILDREN)? - .get(sequence_number)? + .get(sequence_number)?; + + let child_count = all_children.len(); + + let children = all_children .take(4) .map(|result| { result @@ -2107,6 +2111,7 @@ impl Index { }) .map(|address| address.to_string()), charms: Charm::charms(charms), + child_count, children, content_length: inscription.content_length(), content_type: inscription.content_type().map(|s| s.to_string()), diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index d711bd7761..79cb0bf86c 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -1696,6 +1696,7 @@ impl Server { charm.set(&mut acc); acc })), + child_count: info.child_count, children: info.children, fee: info.fee, height: info.height, @@ -5404,7 +5405,7 @@ next .*.* .*.* .*" ), ); diff --git a/src/templates/inscription.rs b/src/templates/inscription.rs index 3ff2f05d7b..b0d2a00871 100644 --- a/src/templates/inscription.rs +++ b/src/templates/inscription.rs @@ -4,6 +4,7 @@ use super::*; pub(crate) struct InscriptionHtml { pub(crate) chain: Chain, pub(crate) charms: u16, + pub(crate) child_count: u64, pub(crate) children: Vec, pub(crate) fee: u64, pub(crate) height: u32, @@ -268,6 +269,7 @@ mod tests { fn with_children() { assert_regex_match!( InscriptionHtml { + child_count: 2, children: vec![inscription_id(2), inscription_id(3)], fee: 1, inscription: inscription("text/plain;charset=utf-8", "HELLOWORLD"), @@ -291,7 +293,7 @@ mod tests {
id
@@ -330,6 +332,7 @@ mod tests { fn with_paginated_children() { assert_regex_match!( InscriptionHtml { + child_count: 1, children: vec![inscription_id(2)], fee: 1, inscription: inscription("text/plain;charset=utf-8", "HELLOWORLD"), @@ -352,7 +355,7 @@ mod tests {
id
diff --git a/templates/inscription.html b/templates/inscription.html index cbf3c5e646..183481f996 100644 --- a/templates/inscription.html +++ b/templates/inscription.html @@ -35,7 +35,7 @@

Inscription {{ self.number }}

%% } %% } diff --git a/tests/json_api.rs b/tests/json_api.rs index dd6c0d16c2..2886291ff5 100644 --- a/tests/json_api.rs +++ b/tests/json_api.rs @@ -158,6 +158,7 @@ fn get_inscription() { api::Inscription { address: None, charms: vec![Charm::Coin, Charm::Uncommon], + child_count: 0, children: Vec::new(), content_length: Some(3), content_type: Some("text/plain;charset=utf-8".to_string()),