From 7061beea6efdde3952e75cc86fab1edc7763df8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Thu, 9 Mar 2023 11:28:50 +0000 Subject: [PATCH] exposing tauri operations for spendable vested and reward coins --- nym-wallet/src-tauri/src/main.rs | 2 ++ .../src/operations/vesting/queries.rs | 36 +++++++++++++++++++ nym-wallet/src/requests/vesting.ts | 4 +++ 3 files changed, 42 insertions(+) diff --git a/nym-wallet/src-tauri/src/main.rs b/nym-wallet/src-tauri/src/main.rs index 15f03fc481..4677e46e69 100644 --- a/nym-wallet/src-tauri/src/main.rs +++ b/nym-wallet/src-tauri/src/main.rs @@ -126,6 +126,8 @@ fn main() { vesting::queries::locked_coins, vesting::queries::original_vesting, vesting::queries::spendable_coins, + vesting::queries::spendable_vested_coins, + vesting::queries::spendable_reward_coins, vesting::queries::get_historical_vesting_staking_reward, vesting::queries::get_spendable_vested_coins, vesting::queries::get_spendable_reward_coins, diff --git a/nym-wallet/src-tauri/src/operations/vesting/queries.rs b/nym-wallet/src-tauri/src/operations/vesting/queries.rs index afef1d3dac..412e88ea71 100644 --- a/nym-wallet/src-tauri/src/operations/vesting/queries.rs +++ b/nym-wallet/src-tauri/src/operations/vesting/queries.rs @@ -54,6 +54,42 @@ pub(crate) async fn spendable_coins( Ok(display) } +#[tauri::command] +pub(crate) async fn spendable_vested_coins( + state: tauri::State<'_, WalletState>, +) -> Result { + log::info!(">>> Query spendable vested coins"); + let guard = state.read().await; + let client = guard.current_client()?; + + let res = client + .nyxd + .get_spendable_vested_coins(client.nyxd.address().as_ref()) + .await?; + + let display = guard.attempt_convert_to_display_dec_coin(res)?; + log::info!("<<< spendable vested coins = {}", display); + Ok(display) +} + +#[tauri::command] +pub(crate) async fn spendable_reward_coins( + state: tauri::State<'_, WalletState>, +) -> Result { + log::info!(">>> Query spendable reward coins"); + let guard = state.read().await; + let client = guard.current_client()?; + + let res = client + .nyxd + .get_spendable_reward_coins(client.nyxd.address().as_ref()) + .await?; + + let display = guard.attempt_convert_to_display_dec_coin(res)?; + log::info!("<<< spendable reward coins = {}", display); + Ok(display) +} + #[tauri::command] pub(crate) async fn vested_coins( vesting_account_address: &str, diff --git a/nym-wallet/src/requests/vesting.ts b/nym-wallet/src/requests/vesting.ts index 993910dd14..4c64e3f63d 100644 --- a/nym-wallet/src/requests/vesting.ts +++ b/nym-wallet/src/requests/vesting.ts @@ -18,6 +18,10 @@ export const getLockedCoins = async (): Promise => invokeWrapper => invokeWrapper('spendable_coins'); +export const getSpendableVestedCoins = async (): Promise => invokeWrapper('spendable_vested_coins'); + +export const getSpendableRewardCoins = async (): Promise => invokeWrapper('spendable_reward_coins'); + export const getVestingCoins = async (vestingAccountAddress: string): Promise => invokeWrapper('vesting_coins', { vestingAccountAddress });