use new vesting requests and types

This commit is contained in:
fmtabbara
2022-03-04 13:35:01 +00:00
parent d296100ffa
commit f9c73183db
8 changed files with 62 additions and 20 deletions
+1
View File
@@ -66,6 +66,7 @@ fn main() {
vesting::bond::vesting_unbond_gateway,
vesting::bond::vesting_unbond_mixnode,
vesting::bond::withdraw_vested_coins,
vesting::bond::vesting_update_mixnode,
vesting::delegate::vesting_delegate_to_mixnode,
vesting::delegate::vesting_undelegate_from_mixnode,
vesting::queries::delegated_free,
@@ -64,3 +64,14 @@ pub async fn withdraw_vested_coins(
nymd_client!(state).withdraw_vested_coins(amount).await?;
Ok(())
}
#[tauri::command]
pub async fn vesting_update_mixnode(
profit_margin_percent: u8,
state: tauri::State<'_, Arc<RwLock<State>>>,
) -> Result<(), BackendError> {
nymd_client!(state)
.vesting_update_mixnode_config(profit_margin_percent)
.await?;
Ok(())
}
+4 -13
View File
@@ -1,17 +1,8 @@
import { invoke } from '@tauri-apps/api'
import { Coin, DelegationResult, EnumNodeType, Gateway, MixNode, TauriTxResult } from '../types'
import { Coin, DelegationResult, EnumNodeType, Gateway, MixNode, TauriTxResult, TBondArgs } from '../types'
export const bond = async ({
type,
data,
pledge,
ownerSignature,
}: {
type: EnumNodeType
data: MixNode | Gateway
pledge: Coin
ownerSignature: string
}): Promise<any> => await invoke(`bond_${type}`, { [type]: data, ownerSignature, pledge })
export const bond = async ({ type, data, pledge, ownerSignature }: TBondArgs): Promise<any> =>
await invoke(`bond_${type}`, { [type]: data, ownerSignature, pledge })
export const unbond = async (type: EnumNodeType) => await invoke(`unbond_${type}`)
@@ -36,5 +27,5 @@ export const undelegate = async ({
export const send = async (args: { amount: Coin; address: string; memo: string }): Promise<TauriTxResult> =>
await invoke('send', args)
export const updateMixnode = async ({ profitMarginPercent }: { profitMarginPercent: number }) =>
export const updateMixnode = async (profitMarginPercent: number) =>
await invoke('update_mixnode', { profitMarginPercent })
+35 -1
View File
@@ -1,7 +1,16 @@
import { invoke } from '@tauri-apps/api'
import { VestingAccountInfo } from 'src/types/rust/vestingaccountinfo'
import { majorToMinor, minorToMajor } from '.'
import { Coin, DelegationResult, OriginalVestingResponse, Period } from '../types'
import {
Coin,
DelegationResult,
EnumNodeType,
Gateway,
MixNode,
OriginalVestingResponse,
Period,
PledgeData,
} from '../types'
export const getLockedCoins = async (address: string): Promise<Coin> => {
const res: Coin = await invoke('locked_coins', { address })
@@ -36,6 +45,20 @@ export const withdrawVestedCoins = async (amount: string) => {
export const getCurrentVestingPeriod = async (address: string): Promise<Period> =>
await invoke('get_current_vesting_period', { address })
export const vestingBond = async ({
type,
data,
pledge,
ownerSignature,
}: {
type: EnumNodeType
data: MixNode | Gateway
pledge: Coin
ownerSignature: string
}): Promise<any> => await invoke(`vesting_bond_${type}`, { [type]: data, ownerSignature, pledge })
export const vestingUnbond = async (type: EnumNodeType) => await invoke(`vesting_unbond_${type}`)
export const vestingDelegateToMixnode = async ({
identity,
amount,
@@ -49,3 +72,14 @@ export const vestingUnelegateFromMixnode = async (identity: string): Promise<Del
export const getVestingAccountInfo = async (address: string): Promise<VestingAccountInfo> =>
await invoke('get_account_info', { address })
export const getVestingPledgeInfo = async ({
address,
type,
}: {
address?: string
type: EnumNodeType
}): Promise<PledgeData> => await invoke(`vesting_get_${type}_pledge`, { address })
export const vestingUpdateMixnode = async (profitMarginPercent: number) =>
await invoke('vesting_update_mixnode', { profitMarginPercent })
@@ -1,4 +0,0 @@
export interface CoreNodeStatusResponse {
identity: string;
count: number;
}
+9 -1
View File
@@ -1,4 +1,4 @@
import { Coin, Denom, MixNode } from '.'
import { Coin, Denom, Gateway, MixNode, PledgeData } from '.'
export enum EnumNodeType {
mixnode = 'mixnode',
@@ -8,6 +8,7 @@ export enum EnumNodeType {
export type TNodeOwnership = {
hasOwnership: boolean
nodeType?: EnumNodeType
vestingPledge?: PledgeData
}
export type TClientDetails = {
@@ -54,6 +55,13 @@ export type TMixnodeBondDetails = {
proxy: any
}
export type TBondArgs = {
type: EnumNodeType
data: MixNode | Gateway
pledge: Coin
ownerSignature: string
}
export type TCurrency = {
minor: 'UNYM' | 'UNYMT'
major: 'NYM' | 'NYMT'
+1
View File
@@ -20,3 +20,4 @@ export * from './network'
export * from './originalvestingresponse'
export * from './vestingperiod'
export * from './vestingaccountinfo'
export * from './pledgedata'
+1 -1
View File
@@ -2,7 +2,7 @@ import { invoke } from '@tauri-apps/api'
import { appWindow } from '@tauri-apps/api/window'
import bs58 from 'bs58'
import { minor, valid } from 'semver'
import { userBalance, majorToMinor, getGasFee } from '../requests'
import { userBalance, majorToMinor } from '../requests'
import { Coin, Network, Period, TCurrency } from '../types'
export const validateKey = (key: string, bytesLength: number): boolean => {