Skip to content

Commit

Permalink
Start working on satscard endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Jan 12, 2025
1 parent 9bc54f8 commit 1396e07
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 1 deletion.
6 changes: 6 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,9 @@ replicate:
swap host:
rsync --archive bin/swap root@{{ host }}.ordinals.net:swap
ssh root@{{ host }}.ordinals.net ./swap

cktap *args:
uv run cktap "$@"

satscard:
open "http://localhost:8000/satscard?u=S&o=0&r=a5x2tplf&n=7664168a4ef7b8e8&s=42b209c86ab90be6418d36b0accc3a53c11901861b55be95b763799842d403dc17cd1b74695a7ffe2d78965535d6fe7f6aafc77f6143912a163cb65862e8fb53"
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ pub mod outgoing;
mod re;
mod representation;
pub mod runes;
mod satscard;
pub mod settings;
mod signer;
pub mod subcommand;
Expand Down
10 changes: 10 additions & 0 deletions src/satscard.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use super::*;

#[derive(Deserialize)]
pub(crate) struct Query {
pub(crate) u: String, // S
pub(crate) o: u64, // 0
pub(crate) r: String, // a5x2tplf, fingerprint?
pub(crate) n: String, // 7664168a4ef7b8e8, nonce?
pub(crate) s: String, // 42b209c86ab90be6418d36b0accc3a53c11901861b55be95b763799842d403dc17cd1b74695a7ffe2d78965535d6fe7f6aafc77f6143912a163cb65862e8fb53, address?
}
8 changes: 7 additions & 1 deletion src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use {
InputHtml, InscriptionHtml, InscriptionsBlockHtml, InscriptionsHtml, OutputHtml, PageContent,
PageHtml, ParentsHtml, PreviewAudioHtml, PreviewCodeHtml, PreviewFontHtml, PreviewImageHtml,
PreviewMarkdownHtml, PreviewModelHtml, PreviewPdfHtml, PreviewTextHtml, PreviewUnknownHtml,
PreviewVideoHtml, RareTxt, RuneHtml, RuneNotFoundHtml, RunesHtml, SatHtml, TransactionHtml,
PreviewVideoHtml, RareTxt, RuneHtml, RuneNotFoundHtml, RunesHtml, SatHtml, SatscardHtml,
TransactionHtml,
},
axum::{
extract::{DefaultBodyLimit, Extension, Json, Path, Query},
Expand Down Expand Up @@ -279,6 +280,7 @@ impl Server {
.route("/rune/{rune}", get(Self::rune))
.route("/runes", get(Self::runes))
.route("/runes/{page}", get(Self::runes_paginated))
.route("/satscard", get(Self::satscard))
.route("/sat/{sat}", get(Self::sat))
.route("/satpoint/{satpoint}", get(Self::satpoint))
.route("/search", get(Self::search_by_query))
Expand Down Expand Up @@ -553,6 +555,10 @@ impl Server {
})
}

async fn satscard(Query(query): Query<satscard::Query>) -> SatscardHtml {
SatscardHtml { query }
}

async fn sat(
Extension(server_config): Extension<Arc<ServerConfig>>,
Extension(index): Extension<Arc<Index>>,
Expand Down
2 changes: 2 additions & 0 deletions src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub(crate) use {
rare::RareTxt,
rune_not_found::RuneNotFoundHtml,
sat::SatHtml,
satscard::SatscardHtml,
};

pub use {
Expand Down Expand Up @@ -50,6 +51,7 @@ pub mod rune;
pub mod rune_not_found;
pub mod runes;
pub mod sat;
mod satscard;
pub mod status;
pub mod transaction;

Expand Down
6 changes: 6 additions & 0 deletions src/templates/satscard.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use super::*;

#[derive(Boilerplate)]
pub(crate) struct SatscardHtml {
pub(crate) query: crate::satscard::Query,
}
16 changes: 16 additions & 0 deletions templates/satscard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<h1>Satscard</h1>

%% let crate::satscard::Query { u, o, r, n, s } = &self.query;

<dl>
<dt>u</dt>
<dd>{{ u }}</dd>
<dt>o</dt>
<dd>{{ o }}</dd>
<dt>r</dt>
<dd>{{ r }}</dd>
<dt>n</dt>
<dd>{{ n }}</dd>
<dt>s</dt>
<dd>{{ s }}</dd>
</dl>

0 comments on commit 1396e07

Please sign in to comment.