exposing tauri operations for spendable vested and reward coins

This commit is contained in:
Jędrzej Stuczyński
2023-03-09 11:28:50 +00:00
parent 60296f2a41
commit 7061beea6e
3 changed files with 42 additions and 0 deletions
+2
View File
@@ -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,
@@ -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<DecCoin, BackendError> {
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<DecCoin, BackendError> {
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,
+4
View File
@@ -18,6 +18,10 @@ export const getLockedCoins = async (): Promise<DecCoin> => invokeWrapper<DecCoi
export const getSpendableCoins = async (): Promise<DecCoin> => invokeWrapper<DecCoin>('spendable_coins');
export const getSpendableVestedCoins = async (): Promise<DecCoin> => invokeWrapper<DecCoin>('spendable_vested_coins');
export const getSpendableRewardCoins = async (): Promise<DecCoin> => invokeWrapper<DecCoin>('spendable_reward_coins');
export const getVestingCoins = async (vestingAccountAddress: string): Promise<DecCoin> =>
invokeWrapper<DecCoin>('vesting_coins', { vestingAccountAddress });