Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly sum Penumbra-minted values returned in total supply API #4836

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading