diff --git a/rest/src/main.rs b/rest/src/main.rs index 38e5ef9f..2881af85 100644 --- a/rest/src/main.rs +++ b/rest/src/main.rs @@ -880,11 +880,37 @@ async fn staking_pool() -> Value { } #[get("/cosmos/bank/v1beta1/supply/unom")] -fn bank_supply_unom() -> Value { +async fn bank_supply_unom() -> Value { + let supply = app_client() + .query(|app| app.total_supply()) + .await + .unwrap(); + json!({ "amount": { "denom": "unom", - "amount": "1" + "amount": supply.to_string(), + } + }) +} + +#[get("/cosmos/bank/v1beta1/supply")] +async fn bank_supply() -> Value { + let supply = app_client() + .query(|app| app.total_supply()) + .await + .unwrap(); + + json!({ + "supply": [ + { + "denom": "unom", + "amount": supply.to_string() + } + ], + "pagination": { + "next_key": null, + "total": "1", } }) } @@ -1356,6 +1382,7 @@ fn rocket() -> _ { ibc_apps_transfer_params, ibc_applications_transfer_params, bank_supply_unom, + bank_supply, validators, validator, staking_params, diff --git a/src/app.rs b/src/app.rs index f1f5fc36..84c8f6eb 100644 --- a/src/app.rs +++ b/src/app.rs @@ -202,6 +202,24 @@ impl InnerApp { Ok(()) } + #[query] + pub fn total_supply(&self) -> Result { + let initial_supply: u64 = 17_500_000_000_000; + + let staking_rewards_minted: u64 = self.staking_rewards.amount_minted.into(); + let dev_rewards_minted: u64 = self.dev_rewards.amount_minted.into(); + let community_pool_rewards_minted: u64 = self.community_pool_rewards.amount_minted.into(); + let incentive_pool_rewards_minted: u64 = self.incentive_pool_rewards.amount_minted.into(); + + Ok(Amount::new( + initial_supply + + staking_rewards_minted + + dev_rewards_minted + + community_pool_rewards_minted + + incentive_pool_rewards_minted, + )) + } + #[query] pub fn escrowed_nbtc(&self, address: Address) -> Result { self.ibc.transfer().symbol_balance::(address)