Skip to content

Commit

Permalink
Remove /runes/balances page (ordinals#3555)
Browse files Browse the repository at this point in the history
  • Loading branch information
lugondev committed Apr 16, 2024
1 parent 22d489b commit ab0b2a9
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 229 deletions.
35 changes: 1 addition & 34 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use {
InscriptionHtml, InscriptionsBlockHtml, InscriptionsHtml, OutputHtml, PageContent, PageHtml,
ParentsHtml, PreviewAudioHtml, PreviewCodeHtml, PreviewFontHtml, PreviewImageHtml,
PreviewMarkdownHtml, PreviewModelHtml, PreviewPdfHtml, PreviewTextHtml, PreviewUnknownHtml,
PreviewVideoHtml, RangeHtml, RareTxt, RuneBalancesHtml, RuneHtml, RunesHtml, SatHtml,
TransactionHtml,
PreviewVideoHtml, RangeHtml, RareTxt, RuneHtml, RunesHtml, SatHtml, TransactionHtml,
},
axum::{
body,
Expand Down Expand Up @@ -256,7 +255,6 @@ impl Server {
.route("/rune/:rune", get(Self::rune))
.route("/runes", get(Self::runes))
.route("/runes/:page", get(Self::runes_paginated))
.route("/runes/balances", get(Self::runes_balances))
.route("/sat/:sat", get(Self::sat))
.route("/search", get(Self::search_by_query))
.route("/search/*query", get(Self::search_by_path))
Expand Down Expand Up @@ -742,37 +740,6 @@ impl Server {
})
}

async fn runes_balances(
Extension(server_config): Extension<Arc<ServerConfig>>,
Extension(index): Extension<Arc<Index>>,
AcceptJson(accept_json): AcceptJson,
) -> ServerResult {
task::block_in_place(|| {
let balances = index.get_rune_balance_map()?;
Ok(if accept_json {
Json(
balances
.into_iter()
.map(|(rune, balances)| {
(
rune,
balances
.into_iter()
.map(|(outpoint, pile)| (outpoint, pile.amount))
.collect(),
)
})
.collect::<BTreeMap<SpacedRune, BTreeMap<OutPoint, u128>>>(),
)
.into_response()
} else {
RuneBalancesHtml { balances }
.page(server_config)
.into_response()
})
})
}

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

Expand All @@ -48,7 +47,6 @@ mod preview;
mod range;
mod rare;
pub mod rune;
pub mod rune_balances;
pub mod runes;
pub mod sat;
pub mod status;
Expand Down
102 changes: 0 additions & 102 deletions src/templates/rune_balances.rs

This file was deleted.

69 changes: 0 additions & 69 deletions tests/json_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,72 +635,3 @@ fn get_runes() {
}
);
}
#[test]
fn get_runes_balances() {
let core = mockcore::builder().network(Network::Regtest).build();

let ord = TestServer::spawn_with_server_args(&core, &["--index-runes", "--regtest"], &[]);

create_wallet(&core, &ord);

core.mine_blocks(3);

let rune0 = Rune(RUNE);
let rune1 = Rune(RUNE + 1);
let rune2 = Rune(RUNE + 2);

let e0 = etch(&core, &ord, rune0);
let e1 = etch(&core, &ord, rune1);
let e2 = etch(&core, &ord, rune2);

core.mine_blocks(1);

let rune_balances: BTreeMap<Rune, BTreeMap<OutPoint, u128>> = vec![
(
rune0,
vec![(
OutPoint {
txid: e0.output.reveal,
vout: 1,
},
1000,
)]
.into_iter()
.collect(),
),
(
rune1,
vec![(
OutPoint {
txid: e1.output.reveal,
vout: 1,
},
1000,
)]
.into_iter()
.collect(),
),
(
rune2,
vec![(
OutPoint {
txid: e2.output.reveal,
vout: 1,
},
1000,
)]
.into_iter()
.collect(),
),
]
.into_iter()
.collect();

let response = ord.json_request("/runes/balances");
assert_eq!(response.status(), StatusCode::OK);

let runes_balance_json: BTreeMap<Rune, BTreeMap<OutPoint, u128>> =
serde_json::from_str(&response.text().unwrap()).unwrap();

pretty_assert_eq!(runes_balance_json, rune_balances);
}
23 changes: 1 addition & 22 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ fn batch(core: &mockcore::Handle, ord: &TestServer, batchfile: batch::File) -> E
let batch::RuneInfo {
destination,
location,
rune,
rune: _,
} = output.rune.clone().unwrap();

if premine.to_integer(divisibility).unwrap() > 0 {
Expand All @@ -370,27 +370,6 @@ fn batch(core: &mockcore::Handle, ord: &TestServer, batchfile: batch::File) -> E

let location = location.unwrap();

ord.assert_response_regex(
"/runes/balances",
format!(
".*<tr>
<td><a href=/rune/{rune}>{rune}</a></td>
<td>
<table>
<tr>
<td class=monospace>
<a href=/output/{location}>{location}</a>
</td>
<td class=monospace>
{premine}\u{A0}{symbol}
</td>
</tr>
</table>
</td>
</tr>.*"
),
);

assert_eq!(core.address(location), destination);
} else {
assert!(destination.is_none());
Expand Down

0 comments on commit ab0b2a9

Please sign in to comment.