diff --git a/backend/canisters/local_user_index/impl/src/queries/http_request.rs b/backend/canisters/local_user_index/impl/src/queries/http_request.rs index 500b1b38f7..f606f633ac 100644 --- a/backend/canisters/local_user_index/impl/src/queries/http_request.rs +++ b/backend/canisters/local_user_index/impl/src/queries/http_request.rs @@ -4,7 +4,7 @@ use ic_cdk::query; use serde::Serialize; use std::collections::{BTreeMap, HashMap}; use std::str::FromStr; -use types::{BuildVersion, CanisterId, HttpRequest, HttpResponse, TimestampMillis, UserId}; +use types::{BuildVersion, CanisterId, Cycles, CyclesTopUp, HttpRequest, HttpResponse, TimestampMillis, UserId}; #[query] fn http_request(request: HttpRequest) -> HttpResponse { @@ -31,7 +31,12 @@ fn http_request(request: HttpRequest) -> HttpResponse { return HttpResponse::not_found(); }; - build_json_response(&user.cycle_top_ups) + let total = user.cycle_top_ups.iter().map(|c| c.amount).sum(); + + build_json_response(&TopUps { + total, + top_ups: &user.cycle_top_ups, + }) } fn get_user_canister_versions(state: &RuntimeState) -> HttpResponse { @@ -83,3 +88,9 @@ struct UserCanisterVersion { count: u32, users: Vec, } + +#[derive(Serialize)] +struct TopUps<'a> { + total: Cycles, + top_ups: &'a [CyclesTopUp], +}