diff --git a/tauri-wallet/src-tauri/src/main.rs b/tauri-wallet/src-tauri/src/main.rs index f62d229dd1..a2aa4ed9b8 100644 --- a/tauri-wallet/src-tauri/src/main.rs +++ b/tauri-wallet/src-tauri/src/main.rs @@ -478,7 +478,7 @@ async fn get_fee( let fee = client.get_fee(operation); let mut coin = Coin { amount: "0".to_string(), - denom: "upunk".to_string(), + denom: "punk".to_string(), }; for f in fee.amount { coin = coin + f.into(); diff --git a/tauri-wallet/src/requests/index.ts b/tauri-wallet/src/requests/index.ts index 7aa82a891f..aef86bb51e 100644 --- a/tauri-wallet/src/requests/index.ts +++ b/tauri-wallet/src/requests/index.ts @@ -1,5 +1,5 @@ import { invoke } from '@tauri-apps/api' -import { TCreateAccount, TSignInWithMnemonic } from '../types' +import { Coin, Operation, TCreateAccount, TSignInWithMnemonic } from '../types' export const createAccount = async (): Promise => await invoke('create_new_account') @@ -8,3 +8,11 @@ export const signInWithMnemonic = async ( mnemonic: string ): Promise => await invoke('connect_with_mnemonic', { mnemonic }) + +export const minorToMajor = async (amount: string): Promise => + await invoke('minor_to_major', { amount }) +export const majorToMinor = async (amount: string): Promise => + await invoke('major_to_minor', { amount }) + +export const getGasFee = async (operation: Operation): Promise => + await invoke('get_fee', { operation }) diff --git a/tauri-wallet/src/routes/send/SendReview.tsx b/tauri-wallet/src/routes/send/SendReview.tsx index 9aa06532dd..e9d0e23095 100644 --- a/tauri-wallet/src/routes/send/SendReview.tsx +++ b/tauri-wallet/src/routes/send/SendReview.tsx @@ -1,17 +1,35 @@ -import React, { useContext } from 'react' -import { Card, Divider, Grid, Theme, Typography } from '@material-ui/core' +import React, { useContext, useEffect, useState } from 'react' +import { + Card, + CircularProgress, + Divider, + Grid, + Theme, + Typography, +} from '@material-ui/core' import { useTheme } from '@material-ui/styles' import { useFormContext } from 'react-hook-form' import { ClientContext } from '../../context/main' +import { getGasFee } from '../../requests' export const SendReview = () => { - const { gasPrice } = useContext(ClientContext) const { getValues } = useFormContext() + const [transferFee, setTransferFee] = useState() + const [isLoadingFee, setIsLoadingFee] = useState(true) const values = getValues() const theme: Theme = useTheme() + useEffect(() => { + const getFee = async () => { + const fee = await getGasFee('Send') + setTransferFee(fee.amount) + setIsLoadingFee(false) + } + getFee() + }, []) + return ( { margin: theme.spacing(3, 0), }} > - - - + {isLoadingFee ? ( + + ) : ( + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + )} ) } diff --git a/tauri-wallet/src/utils/index.ts b/tauri-wallet/src/utils/index.ts index 785b93ac42..e5d8b6944f 100644 --- a/tauri-wallet/src/utils/index.ts +++ b/tauri-wallet/src/utils/index.ts @@ -90,13 +90,3 @@ export const validateRawPort = (rawPort: number): boolean => export const truncate = (text: string, trim: number) => text.substring(0, trim) + '...' - -// export const getDisplaySendGasFee = async (): Promise => { -// const nymGasFee: any = await invoke('get_gas_price') -// const nymGasLimit: any = await invoke('get_gas_limits') - -// const table = buildFeeTable(nymGasFee, nymGasLimit, nymGasLimit) - -// console.log({ nymGasFee, nymGasLimit }) -// return 'coin' -// }