Skip to content

Commit

Permalink
Properly sum values returned in total supply API
Browse files Browse the repository at this point in the history
  • Loading branch information
zbuc committed Aug 26, 2024
1 parent b858016 commit 38b9341
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use super::Server;
impl BankQuery for Server {
/// Returns the total supply for all IBC assets.
/// Internally-minted assets (Penumbra tokens, LP tokens, delegation tokens, etc.)
/// are also included but the supplies are hardcoded at 0 for now.
/// are also included but the supplies are will only reflect what has been transferred out.
///
/// TODO: Implement a way to fetch the total supply for these assets.
/// TODO: implement pagination
Expand Down Expand Up @@ -107,7 +107,11 @@ impl BankQuery for Server {
}
let denom_metadata = denom_metadata.expect("should not be an error");

total_supply.insert(denom_metadata, amount);
// Add to the total supply seen for this denom.
total_supply
.entry(denom_metadata)
.and_modify(|a| *a += amount)
.or_insert(amount);
}

Ok(tonic::Response::new(QueryTotalSupplyResponse {
Expand Down

0 comments on commit 38b9341

Please sign in to comment.