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

Arik/multi parent #1

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub struct Inscription {
pub inscription_number: i32,
pub next: Option<InscriptionId>,
pub output_value: Option<u64>,
pub parent: Option<InscriptionId>,
pub parents: Vec<InscriptionId>,
pub previous: Option<InscriptionId>,
pub rune: Option<SpacedRune>,
pub sat: Option<ordinals::Sat>,
Expand Down
14 changes: 7 additions & 7 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub(crate) struct TransactionInfo {
pub(crate) struct InscriptionInfo {
pub(crate) children: Vec<InscriptionId>,
pub(crate) entry: InscriptionEntry,
pub(crate) parent: Option<InscriptionId>,
pub(crate) parents: Vec<InscriptionId>,
pub(crate) output: Option<TxOut>,
pub(crate) satpoint: SatPoint,
pub(crate) inscription: Inscription,
Expand Down Expand Up @@ -1822,18 +1822,18 @@ impl Index {
None
};

let parent = match entry.parents.first() {
Some(parent) => Some(
let mut parents = Vec::new();
for parent in entry.parents.iter() {
parents.push(
InscriptionEntry::load(
sequence_number_to_inscription_entry
.get(parent)?
.unwrap()
.value(),
)
.id,
),
None => None,
};
);
}

let mut charms = entry.charms;

Expand All @@ -1844,7 +1844,7 @@ impl Index {
Ok(Some(InscriptionInfo {
children,
entry,
parent,
parents,
output,
satpoint,
inscription,
Expand Down
8 changes: 4 additions & 4 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,7 @@ impl Server {
children: info.children,
inscription_number: info.entry.inscription_number,
genesis_height: info.entry.height,
parent: info.parent,
parents: info.parents,
genesis_fee: info.entry.fee,
output_value: info.output.as_ref().map(|o| o.value),
address: info
Expand Down Expand Up @@ -1497,7 +1497,7 @@ impl Server {
inscription_number: info.entry.inscription_number,
next: info.next,
output: info.output,
parent: info.parent,
parents: info.parents,
previous: info.previous,
rune: info.rune,
sat: info.entry.sat,
Expand Down Expand Up @@ -4542,8 +4542,8 @@ next
assert_eq!(
server
.get_json::<api::Inscription>(format!("/inscription/{inscription_id}"))
.parent,
Some(parent_inscription_id),
.parents,
vec![parent_inscription_id],
);

assert_eq!(
Expand Down
6 changes: 3 additions & 3 deletions src/templates/inscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub(crate) struct InscriptionHtml {
pub(crate) inscription_number: i32,
pub(crate) next: Option<InscriptionId>,
pub(crate) output: Option<TxOut>,
pub(crate) parent: Option<InscriptionId>,
pub(crate) parents: Vec<InscriptionId>,
pub(crate) previous: Option<InscriptionId>,
pub(crate) rune: Option<SpacedRune>,
pub(crate) sat: Option<Sat>,
Expand Down Expand Up @@ -209,7 +209,7 @@ mod tests {
fn with_parent() {
assert_regex_match!(
InscriptionHtml {
parent: Some(inscription_id(2)),
parents: vec![inscription_id(2)],
genesis_fee: 1,
inscription: inscription("text/plain;charset=utf-8", "HELLOWORLD"),
inscription_id: inscription_id(1),
Expand All @@ -227,7 +227,7 @@ mod tests {
<dl>
<dt>id</dt>
<dd class=monospace>1{64}i1</dd>
<dt>parent</dt>
<dt>parents</dt>
<dd>
<div class=thumbnails>
<a href=/inscription/2{64}i2><iframe .* src=/preview/2{64}i2></iframe></a>
Expand Down
6 changes: 4 additions & 2 deletions templates/inscription.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ <h1>Inscription {{ self.inscription_number }}</h1>
%% }
<dt>id</dt>
<dd class=monospace>{{ self.inscription_id }}</dd>
%% if let Some(parent) = &self.parent {
<dt>parent</dt>
%% if !&self.parents.is_empty() {
<dt>parents</dt>
%% }
%% for parent in &self.parents {
<dd>
<div class=thumbnails>
{{Iframe::thumbnail(*parent)}}
Expand Down
Loading