Skip to content

Commit f2ddf28

Browse files
committed
fix: revert totals endpoint handler changes
Signed-off-by: William Hankins <[email protected]>
1 parent 60c5074 commit f2ddf28

File tree

2 files changed

+2
-77
lines changed

2 files changed

+2
-77
lines changed

modules/rest_blockfrost/src/handlers/accounts.rs

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -748,82 +748,7 @@ pub async fn handle_account_totals_blockfrost(
748748
params: Vec<String>,
749749
handlers_config: Arc<HandlersConfig>,
750750
) -> Result<RESTResponse> {
751-
let account = match parse_stake_address(&params) {
752-
Ok(addr) => addr,
753-
Err(resp) => return Ok(resp),
754-
};
755-
756-
// Get addresses from historical accounts state
757-
let msg = Arc::new(Message::StateQuery(StateQuery::Accounts(
758-
AccountsStateQuery::GetAccountAssociatedAddresses {
759-
account: account.clone(),
760-
},
761-
)));
762-
let addresses = query_state(
763-
&context,
764-
&handlers_config.historical_accounts_query_topic,
765-
msg,
766-
|message| match message {
767-
Message::StateQueryResponse(StateQueryResponse::Accounts(
768-
AccountsStateQueryResponse::AccountAssociatedAddresses(addresses),
769-
)) => Ok(Some(addresses)),
770-
Message::StateQueryResponse(StateQueryResponse::Accounts(
771-
AccountsStateQueryResponse::NotFound,
772-
)) => Ok(None),
773-
Message::StateQueryResponse(StateQueryResponse::Accounts(
774-
AccountsStateQueryResponse::Error(e),
775-
)) => Err(anyhow::anyhow!(
776-
"Internal server error while retrieving account addresses: {e}"
777-
)),
778-
_ => Err(anyhow::anyhow!(
779-
"Unexpected message type while retrieving account addresses"
780-
)),
781-
},
782-
)
783-
.await?;
784-
785-
let Some(addresses) = addresses else {
786-
return Ok(RESTResponse::with_text(404, "Account not found"));
787-
};
788-
789-
// Get totals from address state
790-
let msg = Arc::new(Message::StateQuery(StateQuery::Addresses(
791-
AddressStateQuery::GetAddressesTotals { addresses },
792-
)));
793-
let totals = query_state(
794-
&context,
795-
&handlers_config.addresses_query_topic,
796-
msg,
797-
|message| match message {
798-
Message::StateQueryResponse(StateQueryResponse::Addresses(
799-
AddressStateQueryResponse::AddressesTotals(utxos),
800-
)) => Ok(utxos),
801-
Message::StateQueryResponse(StateQueryResponse::Addresses(
802-
AddressStateQueryResponse::Error(e),
803-
)) => Err(anyhow::anyhow!(
804-
"Internal server error while retrieving address totals: {e}"
805-
)),
806-
_ => Err(anyhow::anyhow!(
807-
"Unexpected message type while retrieving address totals"
808-
)),
809-
},
810-
)
811-
.await?;
812-
813-
let rest_response = AccountTotalsREST {
814-
stake_address: account.to_string()?,
815-
received_sum: totals.received.into(),
816-
sent_sum: totals.sent.into(),
817-
tx_count: totals.tx_count,
818-
};
819-
820-
match serde_json::to_string_pretty(&rest_response) {
821-
Ok(json) => Ok(RESTResponse::with_json(200, &json)),
822-
Err(e) => Ok(RESTResponse::with_text(
823-
500,
824-
&format!("Internal server error while serializing totals: {e}"),
825-
)),
826-
}
751+
Ok(RESTResponse::with_text(501, "Not implemented"))
827752
}
828753

829754
/// Handle `/accounts/{stake_address}/utxos` Blockfrost-compatible endpoint

modules/rest_blockfrost/src/rest_blockfrost.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ impl BlockfrostREST {
343343
handle_account_assets_blockfrost,
344344
);
345345

346-
// Handler for /accounts/{stake_address}/addreesses/total
346+
// Handler for /accounts/{stake_address}/addresses/total
347347
register_handler(
348348
context.clone(),
349349
DEFAULT_HANDLE_ACCOUNT_TOTALS_TOPIC,

0 commit comments

Comments
 (0)