Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive endpoint for retrieving details about an inscription #2628

Merged
merged 22 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename InscriptionDetailsJson to InscriptionRecursiveJson
  • Loading branch information
lifofifoX committed Feb 2, 2024
commit abf5efa9c647ab4dc53ca3f40b3e025b54da445c
18 changes: 9 additions & 9 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use {
server_config::ServerConfig,
templates::{
BlockHtml, BlockJson, BlocksHtml, BlocksJson, ChildrenHtml, ChildrenJson, ClockSvg,
CollectionsHtml, HomeHtml, InputHtml, InscriptionDetailsJson, InscriptionHtml,
InscriptionJson, InscriptionsBlockHtml, InscriptionsHtml, InscriptionsJson, OutputHtml,
OutputJson, PageContent, PageHtml, PreviewAudioHtml, PreviewCodeHtml, PreviewFontHtml,
PreviewImageHtml, PreviewMarkdownHtml, PreviewModelHtml, PreviewPdfHtml, PreviewTextHtml,
PreviewUnknownHtml, PreviewVideoHtml, RangeHtml, RareTxt, RuneHtml, RuneJson, RunesHtml,
RunesJson, SatHtml, SatInscriptionJson, SatInscriptionsJson, SatJson, TransactionHtml,
TransactionJson,
CollectionsHtml, HomeHtml, InputHtml, InscriptionHtml, InscriptionJson,
InscriptionRecursiveJson, InscriptionsBlockHtml, InscriptionsHtml, InscriptionsJson,
OutputHtml, OutputJson, PageContent, PageHtml, PreviewAudioHtml, PreviewCodeHtml,
PreviewFontHtml, PreviewImageHtml, PreviewMarkdownHtml, PreviewModelHtml, PreviewPdfHtml,
PreviewTextHtml, PreviewUnknownHtml, PreviewVideoHtml, RangeHtml, RareTxt, RuneHtml,
RuneJson, RunesHtml, RunesJson, SatHtml, SatInscriptionJson, SatInscriptionsJson, SatJson,
TransactionHtml, TransactionJson,
},
},
axum::{
Expand Down Expand Up @@ -890,14 +890,14 @@ impl Server {
.map(|address| address.to_string());

Ok(
Json(InscriptionDetailsJson {
Json(InscriptionRecursiveJson {
address,
raphjaph marked this conversation as resolved.
Show resolved Hide resolved
content_type: inscription.content_type().map(|s| s.to_string()),
lifofifoX marked this conversation as resolved.
Show resolved Hide resolved
raphjaph marked this conversation as resolved.
Show resolved Hide resolved
content_length: inscription.content_length(),
raphjaph marked this conversation as resolved.
Show resolved Hide resolved
fee: entry.fee,
height: entry.height,
number: entry.inscription_number,
postage: output.as_ref().map(|o| o.value),
value: output.as_ref().map(|o| o.value),
sat,
satpoint,
lifofifoX marked this conversation as resolved.
Show resolved Hide resolved
timestamp: timestamp(entry.timestamp).timestamp(),
Expand Down
2 changes: 1 addition & 1 deletion src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub(crate) use {
home::HomeHtml,
iframe::Iframe,
input::InputHtml,
inscription::{InscriptionDetailsJson, InscriptionHtml, InscriptionJson},
inscription::{InscriptionHtml, InscriptionJson, InscriptionRecursiveJson},
inscriptions::{InscriptionsHtml, InscriptionsJson},
inscriptions_block::InscriptionsBlockHtml,
metadata::MetadataHtml,
Expand Down
2 changes: 1 addition & 1 deletion src/templates/inscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(crate) struct InscriptionHtml {
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct InscriptionDetailsJson {
pub struct InscriptionRecursiveJson {
pub address: Option<String>,
raphjaph marked this conversation as resolved.
Show resolved Hide resolved
lifofifoX marked this conversation as resolved.
Show resolved Hide resolved
pub content_type: Option<String>,
pub content_length: Option<usize>,
Expand Down
4 changes: 2 additions & 2 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use {
rarity::Rarity,
subcommand::runes::RuneInfo,
templates::{
block::BlockJson, blocks::BlocksJson, inscription::InscriptionDetailsJson,
inscription::InscriptionJson, inscriptions::InscriptionsJson, output::OutputJson,
block::BlockJson, blocks::BlocksJson, inscription::InscriptionJson,
inscription::InscriptionRecursiveJson, inscriptions::InscriptionsJson, output::OutputJson,
rune::RuneJson, runes::RunesJson, sat::SatJson, status::StatusJson,
transaction::TransactionJson,
},
Expand Down
6 changes: 3 additions & 3 deletions tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,21 +308,21 @@ fn recursive_inscription_metadata() {
"application/json"
);

let mut inscription_metadata_json: InscriptionDetailsJson =
let mut inscription_metadata_json: InscriptionRecursiveJson =
serde_json::from_str(&response.text().unwrap()).unwrap();
assert_regex_match!(inscription_metadata_json.address.unwrap(), r"bc1p.*");
inscription_metadata_json.address = None;

pretty_assert_eq!(
inscription_metadata_json,
InscriptionDetailsJson {
InscriptionRecursiveJson {
address: None,
content_type: Some("text/plain;charset=utf-8".to_string()),
content_length: Some(15),
fee: 141,
height: 2,
number: 0,
postage: Some(10000),
value: Some(10000),
sat: ord::Sat(50 * COIN_VALUE),
satpoint: SatPoint {
outpoint: inscription.location.outpoint,
Expand Down